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

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

Issue 2637523002: [promises] Clean up promise utils and remove dead code (Closed)
Patch Set: 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
« src/builtins/builtins-promise.h ('K') | « src/v8.gyp ('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"
11 #include "src/promise-utils.h"
12 #include "test/cctest/compiler/code-assembler-tester.h" 11 #include "test/cctest/compiler/code-assembler-tester.h"
13 #include "test/cctest/compiler/function-tester.h" 12 #include "test/cctest/compiler/function-tester.h"
14 13
15 namespace v8 { 14 namespace v8 {
16 namespace internal { 15 namespace internal {
17 16
18 using compiler::CodeAssemblerTester; 17 using compiler::CodeAssemblerTester;
19 using compiler::FunctionTester; 18 using compiler::FunctionTester;
20 using compiler::Node; 19 using compiler::Node;
21 using compiler::CodeAssemblerLabel; 20 using compiler::CodeAssemblerLabel;
(...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 CHECK(!code.is_null()); 1997 CHECK(!code.is_null());
1999 1998
2000 FunctionTester ft(code, kNumParams); 1999 FunctionTester ft(code, kNumParams);
2001 Handle<Object> result = 2000 Handle<Object> result =
2002 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 2001 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
2003 CHECK(result->IsContext()); 2002 CHECK(result->IsContext());
2004 Handle<Context> context_js = Handle<Context>::cast(result); 2003 Handle<Context> context_js = Handle<Context>::cast(result);
2005 CHECK_EQ(isolate->native_context()->closure(), context_js->closure()); 2004 CHECK_EQ(isolate->native_context()->closure(), context_js->closure());
2006 CHECK_EQ(isolate->heap()->the_hole_value(), context_js->extension()); 2005 CHECK_EQ(isolate->heap()->the_hole_value(), context_js->extension());
2007 CHECK_EQ(*isolate->native_context(), context_js->native_context()); 2006 CHECK_EQ(*isolate->native_context(), context_js->native_context());
2008 CHECK_EQ(Smi::FromInt(0), context_js->get(PromiseUtils::kAlreadyVisitedSlot)); 2007 CHECK_EQ(Smi::FromInt(0),
2009 CHECK(context_js->get(PromiseUtils::kPromiseSlot)->IsJSPromise()); 2008 context_js->get(PromiseBuiltinsAssembler::kAlreadyVisitedSlot));
2009 CHECK(context_js->get(PromiseBuiltinsAssembler::kPromiseSlot)->IsJSPromise());
2010 CHECK_EQ(isolate->heap()->false_value(), 2010 CHECK_EQ(isolate->heap()->false_value(),
2011 context_js->get(PromiseUtils::kDebugEventSlot)); 2011 context_js->get(PromiseBuiltinsAssembler::kDebugEventSlot));
2012 } 2012 }
2013 2013
2014 TEST(CreatePromiseResolvingFunctions) { 2014 TEST(CreatePromiseResolvingFunctions) {
2015 Isolate* isolate(CcTest::InitIsolateOnce()); 2015 Isolate* isolate(CcTest::InitIsolateOnce());
2016 2016
2017 const int kNumParams = 1; 2017 const int kNumParams = 1;
2018 CodeAssemblerTester data(isolate, kNumParams); 2018 CodeAssemblerTester data(isolate, kNumParams);
2019 PromiseBuiltinsAssembler m(data.state()); 2019 PromiseBuiltinsAssembler m(data.state());
2020 2020
2021 Node* const context = m.Parameter(kNumParams + 2); 2021 Node* const context = m.Parameter(kNumParams + 2);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 m.Return(executor_context); 2169 m.Return(executor_context);
2170 2170
2171 Handle<Code> code = data.GenerateCode(); 2171 Handle<Code> code = data.GenerateCode();
2172 CHECK(!code.is_null()); 2172 CHECK(!code.is_null());
2173 2173
2174 FunctionTester ft(code, kNumParams); 2174 FunctionTester ft(code, kNumParams);
2175 Handle<Object> result_obj = 2175 Handle<Object> result_obj =
2176 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 2176 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
2177 CHECK(result_obj->IsContext()); 2177 CHECK(result_obj->IsContext());
2178 Handle<Context> context_js = Handle<Context>::cast(result_obj); 2178 Handle<Context> context_js = Handle<Context>::cast(result_obj);
2179 CHECK_EQ(GetPromiseCapabilityExecutor::kContextLength, context_js->length()); 2179 CHECK_EQ(PromiseBuiltinsAssembler::kCapabilitiesContextLength,
2180 context_js->length());
2180 CHECK_EQ(isolate->native_context()->closure(), context_js->closure()); 2181 CHECK_EQ(isolate->native_context()->closure(), context_js->closure());
2181 CHECK_EQ(isolate->heap()->the_hole_value(), context_js->extension()); 2182 CHECK_EQ(isolate->heap()->the_hole_value(), context_js->extension());
2182 CHECK_EQ(*isolate->native_context(), context_js->native_context()); 2183 CHECK_EQ(*isolate->native_context(), context_js->native_context());
2183 CHECK(context_js->get(GetPromiseCapabilityExecutor::kCapabilitySlot) 2184 CHECK(context_js->get(PromiseBuiltinsAssembler::kCapabilitySlot)
2184 ->IsJSPromiseCapability()); 2185 ->IsJSPromiseCapability());
2185 } 2186 }
2186 2187
2187 TEST(NewPromiseCapability) { 2188 TEST(NewPromiseCapability) {
2188 Isolate* isolate(CcTest::InitIsolateOnce()); 2189 Isolate* isolate(CcTest::InitIsolateOnce());
2189 2190
2190 { // Builtin Promise 2191 { // Builtin Promise
2191 const int kNumParams = 1; 2192 const int kNumParams = 1;
2192 CodeAssemblerTester data(isolate, kNumParams); 2193 CodeAssemblerTester data(isolate, kNumParams);
2193 PromiseBuiltinsAssembler m(data.state()); 2194 PromiseBuiltinsAssembler m(data.state());
(...skipping 26 matching lines...) Expand all
2220 2221
2221 Handle<JSFunction> callbacks[] = { 2222 Handle<JSFunction> callbacks[] = {
2222 handle(JSFunction::cast(result->resolve())), 2223 handle(JSFunction::cast(result->resolve())),
2223 handle(JSFunction::cast(result->reject()))}; 2224 handle(JSFunction::cast(result->reject()))};
2224 2225
2225 for (auto&& callback : callbacks) { 2226 for (auto&& callback : callbacks) {
2226 Handle<Context> context(Context::cast(callback->context())); 2227 Handle<Context> context(Context::cast(callback->context()));
2227 CHECK_EQ(isolate->native_context()->closure(), context->closure()); 2228 CHECK_EQ(isolate->native_context()->closure(), context->closure());
2228 CHECK_EQ(isolate->heap()->the_hole_value(), context->extension()); 2229 CHECK_EQ(isolate->heap()->the_hole_value(), context->extension());
2229 CHECK_EQ(*isolate->native_context(), context->native_context()); 2230 CHECK_EQ(*isolate->native_context(), context->native_context());
2230 CHECK_EQ(PromiseUtils::kPromiseContextLength, context->length()); 2231 CHECK_EQ(PromiseBuiltinsAssembler::kPromiseContextLength,
2231 CHECK_EQ(context->get(PromiseUtils::kPromiseSlot), result->promise()); 2232 context->length());
2233 CHECK_EQ(context->get(PromiseBuiltinsAssembler::kPromiseSlot),
2234 result->promise());
2232 } 2235 }
2233 } 2236 }
2234 2237
2235 { // Custom Promise 2238 { // Custom Promise
2236 const int kNumParams = 2; 2239 const int kNumParams = 2;
2237 CodeAssemblerTester data(isolate, kNumParams); 2240 CodeAssemblerTester data(isolate, kNumParams);
2238 PromiseBuiltinsAssembler m(data.state()); 2241 PromiseBuiltinsAssembler m(data.state());
2239 2242
2240 Node* const context = m.Parameter(kNumParams + 2); 2243 Node* const context = m.Parameter(kNumParams + 2);
2241 2244
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 .ToHandleChecked(); 2293 .ToHandleChecked();
2291 Handle<Object> prop2 = 2294 Handle<Object> prop2 =
2292 JSReceiver::GetProperty(isolate, promise, "rejectedReason") 2295 JSReceiver::GetProperty(isolate, promise, "rejectedReason")
2293 .ToHandleChecked(); 2296 .ToHandleChecked();
2294 CHECK_EQ(*rejected_str, *prop2); 2297 CHECK_EQ(*rejected_str, *prop2);
2295 } 2298 }
2296 } 2299 }
2297 2300
2298 } // namespace internal 2301 } // namespace internal
2299 } // namespace v8 2302 } // namespace v8
OLDNEW
« src/builtins/builtins-promise.h ('K') | « src/v8.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698