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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2567033003: [promises] Port CreateResolvingFunctions to TF (Closed)
Patch Set: cleanup Created 4 years 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
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 #include "src/code-stub-assembler.h" 4 #include "src/code-stub-assembler.h"
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/frames-inl.h" 6 #include "src/frames-inl.h"
7 #include "src/frames.h" 7 #include "src/frames.h"
8 #include "src/promise-utils.h"
8 9
9 namespace v8 { 10 namespace v8 {
10 namespace internal { 11 namespace internal {
11 12
12 using compiler::Node; 13 using compiler::Node;
13 14
14 void CodeStubAssembler::Assert(const NodeGenerator& codition_body, 15 void CodeStubAssembler::Assert(const NodeGenerator& codition_body,
15 const char* message, const char* file, 16 const char* message, const char* file,
16 int line) { 17 int line) {
17 #if defined(DEBUG) 18 #if defined(DEBUG)
(...skipping 8197 matching lines...) Expand 10 before | Expand all | Expand 10 after
8215 } 8216 }
8216 8217
8217 Node* CodeStubAssembler::IsPromiseHookEnabled() { 8218 Node* CodeStubAssembler::IsPromiseHookEnabled() {
8218 Node* const is_promisehook_enabled = 8219 Node* const is_promisehook_enabled =
8219 Load(MachineType::Uint8(), 8220 Load(MachineType::Uint8(),
8220 ExternalConstant( 8221 ExternalConstant(
8221 ExternalReference::is_promisehook_enabled_address(isolate()))); 8222 ExternalReference::is_promisehook_enabled_address(isolate())));
8222 return WordNotEqual(is_promisehook_enabled, Int32Constant(0)); 8223 return WordNotEqual(is_promisehook_enabled, Int32Constant(0));
8223 } 8224 }
8224 8225
8226 Node* CodeStubAssembler::AllocateFunctionWithMapAndContext(Node* map,
8227 Node* shared_info,
8228 Node* context) {
8229 Node* const code =
8230 LoadObjectField(shared_info, SharedFunctionInfo::kCodeOffset);
8231 Node* const code_entry =
8232 IntPtrAdd(code, IntPtrConstant(Code::kHeaderSize - kHeapObjectTag));
8233
8234 Node* const fun = Allocate(JSFunction::kSize);
8235 StoreMapNoWriteBarrier(fun, map);
8236 StoreObjectFieldRoot(fun, JSObject::kPropertiesOffset,
8237 Heap::kEmptyFixedArrayRootIndex);
8238 StoreObjectFieldRoot(fun, JSObject::kElementsOffset,
8239 Heap::kEmptyFixedArrayRootIndex);
8240 StoreObjectFieldRoot(fun, JSFunction::kLiteralsOffset,
8241 Heap::kEmptyLiteralsArrayRootIndex);
8242 StoreObjectFieldRoot(fun, JSFunction::kPrototypeOrInitialMapOffset,
8243 Heap::kTheHoleValueRootIndex);
8244 StoreObjectFieldNoWriteBarrier(fun, JSFunction::kSharedFunctionInfoOffset,
8245 shared_info);
8246 StoreObjectFieldNoWriteBarrier(fun, JSFunction::kContextOffset, context);
8247 StoreObjectFieldNoWriteBarrier(fun, JSFunction::kCodeEntryOffset, code_entry);
8248 StoreObjectFieldRoot(fun, JSFunction::kNextFunctionLinkOffset,
8249 Heap::kUndefinedValueRootIndex);
8250
8251 return fun;
8252 }
8253
8254 Node* CodeStubAssembler::CreatePromiseResolvingFunctionsContext(
8255 Node* promise, Node* debug_event, Node* native_context) {
8256 Node* const context =
8257 Allocate(FixedArray::SizeFor(PromiseUtils::kPromiseContextLength));
8258 Node* const map = HeapConstant(isolate()->factory()->function_context_map());
8259 StoreMapNoWriteBarrier(context, map);
Igor Sheludko 2016/12/13 23:42:34 StoreMapNoWriteBarrier(context, Heap::kFunctionCon
gsathya 2016/12/19 20:12:43 Done.
8260 StoreObjectFieldNoWriteBarrier(
8261 context, FixedArray::kLengthOffset,
8262 SmiConstant(PromiseUtils::kPromiseContextLength));
8263
8264 Node* const empty_fn =
8265 LoadContextElement(native_context, Context::CLOSURE_INDEX);
8266 StoreContextElement(context, Context::CLOSURE_INDEX, empty_fn);
Igor Sheludko 2016/12/13 23:42:34 We can skip write barriers here and below since th
gsathya 2016/12/19 20:12:43 Done.
8267 StoreContextElement(context, Context::PREVIOUS_INDEX, UndefinedConstant());
8268 StoreContextElement(context, Context::EXTENSION_INDEX, TheHoleConstant());
8269 StoreContextElement(context, Context::NATIVE_CONTEXT_INDEX, native_context);
8270 StoreContextElement(context, PromiseUtils::kAlreadyVisitedSlot,
8271 SmiConstant(0));
8272 StoreContextElement(context, PromiseUtils::kPromiseSlot, promise);
8273 StoreContextElement(context, PromiseUtils::kDebugEventSlot, debug_event);
8274 return context;
8275 }
8276
8277 std::pair<Node*, Node*> CodeStubAssembler::CreatePromiseResolvingFunctions(
8278 Node* promise, Node* debug_event, Node* native_context) {
8279 Node* const promise_context = CreatePromiseResolvingFunctionsContext(
8280 promise, debug_event, native_context);
8281 Node* const resolve_info =
8282 LoadContextElement(native_context, Context::PROMISE_RESOLVE_SHARED_FUN);
Igor Sheludko 2016/12/13 23:42:34 Please move the load before the call to respective
gsathya 2016/12/19 20:12:43 Done.
8283 Node* const reject_info =
8284 LoadContextElement(native_context, Context::PROMISE_REJECT_SHARED_FUN);
Igor Sheludko 2016/12/13 23:42:35 Same here.
gsathya 2016/12/19 20:12:43 Done.
8285
8286 Node* const map = LoadContextElement(
8287 native_context, Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX);
8288 Node* const resolve =
8289 AllocateFunctionWithMapAndContext(map, resolve_info, promise_context);
8290 Node* const reject =
8291 AllocateFunctionWithMapAndContext(map, reject_info, promise_context);
8292
8293 return std::make_pair(resolve, reject);
8294 }
8295
8225 Node* CodeStubAssembler::AllocateJSPromise(Node* context) { 8296 Node* CodeStubAssembler::AllocateJSPromise(Node* context) {
8226 Node* const native_context = LoadNativeContext(context); 8297 Node* const native_context = LoadNativeContext(context);
8227 Node* const promise_fun = 8298 Node* const promise_fun =
8228 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); 8299 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX);
8229 Node* const initial_map = 8300 Node* const initial_map =
8230 LoadObjectField(promise_fun, JSFunction::kPrototypeOrInitialMapOffset); 8301 LoadObjectField(promise_fun, JSFunction::kPrototypeOrInitialMapOffset);
8231 Node* const instance = AllocateJSObjectFromMap(initial_map); 8302 Node* const instance = AllocateJSObjectFromMap(initial_map);
8232 8303
8233 return instance; 8304 return instance;
8234 } 8305 }
8235 8306
8236 void CodeStubAssembler::PromiseInit(Node* promise) { 8307 void CodeStubAssembler::PromiseInit(Node* promise) {
8237 StoreObjectField(promise, JSPromise::kStatusOffset, 8308 StoreObjectField(promise, JSPromise::kStatusOffset,
8238 SmiConstant(kPromisePending)); 8309 SmiConstant(kPromisePending));
8239 StoreObjectField(promise, JSPromise::kFlagsOffset, SmiConstant(0)); 8310 StoreObjectField(promise, JSPromise::kFlagsOffset, SmiConstant(0));
8240 } 8311 }
8241 8312
8242 void CodeStubAssembler::PromiseSet(Node* promise, Node* status, Node* result) { 8313 void CodeStubAssembler::PromiseSet(Node* promise, Node* status, Node* result) {
8243 CSA_ASSERT(this, TaggedIsSmi(status)); 8314 CSA_ASSERT(this, TaggedIsSmi(status));
8244 StoreObjectField(promise, JSPromise::kStatusOffset, status); 8315 StoreObjectField(promise, JSPromise::kStatusOffset, status);
8245 StoreObjectField(promise, JSPromise::kResultOffset, result); 8316 StoreObjectField(promise, JSPromise::kResultOffset, result);
8246 StoreObjectField(promise, JSPromise::kFlagsOffset, SmiConstant(0)); 8317 StoreObjectField(promise, JSPromise::kFlagsOffset, SmiConstant(0));
8247 } 8318 }
8248 8319
8249 } // namespace internal 8320 } // namespace internal
8250 } // namespace v8 8321 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698