Changeset 12066
- Timestamp:
- 07/27/09 14:11:30 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/LispThread.java
r12065 r12066 450 450 private static class StackFrame 451 451 { 452 public LispObject operator;453 private LispObject first;454 private LispObject second;455 private LispObject third;456 private LispObject[] args;452 public final LispObject operator; 453 private final LispObject first; 454 private final LispObject second; 455 private final LispObject third; 456 private final LispObject[] args; 457 457 final StackFrame next; 458 458 459 public StackFrame(StackFrame next) { 460 this.next = next; 461 } 462 463 public final void set(LispObject operator) 459 public StackFrame(LispObject operator, StackFrame next) 464 460 { 465 461 this.operator = operator; … … 468 464 third = null; 469 465 args = null; 470 } 471 472 public final void set(LispObject operator, LispObject arg) 466 this.next = next; 467 } 468 469 public StackFrame(LispObject operator, LispObject arg, StackFrame next) 473 470 { 474 471 this.operator = operator; … … 477 474 third = null; 478 475 args = null; 479 } 480 481 public final void set(LispObject operator, LispObject first, 482 LispObject second) 476 this.next = next; 477 } 478 479 public StackFrame(LispObject operator, LispObject first, 480 LispObject second, StackFrame next) 483 481 { 484 482 this.operator = operator; … … 487 485 third = null; 488 486 args = null; 489 } 490 491 public final void set(LispObject operator, LispObject first, 492 LispObject second, LispObject third) 487 this.next = next; 488 } 489 490 public StackFrame(LispObject operator, LispObject first, 491 LispObject second, LispObject third, StackFrame next) 493 492 { 494 493 this.operator = operator; … … 497 496 this.third = third; 498 497 args = null; 499 } 500 501 public final void set(LispObject operator, LispObject[] args) 498 this.next = next; 499 } 500 501 public StackFrame(LispObject operator, LispObject[] args, StackFrame next) 502 502 { 503 503 this.operator = operator; … … 506 506 third = null; 507 507 this.args = args; 508 this.next = next; 508 509 } 509 510 … … 541 542 542 543 private StackFrame stack = null; 543 private final int framePoolSize = 256;544 private final StackFrame[] framePool = new StackFrame[256];545 private int framePointer = -1;546 544 547 545 @Deprecated … … 565 563 } 566 564 567 private final StackFrame newStackFrame() {568 if (++framePointer < framePoolSize) {569 if (framePool[framePointer] == null)570 framePool[framePointer] = new StackFrame(stack);571 return (stack = framePool[framePointer]);572 } else573 return (stack = new StackFrame(stack));574 }575 576 565 public final void pushStackFrame(LispObject operator) 577 566 throws ConditionThrowable 578 567 { 579 newStackFrame().set(operator);568 stack = new StackFrame(operator, stack); 580 569 doProfiling(); 581 570 } … … 584 573 throws ConditionThrowable 585 574 { 586 newStackFrame().set(operator, arg);575 stack = new StackFrame(operator, arg, stack); 587 576 doProfiling(); 588 577 } … … 592 581 throws ConditionThrowable 593 582 { 594 newStackFrame().set(operator, first, second);583 stack = new StackFrame(operator, first, second, stack); 595 584 doProfiling(); 596 585 } … … 600 589 throws ConditionThrowable 601 590 { 602 newStackFrame().set(operator, first, second, third);591 stack = new StackFrame(operator, first, second, third, stack); 603 592 doProfiling(); 604 593 } … … 607 596 throws ConditionThrowable 608 597 { 609 newStackFrame().set(operator, args);598 stack = new StackFrame(operator, args, stack); 610 599 doProfiling(); 611 600 } … … 613 602 public final void popStackFrame() 614 603 { 615 if (stack != null) { 616 if (framePointer < framePoolSize) 617 stack.set(null); 604 if (stack != null) 618 605 stack = stack.next; 619 framePointer--;620 }621 606 } 622 607 … … 624 609 { 625 610 stack = null; 626 // Clear out old frames, in order to prevent leaking references627 // to old objects628 for (StackFrame frame : framePool)629 if (frame != null)630 frame.set(null);631 framePointer = -1;632 611 } 633 612
Note: See TracChangeset
for help on using the changeset viewer.