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

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

Issue 710273002: Expose internal properties of map/set iterators via mirrors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/es6/mirror-iterators.js » ('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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 RUNTIME_FUNCTION(Runtime_SetIteratorNext) { 109 RUNTIME_FUNCTION(Runtime_SetIteratorNext) {
110 SealHandleScope shs(isolate); 110 SealHandleScope shs(isolate);
111 DCHECK(args.length() == 2); 111 DCHECK(args.length() == 2);
112 CONVERT_ARG_CHECKED(JSSetIterator, holder, 0); 112 CONVERT_ARG_CHECKED(JSSetIterator, holder, 0);
113 CONVERT_ARG_CHECKED(JSArray, value_array, 1); 113 CONVERT_ARG_CHECKED(JSArray, value_array, 1);
114 return holder->Next(value_array); 114 return holder->Next(value_array);
115 } 115 }
116 116
117 117
118 // The array returned contains the following information:
119 // 0: HasMore flag
120 // 1: Iteration index
121 // 2: Iteration kind
122 RUNTIME_FUNCTION(Runtime_SetIteratorDetails) {
123 HandleScope scope(isolate);
124 DCHECK(args.length() == 1);
125 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0);
126 Handle<FixedArray> details = isolate->factory()->NewFixedArray(4);
127 details->set(0, isolate->heap()->ToBoolean(holder->HasMore()));
128 details->set(1, holder->index());
129 details->set(2, holder->kind());
130 return *isolate->factory()->NewJSArrayWithElements(details);
131 }
132
133
118 RUNTIME_FUNCTION(Runtime_MapInitialize) { 134 RUNTIME_FUNCTION(Runtime_MapInitialize) {
119 HandleScope scope(isolate); 135 HandleScope scope(isolate);
120 DCHECK(args.length() == 1); 136 DCHECK(args.length() == 1);
121 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 137 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
122 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap(); 138 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap();
123 holder->set_table(*table); 139 holder->set_table(*table);
124 return *holder; 140 return *holder;
125 } 141 }
126 142
127 143
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 234
219 Handle<JSMapIterator> result = isolate->factory()->NewJSMapIterator(); 235 Handle<JSMapIterator> result = isolate->factory()->NewJSMapIterator();
220 result->set_table(holder->table()); 236 result->set_table(holder->table());
221 result->set_index(Smi::FromInt(Smi::cast(holder->index())->value())); 237 result->set_index(Smi::FromInt(Smi::cast(holder->index())->value()));
222 result->set_kind(Smi::FromInt(Smi::cast(holder->kind())->value())); 238 result->set_kind(Smi::FromInt(Smi::cast(holder->kind())->value()));
223 239
224 return *result; 240 return *result;
225 } 241 }
226 242
227 243
244 // The array returned contains the following information:
245 // 0: HasMore flag
246 // 1: Iteration index
247 // 2: Iteration kind
248 RUNTIME_FUNCTION(Runtime_MapIteratorDetails) {
249 HandleScope scope(isolate);
250 DCHECK(args.length() == 1);
251 CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0);
252 Handle<FixedArray> details = isolate->factory()->NewFixedArray(4);
253 details->set(0, isolate->heap()->ToBoolean(holder->HasMore()));
254 details->set(1, holder->index());
255 details->set(2, holder->kind());
256 return *isolate->factory()->NewJSArrayWithElements(details);
257 }
258
259
228 RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) { 260 RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) {
229 HandleScope scope(isolate); 261 HandleScope scope(isolate);
230 DCHECK(args.length() == 2); 262 DCHECK(args.length() == 2);
231 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0); 263 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0);
232 CONVERT_NUMBER_CHECKED(int, max_entries, Int32, args[1]); 264 CONVERT_NUMBER_CHECKED(int, max_entries, Int32, args[1]);
233 RUNTIME_ASSERT(max_entries >= 0); 265 RUNTIME_ASSERT(max_entries >= 0);
234 266
235 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); 267 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
236 if (max_entries == 0 || max_entries > table->NumberOfElements()) { 268 if (max_entries == 0 || max_entries > table->NumberOfElements()) {
237 max_entries = table->NumberOfElements(); 269 max_entries = table->NumberOfElements();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // isolate. If it's called more often, the map should be moved into the 414 // isolate. If it's called more often, the map should be moved into the
383 // strong root list. 415 // strong root list.
384 Handle<Map> map = 416 Handle<Map> map =
385 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); 417 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize);
386 Handle<JSWeakMap> weakmap = 418 Handle<JSWeakMap> weakmap =
387 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); 419 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map));
388 return *WeakCollectionInitialize(isolate, weakmap); 420 return *WeakCollectionInitialize(isolate, weakmap);
389 } 421 }
390 } 422 }
391 } // namespace v8::internal 423 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/es6/mirror-iterators.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698