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

Side by Side Diff: src/compiler/common-operator.cc

Issue 1391333003: Adding support for multiple returns in compiled functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: formatting Created 5 years, 2 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 6
7 #include "src/assembler.h" 7 #include "src/assembler.h"
8 #include "src/base/lazy-instance.h" 8 #include "src/base/lazy-instance.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/opcodes.h" 10 #include "src/compiler/opcodes.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 117
118 #define CACHED_OP_LIST(V) \ 118 #define CACHED_OP_LIST(V) \
119 V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1) \ 119 V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1) \
120 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ 120 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
121 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ 121 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
122 V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ 122 V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
123 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ 123 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
124 V(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1) \ 124 V(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1) \
125 V(Deoptimize, Operator::kNoThrow, 1, 1, 1, 0, 0, 1) \ 125 V(Deoptimize, Operator::kNoThrow, 1, 1, 1, 0, 0, 1) \
126 V(Return, Operator::kNoThrow, 1, 1, 1, 0, 0, 1) \
127 V(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) \ 126 V(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) \
128 V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ 127 V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \
129 V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) 128 V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1)
130 129
131 130
131 #define CACHED_RETURN_LIST(V) \
132 V(1) \
133 V(2) \
134 V(3)
135
136
132 #define CACHED_END_LIST(V) \ 137 #define CACHED_END_LIST(V) \
133 V(1) \ 138 V(1) \
134 V(2) \ 139 V(2) \
135 V(3) \ 140 V(3) \
136 V(4) \ 141 V(4) \
137 V(5) \ 142 V(5) \
138 V(6) \ 143 V(6) \
139 V(7) \ 144 V(7) \
140 V(8) 145 V(8)
141 146
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 : Operator( // -- 247 : Operator( // --
243 IrOpcode::kEnd, Operator::kKontrol, // opcode 248 IrOpcode::kEnd, Operator::kKontrol, // opcode
244 "End", // name 249 "End", // name
245 0, 0, kInputCount, 0, 0, 0) {} // counts 250 0, 0, kInputCount, 0, 0, 0) {} // counts
246 }; 251 };
247 #define CACHED_END(input_count) \ 252 #define CACHED_END(input_count) \
248 EndOperator<input_count> kEnd##input_count##Operator; 253 EndOperator<input_count> kEnd##input_count##Operator;
249 CACHED_END_LIST(CACHED_END) 254 CACHED_END_LIST(CACHED_END)
250 #undef CACHED_END 255 #undef CACHED_END
251 256
257 template <size_t kInputCount>
258 struct ReturnOperator final : public Operator {
259 ReturnOperator()
260 : Operator( // --
261 IrOpcode::kReturn, Operator::kNoThrow, // opcode
262 "Return", // name
263 kInputCount, 1, 1, 0, 0, 1) {} // counts
264 };
265 #define CACHED_RETURN(input_count) \
266 ReturnOperator<input_count> kReturn##input_count##Operator;
267 CACHED_RETURN_LIST(CACHED_RETURN)
268 #undef CACHED_RETURN
269
252 template <BranchHint kBranchHint> 270 template <BranchHint kBranchHint>
253 struct BranchOperator final : public Operator1<BranchHint> { 271 struct BranchOperator final : public Operator1<BranchHint> {
254 BranchOperator() 272 BranchOperator()
255 : Operator1<BranchHint>( // -- 273 : Operator1<BranchHint>( // --
256 IrOpcode::kBranch, Operator::kKontrol, // opcode 274 IrOpcode::kBranch, Operator::kKontrol, // opcode
257 "Branch", // name 275 "Branch", // name
258 1, 0, 1, 0, 0, 2, // counts 276 1, 0, 1, 0, 0, 2, // counts
259 kBranchHint) {} // parameter 277 kBranchHint) {} // parameter
260 }; 278 };
261 BranchOperator<BranchHint::kNone> kBranchNoneOperator; 279 BranchOperator<BranchHint::kNone> kBranchNoneOperator;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 break; 408 break;
391 } 409 }
392 // Uncached. 410 // Uncached.
393 return new (zone()) Operator( //-- 411 return new (zone()) Operator( //--
394 IrOpcode::kEnd, Operator::kKontrol, // opcode 412 IrOpcode::kEnd, Operator::kKontrol, // opcode
395 "End", // name 413 "End", // name
396 0, 0, control_input_count, 0, 0, 0); // counts 414 0, 0, control_input_count, 0, 0, 0); // counts
397 } 415 }
398 416
399 417
418 const Operator* CommonOperatorBuilder::Return(int value_input_count) {
419 switch (value_input_count) {
420 #define CACHED_RETURN(input_count) \
421 case input_count: \
422 return &cache_.kReturn##input_count##Operator;
423 CACHED_RETURN_LIST(CACHED_RETURN)
424 #undef CACHED_RETURN
425 default:
426 break;
427 }
428 // Uncached.
429 return new (zone()) Operator( //--
430 IrOpcode::kReturn, Operator::kNoThrow, // opcode
431 "Return", // name
432 value_input_count, 1, 1, 0, 0, 1); // counts
433 }
434
435
400 const Operator* CommonOperatorBuilder::Branch(BranchHint hint) { 436 const Operator* CommonOperatorBuilder::Branch(BranchHint hint) {
401 switch (hint) { 437 switch (hint) {
402 case BranchHint::kNone: 438 case BranchHint::kNone:
403 return &cache_.kBranchNoneOperator; 439 return &cache_.kBranchNoneOperator;
404 case BranchHint::kTrue: 440 case BranchHint::kTrue:
405 return &cache_.kBranchTrueOperator; 441 return &cache_.kBranchTrueOperator;
406 case BranchHint::kFalse: 442 case BranchHint::kFalse:
407 return &cache_.kBranchFalseOperator; 443 return &cache_.kBranchFalseOperator;
408 } 444 }
409 UNREACHABLE(); 445 UNREACHABLE();
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 Handle<SharedFunctionInfo> shared_info, 817 Handle<SharedFunctionInfo> shared_info,
782 ContextCallingMode context_calling_mode) { 818 ContextCallingMode context_calling_mode) {
783 return new (zone()->New(sizeof(FrameStateFunctionInfo))) 819 return new (zone()->New(sizeof(FrameStateFunctionInfo)))
784 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info, 820 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info,
785 context_calling_mode); 821 context_calling_mode);
786 } 822 }
787 823
788 } // namespace compiler 824 } // namespace compiler
789 } // namespace internal 825 } // namespace internal
790 } // namespace v8 826 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698