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, 4 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
« no previous file with comments | « vm/il_printer.cc ('k') | vm/intermediate_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
1241 intptr_t try_index, 1245 intptr_t try_index,
1242 Value* type_arguments, 1246 ZoneGrowableArray<PushArgumentInstr*>* arguments)
1243 Value* receiver)
1244 : ast_node_(*node), 1247 : ast_node_(*node),
1245 try_index_(try_index) { 1248 try_index_(try_index),
1246 ASSERT(type_arguments != NULL); 1249 arguments_(arguments) { }
1247 ASSERT(receiver != NULL);
1248 inputs_[0] = type_arguments;
1249 inputs_[1] = receiver;
1250 }
1251 1250
1252 DECLARE_COMPUTATION(CreateClosure) 1251 DECLARE_COMPUTATION(CreateClosure)
1253 1252
1254 intptr_t token_pos() const { return ast_node_.token_pos(); } 1253 intptr_t token_pos() const { return ast_node_.token_pos(); }
1255 intptr_t try_index() const { return try_index_; } 1254 intptr_t try_index() const { return try_index_; }
1256 const Function& function() const { return ast_node_.function(); } 1255 const Function& function() const { return ast_node_.function(); }
1257 Value* type_arguments() const { return inputs_[0]; } 1256
1258 Value* receiver() const { return inputs_[1]; } 1257 intptr_t ArgumentCount() const { return arguments_->length(); }
1258 PushArgumentInstr* ArgumentAt(intptr_t index) const {
1259 return (*arguments_)[index];
1260 }
1259 1261
1260 virtual void PrintOperandsTo(BufferFormatter* f) const; 1262 virtual void PrintOperandsTo(BufferFormatter* f) const;
1261 1263
1262 private: 1264 private:
1263 const ClosureNode& ast_node_; 1265 const ClosureNode& ast_node_;
1264 const intptr_t try_index_; 1266 const intptr_t try_index_;
1267 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
1265 1268
1266 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); 1269 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp);
1267 }; 1270 };
1268 1271
1269 1272
1270 class LoadVMFieldComp : public TemplateComputation<1> { 1273 class LoadVMFieldComp : public TemplateComputation<1> {
1271 public: 1274 public:
1272 LoadVMFieldComp(Value* value, 1275 LoadVMFieldComp(Value* value,
1273 intptr_t offset_in_bytes, 1276 intptr_t offset_in_bytes,
1274 const AbstractType& type) 1277 const AbstractType& type)
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 // type name. The concrete instruction classes are the name with Instr 1676 // type name. The concrete instruction classes are the name with Instr
1674 // concatenated. 1677 // concatenated.
1675 #define FOR_EACH_INSTRUCTION(M) \ 1678 #define FOR_EACH_INSTRUCTION(M) \
1676 M(GraphEntry) \ 1679 M(GraphEntry) \
1677 M(JoinEntry) \ 1680 M(JoinEntry) \
1678 M(TargetEntry) \ 1681 M(TargetEntry) \
1679 M(Phi) \ 1682 M(Phi) \
1680 M(Bind) \ 1683 M(Bind) \
1681 M(Parameter) \ 1684 M(Parameter) \
1682 M(ParallelMove) \ 1685 M(ParallelMove) \
1686 M(PushArgument) \
1683 M(Return) \ 1687 M(Return) \
1684 M(Throw) \ 1688 M(Throw) \
1685 M(ReThrow) \ 1689 M(ReThrow) \
1686 M(Goto) \ 1690 M(Goto) \
1687 M(Branch) \ 1691 M(Branch) \
1688 1692
1689 1693
1690 // Forward declarations for Instruction classes. 1694 // Forward declarations for Instruction classes.
1691 class BlockEntryInstr; 1695 class BlockEntryInstr;
1692 class FlowGraphBuilder; 1696 class FlowGraphBuilder;
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 2220
2217 DECLARE_INSTRUCTION(Parameter) 2221 DECLARE_INSTRUCTION(Parameter)
2218 2222
2219 private: 2223 private:
2220 const intptr_t index_; 2224 const intptr_t index_;
2221 2225
2222 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); 2226 DISALLOW_COPY_AND_ASSIGN(ParameterInstr);
2223 }; 2227 };
2224 2228
2225 2229
2230 class PushArgumentInstr : public InstructionWithInputs {
2231 public:
2232 explicit PushArgumentInstr(Value* value) : value_(value) { }
2233
2234 DECLARE_INSTRUCTION(PushArgument)
2235
2236 Value* value() const { return value_; }
2237
2238 virtual LocationSummary* MakeLocationSummary() const;
2239
2240 virtual void EmitNativeCode(FlowGraphCompiler* compiler);
2241
2242 private:
2243 Value* value_;
2244
2245 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr);
2246 };
2247
2248
2226 class ReturnInstr : public InstructionWithInputs { 2249 class ReturnInstr : public InstructionWithInputs {
2227 public: 2250 public:
2228 ReturnInstr(intptr_t token_pos, Value* value) 2251 ReturnInstr(intptr_t token_pos, Value* value)
2229 : InstructionWithInputs(), token_pos_(token_pos), value_(value) { 2252 : InstructionWithInputs(), token_pos_(token_pos), value_(value) {
2230 ASSERT(value_ != NULL); 2253 ASSERT(value_ != NULL);
2231 } 2254 }
2232 2255
2233 DECLARE_INSTRUCTION(Return) 2256 DECLARE_INSTRUCTION(Return)
2234 2257
2235 Value* value() const { return value_; } 2258 Value* value() const { return value_; }
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 const GrowableArray<BlockEntryInstr*>& block_order_; 2583 const GrowableArray<BlockEntryInstr*>& block_order_;
2561 2584
2562 private: 2585 private:
2563 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2586 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2564 }; 2587 };
2565 2588
2566 2589
2567 } // namespace dart 2590 } // namespace dart
2568 2591
2569 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2592 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « vm/il_printer.cc ('k') | vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698