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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 |
OLD | NEW |