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

Side by Side Diff: gin/wrappable.cc

Issue 2236443002: [gin] Use new SetAlignedPointerInInteralFields api function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing nit Created 4 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium 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 "gin/wrappable.h" 5 #include "gin/wrappable.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gin/object_template_builder.h" 8 #include "gin/object_template_builder.h"
9 #include "gin/per_isolate_data.h" 9 #include "gin/per_isolate_data.h"
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 CHECK_EQ(kNumberOfInternalFields, templ->InternalFieldCount()); 51 CHECK_EQ(kNumberOfInternalFields, templ->InternalFieldCount());
52 v8::Local<v8::Object> wrapper; 52 v8::Local<v8::Object> wrapper;
53 // |wrapper| may be empty in some extreme cases, e.g., when 53 // |wrapper| may be empty in some extreme cases, e.g., when
54 // Object.prototype.constructor is overwritten. 54 // Object.prototype.constructor is overwritten.
55 if (!templ->NewInstance(isolate->GetCurrentContext()).ToLocal(&wrapper)) { 55 if (!templ->NewInstance(isolate->GetCurrentContext()).ToLocal(&wrapper)) {
56 // The current wrappable object will be no longer managed by V8. Delete this 56 // The current wrappable object will be no longer managed by V8. Delete this
57 // now. 57 // now.
58 delete this; 58 delete this;
59 return wrapper; 59 return wrapper;
60 } 60 }
61 wrapper->SetAlignedPointerInInternalField(kWrapperInfoIndex, info); 61
62 wrapper->SetAlignedPointerInInternalField(kEncodedValueIndex, this); 62 int indices[] = {kWrapperInfoIndex, kEncodedValueIndex};
63 void* values[] = {info, this};
64 wrapper->SetAlignedPointerInInternalFields(2, indices, values);
63 wrapper_.Reset(isolate, wrapper); 65 wrapper_.Reset(isolate, wrapper);
64 wrapper_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter); 66 wrapper_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter);
65 return wrapper; 67 return wrapper;
66 } 68 }
67 69
68 namespace internal { 70 namespace internal {
69 71
70 void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val, 72 void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val,
71 WrapperInfo* wrapper_info) { 73 WrapperInfo* wrapper_info) {
72 if (!val->IsObject()) 74 if (!val->IsObject())
(...skipping 11 matching lines...) Expand all
84 // instance of the C++ class associated with wrapper_info. 86 // instance of the C++ class associated with wrapper_info.
85 if (info != wrapper_info) 87 if (info != wrapper_info)
86 return NULL; 88 return NULL;
87 89
88 return obj->GetAlignedPointerFromInternalField(kEncodedValueIndex); 90 return obj->GetAlignedPointerFromInternalField(kEncodedValueIndex);
89 } 91 }
90 92
91 } // namespace internal 93 } // namespace internal
92 94
93 } // namespace gin 95 } // namespace gin
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698