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

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

Issue 2611083002: [promises] Add AllocatePromiseResolveThenableJobInfo to TF (Closed)
Patch Set: rebase Created 3 years, 11 months 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
« no previous file with comments | « src/runtime/runtime-promise.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 CHECK(promise_info->promise()->IsJSPromise()); 1867 CHECK(promise_info->promise()->IsJSPromise());
1868 CHECK(promise_info->tasks()->IsFixedArray()); 1868 CHECK(promise_info->tasks()->IsFixedArray());
1869 CHECK(promise_info->deferred_promise()->IsFixedArray()); 1869 CHECK(promise_info->deferred_promise()->IsFixedArray());
1870 CHECK(promise_info->deferred_on_resolve()->IsUndefined(isolate)); 1870 CHECK(promise_info->deferred_on_resolve()->IsUndefined(isolate));
1871 CHECK(promise_info->deferred_on_reject()->IsUndefined(isolate)); 1871 CHECK(promise_info->deferred_on_reject()->IsUndefined(isolate));
1872 CHECK(promise_info->context()->IsContext()); 1872 CHECK(promise_info->context()->IsContext());
1873 CHECK_EQ(kDebugPromiseNoID, promise_info->debug_id()); 1873 CHECK_EQ(kDebugPromiseNoID, promise_info->debug_id());
1874 CHECK_EQ(kDebugNotActive, promise_info->debug_name()); 1874 CHECK_EQ(kDebugNotActive, promise_info->debug_name());
1875 } 1875 }
1876 1876
1877 TEST(AllocatePromiseResolveThenableJobInfo) {
1878 Isolate* isolate(CcTest::InitIsolateOnce());
1879
1880 const int kNumParams = 1;
1881 CodeAssemblerTester data(isolate, kNumParams);
1882 PromiseBuiltinsAssembler p(data.state());
1883
1884 Node* const context = p.Parameter(kNumParams + 2);
1885 Node* const native_context = p.LoadNativeContext(context);
1886 Node* const thenable = p.AllocateAndInitJSPromise(context);
1887 Node* const then_str = p.HeapConstant(isolate->factory()->then_string());
1888 Callable getproperty_callable = CodeFactory::GetProperty(isolate);
1889 Node* const then =
1890 p.CallStub(getproperty_callable, context, thenable, then_str);
1891 Node* resolve = nullptr;
1892 Node* reject = nullptr;
1893 std::tie(resolve, reject) = p.CreatePromiseResolvingFunctions(
1894 thenable, p.FalseConstant(), native_context);
1895
1896 Node* const info = p.AllocatePromiseResolveThenableJobInfo(
1897 thenable, then, resolve, reject, context);
1898 p.Return(info);
1899
1900 Handle<Code> code = data.GenerateCode();
1901 CHECK(!code.is_null());
1902
1903 FunctionTester ft(code, kNumParams);
1904 Handle<Object> result =
1905 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1906 CHECK(result->IsPromiseResolveThenableJobInfo());
1907 Handle<PromiseResolveThenableJobInfo> promise_info =
1908 Handle<PromiseResolveThenableJobInfo>::cast(result);
1909 CHECK(promise_info->thenable()->IsJSPromise());
1910 CHECK(promise_info->then()->IsJSFunction());
1911 CHECK(promise_info->resolve()->IsJSFunction());
1912 CHECK(promise_info->reject()->IsJSFunction());
1913 CHECK_EQ(kDebugPromiseNoID, promise_info->debug_id());
1914 CHECK_EQ(kDebugNotActive, promise_info->debug_name());
1915 CHECK(promise_info->context()->IsContext());
1916 }
1917
1877 TEST(IsSymbol) { 1918 TEST(IsSymbol) {
1878 Isolate* isolate(CcTest::InitIsolateOnce()); 1919 Isolate* isolate(CcTest::InitIsolateOnce());
1879 1920
1880 const int kNumParams = 1; 1921 const int kNumParams = 1;
1881 CodeAssemblerTester data(isolate, kNumParams); 1922 CodeAssemblerTester data(isolate, kNumParams);
1882 CodeStubAssembler m(data.state()); 1923 CodeStubAssembler m(data.state());
1883 1924
1884 Node* const symbol = m.Parameter(0); 1925 Node* const symbol = m.Parameter(0);
1885 m.Return(m.SelectBooleanConstant(m.IsSymbol(symbol))); 1926 m.Return(m.SelectBooleanConstant(m.IsSymbol(symbol)));
1886 1927
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 .ToHandleChecked(); 2229 .ToHandleChecked();
2189 Handle<Object> prop2 = 2230 Handle<Object> prop2 =
2190 JSReceiver::GetProperty(isolate, promise, "rejectedReason") 2231 JSReceiver::GetProperty(isolate, promise, "rejectedReason")
2191 .ToHandleChecked(); 2232 .ToHandleChecked();
2192 CHECK_EQ(*rejected_str, *prop2); 2233 CHECK_EQ(*rejected_str, *prop2);
2193 } 2234 }
2194 } 2235 }
2195 2236
2196 } // namespace internal 2237 } // namespace internal
2197 } // namespace v8 2238 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-promise.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698