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

Side by Side Diff: src/api.cc

Issue 1314053003: Move runtime helper for JSWeakCollection onto objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-runtime-helpers-1
Patch Set: Created 5 years, 3 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/objects.h » ('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 2507 matching lines...) Expand 10 before | Expand all | Expand 10 after
2518 return getBoolProperty(this, "isConstructor"); 2518 return getBoolProperty(this, "isConstructor");
2519 } 2519 }
2520 2520
2521 2521
2522 // --- N a t i v e W e a k M a p --- 2522 // --- N a t i v e W e a k M a p ---
2523 2523
2524 Local<NativeWeakMap> NativeWeakMap::New(Isolate* v8_isolate) { 2524 Local<NativeWeakMap> NativeWeakMap::New(Isolate* v8_isolate) {
2525 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 2525 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
2526 ENTER_V8(isolate); 2526 ENTER_V8(isolate);
2527 i::Handle<i::JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap(); 2527 i::Handle<i::JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap();
2528 i::Runtime::WeakCollectionInitialize(isolate, weakmap); 2528 i::JSWeakCollection::Initialize(weakmap, isolate);
2529 return Utils::NativeWeakMapToLocal(weakmap); 2529 return Utils::NativeWeakMapToLocal(weakmap);
2530 } 2530 }
2531 2531
2532 2532
2533 void NativeWeakMap::Set(Local<Value> v8_key, Local<Value> v8_value) { 2533 void NativeWeakMap::Set(Local<Value> v8_key, Local<Value> v8_value) {
2534 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); 2534 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this);
2535 i::Isolate* isolate = weak_collection->GetIsolate(); 2535 i::Isolate* isolate = weak_collection->GetIsolate();
2536 ENTER_V8(isolate); 2536 ENTER_V8(isolate);
2537 i::HandleScope scope(isolate); 2537 i::HandleScope scope(isolate);
2538 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); 2538 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key);
2539 i::Handle<i::Object> value = Utils::OpenHandle(*v8_value); 2539 i::Handle<i::Object> value = Utils::OpenHandle(*v8_value);
2540 if (!key->IsJSReceiver() && !key->IsSymbol()) { 2540 if (!key->IsJSReceiver() && !key->IsSymbol()) {
2541 DCHECK(false); 2541 DCHECK(false);
2542 return; 2542 return;
2543 } 2543 }
2544 i::Handle<i::ObjectHashTable> table( 2544 i::Handle<i::ObjectHashTable> table(
2545 i::ObjectHashTable::cast(weak_collection->table())); 2545 i::ObjectHashTable::cast(weak_collection->table()));
2546 if (!table->IsKey(*key)) { 2546 if (!table->IsKey(*key)) {
2547 DCHECK(false); 2547 DCHECK(false);
2548 return; 2548 return;
2549 } 2549 }
2550 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value(); 2550 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value();
2551 i::Runtime::WeakCollectionSet(weak_collection, key, value, hash); 2551 i::JSWeakCollection::Set(weak_collection, key, value, hash);
2552 } 2552 }
2553 2553
2554 2554
2555 Local<Value> NativeWeakMap::Get(Local<Value> v8_key) { 2555 Local<Value> NativeWeakMap::Get(Local<Value> v8_key) {
2556 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); 2556 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this);
2557 i::Isolate* isolate = weak_collection->GetIsolate(); 2557 i::Isolate* isolate = weak_collection->GetIsolate();
2558 ENTER_V8(isolate); 2558 ENTER_V8(isolate);
2559 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); 2559 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key);
2560 if (!key->IsJSReceiver() && !key->IsSymbol()) { 2560 if (!key->IsJSReceiver() && !key->IsSymbol()) {
2561 DCHECK(false); 2561 DCHECK(false);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2604 if (!key->IsJSReceiver() && !key->IsSymbol()) { 2604 if (!key->IsJSReceiver() && !key->IsSymbol()) {
2605 DCHECK(false); 2605 DCHECK(false);
2606 return false; 2606 return false;
2607 } 2607 }
2608 i::Handle<i::ObjectHashTable> table( 2608 i::Handle<i::ObjectHashTable> table(
2609 i::ObjectHashTable::cast(weak_collection->table())); 2609 i::ObjectHashTable::cast(weak_collection->table()));
2610 if (!table->IsKey(*key)) { 2610 if (!table->IsKey(*key)) {
2611 DCHECK(false); 2611 DCHECK(false);
2612 return false; 2612 return false;
2613 } 2613 }
2614 return i::Runtime::WeakCollectionDelete(weak_collection, key); 2614 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value();
2615 return i::JSWeakCollection::Delete(weak_collection, key, hash);
2615 } 2616 }
2616 2617
2617 2618
2618 // --- J S O N --- 2619 // --- J S O N ---
2619 2620
2620 MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) { 2621 MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) {
2621 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 2622 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
2622 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, "JSON::Parse", Value); 2623 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, "JSON::Parse", Value);
2623 i::Handle<i::String> string = Utils::OpenHandle(*json_string); 2624 i::Handle<i::String> string = Utils::OpenHandle(*json_string);
2624 i::Handle<i::String> source = i::String::Flatten(string); 2625 i::Handle<i::String> source = i::String::Flatten(string);
(...skipping 5783 matching lines...) Expand 10 before | Expand all | Expand 10 after
8408 Address callback_address = 8409 Address callback_address =
8409 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8410 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8410 VMState<EXTERNAL> state(isolate); 8411 VMState<EXTERNAL> state(isolate);
8411 ExternalCallbackScope call_scope(isolate, callback_address); 8412 ExternalCallbackScope call_scope(isolate, callback_address);
8412 callback(info); 8413 callback(info);
8413 } 8414 }
8414 8415
8415 8416
8416 } // namespace internal 8417 } // namespace internal
8417 } // namespace v8 8418 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698