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

Side by Side Diff: src/x64/lithium-codegen-x64.h

Issue 6697023: Merge 6800:7180 from the bleeding edge branch to the experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/jump-target-x64.cc ('k') | src/x64/lithium-codegen-x64.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 class LCodeGen BASE_EMBEDDED { 46 class LCodeGen BASE_EMBEDDED {
47 public: 47 public:
48 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) 48 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info)
49 : chunk_(chunk), 49 : chunk_(chunk),
50 masm_(assembler), 50 masm_(assembler),
51 info_(info), 51 info_(info),
52 current_block_(-1), 52 current_block_(-1),
53 current_instruction_(-1), 53 current_instruction_(-1),
54 instructions_(chunk->instructions()), 54 instructions_(chunk->instructions()),
55 deoptimizations_(4), 55 deoptimizations_(4),
56 jump_table_(4),
56 deoptimization_literals_(8), 57 deoptimization_literals_(8),
57 inlined_function_count_(0), 58 inlined_function_count_(0),
58 scope_(chunk->graph()->info()->scope()), 59 scope_(info->scope()),
59 status_(UNUSED), 60 status_(UNUSED),
60 deferred_(8), 61 deferred_(8),
61 osr_pc_offset_(-1), 62 osr_pc_offset_(-1),
62 resolver_(this) { 63 resolver_(this) {
63 PopulateDeoptimizationLiteralsWithInlinedFunctions(); 64 PopulateDeoptimizationLiteralsWithInlinedFunctions();
64 } 65 }
65 66
66 // Simple accessors. 67 // Simple accessors.
67 MacroAssembler* masm() const { return masm_; } 68 MacroAssembler* masm() const { return masm_; }
69 CompilationInfo* info() const { return info_; }
68 70
69 // Support for converting LOperands to assembler types. 71 // Support for converting LOperands to assembler types.
70 Register ToRegister(LOperand* op) const; 72 Register ToRegister(LOperand* op) const;
71 XMMRegister ToDoubleRegister(LOperand* op) const; 73 XMMRegister ToDoubleRegister(LOperand* op) const;
72 bool IsInteger32Constant(LConstantOperand* op) const; 74 bool IsInteger32Constant(LConstantOperand* op) const;
73 int ToInteger32(LConstantOperand* op) const; 75 int ToInteger32(LConstantOperand* op) const;
74 bool IsTaggedConstant(LConstantOperand* op) const; 76 bool IsTaggedConstant(LConstantOperand* op) const;
75 Handle<Object> ToHandle(LConstantOperand* op) const; 77 Handle<Object> ToHandle(LConstantOperand* op) const;
76 Operand ToOperand(LOperand* op) const; 78 Operand ToOperand(LOperand* op) const;
77 79
78
79 // Try to generate code for the entire chunk, but it may fail if the 80 // Try to generate code for the entire chunk, but it may fail if the
80 // chunk contains constructs we cannot handle. Returns true if the 81 // chunk contains constructs we cannot handle. Returns true if the
81 // code generation attempt succeeded. 82 // code generation attempt succeeded.
82 bool GenerateCode(); 83 bool GenerateCode();
83 84
84 // Finish the code by setting stack height, safepoint, and bailout 85 // Finish the code by setting stack height, safepoint, and bailout
85 // information on it. 86 // information on it.
86 void FinishCode(Handle<Code> code); 87 void FinishCode(Handle<Code> code);
87 88
88 // Deferred code support. 89 // Deferred code support.
89 void DoDeferredNumberTagD(LNumberTagD* instr); 90 void DoDeferredNumberTagD(LNumberTagD* instr);
90 void DoDeferredTaggedToI(LTaggedToI* instr); 91 void DoDeferredTaggedToI(LTaggedToI* instr);
91 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); 92 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr);
92 void DoDeferredStackCheck(LGoto* instr); 93 void DoDeferredStackCheck(LGoto* instr);
94 void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr);
95 void DoDeferredStringCharFromCode(LStringCharFromCode* instr);
93 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, 96 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
94 Label* map_check); 97 Label* map_check);
95 98
96 // Parallel move support. 99 // Parallel move support.
97 void DoParallelMove(LParallelMove* move); 100 void DoParallelMove(LParallelMove* move);
98 101
99 // Emit frame translation commands for an environment. 102 // Emit frame translation commands for an environment.
100 void WriteTranslation(LEnvironment* environment, Translation* translation); 103 void WriteTranslation(LEnvironment* environment, Translation* translation);
101 104
102 // Declare methods that deal with the individual node types. 105 // Declare methods that deal with the individual node types.
103 #define DECLARE_DO(type) void Do##type(L##type* node); 106 #define DECLARE_DO(type) void Do##type(L##type* node);
104 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) 107 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
105 #undef DECLARE_DO 108 #undef DECLARE_DO
106 109
107 private: 110 private:
108 enum Status { 111 enum Status {
109 UNUSED, 112 UNUSED,
110 GENERATING, 113 GENERATING,
111 DONE, 114 DONE,
112 ABORTED 115 ABORTED
113 }; 116 };
114 117
115 bool is_unused() const { return status_ == UNUSED; } 118 bool is_unused() const { return status_ == UNUSED; }
116 bool is_generating() const { return status_ == GENERATING; } 119 bool is_generating() const { return status_ == GENERATING; }
117 bool is_done() const { return status_ == DONE; } 120 bool is_done() const { return status_ == DONE; }
118 bool is_aborted() const { return status_ == ABORTED; } 121 bool is_aborted() const { return status_ == ABORTED; }
119 122
123 int strict_mode_flag() const {
124 return info()->is_strict() ? kStrictMode : kNonStrictMode;
125 }
126
120 LChunk* chunk() const { return chunk_; } 127 LChunk* chunk() const { return chunk_; }
121 Scope* scope() const { return scope_; } 128 Scope* scope() const { return scope_; }
122 HGraph* graph() const { return chunk_->graph(); } 129 HGraph* graph() const { return chunk_->graph(); }
123 130
124 int GetNextEmittedBlock(int block); 131 int GetNextEmittedBlock(int block);
125 LInstruction* GetNextInstruction(); 132 LInstruction* GetNextInstruction();
126 133
127 void EmitClassOfTest(Label* if_true, 134 void EmitClassOfTest(Label* if_true,
128 Label* if_false, 135 Label* if_false,
129 Handle<String> class_name, 136 Handle<String> class_name,
130 Register input, 137 Register input,
131 Register temporary); 138 Register temporary);
132 139
133 int StackSlotCount() const { return chunk()->spill_slot_count(); } 140 int StackSlotCount() const { return chunk()->spill_slot_count(); }
134 int ParameterCount() const { return scope()->num_parameters(); } 141 int ParameterCount() const { return scope()->num_parameters(); }
135 142
136 void Abort(const char* format, ...); 143 void Abort(const char* format, ...);
137 void Comment(const char* format, ...); 144 void Comment(const char* format, ...);
138 145
139 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } 146 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); }
140 147
141 // Code generation passes. Returns true if code generation should 148 // Code generation passes. Returns true if code generation should
142 // continue. 149 // continue.
143 bool GeneratePrologue(); 150 bool GeneratePrologue();
144 bool GenerateBody(); 151 bool GenerateBody();
145 bool GenerateDeferredCode(); 152 bool GenerateDeferredCode();
153 bool GenerateJumpTable();
146 bool GenerateSafepointTable(); 154 bool GenerateSafepointTable();
147 155
148 void CallCode(Handle<Code> code, 156 void CallCode(Handle<Code> code,
149 RelocInfo::Mode mode, 157 RelocInfo::Mode mode,
150 LInstruction* instr); 158 LInstruction* instr);
151 void CallRuntime(Runtime::Function* function, 159 void CallRuntime(Runtime::Function* function,
152 int num_arguments, 160 int num_arguments,
153 LInstruction* instr); 161 LInstruction* instr);
154 void CallRuntime(Runtime::FunctionId id, 162 void CallRuntime(Runtime::FunctionId id,
155 int num_arguments, 163 int num_arguments,
(...skipping 19 matching lines...) Expand all
175 bool is_tagged); 183 bool is_tagged);
176 void PopulateDeoptimizationData(Handle<Code> code); 184 void PopulateDeoptimizationData(Handle<Code> code);
177 int DefineDeoptimizationLiteral(Handle<Object> literal); 185 int DefineDeoptimizationLiteral(Handle<Object> literal);
178 186
179 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); 187 void PopulateDeoptimizationLiteralsWithInlinedFunctions();
180 188
181 Register ToRegister(int index) const; 189 Register ToRegister(int index) const;
182 XMMRegister ToDoubleRegister(int index) const; 190 XMMRegister ToDoubleRegister(int index) const;
183 191
184 // Specific math operations - used from DoUnaryMathOperation. 192 // Specific math operations - used from DoUnaryMathOperation.
193 void EmitIntegerMathAbs(LUnaryMathOperation* instr);
185 void DoMathAbs(LUnaryMathOperation* instr); 194 void DoMathAbs(LUnaryMathOperation* instr);
186 void DoMathFloor(LUnaryMathOperation* instr); 195 void DoMathFloor(LUnaryMathOperation* instr);
187 void DoMathRound(LUnaryMathOperation* instr); 196 void DoMathRound(LUnaryMathOperation* instr);
188 void DoMathSqrt(LUnaryMathOperation* instr); 197 void DoMathSqrt(LUnaryMathOperation* instr);
189 void DoMathPowHalf(LUnaryMathOperation* instr); 198 void DoMathPowHalf(LUnaryMathOperation* instr);
190 void DoMathLog(LUnaryMathOperation* instr); 199 void DoMathLog(LUnaryMathOperation* instr);
191 void DoMathCos(LUnaryMathOperation* instr); 200 void DoMathCos(LUnaryMathOperation* instr);
192 void DoMathSin(LUnaryMathOperation* instr); 201 void DoMathSin(LUnaryMathOperation* instr);
193 202
194 // Support for recording safepoint and position information. 203 // Support for recording safepoint and position information.
195 void RecordSafepoint(LPointerMap* pointers, 204 void RecordSafepoint(LPointerMap* pointers,
196 Safepoint::Kind kind, 205 Safepoint::Kind kind,
197 int arguments, 206 int arguments,
198 int deoptimization_index); 207 int deoptimization_index);
199 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); 208 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index);
209 void RecordSafepoint(int deoptimization_index);
200 void RecordSafepointWithRegisters(LPointerMap* pointers, 210 void RecordSafepointWithRegisters(LPointerMap* pointers,
201 int arguments, 211 int arguments,
202 int deoptimization_index); 212 int deoptimization_index);
203 void RecordPosition(int position); 213 void RecordPosition(int position);
214 int LastSafepointEnd() {
215 return static_cast<int>(safepoints_.GetPcAfterGap());
216 }
204 217
205 static Condition TokenToCondition(Token::Value op, bool is_unsigned); 218 static Condition TokenToCondition(Token::Value op, bool is_unsigned);
206 void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL); 219 void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL);
207 void EmitBranch(int left_block, int right_block, Condition cc); 220 void EmitBranch(int left_block, int right_block, Condition cc);
208 void EmitCmpI(LOperand* left, LOperand* right); 221 void EmitCmpI(LOperand* left, LOperand* right);
209 void EmitNumberUntagD(Register input, XMMRegister result, LEnvironment* env); 222 void EmitNumberUntagD(Register input, XMMRegister result, LEnvironment* env);
210 223
211 // Emits optimized code for typeof x == "y". Modifies input register. 224 // Emits optimized code for typeof x == "y". Modifies input register.
212 // Returns the condition on which a final split to 225 // Returns the condition on which a final split to
213 // true and false label should be made, to optimize fallthrough. 226 // true and false label should be made, to optimize fallthrough.
214 Condition EmitTypeofIs(Label* true_label, Label* false_label, 227 Condition EmitTypeofIs(Label* true_label, Label* false_label,
215 Register input, Handle<String> type_name); 228 Register input, Handle<String> type_name);
216 229
217 // Emits optimized code for %_IsObject(x). Preserves input register. 230 // Emits optimized code for %_IsObject(x). Preserves input register.
218 // Returns the condition on which a final split to 231 // Returns the condition on which a final split to
219 // true and false label should be made, to optimize fallthrough. 232 // true and false label should be made, to optimize fallthrough.
220 Condition EmitIsObject(Register input, 233 Condition EmitIsObject(Register input,
221 Label* is_not_object, 234 Label* is_not_object,
222 Label* is_object); 235 Label* is_object);
223 236
224 // Emits optimized code for %_IsConstructCall(). 237 // Emits optimized code for %_IsConstructCall().
225 // Caller should branch on equal condition. 238 // Caller should branch on equal condition.
226 void EmitIsConstructCall(Register temp); 239 void EmitIsConstructCall(Register temp);
227 240
241 // Emits code for pushing a constant operand.
242 void EmitPushConstantOperand(LOperand* operand);
243
244 struct JumpTableEntry {
245 inline JumpTableEntry(Address entry)
246 : label(),
247 address(entry) { }
248 Label label;
249 Address address;
250 };
251
228 LChunk* const chunk_; 252 LChunk* const chunk_;
229 MacroAssembler* const masm_; 253 MacroAssembler* const masm_;
230 CompilationInfo* const info_; 254 CompilationInfo* const info_;
231 255
232 int current_block_; 256 int current_block_;
233 int current_instruction_; 257 int current_instruction_;
234 const ZoneList<LInstruction*>* instructions_; 258 const ZoneList<LInstruction*>* instructions_;
235 ZoneList<LEnvironment*> deoptimizations_; 259 ZoneList<LEnvironment*> deoptimizations_;
260 ZoneList<JumpTableEntry> jump_table_;
236 ZoneList<Handle<Object> > deoptimization_literals_; 261 ZoneList<Handle<Object> > deoptimization_literals_;
237 int inlined_function_count_; 262 int inlined_function_count_;
238 Scope* const scope_; 263 Scope* const scope_;
239 Status status_; 264 Status status_;
240 TranslationBuffer translations_; 265 TranslationBuffer translations_;
241 ZoneList<LDeferredCode*> deferred_; 266 ZoneList<LDeferredCode*> deferred_;
242 int osr_pc_offset_; 267 int osr_pc_offset_;
243 268
244 // Builder that keeps track of safepoints in the code. The table 269 // Builder that keeps track of safepoints in the code. The table
245 // itself is emitted at the end of the generated code. 270 // itself is emitted at the end of the generated code.
(...skipping 30 matching lines...) Expand all
276 private: 301 private:
277 LCodeGen* codegen_; 302 LCodeGen* codegen_;
278 Label entry_; 303 Label entry_;
279 Label exit_; 304 Label exit_;
280 Label* external_exit_; 305 Label* external_exit_;
281 }; 306 };
282 307
283 } } // namespace v8::internal 308 } } // namespace v8::internal
284 309
285 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ 310 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_
OLDNEW
« no previous file with comments | « src/x64/jump-target-x64.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698