OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
10 | 10 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 data->SetLiteralArray(*literals); | 206 data->SetLiteralArray(*literals); |
207 } | 207 } |
208 | 208 |
209 // No OSR in Turbofan yet... | 209 // No OSR in Turbofan yet... |
210 BailoutId osr_ast_id = BailoutId::None(); | 210 BailoutId osr_ast_id = BailoutId::None(); |
211 data->SetOsrAstId(Smi::FromInt(osr_ast_id.ToInt())); | 211 data->SetOsrAstId(Smi::FromInt(osr_ast_id.ToInt())); |
212 data->SetOsrPcOffset(Smi::FromInt(-1)); | 212 data->SetOsrPcOffset(Smi::FromInt(-1)); |
213 | 213 |
214 // Populate deoptimization entries. | 214 // Populate deoptimization entries. |
215 for (int i = 0; i < deopt_count; i++) { | 215 for (int i = 0; i < deopt_count; i++) { |
216 FrameStateDescriptor descriptor = code()->GetDeoptimizationEntry(i); | 216 FrameStateDescriptor* descriptor = code()->GetDeoptimizationEntry(i); |
217 data->SetAstId(i, descriptor.bailout_id()); | 217 data->SetAstId(i, descriptor->bailout_id()); |
218 data->SetTranslationIndex(i, Smi::FromInt(0)); | 218 data->SetTranslationIndex(i, Smi::FromInt(0)); |
219 data->SetArgumentsStackHeight(i, Smi::FromInt(0)); | 219 data->SetArgumentsStackHeight(i, Smi::FromInt(0)); |
220 data->SetPc(i, Smi::FromInt(-1)); | 220 data->SetPc(i, Smi::FromInt(-1)); |
221 } | 221 } |
222 | 222 |
223 // Populate the return address patcher entries. | 223 // Populate the return address patcher entries. |
224 for (int i = 0; i < patch_count; ++i) { | 224 for (int i = 0; i < patch_count; ++i) { |
225 LazyDeoptimizationEntry entry = lazy_deoptimization_entries_[i]; | 225 LazyDeoptimizationEntry entry = lazy_deoptimization_entries_[i]; |
226 DCHECK(entry.position_after_call() == entry.continuation()->pos() || | 226 DCHECK(entry.position_after_call() == entry.continuation()->pos() || |
227 IsNopForSmiCodeInlining(code_object, entry.position_after_call(), | 227 IsNopForSmiCodeInlining(code_object, entry.position_after_call(), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 deoptimization_literals_.push_back(literal); | 262 deoptimization_literals_.push_back(literal); |
263 return result; | 263 return result; |
264 } | 264 } |
265 | 265 |
266 | 266 |
267 void CodeGenerator::BuildTranslation(Instruction* instr, | 267 void CodeGenerator::BuildTranslation(Instruction* instr, |
268 int deoptimization_id) { | 268 int deoptimization_id) { |
269 // We should build translation only once. | 269 // We should build translation only once. |
270 DCHECK_EQ(NULL, deoptimization_states_[deoptimization_id]); | 270 DCHECK_EQ(NULL, deoptimization_states_[deoptimization_id]); |
271 | 271 |
272 // TODO(jarin) This should build translation codes from the instruction inputs | 272 FrameStateDescriptor* descriptor = |
273 // and from the framestate descriptor. At the moment, we only create a dummy | |
274 // translation. | |
275 | |
276 FrameStateDescriptor descriptor = | |
277 code()->GetDeoptimizationEntry(deoptimization_id); | 273 code()->GetDeoptimizationEntry(deoptimization_id); |
278 Translation translation(&translations_, 1, 1, zone()); | 274 Translation translation(&translations_, 1, 1, zone()); |
279 translation.BeginJSFrame(descriptor.bailout_id(), Translation::kSelfLiteralId, | 275 translation.BeginJSFrame(descriptor->bailout_id(), |
280 0); | 276 Translation::kSelfLiteralId, |
281 int undefined_literal_id = | 277 descriptor->size() - descriptor->parameters_count()); |
282 DefineDeoptimizationLiteral(isolate()->factory()->undefined_value()); | 278 |
283 translation.StoreLiteral(undefined_literal_id); | 279 for (int i = 0; i < descriptor->size(); i++) { |
| 280 AddTranslationForOperand(&translation, instr, instr->InputAt(i)); |
| 281 } |
284 | 282 |
285 deoptimization_states_[deoptimization_id] = | 283 deoptimization_states_[deoptimization_id] = |
286 new (zone()) DeoptimizationState(translation.index()); | 284 new (zone()) DeoptimizationState(translation.index()); |
287 } | 285 } |
288 | 286 |
289 | 287 |
| 288 void CodeGenerator::AddTranslationForOperand(Translation* translation, |
| 289 Instruction* instr, |
| 290 InstructionOperand* op) { |
| 291 if (op->IsStackSlot()) { |
| 292 translation->StoreStackSlot(op->index()); |
| 293 } else if (op->IsDoubleStackSlot()) { |
| 294 translation->StoreDoubleStackSlot(op->index()); |
| 295 } else if (op->IsRegister()) { |
| 296 InstructionOperandConverter converter(this, instr); |
| 297 translation->StoreRegister(converter.ToRegister(op)); |
| 298 } else if (op->IsDoubleRegister()) { |
| 299 InstructionOperandConverter converter(this, instr); |
| 300 translation->StoreDoubleRegister(converter.ToDoubleRegister(op)); |
| 301 } else if (op->IsImmediate()) { |
| 302 InstructionOperandConverter converter(this, instr); |
| 303 Constant constant = converter.ToConstant(op); |
| 304 Handle<Object> constant_object; |
| 305 switch (constant.type()) { |
| 306 case Constant::kInt32: |
| 307 constant_object = |
| 308 isolate()->factory()->NewNumberFromInt(constant.ToInt32()); |
| 309 break; |
| 310 case Constant::kFloat64: |
| 311 constant_object = |
| 312 isolate()->factory()->NewHeapNumber(constant.ToFloat64()); |
| 313 break; |
| 314 case Constant::kHeapObject: |
| 315 constant_object = constant.ToHeapObject(); |
| 316 break; |
| 317 default: |
| 318 UNREACHABLE(); |
| 319 } |
| 320 int literal_id = DefineDeoptimizationLiteral(constant_object); |
| 321 translation->StoreLiteral(literal_id); |
| 322 } else { |
| 323 UNREACHABLE(); |
| 324 } |
| 325 } |
| 326 |
290 #if !V8_TURBOFAN_BACKEND | 327 #if !V8_TURBOFAN_BACKEND |
291 | 328 |
292 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 329 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
293 UNIMPLEMENTED(); | 330 UNIMPLEMENTED(); |
294 } | 331 } |
295 | 332 |
296 | 333 |
297 void CodeGenerator::AssembleArchBranch(Instruction* instr, | 334 void CodeGenerator::AssembleArchBranch(Instruction* instr, |
298 FlagsCondition condition) { | 335 FlagsCondition condition) { |
299 UNIMPLEMENTED(); | 336 UNIMPLEMENTED(); |
(...skipping 30 matching lines...) Expand all Loading... |
330 #ifdef DEBUG | 367 #ifdef DEBUG |
331 bool CodeGenerator::IsNopForSmiCodeInlining(Handle<Code> code, int start_pc, | 368 bool CodeGenerator::IsNopForSmiCodeInlining(Handle<Code> code, int start_pc, |
332 int end_pc) { | 369 int end_pc) { |
333 UNIMPLEMENTED(); | 370 UNIMPLEMENTED(); |
334 return false; | 371 return false; |
335 } | 372 } |
336 #endif | 373 #endif |
337 | 374 |
338 #endif // !V8_TURBOFAN_BACKEND | 375 #endif // !V8_TURBOFAN_BACKEND |
339 | 376 |
340 | |
341 } // namespace compiler | 377 } // namespace compiler |
342 } // namespace internal | 378 } // namespace internal |
343 } // namespace v8 | 379 } // namespace v8 |
OLD | NEW |