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

Side by Side Diff: vm/intermediate_language.h

Issue 10825035: Add an explicit push-argument instruction to the IL. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_
6 #define VM_INTERMEDIATE_LANGUAGE_H_ 6 #define VM_INTERMEDIATE_LANGUAGE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; 106 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
107 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) 107 FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
108 #undef FORWARD_DECLARATION 108 #undef FORWARD_DECLARATION
109 109
110 // Forward declarations. 110 // Forward declarations.
111 class BindInstr; 111 class BindInstr;
112 class BranchInstr; 112 class BranchInstr;
113 class BufferFormatter; 113 class BufferFormatter;
114 class ComparisonComp; 114 class ComparisonComp;
115 class Instruction; 115 class Instruction;
116 class PushArgumentInstr;
116 class Value; 117 class Value;
117 118
118 class Computation : public ZoneAllocated { 119 class Computation : public ZoneAllocated {
119 public: 120 public:
120 static const int kNoCid = -1; 121 static const int kNoCid = -1;
121 122
122 Computation() : cid_(-1), ic_data_(NULL), locs_(NULL) { 123 Computation() : cid_(-1), ic_data_(NULL), locs_(NULL) {
123 Isolate* isolate = Isolate::Current(); 124 Isolate* isolate = Isolate::Current();
124 cid_ = GetNextCid(isolate); 125 cid_ = GetNextCid(isolate);
125 ic_data_ = GetICDataForCid(cid_, isolate); 126 ic_data_ = GetICDataForCid(cid_, isolate);
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 453
453 private: 454 private:
454 DISALLOW_COPY_AND_ASSIGN(StoreContextComp); 455 DISALLOW_COPY_AND_ASSIGN(StoreContextComp);
455 }; 456 };
456 457
457 458
458 class ClosureCallComp : public Computation { 459 class ClosureCallComp : public Computation {
459 public: 460 public:
460 ClosureCallComp(ClosureCallNode* node, 461 ClosureCallComp(ClosureCallNode* node,
461 intptr_t try_index, 462 intptr_t try_index,
462 ZoneGrowableArray<Value*>* arguments) 463 ZoneGrowableArray<PushArgumentInstr*>* arguments)
463 : ast_node_(*node), 464 : ast_node_(*node),
464 try_index_(try_index), 465 try_index_(try_index),
465 arguments_(arguments) { } 466 arguments_(arguments) { }
466 467
467 DECLARE_COMPUTATION(ClosureCall) 468 DECLARE_COMPUTATION(ClosureCall)
468 469
469 const Array& argument_names() const { return ast_node_.arguments()->names(); } 470 const Array& argument_names() const { return ast_node_.arguments()->names(); }
470 intptr_t token_pos() const { return ast_node_.token_pos(); } 471 intptr_t token_pos() const { return ast_node_.token_pos(); }
471 intptr_t try_index() const { return try_index_; } 472 intptr_t try_index() const { return try_index_; }
472 473
473 intptr_t ArgumentCount() const { return arguments_->length(); } 474 intptr_t ArgumentCount() const { return arguments_->length(); }
474 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } 475 PushArgumentInstr* ArgumentAt(intptr_t index) const {
476 return (*arguments_)[index];
477 }
475 478
476 virtual intptr_t InputCount() const; 479 virtual intptr_t InputCount() const { return 0; }
477 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } 480 virtual Value* InputAt(intptr_t i) const {
478 virtual void SetInputAt(intptr_t i, Value* value) { 481 UNREACHABLE();
479 (*arguments_)[i] = value; 482 return NULL;
480 } 483 }
484 virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); }
481 485
482 virtual void PrintOperandsTo(BufferFormatter* f) const; 486 virtual void PrintOperandsTo(BufferFormatter* f) const;
483 487
484 private: 488 private:
485 const ClosureCallNode& ast_node_; 489 const ClosureCallNode& ast_node_;
486 const intptr_t try_index_; 490 const intptr_t try_index_;
487 ZoneGrowableArray<Value*>* arguments_; 491 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
488 492
489 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); 493 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp);
490 }; 494 };
491 495
492 496
493 class InstanceCallComp : public Computation { 497 class InstanceCallComp : public Computation {
494 public: 498 public:
495 InstanceCallComp(intptr_t token_pos, 499 InstanceCallComp(intptr_t token_pos,
496 intptr_t try_index, 500 intptr_t try_index,
497 const String& function_name, 501 const String& function_name,
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 1232
1229 private: 1233 private:
1230 const intptr_t token_pos_; 1234 const intptr_t token_pos_;
1231 const intptr_t try_index_; 1235 const intptr_t try_index_;
1232 ZoneGrowableArray<Value*>* const elements_; 1236 ZoneGrowableArray<Value*>* const elements_;
1233 1237
1234 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); 1238 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp);
1235 }; 1239 };
1236 1240
1237 1241
1238 class CreateClosureComp : public TemplateComputation<2> { 1242 class CreateClosureComp : public TemplateComputation<0> {
1239 public: 1243 public:
1240 CreateClosureComp(ClosureNode* node, 1244 CreateClosureComp(ClosureNode* node, intptr_t try_index)
1241 intptr_t try_index,
1242 Value* type_arguments,
1243 Value* receiver)
1244 : ast_node_(*node), 1245 : ast_node_(*node),
1245 try_index_(try_index) { 1246 try_index_(try_index) { }
1246 ASSERT(type_arguments != NULL);
1247 ASSERT(receiver != NULL);
1248 inputs_[0] = type_arguments;
1249 inputs_[1] = receiver;
1250 }
1251 1247
1252 DECLARE_COMPUTATION(CreateClosure) 1248 DECLARE_COMPUTATION(CreateClosure)
1253 1249
1254 intptr_t token_pos() const { return ast_node_.token_pos(); } 1250 intptr_t token_pos() const { return ast_node_.token_pos(); }
1255 intptr_t try_index() const { return try_index_; } 1251 intptr_t try_index() const { return try_index_; }
1256 const Function& function() const { return ast_node_.function(); } 1252 const Function& function() const { return ast_node_.function(); }
1257 Value* type_arguments() const { return inputs_[0]; }
1258 Value* receiver() const { return inputs_[1]; }
1259 1253
1260 virtual void PrintOperandsTo(BufferFormatter* f) const; 1254 virtual void PrintOperandsTo(BufferFormatter* f) const;
1261 1255
1262 private: 1256 private:
1263 const ClosureNode& ast_node_; 1257 const ClosureNode& ast_node_;
1264 const intptr_t try_index_; 1258 const intptr_t try_index_;
1265 1259
1266 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); 1260 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp);
1267 }; 1261 };
1268 1262
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 // type name. The concrete instruction classes are the name with Instr 1667 // type name. The concrete instruction classes are the name with Instr
1674 // concatenated. 1668 // concatenated.
1675 #define FOR_EACH_INSTRUCTION(M) \ 1669 #define FOR_EACH_INSTRUCTION(M) \
1676 M(GraphEntry) \ 1670 M(GraphEntry) \
1677 M(JoinEntry) \ 1671 M(JoinEntry) \
1678 M(TargetEntry) \ 1672 M(TargetEntry) \
1679 M(Phi) \ 1673 M(Phi) \
1680 M(Bind) \ 1674 M(Bind) \
1681 M(Parameter) \ 1675 M(Parameter) \
1682 M(ParallelMove) \ 1676 M(ParallelMove) \
1677 M(PushArgument) \
1683 M(Return) \ 1678 M(Return) \
1684 M(Throw) \ 1679 M(Throw) \
1685 M(ReThrow) \ 1680 M(ReThrow) \
1686 M(Goto) \ 1681 M(Goto) \
1687 M(Branch) \ 1682 M(Branch) \
1688 1683
1689 1684
1690 // Forward declarations for Instruction classes. 1685 // Forward declarations for Instruction classes.
1691 class BlockEntryInstr; 1686 class BlockEntryInstr;
1692 class FlowGraphBuilder; 1687 class FlowGraphBuilder;
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 2211
2217 DECLARE_INSTRUCTION(Parameter) 2212 DECLARE_INSTRUCTION(Parameter)
2218 2213
2219 private: 2214 private:
2220 const intptr_t index_; 2215 const intptr_t index_;
2221 2216
2222 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); 2217 DISALLOW_COPY_AND_ASSIGN(ParameterInstr);
2223 }; 2218 };
2224 2219
2225 2220
2221 class PushArgumentInstr : public InstructionWithInputs {
2222 public:
2223 explicit PushArgumentInstr(Value* value) : value_(value) { }
2224
2225 DECLARE_INSTRUCTION(PushArgument)
2226
2227 Value* value() const { return value_; }
2228
2229 virtual LocationSummary* MakeLocationSummary() const;
2230
2231 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2232
2233 private:
2234 Value* value_;
2235
2236 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr);
2237 };
2238
2239
2226 class ReturnInstr : public InstructionWithInputs { 2240 class ReturnInstr : public InstructionWithInputs {
2227 public: 2241 public:
2228 ReturnInstr(intptr_t token_pos, Value* value) 2242 ReturnInstr(intptr_t token_pos, Value* value)
2229 : InstructionWithInputs(), token_pos_(token_pos), value_(value) { 2243 : InstructionWithInputs(), token_pos_(token_pos), value_(value) {
2230 ASSERT(value_ != NULL); 2244 ASSERT(value_ != NULL);
2231 } 2245 }
2232 2246
2233 DECLARE_INSTRUCTION(Return) 2247 DECLARE_INSTRUCTION(Return)
2234 2248
2235 Value* value() const { return value_; } 2249 Value* value() const { return value_; }
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 const GrowableArray<BlockEntryInstr*>& block_order_; 2574 const GrowableArray<BlockEntryInstr*>& block_order_;
2561 2575
2562 private: 2576 private:
2563 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2577 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2564 }; 2578 };
2565 2579
2566 2580
2567 } // namespace dart 2581 } // namespace dart
2568 2582
2569 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2583 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698