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

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

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase master Created 4 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-classes.cc ('k') | src/runtime/runtime-debug.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/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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 HandleScope scope(isolate); 284 HandleScope scope(isolate);
285 DCHECK(args.length() == 3); 285 DCHECK(args.length() == 3);
286 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); 286 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
287 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 287 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
288 CONVERT_SMI_ARG_CHECKED(hash, 2) 288 CONVERT_SMI_ARG_CHECKED(hash, 2)
289 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); 289 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
290 Handle<ObjectHashTable> table( 290 Handle<ObjectHashTable> table(
291 ObjectHashTable::cast(weak_collection->table())); 291 ObjectHashTable::cast(weak_collection->table()));
292 RUNTIME_ASSERT(table->IsKey(*key)); 292 RUNTIME_ASSERT(table->IsKey(*key));
293 Handle<Object> lookup(table->Lookup(key, hash), isolate); 293 Handle<Object> lookup(table->Lookup(key, hash), isolate);
294 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; 294 return lookup->IsTheHole(isolate) ? isolate->heap()->undefined_value()
295 : *lookup;
295 } 296 }
296 297
297 298
298 RUNTIME_FUNCTION(Runtime_WeakCollectionHas) { 299 RUNTIME_FUNCTION(Runtime_WeakCollectionHas) {
299 HandleScope scope(isolate); 300 HandleScope scope(isolate);
300 DCHECK(args.length() == 3); 301 DCHECK(args.length() == 3);
301 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); 302 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
302 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 303 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
303 CONVERT_SMI_ARG_CHECKED(hash, 2) 304 CONVERT_SMI_ARG_CHECKED(hash, 2)
304 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); 305 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
305 Handle<ObjectHashTable> table( 306 Handle<ObjectHashTable> table(
306 ObjectHashTable::cast(weak_collection->table())); 307 ObjectHashTable::cast(weak_collection->table()));
307 RUNTIME_ASSERT(table->IsKey(*key)); 308 RUNTIME_ASSERT(table->IsKey(*key));
308 Handle<Object> lookup(table->Lookup(key, hash), isolate); 309 Handle<Object> lookup(table->Lookup(key, hash), isolate);
309 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); 310 return isolate->heap()->ToBoolean(!lookup->IsTheHole(isolate));
310 } 311 }
311 312
312 313
313 RUNTIME_FUNCTION(Runtime_WeakCollectionDelete) { 314 RUNTIME_FUNCTION(Runtime_WeakCollectionDelete) {
314 HandleScope scope(isolate); 315 HandleScope scope(isolate);
315 DCHECK(args.length() == 3); 316 DCHECK(args.length() == 3);
316 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); 317 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
317 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 318 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
318 CONVERT_SMI_ARG_CHECKED(hash, 2) 319 CONVERT_SMI_ARG_CHECKED(hash, 2)
319 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); 320 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 for (int i = 0; count < max_values && i < table->Capacity(); i++) { 364 for (int i = 0; count < max_values && i < table->Capacity(); i++) {
364 Handle<Object> key(table->KeyAt(i), isolate); 365 Handle<Object> key(table->KeyAt(i), isolate);
365 if (table->IsKey(*key)) values->set(count++, *key); 366 if (table->IsKey(*key)) values->set(count++, *key);
366 } 367 }
367 DCHECK_EQ(max_values, count); 368 DCHECK_EQ(max_values, count);
368 } 369 }
369 return *isolate->factory()->NewJSArrayWithElements(values); 370 return *isolate->factory()->NewJSArrayWithElements(values);
370 } 371 }
371 } // namespace internal 372 } // namespace internal
372 } // namespace v8 373 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | src/runtime/runtime-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698