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

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: Fix nits 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/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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 m.Return(executor_context); 2168 m.Return(executor_context);
2169 2169
2170 Handle<Code> code = data.GenerateCode(); 2170 Handle<Code> code = data.GenerateCode();
2171 CHECK(!code.is_null()); 2171 CHECK(!code.is_null());
2172 2172
2173 FunctionTester ft(code, kNumParams); 2173 FunctionTester ft(code, kNumParams);
2174 Handle<Object> result_obj = 2174 Handle<Object> result_obj =
2175 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 2175 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
2176 CHECK(result_obj->IsContext()); 2176 CHECK(result_obj->IsContext());
2177 Handle<Context> context_js = Handle<Context>::cast(result_obj); 2177 Handle<Context> context_js = Handle<Context>::cast(result_obj);
2178 CHECK_EQ(GetPromiseCapabilityExecutor::kContextLength, context_js->length()); 2178 CHECK_EQ(PromiseBuiltinsAssembler::kCapabilitiesContextLength,
2179 context_js->length());
2179 CHECK_EQ(isolate->native_context()->closure(), context_js->closure()); 2180 CHECK_EQ(isolate->native_context()->closure(), context_js->closure());
2180 CHECK_EQ(isolate->heap()->the_hole_value(), context_js->extension()); 2181 CHECK_EQ(isolate->heap()->the_hole_value(), context_js->extension());
2181 CHECK_EQ(*isolate->native_context(), context_js->native_context()); 2182 CHECK_EQ(*isolate->native_context(), context_js->native_context());
2182 CHECK(context_js->get(GetPromiseCapabilityExecutor::kCapabilitySlot) 2183 CHECK(context_js->get(PromiseBuiltinsAssembler::kCapabilitySlot)
2183 ->IsJSPromiseCapability()); 2184 ->IsJSPromiseCapability());
2184 } 2185 }
2185 2186
2186 TEST(NewPromiseCapability) { 2187 TEST(NewPromiseCapability) {
2187 Isolate* isolate(CcTest::InitIsolateOnce()); 2188 Isolate* isolate(CcTest::InitIsolateOnce());
2188 2189
2189 { // Builtin Promise 2190 { // Builtin Promise
2190 const int kNumParams = 1; 2191 const int kNumParams = 1;
2191 CodeAssemblerTester data(isolate, kNumParams); 2192 CodeAssemblerTester data(isolate, kNumParams);
2192 PromiseBuiltinsAssembler m(data.state()); 2193 PromiseBuiltinsAssembler m(data.state());
(...skipping 26 matching lines...) Expand all
2219 2220
2220 Handle<JSFunction> callbacks[] = { 2221 Handle<JSFunction> callbacks[] = {
2221 handle(JSFunction::cast(result->resolve())), 2222 handle(JSFunction::cast(result->resolve())),
2222 handle(JSFunction::cast(result->reject()))}; 2223 handle(JSFunction::cast(result->reject()))};
2223 2224
2224 for (auto&& callback : callbacks) { 2225 for (auto&& callback : callbacks) {
2225 Handle<Context> context(Context::cast(callback->context())); 2226 Handle<Context> context(Context::cast(callback->context()));
2226 CHECK_EQ(isolate->native_context()->closure(), context->closure()); 2227 CHECK_EQ(isolate->native_context()->closure(), context->closure());
2227 CHECK_EQ(isolate->heap()->the_hole_value(), context->extension()); 2228 CHECK_EQ(isolate->heap()->the_hole_value(), context->extension());
2228 CHECK_EQ(*isolate->native_context(), context->native_context()); 2229 CHECK_EQ(*isolate->native_context(), context->native_context());
2229 CHECK_EQ(PromiseUtils::kPromiseContextLength, context->length()); 2230 CHECK_EQ(PromiseBuiltinsAssembler::kPromiseContextLength,
2230 CHECK_EQ(context->get(PromiseUtils::kPromiseSlot), result->promise()); 2231 context->length());
2232 CHECK_EQ(context->get(PromiseBuiltinsAssembler::kPromiseSlot),
2233 result->promise());
2231 } 2234 }
2232 } 2235 }
2233 2236
2234 { // Custom Promise 2237 { // Custom Promise
2235 const int kNumParams = 2; 2238 const int kNumParams = 2;
2236 CodeAssemblerTester data(isolate, kNumParams); 2239 CodeAssemblerTester data(isolate, kNumParams);
2237 PromiseBuiltinsAssembler m(data.state()); 2240 PromiseBuiltinsAssembler m(data.state());
2238 2241
2239 Node* const context = m.Parameter(kNumParams + 2); 2242 Node* const context = m.Parameter(kNumParams + 2);
2240 2243
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 m.Return(m.SmiConstant(0)); 2477 m.Return(m.SmiConstant(0));
2475 2478
2476 Handle<Code> code = data.GenerateCode(); 2479 Handle<Code> code = data.GenerateCode();
2477 CHECK(!code.is_null()); 2480 CHECK(!code.is_null());
2478 FunctionTester ft(code, kNumParams); 2481 FunctionTester ft(code, kNumParams);
2479 CHECK_EQ(1, Handle<Smi>::cast(ft.Call().ToHandleChecked())->value()); 2482 CHECK_EQ(1, Handle<Smi>::cast(ft.Call().ToHandleChecked())->value());
2480 } 2483 }
2481 2484
2482 } // namespace internal 2485 } // namespace internal
2483 } // namespace v8 2486 } // namespace v8
OLDNEW
« no previous file with comments | « src/v8.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698