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