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

Side by Side Diff: src/interpreter/interpreter-intrinsics.cc

Issue 1645763003: [Interpreter] TurboFan implementation of intrinsics. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update Created 4 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/interpreter/interpreter-intrinsics.h"
6
7 namespace v8 {
8 namespace internal {
9 namespace interpreter {
10
11 using compiler::Node;
12
13 #define __ assembler_->
14
15 IntrinsicsHelper::IntrinsicsHelper(InterpreterAssembler* assembler)
16 : assembler_(assembler) {}
17
18 bool IntrinsicsHelper::IsSupported(Runtime::FunctionId function_id) {
19 switch (function_id) {
20 #define SUPPORTED(name, lower_case, count) case Runtime::kInline##name:
21 INTRINSICS_LIST(SUPPORTED)
22 return true;
rmcilroy 2016/03/08 11:19:30 nit - indent
epertoso 2016/03/08 14:11:09 That's what clang-format does. I can change it man
rmcilroy 2016/03/08 16:09:43 Ok.
23 #undef SUPPORTED
24 default:
25 return false;
26 }
27 }
28
29 Node* IntrinsicsHelper::InvokeIntrinsic(Node* function_id, Node* context,
30 Node* first_arg_reg, Node* arg_count) {
31 InterpreterAssembler::Label abort(assembler_), end(assembler_);
32 InterpreterAssembler::Variable result(assembler_,
33 MachineRepresentation::kTagged);
34
35 #define MAKE_LABEL(name, lower_case, count) \
36 InterpreterAssembler::Label lower_case(assembler_);
37 INTRINSICS_LIST(MAKE_LABEL)
38 #undef MAKE_LABEL
39
40 #define LABEL_POINTER(name, lower_case, count) &lower_case,
41 InterpreterAssembler::Label* labels[] = {INTRINSICS_LIST(LABEL_POINTER)};
42 #undef LABEL_POINTER
43
44 #define CASE(name, lower_case, count) \
45 static_cast<int32_t>(Runtime::kInline##name),
46 int32_t cases[] = {INTRINSICS_LIST(CASE)};
47 #undef CASE
48
49 __ Switch(function_id, &abort, cases, labels, arraysize(cases));
50 #define HANDLE_CASE(name, lower_case, expected_arg_count) \
51 __ Bind(&lower_case); \
52 if (FLAG_debug_code) { \
53 InterpreterAssembler::Label match(assembler_), mismatch(assembler_); \
rmcilroy 2016/03/08 11:19:30 nit - could you pull this out into a seperate func
epertoso 2016/03/08 14:11:09 Sure.
54 Node* argument_count_check = \
55 __ Word32Equal(arg_count, __ Int32Constant(expected_arg_count)); \
56 __ Branch(argument_count_check, &match, &mismatch); \
57 __ Bind(&mismatch); \
58 __ Abort(kWrongArgumentCountForInvokeIntrinsic); \
59 __ Bind(&match); \
60 } \
61 result.Bind(name(first_arg_reg)); \
62 __ Goto(&end);
63 INTRINSICS_LIST(HANDLE_CASE)
64 #undef HANDLE_CASE
65
66 __ Bind(&abort);
67 __ Abort(BailoutReason::kUnexpectedFunctionIDForInvokeIntrinsic);
68
69 __ Bind(&end);
70 return result.value();
71 }
72
73 Node* IntrinsicsHelper::CompareInstanceType(Node* map, int type,
74 InstanceTypeCompareMode mode) {
75 InterpreterAssembler::Variable return_value(assembler_,
76 MachineRepresentation::kTagged);
77 Node* instance_type =
78 __ Load(MachineType::Uint8(), map,
79 __ IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag));
80
81 InterpreterAssembler::Label if_true(assembler_), if_false(assembler_),
82 end(assembler_);
83 switch (mode) {
84 case kInstanceTypeEqual:
85 __ Branch(__ Word32Equal(instance_type, __ Int32Constant(type)), &if_true,
rmcilroy 2016/03/08 11:19:30 just build the condition (i.e., Word32Equal or Int
epertoso 2016/03/08 14:11:09 Done.
86 &if_false);
87 break;
88 case kInstanceTypeGreaterThanOrEqual:
89 __ Branch(
90 __ Int32GreaterThanOrEqual(instance_type, __ Int32Constant(type)),
91 &if_true, &if_false);
92 break;
93 }
94 __ Bind(&if_true);
95 return_value.Bind(__ BooleanConstant(true));
96 __ Goto(&end);
97
98 __ Bind(&if_false);
99 return_value.Bind(__ BooleanConstant(false));
100 __ Goto(&end);
101
102 __ Bind(&end);
103 return return_value.value();
104 }
105
106 Node* IntrinsicsHelper::IsJSReceiver(Node* input) {
rmcilroy 2016/03/08 11:19:30 These intrinsics are simple enough that it's proba
epertoso 2016/03/08 14:11:09 Actually, this is a good point. I'm not sure about
rmcilroy 2016/03/08 16:09:43 I'd create a separate file cctest/interpreter/inte
107 InterpreterAssembler::Variable return_value(assembler_,
108 MachineRepresentation::kTagged);
109
110 InterpreterAssembler::Label if_smi(assembler_), if_not_smi(assembler_),
111 end(assembler_);
112 Node* arg = __ LoadRegister(input);
113
114 __ Branch(__ WordIsSmi(arg), &if_smi, &if_not_smi);
115 __ Bind(&if_smi);
116 return_value.Bind(__ BooleanConstant(false));
117 __ Goto(&end);
118
119 __ Bind(&if_not_smi);
120 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
121 Node* map = __ LoadObjectField(arg, HeapObject::kMapOffset);
122 return_value.Bind(CompareInstanceType(map, FIRST_JS_RECEIVER_TYPE,
123 kInstanceTypeGreaterThanOrEqual));
124 __ Goto(&end);
125
126 __ Bind(&end);
127 return return_value.value();
128 }
129
130 Node* IntrinsicsHelper::IsArray(Node* input) {
131 InterpreterAssembler::Label if_smi(assembler_), if_not_smi(assembler_),
132 end(assembler_);
133 Node* arg = __ LoadRegister(input);
134 __ Branch(__ WordIsSmi(arg), &if_smi, &if_not_smi);
135 InterpreterAssembler::Variable return_value(assembler_,
136 MachineRepresentation::kTagged);
137 __ Bind(&if_smi);
138 return_value.Bind(__ BooleanConstant(false));
139 __ Goto(&end);
140
141 __ Bind(&if_not_smi);
142 Node* map = __ LoadObjectField(arg, HeapObject::kMapOffset);
143 return_value.Bind(
144 CompareInstanceType(map, JS_ARRAY_TYPE, kInstanceTypeEqual));
145 __ Goto(&end);
146
147 __ Bind(&end);
148 return return_value.value();
149 }
150
151 } // namespace interpreter
152 } // namespace internal
153 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698