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

Side by Side Diff: test/cctest/test-code-stub-assembler.cc

Issue 2581503003: [promisehook] Store promise in PromiseReactionJob (Closed)
Patch Set: rebase correctly 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 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 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 } 1890 }
1891 1891
1892 TEST(AllocatePromiseReactionJobInfo) { 1892 TEST(AllocatePromiseReactionJobInfo) {
1893 Isolate* isolate(CcTest::InitIsolateOnce()); 1893 Isolate* isolate(CcTest::InitIsolateOnce());
1894 1894
1895 const int kNumParams = 1; 1895 const int kNumParams = 1;
1896 CodeAssemblerTester data(isolate, kNumParams); 1896 CodeAssemblerTester data(isolate, kNumParams);
1897 CodeStubAssembler m(data.state()); 1897 CodeStubAssembler m(data.state());
1898 1898
1899 Node* const context = m.Parameter(kNumParams + 2); 1899 Node* const context = m.Parameter(kNumParams + 2);
1900 Node* const promise = m.AllocateJSPromise(context);
1900 Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); 1901 Node* const tasks = m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1));
1901 m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant()); 1902 m.StoreFixedArrayElement(tasks, 0, m.UndefinedConstant());
1902 Node* const deferred = 1903 Node* const deferred =
1903 m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1)); 1904 m.AllocateFixedArray(FAST_ELEMENTS, m.IntPtrConstant(1));
1904 m.StoreFixedArrayElement(deferred, 0, m.UndefinedConstant()); 1905 m.StoreFixedArrayElement(deferred, 0, m.UndefinedConstant());
1905 Node* const info = m.AllocatePromiseReactionJobInfo(m.SmiConstant(1), tasks, 1906 Node* const info = m.AllocatePromiseReactionJobInfo(m.SmiConstant(1), promise,
1906 deferred, context); 1907 tasks, deferred, context);
1907 m.Return(info); 1908 m.Return(info);
1908 1909
1909 Handle<Code> code = data.GenerateCode(); 1910 Handle<Code> code = data.GenerateCode();
1910 CHECK(!code.is_null()); 1911 CHECK(!code.is_null());
1911 1912
1912 FunctionTester ft(code, kNumParams); 1913 FunctionTester ft(code, kNumParams);
1913 Handle<Object> result = 1914 Handle<Object> result =
1914 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 1915 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1915 CHECK(result->IsPromiseReactionJobInfo()); 1916 CHECK(result->IsPromiseReactionJobInfo());
1916 Handle<PromiseReactionJobInfo> promise_info = 1917 Handle<PromiseReactionJobInfo> promise_info =
1917 Handle<PromiseReactionJobInfo>::cast(result); 1918 Handle<PromiseReactionJobInfo>::cast(result);
1918 CHECK_EQ(Smi::FromInt(1), promise_info->value()); 1919 CHECK_EQ(Smi::FromInt(1), promise_info->value());
1920 CHECK(promise_info->promise()->IsJSPromise());
1919 CHECK(promise_info->tasks()->IsFixedArray()); 1921 CHECK(promise_info->tasks()->IsFixedArray());
1920 CHECK(promise_info->deferred()->IsFixedArray()); 1922 CHECK(promise_info->deferred()->IsFixedArray());
1921 CHECK(promise_info->context()->IsContext()); 1923 CHECK(promise_info->context()->IsContext());
1922 CHECK(promise_info->debug_id()->IsUndefined(isolate)); 1924 CHECK(promise_info->debug_id()->IsUndefined(isolate));
1923 CHECK(promise_info->debug_name()->IsUndefined(isolate)); 1925 CHECK(promise_info->debug_name()->IsUndefined(isolate));
1924 } 1926 }
1925 1927
1926 TEST(IsSymbol) { 1928 TEST(IsSymbol) {
1927 Isolate* isolate(CcTest::InitIsolateOnce()); 1929 Isolate* isolate(CcTest::InitIsolateOnce());
1928 1930
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 1967
1966 result = ft.Call(isolate->factory()->empty_string()).ToHandleChecked(); 1968 result = ft.Call(isolate->factory()->empty_string()).ToHandleChecked();
1967 CHECK_EQ(isolate->heap()->false_value(), *result); 1969 CHECK_EQ(isolate->heap()->false_value(), *result);
1968 1970
1969 result = ft.Call(isolate->factory()->NewPrivateSymbol()).ToHandleChecked(); 1971 result = ft.Call(isolate->factory()->NewPrivateSymbol()).ToHandleChecked();
1970 CHECK_EQ(isolate->heap()->true_value(), *result); 1972 CHECK_EQ(isolate->heap()->true_value(), *result);
1971 } 1973 }
1972 1974
1973 } // namespace internal 1975 } // namespace internal
1974 } // namespace v8 1976 } // namespace v8
OLDNEW
« src/builtins/builtins-promise.cc ('K') | « src/runtime/runtime-promise.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698