Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: src/execution.cc

Issue 352173006: Clean up the global object naming madness. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/debug.cc ('k') | src/factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/execution.h" 5 #include "src/execution.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 Object*** args); 63 Object*** args);
64 64
65 Handle<Code> code = is_construct 65 Handle<Code> code = is_construct
66 ? isolate->factory()->js_construct_entry_code() 66 ? isolate->factory()->js_construct_entry_code()
67 : isolate->factory()->js_entry_code(); 67 : isolate->factory()->js_entry_code();
68 68
69 // Convert calls on global objects to be calls on the global 69 // Convert calls on global objects to be calls on the global
70 // receiver instead to avoid having a 'this' pointer which refers 70 // receiver instead to avoid having a 'this' pointer which refers
71 // directly to a global object. 71 // directly to a global object.
72 if (receiver->IsGlobalObject()) { 72 if (receiver->IsGlobalObject()) {
73 Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver); 73 receiver = handle(Handle<GlobalObject>::cast(receiver)->global_proxy());
74 receiver = Handle<JSObject>(global->global_receiver());
75 } 74 }
76 75
77 // Make sure that the global object of the context we're about to 76 // Make sure that the global object of the context we're about to
78 // make the current one is indeed a global object. 77 // make the current one is indeed a global object.
79 ASSERT(function->context()->global_object()->IsGlobalObject()); 78 ASSERT(function->context()->global_object()->IsGlobalObject());
80 79
81 { 80 {
82 // Save and restore context around invocation and block the 81 // Save and restore context around invocation and block the
83 // allocation of handles without explicit handle scopes. 82 // allocation of handles without explicit handle scopes.
84 SaveContext save(isolate); 83 SaveContext save(isolate);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 ASSIGN_RETURN_ON_EXCEPTION( 125 ASSIGN_RETURN_ON_EXCEPTION(
127 isolate, callable, TryGetFunctionDelegate(isolate, callable), Object); 126 isolate, callable, TryGetFunctionDelegate(isolate, callable), Object);
128 } 127 }
129 Handle<JSFunction> func = Handle<JSFunction>::cast(callable); 128 Handle<JSFunction> func = Handle<JSFunction>::cast(callable);
130 129
131 // In sloppy mode, convert receiver. 130 // In sloppy mode, convert receiver.
132 if (convert_receiver && !receiver->IsJSReceiver() && 131 if (convert_receiver && !receiver->IsJSReceiver() &&
133 !func->shared()->native() && 132 !func->shared()->native() &&
134 func->shared()->strict_mode() == SLOPPY) { 133 func->shared()->strict_mode() == SLOPPY) {
135 if (receiver->IsUndefined() || receiver->IsNull()) { 134 if (receiver->IsUndefined() || receiver->IsNull()) {
136 Object* global = func->context()->global_object()->global_receiver(); 135 receiver = handle(func->global_proxy());
137 // Under some circumstances, 'global' can be the JSBuiltinsObject 136 ASSERT(!receiver->IsJSBuiltinsObject());
138 // In that case, don't rewrite. (FWIW, the same holds for
139 // GetIsolate()->global_object()->global_receiver().)
140 if (!global->IsJSBuiltinsObject()) {
141 receiver = Handle<Object>(global, func->GetIsolate());
142 }
143 } else { 137 } else {
144 ASSIGN_RETURN_ON_EXCEPTION( 138 ASSIGN_RETURN_ON_EXCEPTION(
145 isolate, receiver, ToObject(isolate, receiver), Object); 139 isolate, receiver, ToObject(isolate, receiver), Object);
146 } 140 }
147 } 141 }
148 142
149 return Invoke(false, func, receiver, argc, argv); 143 return Invoke(false, func, receiver, argc, argv);
150 } 144 }
151 145
152 146
153 MaybeHandle<Object> Execution::New(Handle<JSFunction> func, 147 MaybeHandle<Object> Execution::New(Handle<JSFunction> func,
154 int argc, 148 int argc,
155 Handle<Object> argv[]) { 149 Handle<Object> argv[]) {
156 return Invoke(true, func, func->GetIsolate()->global_object(), argc, argv); 150 return Invoke(true, func, handle(func->global_proxy()), argc, argv);
157 } 151 }
158 152
159 153
160 MaybeHandle<Object> Execution::TryCall(Handle<JSFunction> func, 154 MaybeHandle<Object> Execution::TryCall(Handle<JSFunction> func,
161 Handle<Object> receiver, 155 Handle<Object> receiver,
162 int argc, 156 int argc,
163 Handle<Object> args[], 157 Handle<Object> args[],
164 Handle<Object>* exception_out) { 158 Handle<Object>* exception_out) {
165 // Enter a try-block while executing the JavaScript code. To avoid 159 // Enter a try-block while executing the JavaScript code. To avoid
166 // duplicate error printing it must be non-verbose. Also, to avoid 160 // duplicate error printing it must be non-verbose. Also, to avoid
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 676 }
683 677
684 isolate_->counters()->stack_interrupts()->Increment(); 678 isolate_->counters()->stack_interrupts()->Increment();
685 isolate_->counters()->runtime_profiler_ticks()->Increment(); 679 isolate_->counters()->runtime_profiler_ticks()->Increment();
686 isolate_->runtime_profiler()->OptimizeNow(); 680 isolate_->runtime_profiler()->OptimizeNow();
687 681
688 return isolate_->heap()->undefined_value(); 682 return isolate_->heap()->undefined_value();
689 } 683 }
690 684
691 } } // namespace v8::internal 685 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698