Commit dfa26606 authored by gsathya's avatar gsathya Committed by Commit bot

Add PromiseReactionJobInfo to CSA

BUG=v8:5343

Review-Url: https://codereview.chromium.org/2573703002
Cr-Commit-Position: refs/heads/master@{#41674}
parent 788e74f5
......@@ -8246,5 +8246,26 @@ void CodeStubAssembler::PromiseSet(Node* promise, Node* status, Node* result) {
StoreObjectField(promise, JSPromise::kFlagsOffset, SmiConstant(0));
}
Node* CodeStubAssembler::AllocatePromiseReactionJobInfo(Node* value,
Node* tasks,
Node* deferred,
Node* context) {
Node* const result = Allocate(PromiseReactionJobInfo::kSize);
StoreMapNoWriteBarrier(result, Heap::kPromiseReactionJobInfoMapRootIndex);
StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kValueOffset,
value);
StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kTasksOffset,
tasks);
StoreObjectFieldNoWriteBarrier(
result, PromiseReactionJobInfo::kDeferredOffset, deferred);
StoreObjectFieldRoot(result, PromiseReactionJobInfo::kDebugIdOffset,
Heap::kUndefinedValueRootIndex);
StoreObjectFieldRoot(result, PromiseReactionJobInfo::kDebugNameOffset,
Heap::kUndefinedValueRootIndex);
StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset,
context);
return result;
}
} // namespace internal
} // namespace v8
......@@ -1089,6 +1089,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
// provides a helper for certain init patterns.
void PromiseSet(Node* promise, Node* status, Node* result);
Node* AllocatePromiseReactionJobInfo(Node* value, Node* tasks, Node* deferred,
Node* context);
protected:
void DescriptorLookupLinear(Node* unique_name, Node* descriptors, Node* nof,
Label* if_found, Variable* var_name_index,
......
......@@ -2069,5 +2069,39 @@ TEST(PromiseSet) {
CHECK(!js_promise->has_handler());
}
TEST(AllocatePromiseReactionJobInfo) {
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 1;
CodeAssemblerTester data(isolate, kNumParams);
CodeStubAssembler m(data.state());
Node* const context = m.Parameter(kNumParams + 2);
Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.Int32Constant(1));
m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant());
Node* const deferred =
m.AllocateFixedArray(FAST_ELEMENTS, m.Int32Constant(1));
m.StoreFixedArrayElement(deferred, 0, m.UndefinedConstant());
Node* const info = m.AllocatePromiseReactionJobInfo(m.SmiConstant(1), tasks,
deferred, context);
m.Return(info);
Handle<Code> code = data.GenerateCode();
CHECK(!code.is_null());
FunctionTester ft(code, kNumParams);
Handle<Object> result =
ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
CHECK(result->IsPromiseReactionJobInfo());
Handle<PromiseReactionJobInfo> promise_info =
Handle<PromiseReactionJobInfo>::cast(result);
CHECK_EQ(Smi::FromInt(1), promise_info->value());
CHECK(promise_info->tasks()->IsFixedArray());
CHECK(promise_info->deferred()->IsFixedArray());
CHECK(promise_info->context()->IsContext());
CHECK(promise_info->debug_id()->IsUndefined(isolate));
CHECK(promise_info->debug_name()->IsUndefined(isolate));
}
} // namespace internal
} // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment