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

Side by Side Diff: src/execution.cc

Issue 151603004: A64: Synchronize with r16587. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/execution.h ('k') | src/extensions/statistics-extension.cc » ('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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 #endif // ENABLE_DEBUGGER_SUPPORT 141 #endif // ENABLE_DEBUGGER_SUPPORT
142 return Handle<Object>(); 142 return Handle<Object>();
143 } else { 143 } else {
144 isolate->clear_pending_message(); 144 isolate->clear_pending_message();
145 } 145 }
146 146
147 return Handle<Object>(value->ToObjectUnchecked(), isolate); 147 return Handle<Object>(value->ToObjectUnchecked(), isolate);
148 } 148 }
149 149
150 150
151 Handle<Object> Execution::Call(Handle<Object> callable, 151 Handle<Object> Execution::Call(Isolate* isolate,
152 Handle<Object> callable,
152 Handle<Object> receiver, 153 Handle<Object> receiver,
153 int argc, 154 int argc,
154 Handle<Object> argv[], 155 Handle<Object> argv[],
155 bool* pending_exception, 156 bool* pending_exception,
156 bool convert_receiver) { 157 bool convert_receiver) {
157 *pending_exception = false; 158 *pending_exception = false;
158 159
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
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
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, \
603 isolate->name##_fun(), \
603 isolate->js_builtins_object(), \ 604 isolate->js_builtins_object(), \
604 ARRAY_SIZE(argv), argv, \ 605 ARRAY_SIZE(argv), argv, \
605 has_pending_exception); \ 606 has_pending_exception); \
606 } while (false) 607 } while (false)
607 608
608 609
609 Handle<Object> Execution::ToNumber(Handle<Object> obj, bool* exc) { 610 Handle<Object> Execution::ToNumber(
611 Isolate* isolate, Handle<Object> obj, bool* exc) {
610 RETURN_NATIVE_CALL(to_number, { obj }, exc); 612 RETURN_NATIVE_CALL(to_number, { obj }, exc);
611 } 613 }
612 614
613 615
614 Handle<Object> Execution::ToString(Handle<Object> obj, bool* exc) { 616 Handle<Object> Execution::ToString(
617 Isolate* isolate, Handle<Object> obj, bool* exc) {
615 RETURN_NATIVE_CALL(to_string, { obj }, exc); 618 RETURN_NATIVE_CALL(to_string, { obj }, exc);
616 } 619 }
617 620
618 621
619 Handle<Object> Execution::ToDetailString(Handle<Object> obj, bool* exc) { 622 Handle<Object> Execution::ToDetailString(
623 Isolate* isolate, Handle<Object> obj, bool* exc) {
620 RETURN_NATIVE_CALL(to_detail_string, { obj }, exc); 624 RETURN_NATIVE_CALL(to_detail_string, { obj }, exc);
621 } 625 }
622 626
623 627
624 Handle<Object> Execution::ToObject(Handle<Object> obj, bool* exc) { 628 Handle<Object> Execution::ToObject(
629 Isolate* isolate, Handle<Object> obj, bool* exc) {
625 if (obj->IsSpecObject()) return obj; 630 if (obj->IsSpecObject()) return obj;
626 RETURN_NATIVE_CALL(to_object, { obj }, exc); 631 RETURN_NATIVE_CALL(to_object, { obj }, exc);
627 } 632 }
628 633
629 634
630 Handle<Object> Execution::ToInteger(Handle<Object> obj, bool* exc) { 635 Handle<Object> Execution::ToInteger(
636 Isolate* isolate, Handle<Object> obj, bool* exc) {
631 RETURN_NATIVE_CALL(to_integer, { obj }, exc); 637 RETURN_NATIVE_CALL(to_integer, { obj }, exc);
632 } 638 }
633 639
634 640
635 Handle<Object> Execution::ToUint32(Handle<Object> obj, bool* exc) { 641 Handle<Object> Execution::ToUint32(
642 Isolate* isolate, Handle<Object> obj, bool* exc) {
636 RETURN_NATIVE_CALL(to_uint32, { obj }, exc); 643 RETURN_NATIVE_CALL(to_uint32, { obj }, exc);
637 } 644 }
638 645
639 646
640 Handle<Object> Execution::ToInt32(Handle<Object> obj, bool* exc) { 647 Handle<Object> Execution::ToInt32(
648 Isolate* isolate, Handle<Object> obj, bool* exc) {
641 RETURN_NATIVE_CALL(to_int32, { obj }, exc); 649 RETURN_NATIVE_CALL(to_int32, { obj }, exc);
642 } 650 }
643 651
644 652
645 Handle<Object> Execution::NewDate(double time, bool* exc) { 653 Handle<Object> Execution::NewDate(Isolate* isolate, double time, bool* exc) {
646 Isolate* isolate = Isolate::Current();
647 Handle<Object> time_obj = isolate->factory()->NewNumber(time); 654 Handle<Object> time_obj = isolate->factory()->NewNumber(time);
648 RETURN_NATIVE_CALL(create_date, { time_obj }, exc); 655 RETURN_NATIVE_CALL(create_date, { time_obj }, exc);
649 } 656 }
650 657
651 658
652 #undef RETURN_NATIVE_CALL 659 #undef RETURN_NATIVE_CALL
653 660
654 661
655 Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, 662 Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern,
656 Handle<String> flags, 663 Handle<String> flags,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 return factory->undefined_value(); 698 return factory->undefined_value();
692 } 699 }
693 return result; 700 return result;
694 } 701 }
695 702
696 703
697 Handle<JSFunction> Execution::InstantiateFunction( 704 Handle<JSFunction> Execution::InstantiateFunction(
698 Handle<FunctionTemplateInfo> data, 705 Handle<FunctionTemplateInfo> data,
699 bool* exc) { 706 bool* exc) {
700 Isolate* isolate = data->GetIsolate(); 707 Isolate* isolate = data->GetIsolate();
701 // Fast case: see if the function has already been instantiated 708 if (!data->do_not_cache()) {
702 int serial_number = Smi::cast(data->serial_number())->value(); 709 // Fast case: see if the function has already been instantiated
703 Object* elm = 710 int serial_number = Smi::cast(data->serial_number())->value();
704 isolate->native_context()->function_cache()-> 711 Object* elm =
705 GetElementNoExceptionThrown(serial_number); 712 isolate->native_context()->function_cache()->
706 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm)); 713 GetElementNoExceptionThrown(isolate, serial_number);
714 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm));
715 }
707 // The function has not yet been instantiated in this context; do it. 716 // The function has not yet been instantiated in this context; do it.
708 Handle<Object> args[] = { data }; 717 Handle<Object> args[] = { data };
709 Handle<Object> result = Call(isolate->instantiate_fun(), 718 Handle<Object> result = Call(isolate,
719 isolate->instantiate_fun(),
710 isolate->js_builtins_object(), 720 isolate->js_builtins_object(),
711 ARRAY_SIZE(args), 721 ARRAY_SIZE(args),
712 args, 722 args,
713 exc); 723 exc);
714 if (*exc) return Handle<JSFunction>::null(); 724 if (*exc) return Handle<JSFunction>::null();
715 return Handle<JSFunction>::cast(result); 725 return Handle<JSFunction>::cast(result);
716 } 726 }
717 727
718 728
719 Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data, 729 Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data,
(...skipping 11 matching lines...) Expand all
731 Handle<JSFunction> cons = InstantiateFunction(cons_template, exc); 741 Handle<JSFunction> cons = InstantiateFunction(cons_template, exc);
732 if (*exc) return Handle<JSObject>::null(); 742 if (*exc) return Handle<JSObject>::null();
733 Handle<Object> value = New(cons, 0, NULL, exc); 743 Handle<Object> value = New(cons, 0, NULL, exc);
734 if (*exc) return Handle<JSObject>::null(); 744 if (*exc) return Handle<JSObject>::null();
735 result = *value; 745 result = *value;
736 } 746 }
737 ASSERT(!*exc); 747 ASSERT(!*exc);
738 return Handle<JSObject>(JSObject::cast(result)); 748 return Handle<JSObject>(JSObject::cast(result));
739 } else { 749 } else {
740 Handle<Object> args[] = { data }; 750 Handle<Object> args[] = { data };
741 Handle<Object> result = Call(isolate->instantiate_fun(), 751 Handle<Object> result = Call(isolate,
752 isolate->instantiate_fun(),
742 isolate->js_builtins_object(), 753 isolate->js_builtins_object(),
743 ARRAY_SIZE(args), 754 ARRAY_SIZE(args),
744 args, 755 args,
745 exc); 756 exc);
746 if (*exc) return Handle<JSObject>::null(); 757 if (*exc) return Handle<JSObject>::null();
747 return Handle<JSObject>::cast(result); 758 return Handle<JSObject>::cast(result);
748 } 759 }
749 } 760 }
750 761
751 762
752 void Execution::ConfigureInstance(Handle<Object> instance, 763 void Execution::ConfigureInstance(Isolate* isolate,
764 Handle<Object> instance,
753 Handle<Object> instance_template, 765 Handle<Object> instance_template,
754 bool* exc) { 766 bool* exc) {
755 Isolate* isolate = Isolate::Current();
756 Handle<Object> args[] = { instance, instance_template }; 767 Handle<Object> args[] = { instance, instance_template };
757 Execution::Call(isolate->configure_instance_fun(), 768 Execution::Call(isolate,
769 isolate->configure_instance_fun(),
758 isolate->js_builtins_object(), 770 isolate->js_builtins_object(),
759 ARRAY_SIZE(args), 771 ARRAY_SIZE(args),
760 args, 772 args,
761 exc); 773 exc);
762 } 774 }
763 775
764 776
765 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, 777 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv,
766 Handle<JSFunction> fun, 778 Handle<JSFunction> fun,
767 Handle<Object> pos, 779 Handle<Object> pos,
768 Handle<Object> is_global) { 780 Handle<Object> is_global) {
769 Isolate* isolate = fun->GetIsolate(); 781 Isolate* isolate = fun->GetIsolate();
770 Handle<Object> args[] = { recv, fun, pos, is_global }; 782 Handle<Object> args[] = { recv, fun, pos, is_global };
771 bool caught_exception; 783 bool caught_exception;
772 Handle<Object> result = TryCall(isolate->get_stack_trace_line_fun(), 784 Handle<Object> result = TryCall(isolate->get_stack_trace_line_fun(),
773 isolate->js_builtins_object(), 785 isolate->js_builtins_object(),
774 ARRAY_SIZE(args), 786 ARRAY_SIZE(args),
775 args, 787 args,
776 &caught_exception); 788 &caught_exception);
777 if (caught_exception || !result->IsString()) { 789 if (caught_exception || !result->IsString()) {
778 return isolate->factory()->empty_string(); 790 return isolate->factory()->empty_string();
779 } 791 }
780 792
781 return Handle<String>::cast(result); 793 return Handle<String>::cast(result);
782 } 794 }
783 795
784 796
785 static Object* RuntimePreempt() { 797 static Object* RuntimePreempt(Isolate* isolate) {
786 Isolate* isolate = Isolate::Current();
787
788 // Clear the preempt request flag. 798 // Clear the preempt request flag.
789 isolate->stack_guard()->Continue(PREEMPT); 799 isolate->stack_guard()->Continue(PREEMPT);
790 800
791 ContextSwitcher::PreemptionReceived(); 801 ContextSwitcher::PreemptionReceived();
792 802
793 #ifdef ENABLE_DEBUGGER_SUPPORT 803 #ifdef ENABLE_DEBUGGER_SUPPORT
794 if (isolate->debug()->InDebugger()) { 804 if (isolate->debug()->InDebugger()) {
795 // If currently in the debugger don't do any actual preemption but record 805 // If currently in the debugger don't do any actual preemption but record
796 // that preemption occoured while in the debugger. 806 // that preemption occoured while in the debugger.
797 isolate->debug()->PreemptionWhileInDebugger(); 807 isolate->debug()->PreemptionWhileInDebugger();
798 } else { 808 } else {
799 // Perform preemption. 809 // Perform preemption.
800 v8::Unlocker unlocker(reinterpret_cast<v8::Isolate*>(isolate)); 810 v8::Unlocker unlocker(reinterpret_cast<v8::Isolate*>(isolate));
801 Thread::YieldCPU(); 811 Thread::YieldCPU();
802 } 812 }
803 #else 813 #else
804 { // NOLINT 814 { // NOLINT
805 // Perform preemption. 815 // Perform preemption.
806 v8::Unlocker unlocker(reinterpret_cast<v8::Isolate*>(isolate)); 816 v8::Unlocker unlocker(reinterpret_cast<v8::Isolate*>(isolate));
807 Thread::YieldCPU(); 817 Thread::YieldCPU();
808 } 818 }
809 #endif 819 #endif
810 820
811 return isolate->heap()->undefined_value(); 821 return isolate->heap()->undefined_value();
812 } 822 }
813 823
814 824
815 #ifdef ENABLE_DEBUGGER_SUPPORT 825 #ifdef ENABLE_DEBUGGER_SUPPORT
816 Object* Execution::DebugBreakHelper() { 826 Object* Execution::DebugBreakHelper(Isolate* isolate) {
817 Isolate* isolate = Isolate::Current();
818
819 // Just continue if breaks are disabled. 827 // Just continue if breaks are disabled.
820 if (isolate->debug()->disable_break()) { 828 if (isolate->debug()->disable_break()) {
821 return isolate->heap()->undefined_value(); 829 return isolate->heap()->undefined_value();
822 } 830 }
823 831
824 // Ignore debug break during bootstrapping. 832 // Ignore debug break during bootstrapping.
825 if (isolate->bootstrapper()->IsActive()) { 833 if (isolate->bootstrapper()->IsActive()) {
826 return isolate->heap()->undefined_value(); 834 return isolate->heap()->undefined_value();
827 } 835 }
828 836
(...skipping 25 matching lines...) Expand all
854 } 862 }
855 863
856 // Collect the break state before clearing the flags. 864 // Collect the break state before clearing the flags.
857 bool debug_command_only = 865 bool debug_command_only =
858 isolate->stack_guard()->IsDebugCommand() && 866 isolate->stack_guard()->IsDebugCommand() &&
859 !isolate->stack_guard()->IsDebugBreak(); 867 !isolate->stack_guard()->IsDebugBreak();
860 868
861 // Clear the debug break request flag. 869 // Clear the debug break request flag.
862 isolate->stack_guard()->Continue(DEBUGBREAK); 870 isolate->stack_guard()->Continue(DEBUGBREAK);
863 871
864 ProcessDebugMessages(debug_command_only); 872 ProcessDebugMessages(isolate, debug_command_only);
865 873
866 // Return to continue execution. 874 // Return to continue execution.
867 return isolate->heap()->undefined_value(); 875 return isolate->heap()->undefined_value();
868 } 876 }
869 877
870 878
871 void Execution::ProcessDebugMessages(bool debug_command_only) { 879 void Execution::ProcessDebugMessages(Isolate* isolate,
872 Isolate* isolate = Isolate::Current(); 880 bool debug_command_only) {
873 // Clear the debug command request flag. 881 // Clear the debug command request flag.
874 isolate->stack_guard()->Continue(DEBUGCOMMAND); 882 isolate->stack_guard()->Continue(DEBUGCOMMAND);
875 883
876 StackLimitCheck check(isolate); 884 StackLimitCheck check(isolate);
877 if (check.HasOverflowed()) { 885 if (check.HasOverflowed()) {
878 return; 886 return;
879 } 887 }
880 888
881 HandleScope scope(isolate); 889 HandleScope scope(isolate);
882 // Enter the debugger. Just continue if we fail to enter the debugger. 890 // Enter the debugger. Just continue if we fail to enter the debugger.
883 EnterDebugger debugger; 891 EnterDebugger debugger(isolate);
884 if (debugger.FailedToEnter()) { 892 if (debugger.FailedToEnter()) {
885 return; 893 return;
886 } 894 }
887 895
888 // Notify the debug event listeners. Indicate auto continue if the break was 896 // Notify the debug event listeners. Indicate auto continue if the break was
889 // a debug command break. 897 // a debug command break.
890 isolate->debugger()->OnDebugBreak(isolate->factory()->undefined_value(), 898 isolate->debugger()->OnDebugBreak(isolate->factory()->undefined_value(),
891 debug_command_only); 899 debug_command_only);
892 } 900 }
893 901
(...skipping 10 matching lines...) Expand all
904 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 912 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
905 "StackGuard GC request"); 913 "StackGuard GC request");
906 stack_guard->Continue(GC_REQUEST); 914 stack_guard->Continue(GC_REQUEST);
907 } 915 }
908 916
909 isolate->counters()->stack_interrupts()->Increment(); 917 isolate->counters()->stack_interrupts()->Increment();
910 isolate->counters()->runtime_profiler_ticks()->Increment(); 918 isolate->counters()->runtime_profiler_ticks()->Increment();
911 isolate->runtime_profiler()->OptimizeNow(); 919 isolate->runtime_profiler()->OptimizeNow();
912 #ifdef ENABLE_DEBUGGER_SUPPORT 920 #ifdef ENABLE_DEBUGGER_SUPPORT
913 if (stack_guard->IsDebugBreak() || stack_guard->IsDebugCommand()) { 921 if (stack_guard->IsDebugBreak() || stack_guard->IsDebugCommand()) {
914 DebugBreakHelper(); 922 DebugBreakHelper(isolate);
915 } 923 }
916 #endif 924 #endif
917 if (stack_guard->IsPreempted()) RuntimePreempt(); 925 if (stack_guard->IsPreempted()) RuntimePreempt(isolate);
918 if (stack_guard->IsTerminateExecution()) { 926 if (stack_guard->IsTerminateExecution()) {
919 stack_guard->Continue(TERMINATE); 927 stack_guard->Continue(TERMINATE);
920 return isolate->TerminateExecution(); 928 return isolate->TerminateExecution();
921 } 929 }
922 if (stack_guard->IsInterrupted()) { 930 if (stack_guard->IsInterrupted()) {
923 stack_guard->Continue(INTERRUPT); 931 stack_guard->Continue(INTERRUPT);
924 return isolate->StackOverflow(); 932 return isolate->StackOverflow();
925 } 933 }
926 if (stack_guard->IsFullDeopt()) { 934 if (stack_guard->IsFullDeopt()) {
927 stack_guard->Continue(FULL_DEOPT); 935 stack_guard->Continue(FULL_DEOPT);
928 Deoptimizer::DeoptimizeAll(isolate); 936 Deoptimizer::DeoptimizeAll(isolate);
929 } 937 }
930 return isolate->heap()->undefined_value(); 938 return isolate->heap()->undefined_value();
931 } 939 }
932 940
933 941
934 } } // namespace v8::internal 942 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.h ('k') | src/extensions/statistics-extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698