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

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

Issue 2084623002: Reland: [Interpreter] Map runtime id's to intrinsic id's in InvokeIntrinsic bytecode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reland 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
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/interpreter/interpreter-intrinsics.h" 5 #include "src/interpreter/interpreter-intrinsics.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace interpreter { 9 namespace interpreter {
10 10
11 using compiler::Node; 11 using compiler::Node;
12 12
13 #define __ assembler_-> 13 #define __ assembler_->
14 14
15 IntrinsicsHelper::IntrinsicsHelper(InterpreterAssembler* assembler) 15 IntrinsicsHelper::IntrinsicsHelper(InterpreterAssembler* assembler)
16 : assembler_(assembler) {} 16 : assembler_(assembler) {}
17 17
18 // static
18 bool IntrinsicsHelper::IsSupported(Runtime::FunctionId function_id) { 19 bool IntrinsicsHelper::IsSupported(Runtime::FunctionId function_id) {
19 switch (function_id) { 20 switch (function_id) {
20 #define SUPPORTED(name, lower_case, count) case Runtime::kInline##name: 21 #define SUPPORTED(name, lower_case, count) case Runtime::kInline##name:
21 INTRINSICS_LIST(SUPPORTED) 22 INTRINSICS_LIST(SUPPORTED)
22 return true; 23 return true;
23 #undef SUPPORTED 24 #undef SUPPORTED
24 default: 25 default:
25 return false; 26 return false;
26 } 27 }
27 } 28 }
28 29
30 // static
31 IntrinsicsHelper::IntrinsicId IntrinsicsHelper::FromRuntimeId(
32 Runtime::FunctionId function_id) {
33 switch (function_id) {
34 #define TO_RUNTIME_ID(name, lower_case, count) \
35 case Runtime::kInline##name: \
36 return IntrinsicId::k##name;
37 INTRINSICS_LIST(TO_RUNTIME_ID)
38 #undef TO_RUNTIME_ID
39 default:
40 UNREACHABLE();
41 return static_cast<IntrinsicsHelper::IntrinsicId>(-1);
42 }
43 }
44
45 // static
46 Runtime::FunctionId IntrinsicsHelper::ToRuntimeId(
47 IntrinsicsHelper::IntrinsicId intrinsic_id) {
48 switch (intrinsic_id) {
49 #define TO_INTRINSIC_ID(name, lower_case, count) \
50 case IntrinsicId::k##name: \
51 return Runtime::kInline##name;
52 INTRINSICS_LIST(TO_INTRINSIC_ID)
53 #undef TO_INTRINSIC_ID
54 default:
55 UNREACHABLE();
56 return static_cast<Runtime::FunctionId>(-1);
57 }
58 }
59
29 Node* IntrinsicsHelper::InvokeIntrinsic(Node* function_id, Node* context, 60 Node* IntrinsicsHelper::InvokeIntrinsic(Node* function_id, Node* context,
30 Node* first_arg_reg, Node* arg_count) { 61 Node* first_arg_reg, Node* arg_count) {
31 InterpreterAssembler::Label abort(assembler_), end(assembler_); 62 InterpreterAssembler::Label abort(assembler_), end(assembler_);
32 InterpreterAssembler::Variable result(assembler_, 63 InterpreterAssembler::Variable result(assembler_,
33 MachineRepresentation::kTagged); 64 MachineRepresentation::kTagged);
34 65
35 #define MAKE_LABEL(name, lower_case, count) \ 66 #define MAKE_LABEL(name, lower_case, count) \
36 InterpreterAssembler::Label lower_case(assembler_); 67 InterpreterAssembler::Label lower_case(assembler_);
37 INTRINSICS_LIST(MAKE_LABEL) 68 INTRINSICS_LIST(MAKE_LABEL)
38 #undef MAKE_LABEL 69 #undef MAKE_LABEL
39 70
40 #define LABEL_POINTER(name, lower_case, count) &lower_case, 71 #define LABEL_POINTER(name, lower_case, count) &lower_case,
41 InterpreterAssembler::Label* labels[] = {INTRINSICS_LIST(LABEL_POINTER)}; 72 InterpreterAssembler::Label* labels[] = {INTRINSICS_LIST(LABEL_POINTER)};
42 #undef LABEL_POINTER 73 #undef LABEL_POINTER
43 74
44 #define CASE(name, lower_case, count) \ 75 #define CASE(name, lower_case, count) \
45 static_cast<int32_t>(Runtime::kInline##name), 76 static_cast<int32_t>(IntrinsicId::k##name),
46 int32_t cases[] = {INTRINSICS_LIST(CASE)}; 77 int32_t cases[] = {INTRINSICS_LIST(CASE)};
47 #undef CASE 78 #undef CASE
48 79
49 __ Switch(function_id, &abort, cases, labels, arraysize(cases)); 80 __ Switch(function_id, &abort, cases, labels, arraysize(cases));
50 #define HANDLE_CASE(name, lower_case, expected_arg_count) \ 81 #define HANDLE_CASE(name, lower_case, expected_arg_count) \
51 __ Bind(&lower_case); \ 82 __ Bind(&lower_case); \
52 if (FLAG_debug_code && expected_arg_count >= 0) { \ 83 if (FLAG_debug_code && expected_arg_count >= 0) { \
53 AbortIfArgCountMismatch(expected_arg_count, arg_count); \ 84 AbortIfArgCountMismatch(expected_arg_count, arg_count); \
54 } \ 85 } \
55 result.Bind(name(first_arg_reg, arg_count, context)); \ 86 result.Bind(name(first_arg_reg, arg_count, context)); \
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 Node* comparison = __ Word32Equal(actual, __ Int32Constant(expected)); 258 Node* comparison = __ Word32Equal(actual, __ Int32Constant(expected));
228 __ GotoIf(comparison, &match); 259 __ GotoIf(comparison, &match);
229 __ Abort(kWrongArgumentCountForInvokeIntrinsic); 260 __ Abort(kWrongArgumentCountForInvokeIntrinsic);
230 __ Goto(&match); 261 __ Goto(&match);
231 __ Bind(&match); 262 __ Bind(&match);
232 } 263 }
233 264
234 } // namespace interpreter 265 } // namespace interpreter
235 } // namespace internal 266 } // namespace internal
236 } // namespace v8 267 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter-intrinsics.h ('k') | test/cctest/interpreter/bytecode-expectations-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698