OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 } | 587 } |
588 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); | 588 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); |
589 } | 589 } |
590 | 590 |
591 | 591 |
592 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { | 592 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { |
593 ASSERT(args.length() == 2); | 593 ASSERT(args.length() == 2); |
594 Object* handler = args[0]; | 594 Object* handler = args[0]; |
595 Object* prototype = args[1]; | 595 Object* prototype = args[1]; |
596 Object* used_prototype = | 596 Object* used_prototype = |
597 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); | 597 (prototype->IsJSObject() || prototype->IsJSProxy()) ? prototype |
| 598 : isolate->heap()->null_value(); |
598 return isolate->heap()->AllocateJSProxy(handler, used_prototype); | 599 return isolate->heap()->AllocateJSProxy(handler, used_prototype); |
599 } | 600 } |
600 | 601 |
601 | 602 |
602 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { | |
603 ASSERT(args.length() == 1); | |
604 Object* obj = args[0]; | |
605 return obj->IsJSProxy() | |
606 ? isolate->heap()->true_value() : isolate->heap()->false_value(); | |
607 } | |
608 | |
609 | |
610 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { | |
611 ASSERT(args.length() == 1); | |
612 CONVERT_CHECKED(JSProxy, proxy, args[0]); | |
613 return proxy->handler(); | |
614 } | |
615 | |
616 | |
617 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCatchExtensionObject) { | 603 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCatchExtensionObject) { |
618 ASSERT(args.length() == 2); | 604 ASSERT(args.length() == 2); |
619 CONVERT_CHECKED(String, key, args[0]); | 605 CONVERT_CHECKED(String, key, args[0]); |
620 Object* value = args[1]; | 606 Object* value = args[1]; |
621 ASSERT(!value->IsFailure()); | 607 ASSERT(!value->IsFailure()); |
622 // Create a catch context extension object. | 608 // Create a catch context extension object. |
623 JSFunction* constructor = | 609 JSFunction* constructor = |
624 isolate->context()->global_context()-> | 610 isolate->context()->global_context()-> |
625 context_extension_function(); | 611 context_extension_function(); |
626 Object* object; | 612 Object* object; |
(...skipping 14 matching lines...) Expand all Loading... |
641 | 627 |
642 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 628 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { |
643 NoHandleAllocation ha; | 629 NoHandleAllocation ha; |
644 ASSERT(args.length() == 1); | 630 ASSERT(args.length() == 1); |
645 Object* obj = args[0]; | 631 Object* obj = args[0]; |
646 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 632 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
647 return JSObject::cast(obj)->class_name(); | 633 return JSObject::cast(obj)->class_name(); |
648 } | 634 } |
649 | 635 |
650 | 636 |
651 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | |
652 NoHandleAllocation ha; | |
653 ASSERT(args.length() == 1); | |
654 Object* obj = args[0]; | |
655 if (obj->IsJSGlobalProxy()) obj = obj->GetPrototype(); | |
656 return obj->GetPrototype(); | |
657 } | |
658 | |
659 | |
660 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { | 637 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { |
661 NoHandleAllocation ha; | 638 NoHandleAllocation ha; |
662 ASSERT(args.length() == 2); | 639 ASSERT(args.length() == 2); |
663 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 640 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
664 Object* O = args[0]; | 641 Object* O = args[0]; |
665 Object* V = args[1]; | 642 Object* V = args[1]; |
666 while (true) { | 643 while (true) { |
667 Object* prototype = V->GetPrototype(); | 644 Object* prototype = V->GetPrototype(); |
668 if (prototype->IsNull()) return isolate->heap()->false_value(); | 645 if (prototype->IsNull()) return isolate->heap()->false_value(); |
669 if (O == prototype) return isolate->heap()->true_value(); | 646 if (O == prototype) return isolate->heap()->true_value(); |
(...skipping 11677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12347 } else { | 12324 } else { |
12348 // Handle last resort GC and make sure to allow future allocations | 12325 // Handle last resort GC and make sure to allow future allocations |
12349 // to grow the heap without causing GCs (if possible). | 12326 // to grow the heap without causing GCs (if possible). |
12350 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12327 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12351 isolate->heap()->CollectAllGarbage(false); | 12328 isolate->heap()->CollectAllGarbage(false); |
12352 } | 12329 } |
12353 } | 12330 } |
12354 | 12331 |
12355 | 12332 |
12356 } } // namespace v8::internal | 12333 } } // namespace v8::internal |
OLD | NEW |