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

Side by Side Diff: src/execution.cc

Issue 10878047: Revert to code state of 3.13.1 plus r12350 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 8 years, 3 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/deoptimizer.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Convert calls on global objects to be calls on the global 93 // Convert calls on global objects to be calls on the global
94 // receiver instead to avoid having a 'this' pointer which refers 94 // receiver instead to avoid having a 'this' pointer which refers
95 // directly to a global object. 95 // directly to a global object.
96 if (receiver->IsGlobalObject()) { 96 if (receiver->IsGlobalObject()) {
97 Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver); 97 Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver);
98 receiver = Handle<JSObject>(global->global_receiver()); 98 receiver = Handle<JSObject>(global->global_receiver());
99 } 99 }
100 100
101 // Make sure that the global object of the context we're about to 101 // Make sure that the global object of the context we're about to
102 // make the current one is indeed a global object. 102 // make the current one is indeed a global object.
103 ASSERT(function->context()->global_object()->IsGlobalObject()); 103 ASSERT(function->context()->global()->IsGlobalObject());
104 104
105 { 105 {
106 // Save and restore context around invocation and block the 106 // Save and restore context around invocation and block the
107 // allocation of handles without explicit handle scopes. 107 // allocation of handles without explicit handle scopes.
108 SaveContext save(isolate); 108 SaveContext save(isolate);
109 NoHandleAllocation na; 109 NoHandleAllocation na;
110 JSEntryFunction stub_entry = FUNCTION_CAST<JSEntryFunction>(code->entry()); 110 JSEntryFunction stub_entry = FUNCTION_CAST<JSEntryFunction>(code->entry());
111 111
112 // Call the function through the right JS entry stub. 112 // Call the function through the right JS entry stub.
113 byte* function_entry = function->code()->entry(); 113 byte* function_entry = function->code()->entry();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (!callable->IsJSFunction()) { 158 if (!callable->IsJSFunction()) {
159 callable = TryGetFunctionDelegate(callable, pending_exception); 159 callable = TryGetFunctionDelegate(callable, pending_exception);
160 if (*pending_exception) return callable; 160 if (*pending_exception) return callable;
161 } 161 }
162 Handle<JSFunction> func = Handle<JSFunction>::cast(callable); 162 Handle<JSFunction> func = Handle<JSFunction>::cast(callable);
163 163
164 // In non-strict mode, convert receiver. 164 // In non-strict mode, convert receiver.
165 if (convert_receiver && !receiver->IsJSReceiver() && 165 if (convert_receiver && !receiver->IsJSReceiver() &&
166 !func->shared()->native() && func->shared()->is_classic_mode()) { 166 !func->shared()->native() && func->shared()->is_classic_mode()) {
167 if (receiver->IsUndefined() || receiver->IsNull()) { 167 if (receiver->IsUndefined() || receiver->IsNull()) {
168 Object* global = func->context()->global_object()->global_receiver(); 168 Object* global = func->context()->global()->global_receiver();
169 // Under some circumstances, 'global' can be the JSBuiltinsObject 169 // Under some circumstances, 'global' can be the JSBuiltinsObject
170 // In that case, don't rewrite. (FWIW, the same holds for 170 // In that case, don't rewrite.
171 // GetIsolate()->global_object()->global_receiver().) 171 // (FWIW, the same holds for GetIsolate()->global()->global_receiver().)
172 if (!global->IsJSBuiltinsObject()) receiver = Handle<Object>(global); 172 if (!global->IsJSBuiltinsObject()) receiver = Handle<Object>(global);
173 } else { 173 } else {
174 receiver = ToObject(receiver, pending_exception); 174 receiver = ToObject(receiver, pending_exception);
175 } 175 }
176 if (*pending_exception) return callable; 176 if (*pending_exception) return callable;
177 } 177 }
178 178
179 return Invoke(false, func, receiver, argc, argv, pending_exception); 179 return Invoke(false, func, receiver, argc, argv, pending_exception);
180 } 180 }
181 181
182 182
183 Handle<Object> Execution::New(Handle<JSFunction> func, 183 Handle<Object> Execution::New(Handle<JSFunction> func,
184 int argc, 184 int argc,
185 Handle<Object> argv[], 185 Handle<Object> argv[],
186 bool* pending_exception) { 186 bool* pending_exception) {
187 return Invoke(true, func, Isolate::Current()->global_object(), argc, argv, 187 return Invoke(true, func, Isolate::Current()->global(), argc, argv,
188 pending_exception); 188 pending_exception);
189 } 189 }
190 190
191 191
192 Handle<Object> Execution::TryCall(Handle<JSFunction> func, 192 Handle<Object> Execution::TryCall(Handle<JSFunction> func,
193 Handle<Object> receiver, 193 Handle<Object> receiver,
194 int argc, 194 int argc,
195 Handle<Object> args[], 195 Handle<Object> args[],
196 bool* caught_exception) { 196 bool* caught_exception) {
197 // Enter a try-block while executing the JavaScript code. To avoid 197 // Enter a try-block while executing the JavaScript code. To avoid
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 while (fun->IsJSFunctionProxy()) { 239 while (fun->IsJSFunctionProxy()) {
240 fun = JSFunctionProxy::cast(fun)->call_trap(); 240 fun = JSFunctionProxy::cast(fun)->call_trap();
241 } 241 }
242 if (fun->IsJSFunction()) return Handle<Object>(fun); 242 if (fun->IsJSFunction()) return Handle<Object>(fun);
243 243
244 // Objects created through the API can have an instance-call handler 244 // Objects created through the API can have an instance-call handler
245 // that should be used when calling the object as a function. 245 // that should be used when calling the object as a function.
246 if (fun->IsHeapObject() && 246 if (fun->IsHeapObject() &&
247 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 247 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
248 return Handle<JSFunction>( 248 return Handle<JSFunction>(
249 isolate->native_context()->call_as_function_delegate()); 249 isolate->global_context()->call_as_function_delegate());
250 } 250 }
251 251
252 return factory->undefined_value(); 252 return factory->undefined_value();
253 } 253 }
254 254
255 255
256 Handle<Object> Execution::TryGetFunctionDelegate(Handle<Object> object, 256 Handle<Object> Execution::TryGetFunctionDelegate(Handle<Object> object,
257 bool* has_pending_exception) { 257 bool* has_pending_exception) {
258 ASSERT(!object->IsJSFunction()); 258 ASSERT(!object->IsJSFunction());
259 Isolate* isolate = Isolate::Current(); 259 Isolate* isolate = Isolate::Current();
260 260
261 // If object is a function proxy, get its handler. Iterate if necessary. 261 // If object is a function proxy, get its handler. Iterate if necessary.
262 Object* fun = *object; 262 Object* fun = *object;
263 while (fun->IsJSFunctionProxy()) { 263 while (fun->IsJSFunctionProxy()) {
264 fun = JSFunctionProxy::cast(fun)->call_trap(); 264 fun = JSFunctionProxy::cast(fun)->call_trap();
265 } 265 }
266 if (fun->IsJSFunction()) return Handle<Object>(fun); 266 if (fun->IsJSFunction()) return Handle<Object>(fun);
267 267
268 // Objects created through the API can have an instance-call handler 268 // Objects created through the API can have an instance-call handler
269 // that should be used when calling the object as a function. 269 // that should be used when calling the object as a function.
270 if (fun->IsHeapObject() && 270 if (fun->IsHeapObject() &&
271 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 271 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
272 return Handle<JSFunction>( 272 return Handle<JSFunction>(
273 isolate->native_context()->call_as_function_delegate()); 273 isolate->global_context()->call_as_function_delegate());
274 } 274 }
275 275
276 // If the Object doesn't have an instance-call handler we should 276 // If the Object doesn't have an instance-call handler we should
277 // throw a non-callable exception. 277 // throw a non-callable exception.
278 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError( 278 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError(
279 "called_non_callable", i::HandleVector<i::Object>(&object, 1)); 279 "called_non_callable", i::HandleVector<i::Object>(&object, 1));
280 isolate->Throw(*error_obj); 280 isolate->Throw(*error_obj);
281 *has_pending_exception = true; 281 *has_pending_exception = true;
282 282
283 return isolate->factory()->undefined_value(); 283 return isolate->factory()->undefined_value();
(...skipping 12 matching lines...) Expand all
296 while (fun->IsJSFunctionProxy()) { 296 while (fun->IsJSFunctionProxy()) {
297 fun = JSFunctionProxy::cast(fun)->call_trap(); 297 fun = JSFunctionProxy::cast(fun)->call_trap();
298 } 298 }
299 if (fun->IsJSFunction()) return Handle<Object>(fun); 299 if (fun->IsJSFunction()) return Handle<Object>(fun);
300 300
301 // Objects created through the API can have an instance-call handler 301 // Objects created through the API can have an instance-call handler
302 // that should be used when calling the object as a function. 302 // that should be used when calling the object as a function.
303 if (fun->IsHeapObject() && 303 if (fun->IsHeapObject() &&
304 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 304 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
305 return Handle<JSFunction>( 305 return Handle<JSFunction>(
306 isolate->native_context()->call_as_constructor_delegate()); 306 isolate->global_context()->call_as_constructor_delegate());
307 } 307 }
308 308
309 return isolate->factory()->undefined_value(); 309 return isolate->factory()->undefined_value();
310 } 310 }
311 311
312 312
313 Handle<Object> Execution::TryGetConstructorDelegate( 313 Handle<Object> Execution::TryGetConstructorDelegate(
314 Handle<Object> object, 314 Handle<Object> object,
315 bool* has_pending_exception) { 315 bool* has_pending_exception) {
316 ASSERT(!object->IsJSFunction()); 316 ASSERT(!object->IsJSFunction());
317 Isolate* isolate = Isolate::Current(); 317 Isolate* isolate = Isolate::Current();
318 318
319 // If you return a function from here, it will be called when an 319 // If you return a function from here, it will be called when an
320 // attempt is made to call the given object as a constructor. 320 // attempt is made to call the given object as a constructor.
321 321
322 // If object is a function proxies, get its handler. Iterate if necessary. 322 // If object is a function proxies, get its handler. Iterate if necessary.
323 Object* fun = *object; 323 Object* fun = *object;
324 while (fun->IsJSFunctionProxy()) { 324 while (fun->IsJSFunctionProxy()) {
325 fun = JSFunctionProxy::cast(fun)->call_trap(); 325 fun = JSFunctionProxy::cast(fun)->call_trap();
326 } 326 }
327 if (fun->IsJSFunction()) return Handle<Object>(fun); 327 if (fun->IsJSFunction()) return Handle<Object>(fun);
328 328
329 // Objects created through the API can have an instance-call handler 329 // Objects created through the API can have an instance-call handler
330 // that should be used when calling the object as a function. 330 // that should be used when calling the object as a function.
331 if (fun->IsHeapObject() && 331 if (fun->IsHeapObject() &&
332 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 332 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
333 return Handle<JSFunction>( 333 return Handle<JSFunction>(
334 isolate->native_context()->call_as_constructor_delegate()); 334 isolate->global_context()->call_as_constructor_delegate());
335 } 335 }
336 336
337 // If the Object doesn't have an instance-call handler we should 337 // If the Object doesn't have an instance-call handler we should
338 // throw a non-callable exception. 338 // throw a non-callable exception.
339 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError( 339 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError(
340 "called_non_callable", i::HandleVector<i::Object>(&object, 1)); 340 "called_non_callable", i::HandleVector<i::Object>(&object, 1));
341 isolate->Throw(*error_obj); 341 isolate->Throw(*error_obj);
342 *has_pending_exception = true; 342 *has_pending_exception = true;
343 343
344 return isolate->factory()->undefined_value(); 344 return isolate->factory()->undefined_value();
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 } 673 }
674 674
675 675
676 #undef RETURN_NATIVE_CALL 676 #undef RETURN_NATIVE_CALL
677 677
678 678
679 Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, 679 Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern,
680 Handle<String> flags, 680 Handle<String> flags,
681 bool* exc) { 681 bool* exc) {
682 Handle<JSFunction> function = Handle<JSFunction>( 682 Handle<JSFunction> function = Handle<JSFunction>(
683 pattern->GetIsolate()->native_context()->regexp_function()); 683 pattern->GetIsolate()->global_context()->regexp_function());
684 Handle<Object> re_obj = RegExpImpl::CreateRegExpLiteral( 684 Handle<Object> re_obj = RegExpImpl::CreateRegExpLiteral(
685 function, pattern, flags, exc); 685 function, pattern, flags, exc);
686 if (*exc) return Handle<JSRegExp>(); 686 if (*exc) return Handle<JSRegExp>();
687 return Handle<JSRegExp>::cast(re_obj); 687 return Handle<JSRegExp>::cast(re_obj);
688 } 688 }
689 689
690 690
691 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { 691 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) {
692 Isolate* isolate = string->GetIsolate(); 692 Isolate* isolate = string->GetIsolate();
693 Factory* factory = isolate->factory(); 693 Factory* factory = isolate->factory();
(...skipping 25 matching lines...) Expand all
719 } 719 }
720 720
721 721
722 Handle<JSFunction> Execution::InstantiateFunction( 722 Handle<JSFunction> Execution::InstantiateFunction(
723 Handle<FunctionTemplateInfo> data, 723 Handle<FunctionTemplateInfo> data,
724 bool* exc) { 724 bool* exc) {
725 Isolate* isolate = data->GetIsolate(); 725 Isolate* isolate = data->GetIsolate();
726 // Fast case: see if the function has already been instantiated 726 // Fast case: see if the function has already been instantiated
727 int serial_number = Smi::cast(data->serial_number())->value(); 727 int serial_number = Smi::cast(data->serial_number())->value();
728 Object* elm = 728 Object* elm =
729 isolate->native_context()->function_cache()-> 729 isolate->global_context()->function_cache()->
730 GetElementNoExceptionThrown(serial_number); 730 GetElementNoExceptionThrown(serial_number);
731 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm)); 731 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm));
732 // The function has not yet been instantiated in this context; do it. 732 // The function has not yet been instantiated in this context; do it.
733 Handle<Object> args[] = { data }; 733 Handle<Object> args[] = { data };
734 Handle<Object> result = Call(isolate->instantiate_fun(), 734 Handle<Object> result = Call(isolate->instantiate_fun(),
735 isolate->js_builtins_object(), 735 isolate->js_builtins_object(),
736 ARRAY_SIZE(args), 736 ARRAY_SIZE(args),
737 args, 737 args,
738 exc); 738 exc);
739 if (*exc) return Handle<JSFunction>::null(); 739 if (*exc) return Handle<JSFunction>::null();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 863
864 { 864 {
865 JavaScriptFrameIterator it(isolate); 865 JavaScriptFrameIterator it(isolate);
866 ASSERT(!it.done()); 866 ASSERT(!it.done());
867 Object* fun = it.frame()->function(); 867 Object* fun = it.frame()->function();
868 if (fun && fun->IsJSFunction()) { 868 if (fun && fun->IsJSFunction()) {
869 // Don't stop in builtin functions. 869 // Don't stop in builtin functions.
870 if (JSFunction::cast(fun)->IsBuiltin()) { 870 if (JSFunction::cast(fun)->IsBuiltin()) {
871 return isolate->heap()->undefined_value(); 871 return isolate->heap()->undefined_value();
872 } 872 }
873 GlobalObject* global = JSFunction::cast(fun)->context()->global_object(); 873 GlobalObject* global = JSFunction::cast(fun)->context()->global();
874 // Don't stop in debugger functions. 874 // Don't stop in debugger functions.
875 if (isolate->debug()->IsDebugGlobal(global)) { 875 if (isolate->debug()->IsDebugGlobal(global)) {
876 return isolate->heap()->undefined_value(); 876 return isolate->heap()->undefined_value();
877 } 877 }
878 } 878 }
879 } 879 }
880 880
881 // Collect the break state before clearing the flags. 881 // Collect the break state before clearing the flags.
882 bool debug_command_only = 882 bool debug_command_only =
883 isolate->stack_guard()->IsDebugCommand() && 883 isolate->stack_guard()->IsDebugCommand() &&
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 } 961 }
962 if (stack_guard->IsInterrupted()) { 962 if (stack_guard->IsInterrupted()) {
963 stack_guard->Continue(INTERRUPT); 963 stack_guard->Continue(INTERRUPT);
964 return isolate->StackOverflow(); 964 return isolate->StackOverflow();
965 } 965 }
966 return isolate->heap()->undefined_value(); 966 return isolate->heap()->undefined_value();
967 } 967 }
968 968
969 969
970 } } // namespace v8::internal 970 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/deoptimizer.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698