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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions-inl.h" | 8 #include "src/conversions-inl.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 RUNTIME_FUNCTION(Runtime_GenericHash) { | 39 RUNTIME_FUNCTION(Runtime_GenericHash) { |
40 HandleScope scope(isolate); | 40 HandleScope scope(isolate); |
41 DCHECK(args.length() == 1); | 41 DCHECK(args.length() == 1); |
42 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 42 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
43 Handle<Smi> hash = Object::GetOrCreateHash(isolate, object); | 43 Handle<Smi> hash = Object::GetOrCreateHash(isolate, object); |
44 return *hash; | 44 return *hash; |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 void Runtime::JSSetInitialize(Isolate* isolate, Handle<JSSet> set) { | |
49 Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet(); | |
50 set->set_table(*table); | |
51 } | |
52 | |
53 | |
54 RUNTIME_FUNCTION(Runtime_SetInitialize) { | 48 RUNTIME_FUNCTION(Runtime_SetInitialize) { |
55 HandleScope scope(isolate); | 49 HandleScope scope(isolate); |
56 DCHECK(args.length() == 1); | 50 DCHECK(args.length() == 1); |
57 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 51 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
58 Runtime::JSSetInitialize(isolate, holder); | 52 JSSet::Initialize(holder, isolate); |
59 return *holder; | 53 return *holder; |
60 } | 54 } |
61 | 55 |
62 | 56 |
63 RUNTIME_FUNCTION(Runtime_SetGrow) { | 57 RUNTIME_FUNCTION(Runtime_SetGrow) { |
64 HandleScope scope(isolate); | 58 HandleScope scope(isolate); |
65 DCHECK(args.length() == 1); | 59 DCHECK(args.length() == 1); |
66 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 60 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
67 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 61 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
68 table = OrderedHashSet::EnsureGrowable(table); | 62 table = OrderedHashSet::EnsureGrowable(table); |
69 holder->set_table(*table); | 63 holder->set_table(*table); |
70 return isolate->heap()->undefined_value(); | 64 return isolate->heap()->undefined_value(); |
71 } | 65 } |
72 | 66 |
73 | 67 |
74 RUNTIME_FUNCTION(Runtime_SetShrink) { | 68 RUNTIME_FUNCTION(Runtime_SetShrink) { |
75 HandleScope scope(isolate); | 69 HandleScope scope(isolate); |
76 DCHECK(args.length() == 1); | 70 DCHECK(args.length() == 1); |
77 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 71 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
78 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 72 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
79 table = OrderedHashSet::Shrink(table); | 73 table = OrderedHashSet::Shrink(table); |
80 holder->set_table(*table); | 74 holder->set_table(*table); |
81 return isolate->heap()->undefined_value(); | 75 return isolate->heap()->undefined_value(); |
82 } | 76 } |
83 | 77 |
84 | 78 |
85 void Runtime::JSSetClear(Isolate* isolate, Handle<JSSet> set) { | |
86 Handle<OrderedHashSet> table(OrderedHashSet::cast(set->table())); | |
87 table = OrderedHashSet::Clear(table); | |
88 set->set_table(*table); | |
89 } | |
90 | |
91 | |
92 RUNTIME_FUNCTION(Runtime_SetClear) { | 79 RUNTIME_FUNCTION(Runtime_SetClear) { |
93 HandleScope scope(isolate); | 80 HandleScope scope(isolate); |
94 DCHECK(args.length() == 1); | 81 DCHECK(args.length() == 1); |
95 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 82 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
96 Runtime::JSSetClear(isolate, holder); | 83 JSSet::Clear(holder); |
97 return isolate->heap()->undefined_value(); | 84 return isolate->heap()->undefined_value(); |
98 } | 85 } |
99 | 86 |
100 | 87 |
101 RUNTIME_FUNCTION(Runtime_SetIteratorInitialize) { | 88 RUNTIME_FUNCTION(Runtime_SetIteratorInitialize) { |
102 HandleScope scope(isolate); | 89 HandleScope scope(isolate); |
103 DCHECK(args.length() == 3); | 90 DCHECK(args.length() == 3); |
104 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); | 91 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); |
105 CONVERT_ARG_HANDLE_CHECKED(JSSet, set, 1); | 92 CONVERT_ARG_HANDLE_CHECKED(JSSet, set, 1); |
106 CONVERT_SMI_ARG_CHECKED(kind, 2) | 93 CONVERT_SMI_ARG_CHECKED(kind, 2) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 DCHECK(args.length() == 1); | 133 DCHECK(args.length() == 1); |
147 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); | 134 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); |
148 Handle<FixedArray> details = isolate->factory()->NewFixedArray(4); | 135 Handle<FixedArray> details = isolate->factory()->NewFixedArray(4); |
149 details->set(0, isolate->heap()->ToBoolean(holder->HasMore())); | 136 details->set(0, isolate->heap()->ToBoolean(holder->HasMore())); |
150 details->set(1, holder->index()); | 137 details->set(1, holder->index()); |
151 details->set(2, holder->kind()); | 138 details->set(2, holder->kind()); |
152 return *isolate->factory()->NewJSArrayWithElements(details); | 139 return *isolate->factory()->NewJSArrayWithElements(details); |
153 } | 140 } |
154 | 141 |
155 | 142 |
156 void Runtime::JSMapInitialize(Isolate* isolate, Handle<JSMap> map) { | |
157 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap(); | |
158 map->set_table(*table); | |
159 } | |
160 | |
161 | |
162 RUNTIME_FUNCTION(Runtime_MapInitialize) { | 143 RUNTIME_FUNCTION(Runtime_MapInitialize) { |
163 HandleScope scope(isolate); | 144 HandleScope scope(isolate); |
164 DCHECK(args.length() == 1); | 145 DCHECK(args.length() == 1); |
165 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 146 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
166 Runtime::JSMapInitialize(isolate, holder); | 147 JSMap::Initialize(holder, isolate); |
167 return *holder; | 148 return *holder; |
168 } | 149 } |
169 | 150 |
170 | 151 |
171 RUNTIME_FUNCTION(Runtime_MapShrink) { | 152 RUNTIME_FUNCTION(Runtime_MapShrink) { |
172 HandleScope scope(isolate); | 153 HandleScope scope(isolate); |
173 DCHECK(args.length() == 1); | 154 DCHECK(args.length() == 1); |
174 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 155 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
175 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 156 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
176 table = OrderedHashMap::Shrink(table); | 157 table = OrderedHashMap::Shrink(table); |
177 holder->set_table(*table); | 158 holder->set_table(*table); |
178 return isolate->heap()->undefined_value(); | 159 return isolate->heap()->undefined_value(); |
179 } | 160 } |
180 | 161 |
181 | 162 |
182 void Runtime::JSMapClear(Isolate* isolate, Handle<JSMap> map) { | |
183 Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table())); | |
184 table = OrderedHashMap::Clear(table); | |
185 map->set_table(*table); | |
186 } | |
187 | |
188 | |
189 RUNTIME_FUNCTION(Runtime_MapClear) { | 163 RUNTIME_FUNCTION(Runtime_MapClear) { |
190 HandleScope scope(isolate); | 164 HandleScope scope(isolate); |
191 DCHECK(args.length() == 1); | 165 DCHECK(args.length() == 1); |
192 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 166 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
193 Runtime::JSMapClear(isolate, holder); | 167 JSMap::Clear(holder); |
194 return isolate->heap()->undefined_value(); | 168 return isolate->heap()->undefined_value(); |
195 } | 169 } |
196 | 170 |
197 | 171 |
198 RUNTIME_FUNCTION(Runtime_MapGrow) { | 172 RUNTIME_FUNCTION(Runtime_MapGrow) { |
199 HandleScope scope(isolate); | 173 HandleScope scope(isolate); |
200 DCHECK(args.length() == 1); | 174 DCHECK(args.length() == 1); |
201 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 175 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
202 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 176 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
203 table = OrderedHashMap::EnsureGrowable(table); | 177 table = OrderedHashMap::EnsureGrowable(table); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 423 |
450 RUNTIME_FUNCTION(Runtime_ObservationWeakMapCreate) { | 424 RUNTIME_FUNCTION(Runtime_ObservationWeakMapCreate) { |
451 HandleScope scope(isolate); | 425 HandleScope scope(isolate); |
452 DCHECK(args.length() == 0); | 426 DCHECK(args.length() == 0); |
453 Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap(); | 427 Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap(); |
454 Runtime::WeakCollectionInitialize(isolate, weakmap); | 428 Runtime::WeakCollectionInitialize(isolate, weakmap); |
455 return *weakmap; | 429 return *weakmap; |
456 } | 430 } |
457 } // namespace internal | 431 } // namespace internal |
458 } // namespace v8 | 432 } // namespace v8 |
OLD | NEW |