OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 Handle<Code> code; | 77 Handle<Code> code; |
78 if (construct) { | 78 if (construct) { |
79 JSConstructEntryStub stub; | 79 JSConstructEntryStub stub; |
80 code = stub.GetCode(); | 80 code = stub.GetCode(); |
81 } else { | 81 } else { |
82 JSEntryStub stub; | 82 JSEntryStub stub; |
83 code = stub.GetCode(); | 83 code = stub.GetCode(); |
84 } | 84 } |
85 | 85 |
| 86 // Convert calls on global objects to be calls on the global |
| 87 // receiver instead to avoid having a 'this' pointer which refers |
| 88 // directly to a global object. |
| 89 if (receiver->IsGlobalObject()) { |
| 90 Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver); |
| 91 receiver = Handle<JSObject>(global->global_receiver()); |
| 92 } |
| 93 |
86 { | 94 { |
87 // Save and restore context around invocation and block the | 95 // Save and restore context around invocation and block the |
88 // allocation of handles without explicit handle scopes. | 96 // allocation of handles without explicit handle scopes. |
89 SaveContext save; | 97 SaveContext save; |
90 NoHandleAllocation na; | 98 NoHandleAllocation na; |
91 JSEntryFunction entry = FUNCTION_CAST<JSEntryFunction>(code->entry()); | 99 JSEntryFunction entry = FUNCTION_CAST<JSEntryFunction>(code->entry()); |
92 | 100 |
93 // Call the function through the right JS entry stub. | 101 // Call the function through the right JS entry stub. |
94 value = CALL_GENERATED_CODE(entry, func->code()->entry(), *func, | 102 value = CALL_GENERATED_CODE(entry, func->code()->entry(), *func, |
95 *receiver, argc, args); | 103 *receiver, argc, args); |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 // All allocation spaces other than NEW_SPACE have the same effect. | 666 // All allocation spaces other than NEW_SPACE have the same effect. |
659 Heap::CollectAllGarbage(); | 667 Heap::CollectAllGarbage(); |
660 return v8::Undefined(); | 668 return v8::Undefined(); |
661 } | 669 } |
662 | 670 |
663 | 671 |
664 static GCExtension kGCExtension; | 672 static GCExtension kGCExtension; |
665 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); | 673 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); |
666 | 674 |
667 } } // namespace v8::internal | 675 } } // namespace v8::internal |
OLD | NEW |