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->IsJSObject() || prototype->IsJSProxy()) ? prototype | 597 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); |
598 : isolate->heap()->null_value(); | |
599 return isolate->heap()->AllocateJSProxy(handler, used_prototype); | 598 return isolate->heap()->AllocateJSProxy(handler, used_prototype); |
600 } | 599 } |
601 | 600 |
602 | 601 |
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 | |
603 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCatchExtensionObject) { | 617 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCatchExtensionObject) { |
604 ASSERT(args.length() == 2); | 618 ASSERT(args.length() == 2); |
605 CONVERT_CHECKED(String, key, args[0]); | 619 CONVERT_CHECKED(String, key, args[0]); |
606 Object* value = args[1]; | 620 Object* value = args[1]; |
607 ASSERT(!value->IsFailure()); | 621 ASSERT(!value->IsFailure()); |
608 // Create a catch context extension object. | 622 // Create a catch context extension object. |
609 JSFunction* constructor = | 623 JSFunction* constructor = |
610 isolate->context()->global_context()-> | 624 isolate->context()->global_context()-> |
611 context_extension_function(); | 625 context_extension_function(); |
612 Object* object; | 626 Object* object; |
(...skipping 14 matching lines...) Expand all Loading... | |
627 | 641 |
628 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 642 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { |
629 NoHandleAllocation ha; | 643 NoHandleAllocation ha; |
630 ASSERT(args.length() == 1); | 644 ASSERT(args.length() == 1); |
631 Object* obj = args[0]; | 645 Object* obj = args[0]; |
632 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 646 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
633 return JSObject::cast(obj)->class_name(); | 647 return JSObject::cast(obj)->class_name(); |
634 } | 648 } |
635 | 649 |
636 | 650 |
651 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | |
652 NoHandleAllocation ha; | |
653 ASSERT(args.length() == 1); | |
654 Object* obj = args[0]; | |
655 obj = obj->GetPrototype(); | |
656 while (obj->IsJSObject() && | |
Kevin Millikin (Chromium)
2011/06/03 09:52:48
Maybe clearer with do...while, if you like that so
| |
657 JSObject::cast(obj)->map()->is_hidden_prototype()) { | |
658 obj = obj->GetPrototype(); | |
659 } | |
660 return obj; | |
661 } | |
662 | |
663 | |
637 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { | 664 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { |
638 NoHandleAllocation ha; | 665 NoHandleAllocation ha; |
639 ASSERT(args.length() == 2); | 666 ASSERT(args.length() == 2); |
640 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 667 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
641 Object* O = args[0]; | 668 Object* O = args[0]; |
642 Object* V = args[1]; | 669 Object* V = args[1]; |
643 while (true) { | 670 while (true) { |
644 Object* prototype = V->GetPrototype(); | 671 Object* prototype = V->GetPrototype(); |
645 if (prototype->IsNull()) return isolate->heap()->false_value(); | 672 if (prototype->IsNull()) return isolate->heap()->false_value(); |
646 if (O == prototype) return isolate->heap()->true_value(); | 673 if (O == prototype) return isolate->heap()->true_value(); |
(...skipping 11677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12324 } else { | 12351 } else { |
12325 // Handle last resort GC and make sure to allow future allocations | 12352 // Handle last resort GC and make sure to allow future allocations |
12326 // to grow the heap without causing GCs (if possible). | 12353 // to grow the heap without causing GCs (if possible). |
12327 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12354 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12328 isolate->heap()->CollectAllGarbage(false); | 12355 isolate->heap()->CollectAllGarbage(false); |
12329 } | 12356 } |
12330 } | 12357 } |
12331 | 12358 |
12332 | 12359 |
12333 } } // namespace v8::internal | 12360 } } // namespace v8::internal |
OLD | NEW |