OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 #include "src/code-stub-assembler.h" | 7 #include "src/code-stub-assembler.h" |
8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "test/cctest/compiler/code-assembler-tester.h" | 10 #include "test/cctest/compiler/code-assembler-tester.h" |
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2062 FunctionTester ft(code, kNumParams); | 2062 FunctionTester ft(code, kNumParams); |
2063 Handle<Object> result = | 2063 Handle<Object> result = |
2064 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); | 2064 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); |
2065 CHECK(result->IsJSPromise()); | 2065 CHECK(result->IsJSPromise()); |
2066 Handle<JSPromise> js_promise = Handle<JSPromise>::cast(result); | 2066 Handle<JSPromise> js_promise = Handle<JSPromise>::cast(result); |
2067 CHECK_EQ(kPromisePending, js_promise->status()); | 2067 CHECK_EQ(kPromisePending, js_promise->status()); |
2068 CHECK_EQ(Smi::FromInt(1), js_promise->result()); | 2068 CHECK_EQ(Smi::FromInt(1), js_promise->result()); |
2069 CHECK(!js_promise->has_handler()); | 2069 CHECK(!js_promise->has_handler()); |
2070 } | 2070 } |
2071 | 2071 |
| 2072 TEST(AllocatePromiseReactionJobInfo) { |
| 2073 Isolate* isolate(CcTest::InitIsolateOnce()); |
| 2074 |
| 2075 const int kNumParams = 1; |
| 2076 CodeAssemblerTester data(isolate, kNumParams); |
| 2077 CodeStubAssembler m(data.state()); |
| 2078 |
| 2079 Node* const context = m.Parameter(kNumParams + 2); |
| 2080 Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.Int32Constant(1)); |
| 2081 m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant()); |
| 2082 Node* const deferred = |
| 2083 m.AllocateFixedArray(FAST_ELEMENTS, m.Int32Constant(1)); |
| 2084 m.StoreFixedArrayElement(deferred, 0, m.UndefinedConstant()); |
| 2085 Node* const info = m.AllocatePromiseReactionJobInfo(m.SmiConstant(1), tasks, |
| 2086 deferred, context); |
| 2087 m.Return(info); |
| 2088 |
| 2089 Handle<Code> code = data.GenerateCode(); |
| 2090 CHECK(!code.is_null()); |
| 2091 |
| 2092 FunctionTester ft(code, kNumParams); |
| 2093 Handle<Object> result = |
| 2094 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); |
| 2095 CHECK(result->IsPromiseReactionJobInfo()); |
| 2096 Handle<PromiseReactionJobInfo> promise_info = |
| 2097 Handle<PromiseReactionJobInfo>::cast(result); |
| 2098 CHECK_EQ(Smi::FromInt(1), promise_info->value()); |
| 2099 CHECK(promise_info->tasks()->IsFixedArray()); |
| 2100 CHECK(promise_info->deferred()->IsFixedArray()); |
| 2101 CHECK(promise_info->context()->IsContext()); |
| 2102 CHECK(promise_info->debug_id()->IsUndefined(isolate)); |
| 2103 CHECK(promise_info->debug_name()->IsUndefined(isolate)); |
| 2104 } |
| 2105 |
2072 } // namespace internal | 2106 } // namespace internal |
2073 } // namespace v8 | 2107 } // namespace v8 |
OLD | NEW |