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

Side by Side Diff: test/cctest/interpreter/test-interpreter-intrinsics.cc

Issue 2019433003: [Interpreter] Add intrinsic for Runtime::kInlineCall. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 6 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 | « test/cctest/interpreter/bytecode_expectations/Generators.golden ('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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/interpreter/interpreter-intrinsics.h" 7 #include "src/interpreter/interpreter-intrinsics.h"
8 #include "test/cctest/interpreter/interpreter-tester.h" 8 #include "test/cctest/interpreter/interpreter-tester.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 11 matching lines...) Expand all
22 factory_(isolate->factory()), 22 factory_(isolate->factory()),
23 function_id_(function_id) {} 23 function_id_(function_id) {}
24 24
25 template <class... A> 25 template <class... A>
26 Handle<Object> Invoke(A... args) { 26 Handle<Object> Invoke(A... args) {
27 CHECK(IntrinsicsHelper::IsSupported(function_id_)); 27 CHECK(IntrinsicsHelper::IsSupported(function_id_));
28 BytecodeArrayBuilder builder(isolate_, zone_, sizeof...(args), 0, 0); 28 BytecodeArrayBuilder builder(isolate_, zone_, sizeof...(args), 0, 0);
29 builder.CallRuntime(function_id_, builder.Parameter(0), sizeof...(args)) 29 builder.CallRuntime(function_id_, builder.Parameter(0), sizeof...(args))
30 .Return(); 30 .Return();
31 InterpreterTester tester(isolate_, builder.ToBytecodeArray()); 31 InterpreterTester tester(isolate_, builder.ToBytecodeArray());
32 auto callable = tester.GetCallable<Handle<Object>>(); 32 auto callable = tester.GetCallable<A...>();
33 return callable(args...).ToHandleChecked(); 33 return callable(args...).ToHandleChecked();
34 } 34 }
35 35
36 Handle<Object> NewObject(const char* script) { 36 Handle<Object> NewObject(const char* script) {
37 return v8::Utils::OpenHandle(*CompileRun(script)); 37 return v8::Utils::OpenHandle(*CompileRun(script));
38 } 38 }
39 39
40 Handle<Object> Undefined() { return factory_->undefined_value(); } 40 Handle<Object> Undefined() { return factory_->undefined_value(); }
41 Handle<Object> Null() { return factory_->null_value(); } 41 Handle<Object> Null() { return factory_->null_value(); }
42 42
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("([1])"))); 84 CHECK_EQ(*factory->true_value(), *helper.Invoke(helper.NewObject("([1])")));
85 CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("({})"))); 85 CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("({})")));
86 CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("(/x/)"))); 86 CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("(/x/)")));
87 CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Undefined())); 87 CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Undefined()));
88 CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Null())); 88 CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.Null()));
89 CHECK_EQ(*factory->false_value(), 89 CHECK_EQ(*factory->false_value(),
90 *helper.Invoke(helper.NewObject("'string'"))); 90 *helper.Invoke(helper.NewObject("'string'")));
91 CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42"))); 91 CHECK_EQ(*factory->false_value(), *helper.Invoke(helper.NewObject("42")));
92 } 92 }
93 93
94 TEST(Call) {
95 HandleAndZoneScope handles;
96 Isolate* isolate = handles.main_isolate();
97 Factory* factory = isolate->factory();
98 InvokeIntrinsicHelper helper(isolate, handles.main_zone(),
99 Runtime::kInlineCall);
100
101 CHECK_EQ(Smi::FromInt(20),
102 *helper.Invoke(helper.NewObject("(function() { return this.x; })"),
103 helper.NewObject("({ x: 20 })")));
104 CHECK_EQ(Smi::FromInt(50),
105 *helper.Invoke(helper.NewObject("(function(arg1) { return arg1; })"),
106 factory->undefined_value(),
107 handle(Smi::FromInt(50), isolate)));
108 CHECK_EQ(
109 Smi::FromInt(20),
110 *helper.Invoke(
111 helper.NewObject("(function(a, b, c) { return a + b + c; })"),
112 factory->undefined_value(), handle(Smi::FromInt(10), isolate),
113 handle(Smi::FromInt(7), isolate), handle(Smi::FromInt(3), isolate)));
114 }
115
94 } // namespace interpreter 116 } // namespace interpreter
95 } // namespace internal 117 } // namespace internal
96 } // namespace v8 118 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/Generators.golden ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698