Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: src/runtime/runtime-collections.cc

Issue 1204623002: Expose Map/Set methods through the API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 HandleScope scope(isolate); 75 HandleScope scope(isolate);
76 DCHECK(args.length() == 1); 76 DCHECK(args.length() == 1);
77 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); 77 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
78 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); 78 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
79 table = OrderedHashSet::Shrink(table); 79 table = OrderedHashSet::Shrink(table);
80 holder->set_table(*table); 80 holder->set_table(*table);
81 return isolate->heap()->undefined_value(); 81 return isolate->heap()->undefined_value();
82 } 82 }
83 83
84 84
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
85 RUNTIME_FUNCTION(Runtime_SetClear) { 92 RUNTIME_FUNCTION(Runtime_SetClear) {
86 HandleScope scope(isolate); 93 HandleScope scope(isolate);
87 DCHECK(args.length() == 1); 94 DCHECK(args.length() == 1);
88 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); 95 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
89 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); 96 Runtime::JSSetClear(isolate, holder);
90 table = OrderedHashSet::Clear(table);
91 holder->set_table(*table);
92 return isolate->heap()->undefined_value(); 97 return isolate->heap()->undefined_value();
93 } 98 }
94 99
95 100
96 RUNTIME_FUNCTION(Runtime_SetIteratorInitialize) { 101 RUNTIME_FUNCTION(Runtime_SetIteratorInitialize) {
97 HandleScope scope(isolate); 102 HandleScope scope(isolate);
98 DCHECK(args.length() == 3); 103 DCHECK(args.length() == 3);
99 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); 104 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0);
100 CONVERT_ARG_HANDLE_CHECKED(JSSet, set, 1); 105 CONVERT_ARG_HANDLE_CHECKED(JSSet, set, 1);
101 CONVERT_SMI_ARG_CHECKED(kind, 2) 106 CONVERT_SMI_ARG_CHECKED(kind, 2)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 HandleScope scope(isolate); 172 HandleScope scope(isolate);
168 DCHECK(args.length() == 1); 173 DCHECK(args.length() == 1);
169 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 174 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
170 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); 175 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
171 table = OrderedHashMap::Shrink(table); 176 table = OrderedHashMap::Shrink(table);
172 holder->set_table(*table); 177 holder->set_table(*table);
173 return isolate->heap()->undefined_value(); 178 return isolate->heap()->undefined_value();
174 } 179 }
175 180
176 181
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
177 RUNTIME_FUNCTION(Runtime_MapClear) { 189 RUNTIME_FUNCTION(Runtime_MapClear) {
178 HandleScope scope(isolate); 190 HandleScope scope(isolate);
179 DCHECK(args.length() == 1); 191 DCHECK(args.length() == 1);
180 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 192 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
181 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); 193 Runtime::JSMapClear(isolate, holder);
182 table = OrderedHashMap::Clear(table);
183 holder->set_table(*table);
184 return isolate->heap()->undefined_value(); 194 return isolate->heap()->undefined_value();
185 } 195 }
186 196
187 197
188 RUNTIME_FUNCTION(Runtime_MapGrow) { 198 RUNTIME_FUNCTION(Runtime_MapGrow) {
189 HandleScope scope(isolate); 199 HandleScope scope(isolate);
190 DCHECK(args.length() == 1); 200 DCHECK(args.length() == 1);
191 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 201 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
192 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); 202 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
193 table = OrderedHashMap::EnsureGrowable(table); 203 table = OrderedHashMap::EnsureGrowable(table);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 449
440 RUNTIME_FUNCTION(Runtime_ObservationWeakMapCreate) { 450 RUNTIME_FUNCTION(Runtime_ObservationWeakMapCreate) {
441 HandleScope scope(isolate); 451 HandleScope scope(isolate);
442 DCHECK(args.length() == 0); 452 DCHECK(args.length() == 0);
443 Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap(); 453 Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap();
444 Runtime::WeakCollectionInitialize(isolate, weakmap); 454 Runtime::WeakCollectionInitialize(isolate, weakmap);
445 return *weakmap; 455 return *weakmap;
446 } 456 }
447 } // namespace internal 457 } // namespace internal
448 } // namespace v8 458 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698