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/builtins/builtins-promise.h" | 6 #include "src/builtins/builtins-promise.h" |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 | 1825 |
1826 TEST(AllocateJSPromise) { | 1826 TEST(AllocateJSPromise) { |
1827 Isolate* isolate(CcTest::InitIsolateOnce()); | 1827 Isolate* isolate(CcTest::InitIsolateOnce()); |
1828 | 1828 |
1829 const int kNumParams = 1; | 1829 const int kNumParams = 1; |
1830 CodeAssemblerTester data(isolate, kNumParams); | 1830 CodeAssemblerTester data(isolate, kNumParams); |
1831 CodeStubAssembler m(data.state()); | 1831 CodeStubAssembler m(data.state()); |
1832 | 1832 |
1833 Node* const context = m.Parameter(kNumParams + 2); | 1833 Node* const context = m.Parameter(kNumParams + 2); |
1834 Node* const promise = m.AllocateJSPromise(context); | 1834 Node* const promise = m.AllocateJSPromise(context); |
| 1835 m.PromiseInit(promise); |
1835 m.Return(promise); | 1836 m.Return(promise); |
1836 | 1837 |
1837 Handle<Code> code = data.GenerateCode(); | 1838 Handle<Code> code = data.GenerateCode(); |
1838 CHECK(!code.is_null()); | 1839 CHECK(!code.is_null()); |
1839 | 1840 |
1840 FunctionTester ft(code, kNumParams); | 1841 FunctionTester ft(code, kNumParams); |
1841 Handle<Object> result = | 1842 Handle<Object> result = |
1842 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); | 1843 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); |
1843 CHECK(result->IsJSPromise()); | 1844 CHECK(result->IsJSPromise()); |
1844 } | 1845 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 | 1896 |
1896 TEST(AllocatePromiseReactionJobInfo) { | 1897 TEST(AllocatePromiseReactionJobInfo) { |
1897 Isolate* isolate(CcTest::InitIsolateOnce()); | 1898 Isolate* isolate(CcTest::InitIsolateOnce()); |
1898 | 1899 |
1899 const int kNumParams = 1; | 1900 const int kNumParams = 1; |
1900 CodeAssemblerTester data(isolate, kNumParams); | 1901 CodeAssemblerTester data(isolate, kNumParams); |
1901 CodeStubAssembler m(data.state()); | 1902 CodeStubAssembler m(data.state()); |
1902 | 1903 |
1903 Node* const context = m.Parameter(kNumParams + 2); | 1904 Node* const context = m.Parameter(kNumParams + 2); |
1904 Node* const promise = m.AllocateJSPromise(context); | 1905 Node* const promise = m.AllocateJSPromise(context); |
| 1906 m.PromiseInit(promise); |
1905 Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); | 1907 Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); |
1906 m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant()); | 1908 m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant()); |
1907 Node* const deferred_promise = | 1909 Node* const deferred_promise = |
1908 m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); | 1910 m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); |
1909 m.StoreFixedArrayElement(deferred_promise, 0, m.UndefinedConstant()); | 1911 m.StoreFixedArrayElement(deferred_promise, 0, m.UndefinedConstant()); |
1910 Node* const info = m.AllocatePromiseReactionJobInfo( | 1912 Node* const info = m.AllocatePromiseReactionJobInfo( |
1911 promise, m.SmiConstant(1), tasks, deferred_promise, m.UndefinedConstant(), | 1913 promise, m.SmiConstant(1), tasks, deferred_promise, m.UndefinedConstant(), |
1912 m.UndefinedConstant(), context); | 1914 m.UndefinedConstant(), context); |
1913 m.Return(info); | 1915 m.Return(info); |
1914 | 1916 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2097 CHECK_EQ(isolate->heap()->empty_fixed_array(), fun->elements()); | 2099 CHECK_EQ(isolate->heap()->empty_fixed_array(), fun->elements()); |
2098 CHECK_EQ(isolate->heap()->empty_literals_array(), fun->literals()); | 2100 CHECK_EQ(isolate->heap()->empty_literals_array(), fun->literals()); |
2099 CHECK_EQ(isolate->heap()->the_hole_value(), fun->prototype_or_initial_map()); | 2101 CHECK_EQ(isolate->heap()->the_hole_value(), fun->prototype_or_initial_map()); |
2100 CHECK_EQ(*isolate->promise_resolve_shared_fun(), fun->shared()); | 2102 CHECK_EQ(*isolate->promise_resolve_shared_fun(), fun->shared()); |
2101 CHECK_EQ(isolate->promise_resolve_shared_fun()->code(), fun->code()); | 2103 CHECK_EQ(isolate->promise_resolve_shared_fun()->code(), fun->code()); |
2102 CHECK_EQ(isolate->heap()->undefined_value(), fun->next_function_link()); | 2104 CHECK_EQ(isolate->heap()->undefined_value(), fun->next_function_link()); |
2103 } | 2105 } |
2104 | 2106 |
2105 } // namespace internal | 2107 } // namespace internal |
2106 } // namespace v8 | 2108 } // namespace v8 |
OLD | NEW |