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

Side by Side Diff: src/api.cc

Issue 2031533002: [dictionaries] Use IsKey(Isolate* i, Object* o) everywhere (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use new IsTheHole 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 | « no previous file | src/bootstrapper.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 2643 matching lines...) Expand 10 before | Expand all | Expand 10 after
2654 ENTER_V8(isolate); 2654 ENTER_V8(isolate);
2655 i::HandleScope scope(isolate); 2655 i::HandleScope scope(isolate);
2656 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); 2656 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key);
2657 i::Handle<i::Object> value = Utils::OpenHandle(*v8_value); 2657 i::Handle<i::Object> value = Utils::OpenHandle(*v8_value);
2658 if (!key->IsJSReceiver() && !key->IsSymbol()) { 2658 if (!key->IsJSReceiver() && !key->IsSymbol()) {
2659 DCHECK(false); 2659 DCHECK(false);
2660 return; 2660 return;
2661 } 2661 }
2662 i::Handle<i::ObjectHashTable> table( 2662 i::Handle<i::ObjectHashTable> table(
2663 i::ObjectHashTable::cast(weak_collection->table())); 2663 i::ObjectHashTable::cast(weak_collection->table()));
2664 if (!table->IsKey(*key)) { 2664 if (!table->IsKey(isolate, *key)) {
2665 DCHECK(false); 2665 DCHECK(false);
2666 return; 2666 return;
2667 } 2667 }
2668 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value(); 2668 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value();
2669 i::JSWeakCollection::Set(weak_collection, key, value, hash); 2669 i::JSWeakCollection::Set(weak_collection, key, value, hash);
2670 } 2670 }
2671 2671
2672 2672
2673 Local<Value> NativeWeakMap::Get(Local<Value> v8_key) { 2673 Local<Value> NativeWeakMap::Get(Local<Value> v8_key) {
2674 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); 2674 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this);
2675 i::Isolate* isolate = weak_collection->GetIsolate(); 2675 i::Isolate* isolate = weak_collection->GetIsolate();
2676 ENTER_V8(isolate); 2676 ENTER_V8(isolate);
2677 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); 2677 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key);
2678 if (!key->IsJSReceiver() && !key->IsSymbol()) { 2678 if (!key->IsJSReceiver() && !key->IsSymbol()) {
2679 DCHECK(false); 2679 DCHECK(false);
2680 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 2680 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
2681 } 2681 }
2682 i::Handle<i::ObjectHashTable> table( 2682 i::Handle<i::ObjectHashTable> table(
2683 i::ObjectHashTable::cast(weak_collection->table())); 2683 i::ObjectHashTable::cast(weak_collection->table()));
2684 if (!table->IsKey(*key)) { 2684 if (!table->IsKey(isolate, *key)) {
2685 DCHECK(false); 2685 DCHECK(false);
2686 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 2686 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
2687 } 2687 }
2688 i::Handle<i::Object> lookup(table->Lookup(key), isolate); 2688 i::Handle<i::Object> lookup(table->Lookup(key), isolate);
2689 if (lookup->IsTheHole(isolate)) 2689 if (lookup->IsTheHole(isolate))
2690 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 2690 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
2691 return Utils::ToLocal(lookup); 2691 return Utils::ToLocal(lookup);
2692 } 2692 }
2693 2693
2694 2694
2695 bool NativeWeakMap::Has(Local<Value> v8_key) { 2695 bool NativeWeakMap::Has(Local<Value> v8_key) {
2696 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); 2696 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this);
2697 i::Isolate* isolate = weak_collection->GetIsolate(); 2697 i::Isolate* isolate = weak_collection->GetIsolate();
2698 ENTER_V8(isolate); 2698 ENTER_V8(isolate);
2699 i::HandleScope scope(isolate); 2699 i::HandleScope scope(isolate);
2700 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); 2700 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key);
2701 if (!key->IsJSReceiver() && !key->IsSymbol()) { 2701 if (!key->IsJSReceiver() && !key->IsSymbol()) {
2702 DCHECK(false); 2702 DCHECK(false);
2703 return false; 2703 return false;
2704 } 2704 }
2705 i::Handle<i::ObjectHashTable> table( 2705 i::Handle<i::ObjectHashTable> table(
2706 i::ObjectHashTable::cast(weak_collection->table())); 2706 i::ObjectHashTable::cast(weak_collection->table()));
2707 if (!table->IsKey(*key)) { 2707 if (!table->IsKey(isolate, *key)) {
2708 DCHECK(false); 2708 DCHECK(false);
2709 return false; 2709 return false;
2710 } 2710 }
2711 i::Handle<i::Object> lookup(table->Lookup(key), isolate); 2711 i::Handle<i::Object> lookup(table->Lookup(key), isolate);
2712 return !lookup->IsTheHole(isolate); 2712 return !lookup->IsTheHole(isolate);
2713 } 2713 }
2714 2714
2715 2715
2716 bool NativeWeakMap::Delete(Local<Value> v8_key) { 2716 bool NativeWeakMap::Delete(Local<Value> v8_key) {
2717 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); 2717 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this);
2718 i::Isolate* isolate = weak_collection->GetIsolate(); 2718 i::Isolate* isolate = weak_collection->GetIsolate();
2719 ENTER_V8(isolate); 2719 ENTER_V8(isolate);
2720 i::HandleScope scope(isolate); 2720 i::HandleScope scope(isolate);
2721 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); 2721 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key);
2722 if (!key->IsJSReceiver() && !key->IsSymbol()) { 2722 if (!key->IsJSReceiver() && !key->IsSymbol()) {
2723 DCHECK(false); 2723 DCHECK(false);
2724 return false; 2724 return false;
2725 } 2725 }
2726 i::Handle<i::ObjectHashTable> table( 2726 i::Handle<i::ObjectHashTable> table(
2727 i::ObjectHashTable::cast(weak_collection->table())); 2727 i::ObjectHashTable::cast(weak_collection->table()));
2728 if (!table->IsKey(*key)) { 2728 if (!table->IsKey(isolate, *key)) {
2729 DCHECK(false); 2729 DCHECK(false);
2730 return false; 2730 return false;
2731 } 2731 }
2732 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value(); 2732 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value();
2733 return i::JSWeakCollection::Delete(weak_collection, key, hash); 2733 return i::JSWeakCollection::Delete(weak_collection, key, hash);
2734 } 2734 }
2735 2735
2736 2736
2737 // --- J S O N --- 2737 // --- J S O N ---
2738 2738
(...skipping 6077 matching lines...) Expand 10 before | Expand all | Expand 10 after
8816 Address callback_address = 8816 Address callback_address =
8817 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8817 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8818 VMState<EXTERNAL> state(isolate); 8818 VMState<EXTERNAL> state(isolate);
8819 ExternalCallbackScope call_scope(isolate, callback_address); 8819 ExternalCallbackScope call_scope(isolate, callback_address);
8820 callback(info); 8820 callback(info);
8821 } 8821 }
8822 8822
8823 8823
8824 } // namespace internal 8824 } // namespace internal
8825 } // namespace v8 8825 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698