Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 | 149 |
| 150 | 150 |
| 151 Handle<Object> Execution::Call(Handle<Object> callable, | 151 Handle<Object> Execution::Call(Handle<Object> callable, |
| 152 Handle<Object> receiver, | 152 Handle<Object> receiver, |
| 153 int argc, | 153 int argc, |
| 154 Handle<Object> argv[], | 154 Handle<Object> argv[], |
| 155 bool* pending_exception, | 155 bool* pending_exception, |
| 156 bool convert_receiver) { | 156 bool convert_receiver) { |
| 157 *pending_exception = false; | 157 *pending_exception = false; |
| 158 | 158 |
| 159 Isolate* isolate = Isolate::Current(); | |
|
Sven Panne
2013/09/02 14:23:45
I think all callers have the Isolate already, so w
dcarney
2013/09/02 15:38:44
You missed nothing. I didn't want to transform th
| |
| 159 if (!callable->IsJSFunction()) { | 160 if (!callable->IsJSFunction()) { |
| 160 callable = TryGetFunctionDelegate(callable, pending_exception); | 161 callable = TryGetFunctionDelegate(isolate, callable, pending_exception); |
| 161 if (*pending_exception) return callable; | 162 if (*pending_exception) return callable; |
| 162 } | 163 } |
| 163 Handle<JSFunction> func = Handle<JSFunction>::cast(callable); | 164 Handle<JSFunction> func = Handle<JSFunction>::cast(callable); |
| 164 | 165 |
| 165 // In non-strict mode, convert receiver. | 166 // In non-strict mode, convert receiver. |
| 166 if (convert_receiver && !receiver->IsJSReceiver() && | 167 if (convert_receiver && !receiver->IsJSReceiver() && |
| 167 !func->shared()->native() && func->shared()->is_classic_mode()) { | 168 !func->shared()->native() && func->shared()->is_classic_mode()) { |
| 168 if (receiver->IsUndefined() || receiver->IsNull()) { | 169 if (receiver->IsUndefined() || receiver->IsNull()) { |
| 169 Object* global = func->context()->global_object()->global_receiver(); | 170 Object* global = func->context()->global_object()->global_receiver(); |
| 170 // Under some circumstances, 'global' can be the JSBuiltinsObject | 171 // Under some circumstances, 'global' can be the JSBuiltinsObject |
| 171 // In that case, don't rewrite. (FWIW, the same holds for | 172 // In that case, don't rewrite. (FWIW, the same holds for |
| 172 // GetIsolate()->global_object()->global_receiver().) | 173 // GetIsolate()->global_object()->global_receiver().) |
| 173 if (!global->IsJSBuiltinsObject()) { | 174 if (!global->IsJSBuiltinsObject()) { |
| 174 receiver = Handle<Object>(global, func->GetIsolate()); | 175 receiver = Handle<Object>(global, func->GetIsolate()); |
| 175 } | 176 } |
| 176 } else { | 177 } else { |
| 177 receiver = ToObject(receiver, pending_exception); | 178 receiver = ToObject(isolate, receiver, pending_exception); |
| 178 } | 179 } |
| 179 if (*pending_exception) return callable; | 180 if (*pending_exception) return callable; |
| 180 } | 181 } |
| 181 | 182 |
| 182 return Invoke(false, func, receiver, argc, argv, pending_exception); | 183 return Invoke(false, func, receiver, argc, argv, pending_exception); |
| 183 } | 184 } |
| 184 | 185 |
| 185 | 186 |
| 186 Handle<Object> Execution::New(Handle<JSFunction> func, | 187 Handle<Object> Execution::New(Handle<JSFunction> func, |
| 187 int argc, | 188 int argc, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 } | 228 } |
| 228 isolate->OptionalRescheduleException(true); | 229 isolate->OptionalRescheduleException(true); |
| 229 } | 230 } |
| 230 | 231 |
| 231 ASSERT(!isolate->has_pending_exception()); | 232 ASSERT(!isolate->has_pending_exception()); |
| 232 ASSERT(!isolate->external_caught_exception()); | 233 ASSERT(!isolate->external_caught_exception()); |
| 233 return result; | 234 return result; |
| 234 } | 235 } |
| 235 | 236 |
| 236 | 237 |
| 237 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { | 238 Handle<Object> Execution::GetFunctionDelegate(Isolate* isolate, |
| 239 Handle<Object> object) { | |
| 238 ASSERT(!object->IsJSFunction()); | 240 ASSERT(!object->IsJSFunction()); |
| 239 Isolate* isolate = Isolate::Current(); | |
| 240 Factory* factory = isolate->factory(); | 241 Factory* factory = isolate->factory(); |
| 241 | 242 |
| 242 // If you return a function from here, it will be called when an | 243 // If you return a function from here, it will be called when an |
| 243 // attempt is made to call the given object as a function. | 244 // attempt is made to call the given object as a function. |
| 244 | 245 |
| 245 // If object is a function proxy, get its handler. Iterate if necessary. | 246 // If object is a function proxy, get its handler. Iterate if necessary. |
| 246 Object* fun = *object; | 247 Object* fun = *object; |
| 247 while (fun->IsJSFunctionProxy()) { | 248 while (fun->IsJSFunctionProxy()) { |
| 248 fun = JSFunctionProxy::cast(fun)->call_trap(); | 249 fun = JSFunctionProxy::cast(fun)->call_trap(); |
| 249 } | 250 } |
| 250 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); | 251 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); |
| 251 | 252 |
| 252 // Objects created through the API can have an instance-call handler | 253 // Objects created through the API can have an instance-call handler |
| 253 // that should be used when calling the object as a function. | 254 // that should be used when calling the object as a function. |
| 254 if (fun->IsHeapObject() && | 255 if (fun->IsHeapObject() && |
| 255 HeapObject::cast(fun)->map()->has_instance_call_handler()) { | 256 HeapObject::cast(fun)->map()->has_instance_call_handler()) { |
| 256 return Handle<JSFunction>( | 257 return Handle<JSFunction>( |
| 257 isolate->native_context()->call_as_function_delegate()); | 258 isolate->native_context()->call_as_function_delegate()); |
| 258 } | 259 } |
| 259 | 260 |
| 260 return factory->undefined_value(); | 261 return factory->undefined_value(); |
| 261 } | 262 } |
| 262 | 263 |
| 263 | 264 |
| 264 Handle<Object> Execution::TryGetFunctionDelegate(Handle<Object> object, | 265 Handle<Object> Execution::TryGetFunctionDelegate(Isolate* isolate, |
| 266 Handle<Object> object, | |
| 265 bool* has_pending_exception) { | 267 bool* has_pending_exception) { |
| 266 ASSERT(!object->IsJSFunction()); | 268 ASSERT(!object->IsJSFunction()); |
| 267 Isolate* isolate = Isolate::Current(); | |
| 268 | 269 |
| 269 // If object is a function proxy, get its handler. Iterate if necessary. | 270 // If object is a function proxy, get its handler. Iterate if necessary. |
| 270 Object* fun = *object; | 271 Object* fun = *object; |
| 271 while (fun->IsJSFunctionProxy()) { | 272 while (fun->IsJSFunctionProxy()) { |
| 272 fun = JSFunctionProxy::cast(fun)->call_trap(); | 273 fun = JSFunctionProxy::cast(fun)->call_trap(); |
| 273 } | 274 } |
| 274 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); | 275 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); |
| 275 | 276 |
| 276 // Objects created through the API can have an instance-call handler | 277 // Objects created through the API can have an instance-call handler |
| 277 // that should be used when calling the object as a function. | 278 // that should be used when calling the object as a function. |
| 278 if (fun->IsHeapObject() && | 279 if (fun->IsHeapObject() && |
| 279 HeapObject::cast(fun)->map()->has_instance_call_handler()) { | 280 HeapObject::cast(fun)->map()->has_instance_call_handler()) { |
| 280 return Handle<JSFunction>( | 281 return Handle<JSFunction>( |
| 281 isolate->native_context()->call_as_function_delegate()); | 282 isolate->native_context()->call_as_function_delegate()); |
| 282 } | 283 } |
| 283 | 284 |
| 284 // If the Object doesn't have an instance-call handler we should | 285 // If the Object doesn't have an instance-call handler we should |
| 285 // throw a non-callable exception. | 286 // throw a non-callable exception. |
| 286 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError( | 287 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError( |
| 287 "called_non_callable", i::HandleVector<i::Object>(&object, 1)); | 288 "called_non_callable", i::HandleVector<i::Object>(&object, 1)); |
| 288 isolate->Throw(*error_obj); | 289 isolate->Throw(*error_obj); |
| 289 *has_pending_exception = true; | 290 *has_pending_exception = true; |
| 290 | 291 |
| 291 return isolate->factory()->undefined_value(); | 292 return isolate->factory()->undefined_value(); |
| 292 } | 293 } |
| 293 | 294 |
| 294 | 295 |
| 295 Handle<Object> Execution::GetConstructorDelegate(Handle<Object> object) { | 296 Handle<Object> Execution::GetConstructorDelegate(Isolate* isolate, |
| 297 Handle<Object> object) { | |
| 296 ASSERT(!object->IsJSFunction()); | 298 ASSERT(!object->IsJSFunction()); |
| 297 Isolate* isolate = Isolate::Current(); | |
| 298 | 299 |
| 299 // If you return a function from here, it will be called when an | 300 // If you return a function from here, it will be called when an |
| 300 // attempt is made to call the given object as a constructor. | 301 // attempt is made to call the given object as a constructor. |
| 301 | 302 |
| 302 // If object is a function proxies, get its handler. Iterate if necessary. | 303 // If object is a function proxies, get its handler. Iterate if necessary. |
| 303 Object* fun = *object; | 304 Object* fun = *object; |
| 304 while (fun->IsJSFunctionProxy()) { | 305 while (fun->IsJSFunctionProxy()) { |
| 305 fun = JSFunctionProxy::cast(fun)->call_trap(); | 306 fun = JSFunctionProxy::cast(fun)->call_trap(); |
| 306 } | 307 } |
| 307 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); | 308 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); |
| 308 | 309 |
| 309 // Objects created through the API can have an instance-call handler | 310 // Objects created through the API can have an instance-call handler |
| 310 // that should be used when calling the object as a function. | 311 // that should be used when calling the object as a function. |
| 311 if (fun->IsHeapObject() && | 312 if (fun->IsHeapObject() && |
| 312 HeapObject::cast(fun)->map()->has_instance_call_handler()) { | 313 HeapObject::cast(fun)->map()->has_instance_call_handler()) { |
| 313 return Handle<JSFunction>( | 314 return Handle<JSFunction>( |
| 314 isolate->native_context()->call_as_constructor_delegate()); | 315 isolate->native_context()->call_as_constructor_delegate()); |
| 315 } | 316 } |
| 316 | 317 |
| 317 return isolate->factory()->undefined_value(); | 318 return isolate->factory()->undefined_value(); |
| 318 } | 319 } |
| 319 | 320 |
| 320 | 321 |
| 321 Handle<Object> Execution::TryGetConstructorDelegate( | 322 Handle<Object> Execution::TryGetConstructorDelegate( |
| 323 Isolate* isolate, | |
| 322 Handle<Object> object, | 324 Handle<Object> object, |
| 323 bool* has_pending_exception) { | 325 bool* has_pending_exception) { |
| 324 ASSERT(!object->IsJSFunction()); | 326 ASSERT(!object->IsJSFunction()); |
| 325 Isolate* isolate = Isolate::Current(); | |
| 326 | 327 |
| 327 // If you return a function from here, it will be called when an | 328 // If you return a function from here, it will be called when an |
| 328 // attempt is made to call the given object as a constructor. | 329 // attempt is made to call the given object as a constructor. |
| 329 | 330 |
| 330 // If object is a function proxies, get its handler. Iterate if necessary. | 331 // If object is a function proxies, get its handler. Iterate if necessary. |
| 331 Object* fun = *object; | 332 Object* fun = *object; |
| 332 while (fun->IsJSFunctionProxy()) { | 333 while (fun->IsJSFunctionProxy()) { |
| 333 fun = JSFunctionProxy::cast(fun)->call_trap(); | 334 fun = JSFunctionProxy::cast(fun)->call_trap(); |
| 334 } | 335 } |
| 335 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); | 336 if (fun->IsJSFunction()) return Handle<Object>(fun, isolate); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 if (stored_limit != 0) { | 590 if (stored_limit != 0) { |
| 590 SetStackLimit(stored_limit); | 591 SetStackLimit(stored_limit); |
| 591 } | 592 } |
| 592 } | 593 } |
| 593 | 594 |
| 594 | 595 |
| 595 // --- C a l l s t o n a t i v e s --- | 596 // --- C a l l s t o n a t i v e s --- |
| 596 | 597 |
| 597 #define RETURN_NATIVE_CALL(name, args, has_pending_exception) \ | 598 #define RETURN_NATIVE_CALL(name, args, has_pending_exception) \ |
| 598 do { \ | 599 do { \ |
| 599 Isolate* isolate = Isolate::Current(); \ | |
| 600 Handle<Object> argv[] = args; \ | 600 Handle<Object> argv[] = args; \ |
| 601 ASSERT(has_pending_exception != NULL); \ | 601 ASSERT(has_pending_exception != NULL); \ |
| 602 return Call(isolate->name##_fun(), \ | 602 return Call(isolate->name##_fun(), \ |
| 603 isolate->js_builtins_object(), \ | 603 isolate->js_builtins_object(), \ |
| 604 ARRAY_SIZE(argv), argv, \ | 604 ARRAY_SIZE(argv), argv, \ |
| 605 has_pending_exception); \ | 605 has_pending_exception); \ |
| 606 } while (false) | 606 } while (false) |
| 607 | 607 |
| 608 | 608 |
| 609 Handle<Object> Execution::ToNumber(Handle<Object> obj, bool* exc) { | 609 Handle<Object> Execution::ToNumber( |
| 610 Isolate* isolate, Handle<Object> obj, bool* exc) { | |
| 610 RETURN_NATIVE_CALL(to_number, { obj }, exc); | 611 RETURN_NATIVE_CALL(to_number, { obj }, exc); |
| 611 } | 612 } |
| 612 | 613 |
| 613 | 614 |
| 614 Handle<Object> Execution::ToString(Handle<Object> obj, bool* exc) { | 615 Handle<Object> Execution::ToString( |
| 616 Isolate* isolate, Handle<Object> obj, bool* exc) { | |
| 615 RETURN_NATIVE_CALL(to_string, { obj }, exc); | 617 RETURN_NATIVE_CALL(to_string, { obj }, exc); |
| 616 } | 618 } |
| 617 | 619 |
| 618 | 620 |
| 619 Handle<Object> Execution::ToDetailString(Handle<Object> obj, bool* exc) { | 621 Handle<Object> Execution::ToDetailString( |
| 622 Isolate* isolate, Handle<Object> obj, bool* exc) { | |
| 620 RETURN_NATIVE_CALL(to_detail_string, { obj }, exc); | 623 RETURN_NATIVE_CALL(to_detail_string, { obj }, exc); |
| 621 } | 624 } |
| 622 | 625 |
| 623 | 626 |
| 624 Handle<Object> Execution::ToObject(Handle<Object> obj, bool* exc) { | 627 Handle<Object> Execution::ToObject( |
| 628 Isolate* isolate, Handle<Object> obj, bool* exc) { | |
| 625 if (obj->IsSpecObject()) return obj; | 629 if (obj->IsSpecObject()) return obj; |
| 626 RETURN_NATIVE_CALL(to_object, { obj }, exc); | 630 RETURN_NATIVE_CALL(to_object, { obj }, exc); |
| 627 } | 631 } |
| 628 | 632 |
| 629 | 633 |
| 630 Handle<Object> Execution::ToInteger(Handle<Object> obj, bool* exc) { | 634 Handle<Object> Execution::ToInteger( |
| 635 Isolate* isolate, Handle<Object> obj, bool* exc) { | |
| 631 RETURN_NATIVE_CALL(to_integer, { obj }, exc); | 636 RETURN_NATIVE_CALL(to_integer, { obj }, exc); |
| 632 } | 637 } |
| 633 | 638 |
| 634 | 639 |
| 635 Handle<Object> Execution::ToUint32(Handle<Object> obj, bool* exc) { | 640 Handle<Object> Execution::ToUint32( |
| 641 Isolate* isolate, Handle<Object> obj, bool* exc) { | |
| 636 RETURN_NATIVE_CALL(to_uint32, { obj }, exc); | 642 RETURN_NATIVE_CALL(to_uint32, { obj }, exc); |
| 637 } | 643 } |
| 638 | 644 |
| 639 | 645 |
| 640 Handle<Object> Execution::ToInt32(Handle<Object> obj, bool* exc) { | 646 Handle<Object> Execution::ToInt32( |
| 647 Isolate* isolate, Handle<Object> obj, bool* exc) { | |
| 641 RETURN_NATIVE_CALL(to_int32, { obj }, exc); | 648 RETURN_NATIVE_CALL(to_int32, { obj }, exc); |
| 642 } | 649 } |
| 643 | 650 |
| 644 | 651 |
| 645 Handle<Object> Execution::NewDate(double time, bool* exc) { | 652 Handle<Object> Execution::NewDate(Isolate* isolate, double time, bool* exc) { |
| 646 Isolate* isolate = Isolate::Current(); | |
| 647 Handle<Object> time_obj = isolate->factory()->NewNumber(time); | 653 Handle<Object> time_obj = isolate->factory()->NewNumber(time); |
| 648 RETURN_NATIVE_CALL(create_date, { time_obj }, exc); | 654 RETURN_NATIVE_CALL(create_date, { time_obj }, exc); |
| 649 } | 655 } |
| 650 | 656 |
| 651 | 657 |
| 652 #undef RETURN_NATIVE_CALL | 658 #undef RETURN_NATIVE_CALL |
| 653 | 659 |
| 654 | 660 |
| 655 Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, | 661 Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, |
| 656 Handle<String> flags, | 662 Handle<String> flags, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 isolate->js_builtins_object(), | 748 isolate->js_builtins_object(), |
| 743 ARRAY_SIZE(args), | 749 ARRAY_SIZE(args), |
| 744 args, | 750 args, |
| 745 exc); | 751 exc); |
| 746 if (*exc) return Handle<JSObject>::null(); | 752 if (*exc) return Handle<JSObject>::null(); |
| 747 return Handle<JSObject>::cast(result); | 753 return Handle<JSObject>::cast(result); |
| 748 } | 754 } |
| 749 } | 755 } |
| 750 | 756 |
| 751 | 757 |
| 752 void Execution::ConfigureInstance(Handle<Object> instance, | 758 void Execution::ConfigureInstance(Isolate* isolate, |
| 759 Handle<Object> instance, | |
| 753 Handle<Object> instance_template, | 760 Handle<Object> instance_template, |
| 754 bool* exc) { | 761 bool* exc) { |
| 755 Isolate* isolate = Isolate::Current(); | |
| 756 Handle<Object> args[] = { instance, instance_template }; | 762 Handle<Object> args[] = { instance, instance_template }; |
| 757 Execution::Call(isolate->configure_instance_fun(), | 763 Execution::Call(isolate->configure_instance_fun(), |
| 758 isolate->js_builtins_object(), | 764 isolate->js_builtins_object(), |
| 759 ARRAY_SIZE(args), | 765 ARRAY_SIZE(args), |
| 760 args, | 766 args, |
| 761 exc); | 767 exc); |
| 762 } | 768 } |
| 763 | 769 |
| 764 | 770 |
| 765 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, | 771 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, |
| 766 Handle<JSFunction> fun, | 772 Handle<JSFunction> fun, |
| 767 Handle<Object> pos, | 773 Handle<Object> pos, |
| 768 Handle<Object> is_global) { | 774 Handle<Object> is_global) { |
| 769 Isolate* isolate = fun->GetIsolate(); | 775 Isolate* isolate = fun->GetIsolate(); |
| 770 Handle<Object> args[] = { recv, fun, pos, is_global }; | 776 Handle<Object> args[] = { recv, fun, pos, is_global }; |
| 771 bool caught_exception; | 777 bool caught_exception; |
| 772 Handle<Object> result = TryCall(isolate->get_stack_trace_line_fun(), | 778 Handle<Object> result = TryCall(isolate->get_stack_trace_line_fun(), |
| 773 isolate->js_builtins_object(), | 779 isolate->js_builtins_object(), |
| 774 ARRAY_SIZE(args), | 780 ARRAY_SIZE(args), |
| 775 args, | 781 args, |
| 776 &caught_exception); | 782 &caught_exception); |
| 777 if (caught_exception || !result->IsString()) { | 783 if (caught_exception || !result->IsString()) { |
| 778 return isolate->factory()->empty_string(); | 784 return isolate->factory()->empty_string(); |
| 779 } | 785 } |
| 780 | 786 |
| 781 return Handle<String>::cast(result); | 787 return Handle<String>::cast(result); |
| 782 } | 788 } |
| 783 | 789 |
| 784 | 790 |
| 785 static Object* RuntimePreempt() { | 791 static Object* RuntimePreempt(Isolate* isolate) { |
| 786 Isolate* isolate = Isolate::Current(); | |
| 787 | |
| 788 // Clear the preempt request flag. | 792 // Clear the preempt request flag. |
| 789 isolate->stack_guard()->Continue(PREEMPT); | 793 isolate->stack_guard()->Continue(PREEMPT); |
| 790 | 794 |
| 791 ContextSwitcher::PreemptionReceived(); | 795 ContextSwitcher::PreemptionReceived(); |
| 792 | 796 |
| 793 #ifdef ENABLE_DEBUGGER_SUPPORT | 797 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 794 if (isolate->debug()->InDebugger()) { | 798 if (isolate->debug()->InDebugger()) { |
| 795 // If currently in the debugger don't do any actual preemption but record | 799 // If currently in the debugger don't do any actual preemption but record |
| 796 // that preemption occoured while in the debugger. | 800 // that preemption occoured while in the debugger. |
| 797 isolate->debug()->PreemptionWhileInDebugger(); | 801 isolate->debug()->PreemptionWhileInDebugger(); |
| 798 } else { | 802 } else { |
| 799 // Perform preemption. | 803 // Perform preemption. |
| 800 v8::Unlocker unlocker(reinterpret_cast<v8::Isolate*>(isolate)); | 804 v8::Unlocker unlocker(reinterpret_cast<v8::Isolate*>(isolate)); |
| 801 Thread::YieldCPU(); | 805 Thread::YieldCPU(); |
| 802 } | 806 } |
| 803 #else | 807 #else |
| 804 { // NOLINT | 808 { // NOLINT |
| 805 // Perform preemption. | 809 // Perform preemption. |
| 806 v8::Unlocker unlocker(reinterpret_cast<v8::Isolate*>(isolate)); | 810 v8::Unlocker unlocker(reinterpret_cast<v8::Isolate*>(isolate)); |
| 807 Thread::YieldCPU(); | 811 Thread::YieldCPU(); |
| 808 } | 812 } |
| 809 #endif | 813 #endif |
| 810 | 814 |
| 811 return isolate->heap()->undefined_value(); | 815 return isolate->heap()->undefined_value(); |
| 812 } | 816 } |
| 813 | 817 |
| 814 | 818 |
| 815 #ifdef ENABLE_DEBUGGER_SUPPORT | 819 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 816 Object* Execution::DebugBreakHelper() { | 820 Object* Execution::DebugBreakHelper(Isolate* isolate) { |
| 817 Isolate* isolate = Isolate::Current(); | |
| 818 | |
| 819 // Just continue if breaks are disabled. | 821 // Just continue if breaks are disabled. |
| 820 if (isolate->debug()->disable_break()) { | 822 if (isolate->debug()->disable_break()) { |
| 821 return isolate->heap()->undefined_value(); | 823 return isolate->heap()->undefined_value(); |
| 822 } | 824 } |
| 823 | 825 |
| 824 // Ignore debug break during bootstrapping. | 826 // Ignore debug break during bootstrapping. |
| 825 if (isolate->bootstrapper()->IsActive()) { | 827 if (isolate->bootstrapper()->IsActive()) { |
| 826 return isolate->heap()->undefined_value(); | 828 return isolate->heap()->undefined_value(); |
| 827 } | 829 } |
| 828 | 830 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 854 } | 856 } |
| 855 | 857 |
| 856 // Collect the break state before clearing the flags. | 858 // Collect the break state before clearing the flags. |
| 857 bool debug_command_only = | 859 bool debug_command_only = |
| 858 isolate->stack_guard()->IsDebugCommand() && | 860 isolate->stack_guard()->IsDebugCommand() && |
| 859 !isolate->stack_guard()->IsDebugBreak(); | 861 !isolate->stack_guard()->IsDebugBreak(); |
| 860 | 862 |
| 861 // Clear the debug break request flag. | 863 // Clear the debug break request flag. |
| 862 isolate->stack_guard()->Continue(DEBUGBREAK); | 864 isolate->stack_guard()->Continue(DEBUGBREAK); |
| 863 | 865 |
| 864 ProcessDebugMessages(debug_command_only); | 866 ProcessDebugMessages(isolate, debug_command_only); |
| 865 | 867 |
| 866 // Return to continue execution. | 868 // Return to continue execution. |
| 867 return isolate->heap()->undefined_value(); | 869 return isolate->heap()->undefined_value(); |
| 868 } | 870 } |
| 869 | 871 |
| 870 | 872 |
| 871 void Execution::ProcessDebugMessages(bool debug_command_only) { | 873 void Execution::ProcessDebugMessages(Isolate* isolate, |
| 872 Isolate* isolate = Isolate::Current(); | 874 bool debug_command_only) { |
| 873 // Clear the debug command request flag. | 875 // Clear the debug command request flag. |
| 874 isolate->stack_guard()->Continue(DEBUGCOMMAND); | 876 isolate->stack_guard()->Continue(DEBUGCOMMAND); |
| 875 | 877 |
| 876 StackLimitCheck check(isolate); | 878 StackLimitCheck check(isolate); |
| 877 if (check.HasOverflowed()) { | 879 if (check.HasOverflowed()) { |
| 878 return; | 880 return; |
| 879 } | 881 } |
| 880 | 882 |
| 881 HandleScope scope(isolate); | 883 HandleScope scope(isolate); |
| 882 // Enter the debugger. Just continue if we fail to enter the debugger. | 884 // Enter the debugger. Just continue if we fail to enter the debugger. |
| 883 EnterDebugger debugger; | 885 EnterDebugger debugger(isolate); |
| 884 if (debugger.FailedToEnter()) { | 886 if (debugger.FailedToEnter()) { |
| 885 return; | 887 return; |
| 886 } | 888 } |
| 887 | 889 |
| 888 // Notify the debug event listeners. Indicate auto continue if the break was | 890 // Notify the debug event listeners. Indicate auto continue if the break was |
| 889 // a debug command break. | 891 // a debug command break. |
| 890 isolate->debugger()->OnDebugBreak(isolate->factory()->undefined_value(), | 892 isolate->debugger()->OnDebugBreak(isolate->factory()->undefined_value(), |
| 891 debug_command_only); | 893 debug_command_only); |
| 892 } | 894 } |
| 893 | 895 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 904 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 906 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 905 "StackGuard GC request"); | 907 "StackGuard GC request"); |
| 906 stack_guard->Continue(GC_REQUEST); | 908 stack_guard->Continue(GC_REQUEST); |
| 907 } | 909 } |
| 908 | 910 |
| 909 isolate->counters()->stack_interrupts()->Increment(); | 911 isolate->counters()->stack_interrupts()->Increment(); |
| 910 isolate->counters()->runtime_profiler_ticks()->Increment(); | 912 isolate->counters()->runtime_profiler_ticks()->Increment(); |
| 911 isolate->runtime_profiler()->OptimizeNow(); | 913 isolate->runtime_profiler()->OptimizeNow(); |
| 912 #ifdef ENABLE_DEBUGGER_SUPPORT | 914 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 913 if (stack_guard->IsDebugBreak() || stack_guard->IsDebugCommand()) { | 915 if (stack_guard->IsDebugBreak() || stack_guard->IsDebugCommand()) { |
| 914 DebugBreakHelper(); | 916 DebugBreakHelper(isolate); |
| 915 } | 917 } |
| 916 #endif | 918 #endif |
| 917 if (stack_guard->IsPreempted()) RuntimePreempt(); | 919 if (stack_guard->IsPreempted()) RuntimePreempt(isolate); |
| 918 if (stack_guard->IsTerminateExecution()) { | 920 if (stack_guard->IsTerminateExecution()) { |
| 919 stack_guard->Continue(TERMINATE); | 921 stack_guard->Continue(TERMINATE); |
| 920 return isolate->TerminateExecution(); | 922 return isolate->TerminateExecution(); |
| 921 } | 923 } |
| 922 if (stack_guard->IsInterrupted()) { | 924 if (stack_guard->IsInterrupted()) { |
| 923 stack_guard->Continue(INTERRUPT); | 925 stack_guard->Continue(INTERRUPT); |
| 924 return isolate->StackOverflow(); | 926 return isolate->StackOverflow(); |
| 925 } | 927 } |
| 926 if (stack_guard->IsFullDeopt()) { | 928 if (stack_guard->IsFullDeopt()) { |
| 927 stack_guard->Continue(FULL_DEOPT); | 929 stack_guard->Continue(FULL_DEOPT); |
| 928 Deoptimizer::DeoptimizeAll(isolate); | 930 Deoptimizer::DeoptimizeAll(isolate); |
| 929 } | 931 } |
| 930 return isolate->heap()->undefined_value(); | 932 return isolate->heap()->undefined_value(); |
| 931 } | 933 } |
| 932 | 934 |
| 933 | 935 |
| 934 } } // namespace v8::internal | 936 } } // namespace v8::internal |
| OLD | NEW |