OLD | NEW |
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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // Local or spill slot. Skip the frame pointer, function, and | 317 // Local or spill slot. Skip the frame pointer, function, and |
318 // context in the fixed part of the frame. | 318 // context in the fixed part of the frame. |
319 return MemOperand(fp, -(index + 3) * kPointerSize); | 319 return MemOperand(fp, -(index + 3) * kPointerSize); |
320 } else { | 320 } else { |
321 // Incoming parameter. Skip the return address. | 321 // Incoming parameter. Skip the return address. |
322 return MemOperand(fp, -(index - 1) * kPointerSize); | 322 return MemOperand(fp, -(index - 1) * kPointerSize); |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 | 326 |
| 327 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 328 Translation* translation) { |
| 329 if (environment == NULL) return; |
| 330 |
| 331 // The translation includes one command per value in the environment. |
| 332 int translation_size = environment->values()->length(); |
| 333 // The output frame height does not include the parameters. |
| 334 int height = translation_size - environment->parameter_count(); |
| 335 |
| 336 WriteTranslation(environment->outer(), translation); |
| 337 int closure_id = DefineDeoptimizationLiteral(environment->closure()); |
| 338 translation->BeginFrame(environment->ast_id(), closure_id, height); |
| 339 for (int i = 0; i < translation_size; ++i) { |
| 340 LOperand* value = environment->values()->at(i); |
| 341 // spilled_registers_ and spilled_double_registers_ are either |
| 342 // both NULL or both set. |
| 343 if (environment->spilled_registers() != NULL && value != NULL) { |
| 344 if (value->IsRegister() && |
| 345 environment->spilled_registers()[value->index()] != NULL) { |
| 346 translation->MarkDuplicate(); |
| 347 AddToTranslation(translation, |
| 348 environment->spilled_registers()[value->index()], |
| 349 environment->HasTaggedValueAt(i)); |
| 350 } else if ( |
| 351 value->IsDoubleRegister() && |
| 352 environment->spilled_double_registers()[value->index()] != NULL) { |
| 353 translation->MarkDuplicate(); |
| 354 AddToTranslation( |
| 355 translation, |
| 356 environment->spilled_double_registers()[value->index()], |
| 357 false); |
| 358 } |
| 359 } |
| 360 |
| 361 AddToTranslation(translation, value, environment->HasTaggedValueAt(i)); |
| 362 } |
| 363 } |
| 364 |
| 365 |
327 void LCodeGen::AddToTranslation(Translation* translation, | 366 void LCodeGen::AddToTranslation(Translation* translation, |
328 LOperand* op, | 367 LOperand* op, |
329 bool is_tagged) { | 368 bool is_tagged) { |
330 if (op == NULL) { | 369 if (op == NULL) { |
331 // TODO(twuerthinger): Introduce marker operands to indicate that this value | 370 // TODO(twuerthinger): Introduce marker operands to indicate that this value |
332 // is not present and must be reconstructed from the deoptimizer. Currently | 371 // is not present and must be reconstructed from the deoptimizer. Currently |
333 // this is only used for the arguments object. | 372 // this is only used for the arguments object. |
334 translation->StoreArgumentsObject(); | 373 translation->StoreArgumentsObject(); |
335 } else if (op->IsStackSlot()) { | 374 } else if (op->IsStackSlot()) { |
336 if (is_tagged) { | 375 if (is_tagged) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 // Layout of the translation: | 471 // Layout of the translation: |
433 // 0 ........................................................ size - 1 + 4 | 472 // 0 ........................................................ size - 1 + 4 |
434 // [expression stack including arguments] [locals] [4 words] [parameters] | 473 // [expression stack including arguments] [locals] [4 words] [parameters] |
435 // |>------------ translation_size ------------<| | 474 // |>------------ translation_size ------------<| |
436 | 475 |
437 int frame_count = 0; | 476 int frame_count = 0; |
438 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { | 477 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { |
439 ++frame_count; | 478 ++frame_count; |
440 } | 479 } |
441 Translation translation(&translations_, frame_count); | 480 Translation translation(&translations_, frame_count); |
442 environment->WriteTranslation(this, &translation); | 481 WriteTranslation(environment, &translation); |
443 int deoptimization_index = deoptimizations_.length(); | 482 int deoptimization_index = deoptimizations_.length(); |
444 environment->Register(deoptimization_index, translation.index()); | 483 environment->Register(deoptimization_index, translation.index()); |
445 deoptimizations_.Add(environment); | 484 deoptimizations_.Add(environment); |
446 } | 485 } |
447 } | 486 } |
448 | 487 |
449 | 488 |
450 void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) { | 489 void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) { |
451 RegisterEnvironmentForDeoptimization(environment); | 490 RegisterEnvironmentForDeoptimization(environment); |
452 ASSERT(environment->HasBeenRegistered()); | 491 ASSERT(environment->HasBeenRegistered()); |
(...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2646 | 2685 |
2647 | 2686 |
2648 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 2687 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
2649 Abort("DoOsrEntry unimplemented."); | 2688 Abort("DoOsrEntry unimplemented."); |
2650 } | 2689 } |
2651 | 2690 |
2652 | 2691 |
2653 #undef __ | 2692 #undef __ |
2654 | 2693 |
2655 } } // namespace v8::internal | 2694 } } // namespace v8::internal |
OLD | NEW |