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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // TODO(jarin) This should build translation codes from the instruction inputs |
273 // and from the framestate descriptor. At the moment, we only create a dummy | 273 // and from the framestate descriptor. At the moment, we only create a dummy |
274 // translation. | 274 // translation. |
275 | 275 |
276 FrameStateDescriptor descriptor = | 276 FrameStateDescriptor* descriptor = |
277 code()->GetDeoptimizationEntry(deoptimization_id); | 277 code()->GetDeoptimizationEntry(deoptimization_id); |
278 Translation translation(&translations_, 1, 1, zone()); | 278 Translation translation(&translations_, 1, 1, zone()); |
279 translation.BeginJSFrame(descriptor.bailout_id(), Translation::kSelfLiteralId, | 279 translation.BeginJSFrame(descriptor->bailout_id(), |
280 0); | 280 Translation::kSelfLiteralId, |
281 int undefined_literal_id = | 281 descriptor->size() - descriptor->parameters_count()); |
282 DefineDeoptimizationLiteral(isolate()->factory()->undefined_value()); | 282 |
283 translation.StoreLiteral(undefined_literal_id); | 283 for (int i = 0; i < descriptor->size(); i++) { |
| 284 AddTranslationForOperand(&translation, instr, instr->InputAt(i)); |
| 285 } |
284 | 286 |
285 deoptimization_states_[deoptimization_id] = | 287 deoptimization_states_[deoptimization_id] = |
286 new (zone()) DeoptimizationState(translation.index()); | 288 new (zone()) DeoptimizationState(translation.index()); |
287 } | 289 } |
288 | 290 |
289 | 291 |
| 292 void CodeGenerator::AddTranslationForOperand(Translation* translation, |
| 293 Instruction* instr, |
| 294 InstructionOperand* op) { |
| 295 if (op->IsStackSlot()) { |
| 296 translation->StoreStackSlot(op->index()); |
| 297 } else if (op->IsDoubleStackSlot()) { |
| 298 translation->StoreDoubleStackSlot(op->index()); |
| 299 } else if (op->IsRegister()) { |
| 300 InstructionOperandConverter converter(this, instr); |
| 301 translation->StoreRegister(converter.ToRegister(op)); |
| 302 } else if (op->IsDoubleRegister()) { |
| 303 InstructionOperandConverter converter(this, instr); |
| 304 translation->StoreDoubleRegister(converter.ToDoubleRegister(op)); |
| 305 } else if (op->IsImmediate()) { |
| 306 InstructionOperandConverter converter(this, instr); |
| 307 Constant constant = converter.ToConstant(op); |
| 308 Handle<Object> constant_object; |
| 309 switch (constant.type()) { |
| 310 case Constant::kInt32: |
| 311 constant_object = |
| 312 isolate()->factory()->NewNumberFromInt(constant.ToInt32()); |
| 313 break; |
| 314 case Constant::kFloat64: |
| 315 constant_object = |
| 316 isolate()->factory()->NewHeapNumber(constant.ToFloat64()); |
| 317 break; |
| 318 case Constant::kHeapObject: |
| 319 constant_object = constant.ToHeapObject(); |
| 320 break; |
| 321 default: |
| 322 UNREACHABLE(); |
| 323 } |
| 324 int literal_id = DefineDeoptimizationLiteral(constant_object); |
| 325 translation->StoreLiteral(literal_id); |
| 326 } else { |
| 327 UNREACHABLE(); |
| 328 } |
| 329 } |
| 330 |
290 #if !V8_TURBOFAN_BACKEND | 331 #if !V8_TURBOFAN_BACKEND |
291 | 332 |
292 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 333 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
293 UNIMPLEMENTED(); | 334 UNIMPLEMENTED(); |
294 } | 335 } |
295 | 336 |
296 | 337 |
297 void CodeGenerator::AssembleArchBranch(Instruction* instr, | 338 void CodeGenerator::AssembleArchBranch(Instruction* instr, |
298 FlagsCondition condition) { | 339 FlagsCondition condition) { |
299 UNIMPLEMENTED(); | 340 UNIMPLEMENTED(); |
(...skipping 30 matching lines...) Expand all Loading... |
330 #ifdef DEBUG | 371 #ifdef DEBUG |
331 bool CodeGenerator::IsNopForSmiCodeInlining(Handle<Code> code, int start_pc, | 372 bool CodeGenerator::IsNopForSmiCodeInlining(Handle<Code> code, int start_pc, |
332 int end_pc) { | 373 int end_pc) { |
333 UNIMPLEMENTED(); | 374 UNIMPLEMENTED(); |
334 return false; | 375 return false; |
335 } | 376 } |
336 #endif | 377 #endif |
337 | 378 |
338 #endif // !V8_TURBOFAN_BACKEND | 379 #endif // !V8_TURBOFAN_BACKEND |
339 | 380 |
340 | |
341 } // namespace compiler | 381 } // namespace compiler |
342 } // namespace internal | 382 } // namespace internal |
343 } // namespace v8 | 383 } // namespace v8 |
OLD | NEW |