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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 Handle<Object> name(args[0], isolate); | 622 Handle<Object> name(args[0], isolate); |
623 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 623 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
624 Symbol* symbol; | 624 Symbol* symbol; |
625 MaybeObject* maybe = isolate->heap()->AllocatePrivateSymbol(); | 625 MaybeObject* maybe = isolate->heap()->AllocatePrivateSymbol(); |
626 if (!maybe->To(&symbol)) return maybe; | 626 if (!maybe->To(&symbol)) return maybe; |
627 if (name->IsString()) symbol->set_name(*name); | 627 if (name->IsString()) symbol->set_name(*name); |
628 return symbol; | 628 return symbol; |
629 } | 629 } |
630 | 630 |
631 | 631 |
632 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolName) { | 632 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolDescription) { |
633 SealHandleScope shs(isolate); | 633 SealHandleScope shs(isolate); |
634 ASSERT(args.length() == 1); | 634 ASSERT(args.length() == 1); |
635 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 635 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
636 return symbol->name(); | 636 return symbol->name(); |
637 } | 637 } |
638 | 638 |
639 | 639 |
| 640 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolSetSymbolData) { |
| 641 HandleScope shs(isolate); |
| 642 ASSERT(args.length() == 2); |
| 643 CONVERT_ARG_CHECKED(JSObject, wrapper, 0); |
| 644 CONVERT_ARG_CHECKED(Symbol, symbol, 1); |
| 645 Handle<String> key(isolate->factory()->symbol_string()); |
| 646 Handle<JSObject> holder(wrapper, isolate); |
| 647 Handle<Symbol> value(symbol, isolate); |
| 648 JSObject::SetHiddenProperty(holder, key, value); |
| 649 return isolate->heap()->undefined_value(); |
| 650 } |
| 651 |
| 652 |
| 653 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolGetSymbolData) { |
| 654 HandleScope shs(isolate); |
| 655 ASSERT(args.length() == 1); |
| 656 CONVERT_ARG_CHECKED(JSObject, wrapper, 0); |
| 657 Handle<String> key(isolate->factory()->symbol_string()); |
| 658 Handle<Object> result(wrapper->GetHiddenProperty(*key), isolate); |
| 659 if (result->IsTheHole()) return isolate->heap()->undefined_value(); |
| 660 return *result; |
| 661 } |
| 662 |
| 663 |
640 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolIsPrivate) { | 664 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolIsPrivate) { |
641 SealHandleScope shs(isolate); | 665 SealHandleScope shs(isolate); |
642 ASSERT(args.length() == 1); | 666 ASSERT(args.length() == 1); |
643 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 667 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
644 return isolate->heap()->ToBoolean(symbol->is_private()); | 668 return isolate->heap()->ToBoolean(symbol->is_private()); |
645 } | 669 } |
646 | 670 |
647 | 671 |
648 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { | 672 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { |
649 SealHandleScope shs(isolate); | 673 SealHandleScope shs(isolate); |
(...skipping 14241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14891 // Handle last resort GC and make sure to allow future allocations | 14915 // Handle last resort GC and make sure to allow future allocations |
14892 // to grow the heap without causing GCs (if possible). | 14916 // to grow the heap without causing GCs (if possible). |
14893 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14917 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14894 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14918 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14895 "Runtime::PerformGC"); | 14919 "Runtime::PerformGC"); |
14896 } | 14920 } |
14897 } | 14921 } |
14898 | 14922 |
14899 | 14923 |
14900 } } // namespace v8::internal | 14924 } } // namespace v8::internal |
OLD | NEW |