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 1886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 Isolate* isolate(CcTest::InitIsolateOnce()); | 1897 Isolate* isolate(CcTest::InitIsolateOnce()); |
1898 | 1898 |
1899 const int kNumParams = 1; | 1899 const int kNumParams = 1; |
1900 CodeAssemblerTester data(isolate, kNumParams); | 1900 CodeAssemblerTester data(isolate, kNumParams); |
1901 CodeStubAssembler m(data.state()); | 1901 CodeStubAssembler m(data.state()); |
1902 | 1902 |
1903 Node* const context = m.Parameter(kNumParams + 2); | 1903 Node* const context = m.Parameter(kNumParams + 2); |
1904 Node* const promise = m.AllocateJSPromise(context); | 1904 Node* const promise = m.AllocateJSPromise(context); |
1905 Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); | 1905 Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); |
1906 m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant()); | 1906 m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant()); |
1907 Node* const deferred = | 1907 Node* const deferred_promise = |
1908 m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); | 1908 m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); |
1909 m.StoreFixedArrayElement(deferred, 0, m.UndefinedConstant()); | 1909 m.StoreFixedArrayElement(deferred_promise, 0, m.UndefinedConstant()); |
1910 Node* const info = m.AllocatePromiseReactionJobInfo(m.SmiConstant(1), promise, | 1910 Node* const info = m.AllocatePromiseReactionJobInfo( |
1911 tasks, deferred, context); | 1911 promise, m.SmiConstant(1), tasks, deferred_promise, m.UndefinedConstant(), |
| 1912 m.UndefinedConstant(), context); |
1912 m.Return(info); | 1913 m.Return(info); |
1913 | 1914 |
1914 Handle<Code> code = data.GenerateCode(); | 1915 Handle<Code> code = data.GenerateCode(); |
1915 CHECK(!code.is_null()); | 1916 CHECK(!code.is_null()); |
1916 | 1917 |
1917 FunctionTester ft(code, kNumParams); | 1918 FunctionTester ft(code, kNumParams); |
1918 Handle<Object> result = | 1919 Handle<Object> result = |
1919 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); | 1920 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); |
1920 CHECK(result->IsPromiseReactionJobInfo()); | 1921 CHECK(result->IsPromiseReactionJobInfo()); |
1921 Handle<PromiseReactionJobInfo> promise_info = | 1922 Handle<PromiseReactionJobInfo> promise_info = |
1922 Handle<PromiseReactionJobInfo>::cast(result); | 1923 Handle<PromiseReactionJobInfo>::cast(result); |
1923 CHECK_EQ(Smi::FromInt(1), promise_info->value()); | 1924 CHECK_EQ(Smi::FromInt(1), promise_info->value()); |
1924 CHECK(promise_info->promise()->IsJSPromise()); | 1925 CHECK(promise_info->promise()->IsJSPromise()); |
1925 CHECK(promise_info->tasks()->IsFixedArray()); | 1926 CHECK(promise_info->tasks()->IsFixedArray()); |
1926 CHECK(promise_info->deferred()->IsFixedArray()); | 1927 CHECK(promise_info->deferred_promise()->IsFixedArray()); |
| 1928 CHECK(promise_info->deferred_on_resolve()->IsUndefined(isolate)); |
| 1929 CHECK(promise_info->deferred_on_reject()->IsUndefined(isolate)); |
1927 CHECK(promise_info->context()->IsContext()); | 1930 CHECK(promise_info->context()->IsContext()); |
1928 CHECK(promise_info->debug_id()->IsUndefined(isolate)); | 1931 CHECK(promise_info->debug_id()->IsUndefined(isolate)); |
1929 CHECK(promise_info->debug_name()->IsUndefined(isolate)); | 1932 CHECK(promise_info->debug_name()->IsUndefined(isolate)); |
1930 } | 1933 } |
1931 | 1934 |
1932 TEST(IsSymbol) { | 1935 TEST(IsSymbol) { |
1933 Isolate* isolate(CcTest::InitIsolateOnce()); | 1936 Isolate* isolate(CcTest::InitIsolateOnce()); |
1934 | 1937 |
1935 const int kNumParams = 1; | 1938 const int kNumParams = 1; |
1936 CodeAssemblerTester data(isolate, kNumParams); | 1939 CodeAssemblerTester data(isolate, kNumParams); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2094 CHECK_EQ(isolate->heap()->empty_fixed_array(), fun->elements()); | 2097 CHECK_EQ(isolate->heap()->empty_fixed_array(), fun->elements()); |
2095 CHECK_EQ(isolate->heap()->empty_literals_array(), fun->literals()); | 2098 CHECK_EQ(isolate->heap()->empty_literals_array(), fun->literals()); |
2096 CHECK_EQ(isolate->heap()->the_hole_value(), fun->prototype_or_initial_map()); | 2099 CHECK_EQ(isolate->heap()->the_hole_value(), fun->prototype_or_initial_map()); |
2097 CHECK_EQ(*isolate->promise_resolve_shared_fun(), fun->shared()); | 2100 CHECK_EQ(*isolate->promise_resolve_shared_fun(), fun->shared()); |
2098 CHECK_EQ(isolate->promise_resolve_shared_fun()->code(), fun->code()); | 2101 CHECK_EQ(isolate->promise_resolve_shared_fun()->code(), fun->code()); |
2099 CHECK_EQ(isolate->heap()->undefined_value(), fun->next_function_link()); | 2102 CHECK_EQ(isolate->heap()->undefined_value(), fun->next_function_link()); |
2100 } | 2103 } |
2101 | 2104 |
2102 } // namespace internal | 2105 } // namespace internal |
2103 } // namespace v8 | 2106 } // namespace v8 |
OLD | NEW |