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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
614 Handle<Object> name(args[0], isolate); | 614 Handle<Object> name(args[0], isolate); |
615 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 615 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
616 Symbol* symbol; | 616 Symbol* symbol; |
617 MaybeObject* maybe = isolate->heap()->AllocatePrivateSymbol(); | 617 MaybeObject* maybe = isolate->heap()->AllocatePrivateSymbol(); |
618 if (!maybe->To(&symbol)) return maybe; | 618 if (!maybe->To(&symbol)) return maybe; |
619 if (name->IsString()) symbol->set_name(*name); | 619 if (name->IsString()) symbol->set_name(*name); |
620 return symbol; | 620 return symbol; |
621 } | 621 } |
622 | 622 |
623 | 623 |
624 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) { | |
625 HandleScope scope(isolate); | |
626 ASSERT(args.length() == 1); | |
627 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | |
628 Handle<JSObject> registry = isolate->GetSymbolRegistry(); | |
629 Handle<String> part = handle(isolate->heap()->private_intern_string()); | |
Michael Starzinger
2014/03/24 15:17:19
nit: You can just use isolate->factory()->private_
rossberg
2014/03/24 15:54:46
Done.
| |
630 Handle<JSObject> privates = | |
631 Handle<JSObject>::cast(JSObject::GetProperty(registry, part)); | |
632 Handle<Object> symbol = JSObject::GetProperty(privates, name); | |
633 if (!symbol->IsSymbol()) { | |
634 ASSERT(symbol->IsUndefined()); | |
635 symbol = isolate->factory()->NewPrivateSymbol(); | |
636 Handle<Symbol>::cast(symbol)->set_name(*name); | |
637 JSObject::SetProperty(privates, name, symbol, NONE, STRICT); | |
638 } | |
639 return *symbol; | |
640 } | |
641 | |
642 | |
624 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewSymbolWrapper) { | 643 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewSymbolWrapper) { |
625 ASSERT(args.length() == 1); | 644 ASSERT(args.length() == 1); |
626 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 645 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
627 return symbol->ToObject(isolate); | 646 return symbol->ToObject(isolate); |
628 } | 647 } |
629 | 648 |
630 | 649 |
631 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolDescription) { | 650 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolDescription) { |
632 SealHandleScope shs(isolate); | 651 SealHandleScope shs(isolate); |
633 ASSERT(args.length() == 1); | 652 ASSERT(args.length() == 1); |
634 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 653 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
635 return symbol->name(); | 654 return symbol->name(); |
636 } | 655 } |
637 | 656 |
638 | 657 |
639 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolRegistry) { | 658 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolRegistry) { |
640 SealHandleScope shs(isolate); | 659 HandleScope hs(isolate); |
Michael Starzinger
2014/03/24 15:17:19
nit: s/hs/scope/ for consistency and grep-ability.
rossberg
2014/03/24 15:54:46
Done.
| |
641 ASSERT(args.length() == 0); | 660 ASSERT(args.length() == 0); |
642 return isolate->heap()->symbol_registry(); | 661 return *isolate->GetSymbolRegistry(); |
643 } | 662 } |
644 | 663 |
645 | 664 |
646 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolIsPrivate) { | 665 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolIsPrivate) { |
647 SealHandleScope shs(isolate); | 666 SealHandleScope shs(isolate); |
648 ASSERT(args.length() == 1); | 667 ASSERT(args.length() == 1); |
649 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 668 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
650 return isolate->heap()->ToBoolean(symbol->is_private()); | 669 return isolate->heap()->ToBoolean(symbol->is_private()); |
651 } | 670 } |
652 | 671 |
(...skipping 14407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15060 // Handle last resort GC and make sure to allow future allocations | 15079 // Handle last resort GC and make sure to allow future allocations |
15061 // to grow the heap without causing GCs (if possible). | 15080 // to grow the heap without causing GCs (if possible). |
15062 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15081 isolate->counters()->gc_last_resort_from_js()->Increment(); |
15063 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15082 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
15064 "Runtime::PerformGC"); | 15083 "Runtime::PerformGC"); |
15065 } | 15084 } |
15066 } | 15085 } |
15067 | 15086 |
15068 | 15087 |
15069 } } // namespace v8::internal | 15088 } } // namespace v8::internal |
OLD | NEW |