822 directly accessed by smalltalk code. The reason is that the sender field |
822 directly accessed by smalltalk code. The reason is that the sender field |
823 is lazily filled in by the VM, in the sender-accessor, and is usually |
823 is lazily filled in by the VM, in the sender-accessor, and is usually |
824 invalid until needed." |
824 invalid until needed." |
825 |
825 |
826 %{ /* NOCONTEXT */ |
826 %{ /* NOCONTEXT */ |
|
827 #ifdef __SCHTEAM__ |
|
828 if (((STContinuation)self).caller == null) { |
|
829 return __c__._RETURN_true(); |
|
830 } |
|
831 return __c__._RETURN_false(); |
|
832 /* NOTREACHED */ |
|
833 #else |
827 if ( __INST(sender_) == nil ) { |
834 if ( __INST(sender_) == nil ) { |
828 RETURN (true); |
835 RETURN (true); |
829 } |
836 } |
830 RETURN (false); |
837 RETURN (false); |
|
838 #endif |
831 %}. |
839 %}. |
832 ^ self sender isNil |
840 ^ self sender isNil |
833 ! |
841 ! |
834 |
842 |
835 setLineNumber:aNumber |
843 setLineNumber:aNumber |
2028 return a replacement string. otherwise nil. |
2036 return a replacement string. otherwise nil. |
2029 This cares for invalid (free) objects which may appear with bad primitive code, |
2037 This cares for invalid (free) objects which may appear with bad primitive code, |
2030 and prevents a crash in such a case." |
2038 and prevents a crash in such a case." |
2031 |
2039 |
2032 %{ |
2040 %{ |
2033 #ifndef __SCHTEAM__ |
2041 #ifdef __SCHTEAM__ |
|
2042 return __c__._RETURN( ((STContinuation)self).stSelf(__c__) ); |
|
2043 #else |
2034 /* |
2044 /* |
2035 * special handling for (invalid) free objects. |
2045 * special handling for (invalid) free objects. |
2036 * these only appear if some primitiveCode does not correctly use SEND macros, |
2046 * these only appear if some primitiveCode does not correctly use SEND macros, |
2037 * which may lead to sends to free objects. In normal operation, this 'cannot' happen. |
2047 * which may lead to sends to free objects. In normal operation, this 'cannot' happen. |
2038 */ |
2048 */ |
2201 "/ although they aren't really - this is expert knowledge, no need to understand that ...) |
2211 "/ although they aren't really - this is expert knowledge, no need to understand that ...) |
2202 |
2212 |
2203 %{ /* NOCONTEXT */ |
2213 %{ /* NOCONTEXT */ |
2204 #ifdef __SCHTEAM__ |
2214 #ifdef __SCHTEAM__ |
2205 { |
2215 { |
2206 STContinuation caller = self.sender(); |
2216 STContinuation lastCallee = (STContinuation)self; |
|
2217 STContinuation caller = lastCallee.caller; |
2207 |
2218 |
2208 while (caller != null) { |
2219 while (caller != null) { |
2209 if (caller.isExceptionalSmalltalkContext()) { |
2220 if (caller.isExceptionalSmalltalkContext()) { |
|
2221 caller = lastCallee.sender(); // exposed |
2210 return context._RETURN(caller); |
2222 return context._RETURN(caller); |
2211 } |
2223 } |
2212 caller = caller.sender(); |
2224 lastCallee = caller; |
|
2225 caller = lastCallee.caller; |
2213 } |
2226 } |
2214 return context._RETURN( STObject.Nil ); |
2227 return context._RETURN( STObject.Nil ); |
2215 } |
2228 } |
2216 /* NOTREACHED */ |
2229 /* NOTREACHED */ |
2217 #else |
2230 #else |
2267 "/ although they aren't really - this is expert knowledge, no need to understand that ...) |
2280 "/ although they aren't really - this is expert knowledge, no need to understand that ...) |
2268 |
2281 |
2269 %{ /* NOCONTEXT */ |
2282 %{ /* NOCONTEXT */ |
2270 #ifdef __SCHTEAM__ |
2283 #ifdef __SCHTEAM__ |
2271 { |
2284 { |
2272 STContinuation cont = self.sender(); |
2285 STContinuation lastCallee = (STContinuation)self; |
|
2286 STContinuation cont = lastCallee.caller; |
|
2287 |
2273 STObject sel1 = context.stArg(0); |
2288 STObject sel1 = context.stArg(0); |
2274 STObject sel2 = context.stArg(1); |
2289 STObject sel2 = context.stArg(1); |
2275 STObject sel3 = context.stArg(2); |
2290 STObject sel3 = context.stArg(2); |
2276 |
2291 |
2277 while (cont != null) { |
2292 while (cont != null) { |
2374 { |
2391 { |
2375 if (self == aContext) { |
2392 if (self == aContext) { |
2376 return __c__._RETURN(self); |
2393 return __c__._RETURN(self); |
2377 } |
2394 } |
2378 |
2395 |
2379 STContinuation theContext = self.sender(); |
2396 STContinuation lastCallee = (STContinuation)self; |
|
2397 STContinuation theContext = lastCallee.caller; |
2380 |
2398 |
2381 while (theContext != null) { |
2399 while (theContext != null) { |
2382 if ((theContext == aContext) |
2400 if ((theContext == aContext) |
2383 || theContext.isMarkedForUnwind()) { |
2401 || theContext.isMarkedForUnwind()) { |
|
2402 theContext = lastCallee.sender(); // exposed |
2384 return __c__._RETURN(theContext); |
2403 return __c__._RETURN(theContext); |
2385 } |
2404 } |
2386 theContext = theContext.sender(); |
2405 lastCallee = theContext; |
|
2406 theContext = lastCallee.caller; |
2387 } |
2407 } |
2388 } |
2408 } |
2389 #else |
2409 #else |
2390 OBJ theContext; |
2410 OBJ theContext; |
2391 |
2411 |
2444 "/ although they aren't really - this is expert knowledge, no need to understand that ...) |
2464 "/ although they aren't really - this is expert knowledge, no need to understand that ...) |
2445 |
2465 |
2446 %{ /* NOCONTEXT */ |
2466 %{ /* NOCONTEXT */ |
2447 #ifdef __SCHTEAM__ |
2467 #ifdef __SCHTEAM__ |
2448 { |
2468 { |
2449 STContinuation theContext = self.sender(); |
2469 STContinuation lastCallee = (STContinuation)self; |
|
2470 STContinuation theContext = lastCallee.caller; |
|
2471 |
2450 while (theContext != null) { |
2472 while (theContext != null) { |
2451 if (theContext.isMarkedSpecial()) { |
2473 if (theContext.isMarkedSpecial()) { |
2452 if ((findHandleContext == STObject.True) |
2474 if ((findHandleContext == STObject.True) |
2453 && theContext.isMarkedForHandle()) { |
2475 && theContext.isMarkedForHandle()) { |
|
2476 theContext = lastCallee.sender(); // exposed |
2454 return __c__._RETURN(theContext); |
2477 return __c__._RETURN(theContext); |
2455 } |
2478 } |
2456 if ((findRaiseContext == STObject.True) |
2479 if ((findRaiseContext == STObject.True) |
2457 && theContext.isMarkedForRaise()) { |
2480 && theContext.isMarkedForRaise()) { |
|
2481 theContext = lastCallee.sender(); // exposed |
2458 return __c__._RETURN(theContext); |
2482 return __c__._RETURN(theContext); |
2459 } |
2483 } |
2460 } |
2484 } |
2461 theContext = theContext.sender(); |
2485 lastCallee = theContext; |
|
2486 theContext = lastCallee.caller; |
2462 } |
2487 } |
2463 } |
2488 } |
2464 #else |
2489 #else |
2465 OBJ theContext; |
2490 OBJ theContext; |
2466 int flagMask = 0; |
2491 int flagMask = 0; |
2620 "Modified: / 19-08-2013 / 12:13:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2645 "Modified: / 19-08-2013 / 12:13:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2621 ! |
2646 ! |
2622 |
2647 |
2623 canResume |
2648 canResume |
2624 "return true, if the receiver allows to be resumed. |
2649 "return true, if the receiver allows to be resumed. |
2625 Due to the implementation, this requires that the context which |
2650 In ST/X, due to the implementation, this requires that the context which |
2626 is right below the receiver is returnable." |
2651 is right below the receiver is returnable and still active." |
2627 |
2652 |
2628 |theContext| |
2653 |theContext| |
2629 |
2654 |
2630 " |
2655 " |
2631 starting with this context, find the one below |
2656 starting with this context, find the one below |
2632 (i.e. the one that I have called) and return from it. |
2657 (i.e. the one that I have called) and return from it. |
2633 " |
2658 " |
2634 %{ |
2659 %{ |
2635 #ifdef __SCHTEAM__ |
2660 #ifdef __SCHTEAM__ |
|
2661 // in the SCHTEAM-engine, all contexts are resumable |
2636 return context._RETURN_true(); |
2662 return context._RETURN_true(); |
2637 #else |
2663 #else |
2638 OBJ sndr; |
2664 OBJ sndr; |
2639 |
2665 |
2640 theContext = __thisContext; |
2666 theContext = __thisContext; |
2664 was compiled (stc flag +/-optContext). |
2690 was compiled (stc flag +/-optContext). |
2665 If it was compiled with +optContext, methods are compiled |
2691 If it was compiled with +optContext, methods are compiled |
2666 non returnable, unless a return-pragma was present in the method. |
2692 non returnable, unless a return-pragma was present in the method. |
2667 Since this saves some administrative work in every method |
2693 Since this saves some administrative work in every method |
2668 invocation and makes overall execution faster, the system classes |
2694 invocation and makes overall execution faster, the system classes |
2669 are all compiled with this flag turned on." |
2695 are all compiled with this flag turned on. |
|
2696 This means, that by default, it is not possible to walk up the |
|
2697 calling chain and return to an arbitrary context. |
|
2698 For contexts which are known to require this (i.e. handlers as found |
|
2699 by the exception walkers, these are marked specially (markForReturn), |
|
2700 so compilers know that they should create full featured contexts." |
2670 |
2701 |
2671 %{ /* NOCONTEXT */ |
2702 %{ /* NOCONTEXT */ |
2672 #ifdef __SCHTEAM__ |
2703 #ifdef __SCHTEAM__ |
|
2704 // in the SCHTEAM-engine, all contexts can be returned from |
2673 return context._RETURN_true(); |
2705 return context._RETURN_true(); |
2674 #else |
2706 #else |
2675 RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(__CANNOT_RETURN)) ? false : true ); |
2707 RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(__CANNOT_RETURN)) ? false : true ); |
2676 #endif |
2708 #endif |
2677 %}. |
2709 %}. |
2704 isNonLifo |
2736 isNonLifo |
2705 "return true, if this is a nonLifo context. |
2737 "return true, if this is a nonLifo context. |
2706 A nonLifo context is one that is still on the machine stack, |
2738 A nonLifo context is one that is still on the machine stack, |
2707 but has a reference taken and needs to be converted to a real |
2739 but has a reference taken and needs to be converted to a real |
2708 object (in objectMemory) when the method/block returns. |
2740 object (in objectMemory) when the method/block returns. |
2709 You dont have to understand this - this is a special ST/X |
2741 You don't have to understand this - this is a special ST/X |
2710 debug query, which may be removed without notice." |
2742 debug query, which may be removed without notice." |
2711 |
2743 |
2712 %{ /* NOCONTEXT */ |
2744 %{ /* NOCONTEXT */ |
2713 #ifdef __SCHTEAM__ |
2745 #ifdef __SCHTEAM__ |
2714 ERROR("unimplemented"); |
2746 return __c__._RETURN ( ((STContinuation)self).isNonLifo() ); |
2715 #else |
2747 #else |
2716 RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__NONLIFO)) ? true : false ); |
2748 RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__NONLIFO)) ? true : false ); |
2717 #endif |
2749 #endif |
2718 %} |
2750 %} |
2719 ! |
2751 ! |
2720 |
2752 |
2721 isOnMachineStack |
2753 isOnMachineStack |
2722 "return true, if this is a machine stack context as opposed to a |
2754 "return true, if this is a machine stack context as opposed to a |
2723 real heap context. |
2755 real heap context (i.e. if it has not been captured and returned from). |
2724 You dont have to understand this - this is a special ST/X |
2756 You don't have to understand this - this is a special ST/X |
2725 debug query, which may be removed without notice." |
2757 debug query, which may be removed without notice." |
2726 |
2758 |
2727 %{ /* NOCONTEXT */ |
2759 %{ /* NOCONTEXT */ |
2728 #ifdef __SCHTEAM__ |
2760 #ifdef __SCHTEAM__ |
2729 ERROR("unimplemented"); |
2761 return __c__._RETURN ( ! ((STContinuation)self).isCopiedToHeap() ); |
2730 #else |
2762 #else |
2731 RETURN ( (__qSpace(self) >= STACKSPACE) ? true : false ); |
2763 RETURN ( (__qSpace(self) >= STACKSPACE) ? true : false ); |
2732 #endif |
2764 #endif |
2733 %} |
2765 %} |
2734 ! |
2766 ! |
2735 |
2767 |
2736 isRaiseContext |
2768 isRaiseContext |
2737 "return true, if this is a context with exception-raise flag set" |
2769 "return true, if this is a context with exception-raise flag set" |
2738 |
2770 |
2739 %{ /* NOCONTEXT */ |
2771 %{ /* NOCONTEXT */ |
2740 #ifdef __SCHTEAM__ |
2772 #ifdef __SCHTEAM__ |
2741 ERROR("unimplemented"); |
2773 return __c__._RETURN ( ((STContinuation)self).isMarkedForRaise() ); |
2742 #else |
2774 #else |
2743 RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__RAISE_MARK)) ? true : false ); |
2775 RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__RAISE_MARK)) ? true : false ); |
2744 #endif |
2776 #endif |
2745 %} |
2777 %} |
2746 ! |
2778 ! |
2747 |
2779 |
2748 isSpecial |
2780 isSpecial |
2749 "return true, if this is either a nonLifo or interrupted context" |
2781 "return true, if this is either a nonLifo or interrupted context" |
2750 |
2782 |
2751 %{ /* NOCONTEXT */ |
2783 %{ /* NOCONTEXT */ |
2752 #ifdef __SCHTEAM__ |
2784 #ifdef __SCHTEAM__ |
2753 ERROR("unimplemented"); |
2785 return __c__._RETURN ( ((STContinuation)self).isMarkedSpecial() ); |
2754 #else |
2786 #else |
2755 RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__SPECIAL)) ? true : false ); |
2787 RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__SPECIAL)) ? true : false ); |
2756 #endif |
2788 #endif |
2757 %} |
2789 %} |
2758 ! |
2790 ! |
2759 |
2791 |
2760 isUnwindContext |
2792 isUnwindContext |
2761 "return true, if this is an unwindContext" |
2793 "return true, if this is an unwindContext" |
2762 |
2794 |
2763 %{ /* NOCONTEXT */ |
2795 %{ /* NOCONTEXT */ |
2764 #ifdef __SCHTEAM__ |
2796 #ifdef __SCHTEAM__ |
2765 ERROR("unimplemented"); |
2797 return __c__._RETURN ( ((STContinuation)self).isMarkedForUnwind() ); |
2766 #else |
2798 #else |
2767 RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__UNWIND_MARK)) ? true : false ); |
2799 RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__UNWIND_MARK)) ? true : false ); |
2768 #endif |
2800 #endif |
2769 %} |
2801 %} |
2770 ! |
2802 ! |
2771 |
2803 |
2772 tempNames |
2804 tempNames |