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

Side by Side Diff: src/execution.cc

Issue 6794050: Revert "[Arguments] Merge (7442,7496] from bleeding_edge." (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/arguments
Patch Set: Created 9 years, 8 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/extensions/experimental/break-iterator.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 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 ASSERT(!Isolate::Current()->has_pending_exception()); 194 ASSERT(!Isolate::Current()->has_pending_exception());
195 ASSERT(!Isolate::Current()->external_caught_exception()); 195 ASSERT(!Isolate::Current()->external_caught_exception());
196 return result; 196 return result;
197 } 197 }
198 198
199 199
200 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { 200 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) {
201 ASSERT(!object->IsJSFunction()); 201 ASSERT(!object->IsJSFunction());
202 Isolate* isolate = Isolate::Current();
203 Factory* factory = isolate->factory();
204 202
205 // If you return a function from here, it will be called when an 203 // If you return a function from here, it will be called when an
206 // attempt is made to call the given object as a function. 204 // attempt is made to call the given object as a function.
207 205
208 // Regular expressions can be called as functions in both Firefox 206 // Regular expressions can be called as functions in both Firefox
209 // and Safari so we allow it too. 207 // and Safari so we allow it too.
210 if (object->IsJSRegExp()) { 208 if (object->IsJSRegExp()) {
211 Handle<String> exec = factory->exec_symbol(); 209 Handle<String> exec = FACTORY->exec_symbol();
212 // TODO(lrn): Bug 617. We should use the default function here, not the 210 // TODO(lrn): Bug 617. We should use the default function here, not the
213 // one on the RegExp object. 211 // one on the RegExp object.
214 Object* exec_function; 212 Object* exec_function;
215 { MaybeObject* maybe_exec_function = object->GetProperty(*exec); 213 { MaybeObject* maybe_exec_function = object->GetProperty(*exec);
216 // This can lose an exception, but the alternative is to put a failure 214 // This can lose an exception, but the alternative is to put a failure
217 // object in a handle, which is not GC safe. 215 // object in a handle, which is not GC safe.
218 if (!maybe_exec_function->ToObject(&exec_function)) { 216 if (!maybe_exec_function->ToObject(&exec_function)) {
219 return factory->undefined_value(); 217 return FACTORY->undefined_value();
220 } 218 }
221 } 219 }
222 return Handle<Object>(exec_function); 220 return Handle<Object>(exec_function);
223 } 221 }
224 222
225 // Objects created through the API can have an instance-call handler 223 // Objects created through the API can have an instance-call handler
226 // that should be used when calling the object as a function. 224 // that should be used when calling the object as a function.
227 if (object->IsHeapObject() && 225 if (object->IsHeapObject() &&
228 HeapObject::cast(*object)->map()->has_instance_call_handler()) { 226 HeapObject::cast(*object)->map()->has_instance_call_handler()) {
229 return Handle<JSFunction>( 227 return Handle<JSFunction>(
230 isolate->global_context()->call_as_function_delegate()); 228 Isolate::Current()->global_context()->call_as_function_delegate());
231 } 229 }
232 230
233 return factory->undefined_value(); 231 return FACTORY->undefined_value();
234 } 232 }
235 233
236 234
237 Handle<Object> Execution::GetConstructorDelegate(Handle<Object> object) { 235 Handle<Object> Execution::GetConstructorDelegate(Handle<Object> object) {
238 ASSERT(!object->IsJSFunction()); 236 ASSERT(!object->IsJSFunction());
239 Isolate* isolate = Isolate::Current();
240 237
241 // If you return a function from here, it will be called when an 238 // If you return a function from here, it will be called when an
242 // attempt is made to call the given object as a constructor. 239 // attempt is made to call the given object as a constructor.
243 240
244 // Objects created through the API can have an instance-call handler 241 // Objects created through the API can have an instance-call handler
245 // that should be used when calling the object as a function. 242 // that should be used when calling the object as a function.
246 if (object->IsHeapObject() && 243 if (object->IsHeapObject() &&
247 HeapObject::cast(*object)->map()->has_instance_call_handler()) { 244 HeapObject::cast(*object)->map()->has_instance_call_handler()) {
248 return Handle<JSFunction>( 245 return Handle<JSFunction>(
249 isolate->global_context()->call_as_constructor_delegate()); 246 Isolate::Current()->global_context()->call_as_constructor_delegate());
250 } 247 }
251 248
252 return isolate->factory()->undefined_value(); 249 return FACTORY->undefined_value();
253 } 250 }
254 251
255 252
256 bool StackGuard::IsStackOverflow() { 253 bool StackGuard::IsStackOverflow() {
257 ExecutionAccess access(isolate_); 254 ExecutionAccess access(isolate_);
258 return (thread_local_.jslimit_ != kInterruptLimit && 255 return (thread_local_.jslimit_ != kInterruptLimit &&
259 thread_local_.climit_ != kInterruptLimit); 256 thread_local_.climit_ != kInterruptLimit);
260 } 257 }
261 258
262 259
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 if (stored_limit != 0) { 460 if (stored_limit != 0) {
464 StackGuard::SetStackLimit(stored_limit); 461 StackGuard::SetStackLimit(stored_limit);
465 } 462 }
466 } 463 }
467 464
468 465
469 // --- C a l l s t o n a t i v e s --- 466 // --- C a l l s t o n a t i v e s ---
470 467
471 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \ 468 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \
472 do { \ 469 do { \
473 Isolate* isolate = Isolate::Current(); \
474 Object** args[argc] = argv; \ 470 Object** args[argc] = argv; \
475 ASSERT(has_pending_exception != NULL); \ 471 ASSERT(has_pending_exception != NULL); \
476 return Call(isolate->name##_fun(), \ 472 return Call(Isolate::Current()->name##_fun(), \
477 isolate->js_builtins_object(), argc, args, \ 473 Isolate::Current()->js_builtins_object(), argc, args, \
478 has_pending_exception); \ 474 has_pending_exception); \
479 } while (false) 475 } while (false)
480 476
481 477
482 Handle<Object> Execution::ToBoolean(Handle<Object> obj) { 478 Handle<Object> Execution::ToBoolean(Handle<Object> obj) {
483 // See the similar code in runtime.js:ToBoolean. 479 // See the similar code in runtime.js:ToBoolean.
484 if (obj->IsBoolean()) return obj; 480 if (obj->IsBoolean()) return obj;
485 bool result = true; 481 bool result = true;
486 if (obj->IsString()) { 482 if (obj->IsString()) {
487 result = Handle<String>::cast(obj)->length() != 0; 483 result = Handle<String>::cast(obj)->length() != 0;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 Handle<JSFunction> function = Handle<JSFunction>( 542 Handle<JSFunction> function = Handle<JSFunction>(
547 pattern->GetIsolate()->global_context()->regexp_function()); 543 pattern->GetIsolate()->global_context()->regexp_function());
548 Handle<Object> re_obj = RegExpImpl::CreateRegExpLiteral( 544 Handle<Object> re_obj = RegExpImpl::CreateRegExpLiteral(
549 function, pattern, flags, exc); 545 function, pattern, flags, exc);
550 if (*exc) return Handle<JSRegExp>(); 546 if (*exc) return Handle<JSRegExp>();
551 return Handle<JSRegExp>::cast(re_obj); 547 return Handle<JSRegExp>::cast(re_obj);
552 } 548 }
553 549
554 550
555 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { 551 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) {
556 Isolate* isolate = string->GetIsolate();
557 Factory* factory = isolate->factory();
558
559 int int_index = static_cast<int>(index); 552 int int_index = static_cast<int>(index);
560 if (int_index < 0 || int_index >= string->length()) { 553 if (int_index < 0 || int_index >= string->length()) {
561 return factory->undefined_value(); 554 return FACTORY->undefined_value();
562 } 555 }
563 556
564 Handle<Object> char_at = 557 Handle<Object> char_at =
565 GetProperty(isolate->js_builtins_object(), 558 GetProperty(Isolate::Current()->js_builtins_object(),
566 factory->char_at_symbol()); 559 FACTORY->char_at_symbol());
567 if (!char_at->IsJSFunction()) { 560 if (!char_at->IsJSFunction()) {
568 return factory->undefined_value(); 561 return FACTORY->undefined_value();
569 } 562 }
570 563
571 bool caught_exception; 564 bool caught_exception;
572 Handle<Object> index_object = factory->NewNumberFromInt(int_index); 565 Handle<Object> index_object = FACTORY->NewNumberFromInt(int_index);
573 Object** index_arg[] = { index_object.location() }; 566 Object** index_arg[] = { index_object.location() };
574 Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at), 567 Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at),
575 string, 568 string,
576 ARRAY_SIZE(index_arg), 569 ARRAY_SIZE(index_arg),
577 index_arg, 570 index_arg,
578 &caught_exception); 571 &caught_exception);
579 if (caught_exception) { 572 if (caught_exception) {
580 return factory->undefined_value(); 573 return FACTORY->undefined_value();
581 } 574 }
582 return result; 575 return result;
583 } 576 }
584 577
585 578
586 Handle<JSFunction> Execution::InstantiateFunction( 579 Handle<JSFunction> Execution::InstantiateFunction(
587 Handle<FunctionTemplateInfo> data, bool* exc) { 580 Handle<FunctionTemplateInfo> data, bool* exc) {
588 Isolate* isolate = data->GetIsolate();
589 // Fast case: see if the function has already been instantiated 581 // Fast case: see if the function has already been instantiated
590 int serial_number = Smi::cast(data->serial_number())->value(); 582 int serial_number = Smi::cast(data->serial_number())->value();
591 Object* elm = 583 Object* elm =
592 isolate->global_context()->function_cache()-> 584 Isolate::Current()->global_context()->function_cache()->
593 GetElementNoExceptionThrown(serial_number); 585 GetElementNoExceptionThrown(serial_number);
594 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm)); 586 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm));
595 // The function has not yet been instantiated in this context; do it. 587 // The function has not yet been instantiated in this context; do it.
596 Object** args[1] = { Handle<Object>::cast(data).location() }; 588 Object** args[1] = { Handle<Object>::cast(data).location() };
597 Handle<Object> result = 589 Handle<Object> result =
598 Call(isolate->instantiate_fun(), 590 Call(Isolate::Current()->instantiate_fun(),
599 isolate->js_builtins_object(), 1, args, exc); 591 Isolate::Current()->js_builtins_object(), 1, args, exc);
600 if (*exc) return Handle<JSFunction>::null(); 592 if (*exc) return Handle<JSFunction>::null();
601 return Handle<JSFunction>::cast(result); 593 return Handle<JSFunction>::cast(result);
602 } 594 }
603 595
604 596
605 Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data, 597 Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data,
606 bool* exc) { 598 bool* exc) {
607 Isolate* isolate = data->GetIsolate();
608 if (data->property_list()->IsUndefined() && 599 if (data->property_list()->IsUndefined() &&
609 !data->constructor()->IsUndefined()) { 600 !data->constructor()->IsUndefined()) {
610 // Initialization to make gcc happy. 601 // Initialization to make gcc happy.
611 Object* result = NULL; 602 Object* result = NULL;
612 { 603 {
613 HandleScope scope(isolate); 604 HandleScope scope;
614 Handle<FunctionTemplateInfo> cons_template = 605 Handle<FunctionTemplateInfo> cons_template =
615 Handle<FunctionTemplateInfo>( 606 Handle<FunctionTemplateInfo>(
616 FunctionTemplateInfo::cast(data->constructor())); 607 FunctionTemplateInfo::cast(data->constructor()));
617 Handle<JSFunction> cons = InstantiateFunction(cons_template, exc); 608 Handle<JSFunction> cons = InstantiateFunction(cons_template, exc);
618 if (*exc) return Handle<JSObject>::null(); 609 if (*exc) return Handle<JSObject>::null();
619 Handle<Object> value = New(cons, 0, NULL, exc); 610 Handle<Object> value = New(cons, 0, NULL, exc);
620 if (*exc) return Handle<JSObject>::null(); 611 if (*exc) return Handle<JSObject>::null();
621 result = *value; 612 result = *value;
622 } 613 }
623 ASSERT(!*exc); 614 ASSERT(!*exc);
624 return Handle<JSObject>(JSObject::cast(result)); 615 return Handle<JSObject>(JSObject::cast(result));
625 } else { 616 } else {
626 Object** args[1] = { Handle<Object>::cast(data).location() }; 617 Object** args[1] = { Handle<Object>::cast(data).location() };
627 Handle<Object> result = 618 Handle<Object> result =
628 Call(isolate->instantiate_fun(), 619 Call(Isolate::Current()->instantiate_fun(),
629 isolate->js_builtins_object(), 1, args, exc); 620 Isolate::Current()->js_builtins_object(), 1, args, exc);
630 if (*exc) return Handle<JSObject>::null(); 621 if (*exc) return Handle<JSObject>::null();
631 return Handle<JSObject>::cast(result); 622 return Handle<JSObject>::cast(result);
632 } 623 }
633 } 624 }
634 625
635 626
636 void Execution::ConfigureInstance(Handle<Object> instance, 627 void Execution::ConfigureInstance(Handle<Object> instance,
637 Handle<Object> instance_template, 628 Handle<Object> instance_template,
638 bool* exc) { 629 bool* exc) {
639 Isolate* isolate = Isolate::Current();
640 Object** args[2] = { instance.location(), instance_template.location() }; 630 Object** args[2] = { instance.location(), instance_template.location() };
641 Execution::Call(isolate->configure_instance_fun(), 631 Execution::Call(Isolate::Current()->configure_instance_fun(),
642 isolate->js_builtins_object(), 2, args, exc); 632 Isolate::Current()->js_builtins_object(), 2, args, exc);
643 } 633 }
644 634
645 635
646 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, 636 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv,
647 Handle<JSFunction> fun, 637 Handle<JSFunction> fun,
648 Handle<Object> pos, 638 Handle<Object> pos,
649 Handle<Object> is_global) { 639 Handle<Object> is_global) {
650 Isolate* isolate = fun->GetIsolate();
651 const int argc = 4; 640 const int argc = 4;
652 Object** args[argc] = { recv.location(), 641 Object** args[argc] = { recv.location(),
653 Handle<Object>::cast(fun).location(), 642 Handle<Object>::cast(fun).location(),
654 pos.location(), 643 pos.location(),
655 is_global.location() }; 644 is_global.location() };
656 bool caught_exception = false; 645 bool caught_exception = false;
657 Handle<Object> result = 646 Handle<Object> result =
658 TryCall(isolate->get_stack_trace_line_fun(), 647 TryCall(Isolate::Current()->get_stack_trace_line_fun(),
659 isolate->js_builtins_object(), argc, args, 648 Isolate::Current()->js_builtins_object(), argc, args,
660 &caught_exception); 649 &caught_exception);
661 if (caught_exception || !result->IsString()) { 650 if (caught_exception || !result->IsString()) return FACTORY->empty_symbol();
662 return isolate->factory()->empty_symbol();
663 }
664
665 return Handle<String>::cast(result); 651 return Handle<String>::cast(result);
666 } 652 }
667 653
668 654
669 static Object* RuntimePreempt() { 655 static Object* RuntimePreempt() {
670 Isolate* isolate = Isolate::Current(); 656 Isolate* isolate = Isolate::Current();
671 657
672 // Clear the preempt request flag. 658 // Clear the preempt request flag.
673 isolate->stack_guard()->Continue(PREEMPT); 659 isolate->stack_guard()->Continue(PREEMPT);
674 660
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // Clear the debug break request flag. 721 // Clear the debug break request flag.
736 isolate->stack_guard()->Continue(DEBUGBREAK); 722 isolate->stack_guard()->Continue(DEBUGBREAK);
737 723
738 ProcessDebugMesssages(debug_command_only); 724 ProcessDebugMesssages(debug_command_only);
739 725
740 // Return to continue execution. 726 // Return to continue execution.
741 return isolate->heap()->undefined_value(); 727 return isolate->heap()->undefined_value();
742 } 728 }
743 729
744 void Execution::ProcessDebugMesssages(bool debug_command_only) { 730 void Execution::ProcessDebugMesssages(bool debug_command_only) {
745 Isolate* isolate = Isolate::Current();
746 // Clear the debug command request flag. 731 // Clear the debug command request flag.
747 isolate->stack_guard()->Continue(DEBUGCOMMAND); 732 Isolate::Current()->stack_guard()->Continue(DEBUGCOMMAND);
748 733
749 HandleScope scope(isolate); 734 HandleScope scope;
750 // Enter the debugger. Just continue if we fail to enter the debugger. 735 // Enter the debugger. Just continue if we fail to enter the debugger.
751 EnterDebugger debugger; 736 EnterDebugger debugger;
752 if (debugger.FailedToEnter()) { 737 if (debugger.FailedToEnter()) {
753 return; 738 return;
754 } 739 }
755 740
756 // Notify the debug event listeners. Indicate auto continue if the break was 741 // Notify the debug event listeners. Indicate auto continue if the break was
757 // a debug command break. 742 // a debug command break.
758 isolate->debugger()->OnDebugBreak(isolate->factory()->undefined_value(), 743 Isolate::Current()->debugger()->OnDebugBreak(FACTORY->undefined_value(),
759 debug_command_only); 744 debug_command_only);
760 } 745 }
761 746
762 747
763 #endif 748 #endif
764 749
765 MaybeObject* Execution::HandleStackGuardInterrupt() { 750 MaybeObject* Execution::HandleStackGuardInterrupt() {
766 Isolate* isolate = Isolate::Current(); 751 Isolate* isolate = Isolate::Current();
767 StackGuard* stack_guard = isolate->stack_guard(); 752 StackGuard* stack_guard = isolate->stack_guard();
768 isolate->counters()->stack_interrupts()->Increment(); 753 isolate->counters()->stack_interrupts()->Increment();
769 if (stack_guard->IsRuntimeProfilerTick()) { 754 if (stack_guard->IsRuntimeProfilerTick()) {
(...skipping 12 matching lines...) Expand all
782 return isolate->TerminateExecution(); 767 return isolate->TerminateExecution();
783 } 768 }
784 if (stack_guard->IsInterrupted()) { 769 if (stack_guard->IsInterrupted()) {
785 stack_guard->Continue(INTERRUPT); 770 stack_guard->Continue(INTERRUPT);
786 return isolate->StackOverflow(); 771 return isolate->StackOverflow();
787 } 772 }
788 return isolate->heap()->undefined_value(); 773 return isolate->heap()->undefined_value();
789 } 774 }
790 775
791 } } // namespace v8::internal 776 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/deoptimizer.cc ('k') | src/extensions/experimental/break-iterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698