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

Side by Side Diff: src/builtins/builtins-promise-gen.cc

Issue 2889863002: Allow embedder to set promise internal field count (Closed)
Patch Set: Created 3 years, 7 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/bootstrapper.cc ('k') | 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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/builtins/builtins-promise-gen.h" 5 #include "src/builtins/builtins-promise-gen.h"
6 6
7 #include "src/builtins/builtins-constructor-gen.h" 7 #include "src/builtins/builtins-constructor-gen.h"
8 #include "src/builtins/builtins-utils-gen.h" 8 #include "src/builtins/builtins-utils-gen.h"
9 #include "src/builtins/builtins.h" 9 #include "src/builtins/builtins.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
11 #include "src/code-stub-assembler.h" 11 #include "src/code-stub-assembler.h"
12 #include "src/objects-inl.h" 12 #include "src/objects-inl.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 16
17 using compiler::Node; 17 using compiler::Node;
18 18
19 Node* PromiseBuiltinsAssembler::AllocateJSPromise(Node* context) { 19 Node* PromiseBuiltinsAssembler::AllocateJSPromise(Node* context) {
20 // Does this need to change to account for new internal fields?
gsathya 2017/05/18 16:48:33 Nope this is fine, just the init code below.
20 Node* const native_context = LoadNativeContext(context); 21 Node* const native_context = LoadNativeContext(context);
21 Node* const promise_fun = 22 Node* const promise_fun =
22 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); 23 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX);
23 Node* const initial_map = 24 Node* const initial_map =
24 LoadObjectField(promise_fun, JSFunction::kPrototypeOrInitialMapOffset); 25 LoadObjectField(promise_fun, JSFunction::kPrototypeOrInitialMapOffset);
25 Node* const instance = AllocateJSObjectFromMap(initial_map); 26 Node* const instance = AllocateJSObjectFromMap(initial_map);
26 return instance; 27 return instance;
27 } 28 }
28 29
29 void PromiseBuiltinsAssembler::PromiseInit(Node* promise) { 30 void PromiseBuiltinsAssembler::PromiseInit(Node* promise) {
30 StoreObjectFieldNoWriteBarrier(promise, JSPromise::kStatusOffset, 31 StoreObjectFieldNoWriteBarrier(promise, JSPromise::kStatusOffset,
31 SmiConstant(v8::Promise::kPending)); 32 SmiConstant(v8::Promise::kPending));
32 StoreObjectFieldNoWriteBarrier(promise, JSPromise::kFlagsOffset, 33 StoreObjectFieldNoWriteBarrier(promise, JSPromise::kFlagsOffset,
33 SmiConstant(0)); 34 SmiConstant(0));
35 for (int i = 0; i < v8::Promise::kEmbedderFieldCount; i++) {
36 int offset = JSPromise::kSize + i * kPointerSize;
37 StoreObjectFieldNoWriteBarrier(promise, offset, SmiConstant(Smi::kZero));
38 }
34 } 39 }
35 40
36 Node* PromiseBuiltinsAssembler::AllocateAndInitJSPromise(Node* context) { 41 Node* PromiseBuiltinsAssembler::AllocateAndInitJSPromise(Node* context) {
37 return AllocateAndInitJSPromise(context, UndefinedConstant()); 42 return AllocateAndInitJSPromise(context, UndefinedConstant());
38 } 43 }
39 44
40 Node* PromiseBuiltinsAssembler::AllocateAndInitJSPromise(Node* context, 45 Node* PromiseBuiltinsAssembler::AllocateAndInitJSPromise(Node* context,
41 Node* parent) { 46 Node* parent) {
42 Node* const instance = AllocateJSPromise(context); 47 Node* const instance = AllocateJSPromise(context);
43 PromiseInit(instance); 48 PromiseInit(instance);
(...skipping 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 CSA_ASSERT(this, HasInstanceType(result_promise, JS_PROMISE_TYPE)); 1799 CSA_ASSERT(this, HasInstanceType(result_promise, JS_PROMISE_TYPE));
1795 1800
1796 InternalPerformPromiseThen(context, promise, resolve_reaction, 1801 InternalPerformPromiseThen(context, promise, resolve_reaction,
1797 reject_reaction, result_promise, 1802 reject_reaction, result_promise,
1798 UndefinedConstant(), UndefinedConstant()); 1803 UndefinedConstant(), UndefinedConstant());
1799 Return(result_promise); 1804 Return(result_promise);
1800 } 1805 }
1801 1806
1802 } // namespace internal 1807 } // namespace internal
1803 } // namespace v8 1808 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698