OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/runtime/runtime-utils.h" | 8 #include "src/runtime/runtime-utils.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 Object::GetProperty(privates, name)); | 44 Object::GetProperty(privates, name)); |
45 if (!symbol->IsSymbol()) { | 45 if (!symbol->IsSymbol()) { |
46 DCHECK(symbol->IsUndefined()); | 46 DCHECK(symbol->IsUndefined()); |
47 symbol = isolate->factory()->NewPrivateSymbol(name); | 47 symbol = isolate->factory()->NewPrivateSymbol(name); |
48 JSObject::AddProperty(Handle<JSObject>::cast(privates), name, symbol, NONE); | 48 JSObject::AddProperty(Handle<JSObject>::cast(privates), name, symbol, NONE); |
49 } | 49 } |
50 return *symbol; | 50 return *symbol; |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 RUNTIME_FUNCTION(Runtime_NewSymbolWrapper) { | |
55 HandleScope scope(isolate); | |
56 DCHECK(args.length() == 1); | |
57 CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0); | |
58 return *Object::ToObject(isolate, symbol).ToHandleChecked(); | |
59 } | |
60 | |
61 | |
62 RUNTIME_FUNCTION(Runtime_SymbolDescription) { | 54 RUNTIME_FUNCTION(Runtime_SymbolDescription) { |
63 SealHandleScope shs(isolate); | 55 SealHandleScope shs(isolate); |
64 DCHECK(args.length() == 1); | 56 DCHECK(args.length() == 1); |
65 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 57 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
66 return symbol->name(); | 58 return symbol->name(); |
67 } | 59 } |
68 | 60 |
69 | 61 |
70 RUNTIME_FUNCTION(Runtime_SymbolRegistry) { | 62 RUNTIME_FUNCTION(Runtime_SymbolRegistry) { |
71 HandleScope scope(isolate); | 63 HandleScope scope(isolate); |
72 DCHECK(args.length() == 0); | 64 DCHECK(args.length() == 0); |
73 return *isolate->GetSymbolRegistry(); | 65 return *isolate->GetSymbolRegistry(); |
74 } | 66 } |
75 | 67 |
76 | 68 |
77 RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) { | 69 RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) { |
78 SealHandleScope shs(isolate); | 70 SealHandleScope shs(isolate); |
79 DCHECK(args.length() == 1); | 71 DCHECK(args.length() == 1); |
80 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 72 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
81 return isolate->heap()->ToBoolean(symbol->is_private()); | 73 return isolate->heap()->ToBoolean(symbol->is_private()); |
82 } | 74 } |
83 } // namespace internal | 75 } // namespace internal |
84 } // namespace v8 | 76 } // namespace v8 |
OLD | NEW |