| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 fail_label->Branch(greater_equal, not_taken); | 1861 fail_label->Branch(greater_equal, not_taken); |
| 1862 | 1862 |
| 1863 // 0 is placeholder. | 1863 // 0 is placeholder. |
| 1864 __ jmp(Operand(eax, eax, times_1, 0x0, RelocInfo::INTERNAL_REFERENCE)); | 1864 __ jmp(Operand(eax, eax, times_1, 0x0, RelocInfo::INTERNAL_REFERENCE)); |
| 1865 // calculate address to overwrite later with actual address of table. | 1865 // calculate address to overwrite later with actual address of table. |
| 1866 int32_t jump_table_ref = __ pc_offset() - sizeof(int32_t); | 1866 int32_t jump_table_ref = __ pc_offset() - sizeof(int32_t); |
| 1867 | 1867 |
| 1868 __ Align(4); | 1868 __ Align(4); |
| 1869 JumpTarget table_start(this); | 1869 JumpTarget table_start(this); |
| 1870 table_start.Bind(); | 1870 table_start.Bind(); |
| 1871 __ WriteInternalReference(jump_table_ref, *table_start.label()); | 1871 __ WriteInternalReference(jump_table_ref, *table_start.entry_label()); |
| 1872 | 1872 |
| 1873 for (int i = 0; i < range; i++) { | 1873 for (int i = 0; i < range; i++) { |
| 1874 // table entry, 0 is placeholder for case address | 1874 // table entry, 0 is placeholder for case address |
| 1875 __ dd(0x0, RelocInfo::INTERNAL_REFERENCE); | 1875 __ dd(0x0, RelocInfo::INTERNAL_REFERENCE); |
| 1876 } | 1876 } |
| 1877 | 1877 |
| 1878 GenerateFastCaseSwitchCases(node, case_labels, &table_start); | 1878 GenerateFastCaseSwitchCases(node, case_labels, &table_start); |
| 1879 | 1879 |
| 1880 for (int i = 0, entry_pos = table_start.label()->pos(); | 1880 for (int i = 0, entry_pos = table_start.entry_label()->pos(); |
| 1881 i < range; | 1881 i < range; |
| 1882 i++, entry_pos += sizeof(uint32_t)) { | 1882 i++, entry_pos += sizeof(uint32_t)) { |
| 1883 __ WriteInternalReference(entry_pos, *case_targets[i]->label()); | 1883 __ WriteInternalReference(entry_pos, *case_targets[i]->entry_label()); |
| 1884 } | 1884 } |
| 1885 } | 1885 } |
| 1886 | 1886 |
| 1887 | 1887 |
| 1888 void CodeGenerator::VisitSwitchStatement(SwitchStatement* node) { | 1888 void CodeGenerator::VisitSwitchStatement(SwitchStatement* node) { |
| 1889 ASSERT(!in_spilled_code()); | 1889 ASSERT(!in_spilled_code()); |
| 1890 Comment cmnt(masm_, "[ SwitchStatement"); | 1890 Comment cmnt(masm_, "[ SwitchStatement"); |
| 1891 CodeForStatement(node); | 1891 CodeForStatement(node); |
| 1892 node->set_break_stack_height(break_stack_height_); | 1892 node->set_break_stack_height(break_stack_height_); |
| 1893 node->break_target()->set_code_generator(this); | 1893 node->break_target()->set_code_generator(this); |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2410 // We should probably try to unify the escaping targets and the return | 2410 // We should probably try to unify the escaping targets and the return |
| 2411 // target. | 2411 // target. |
| 2412 int nof_escapes = node->escaping_targets()->length(); | 2412 int nof_escapes = node->escaping_targets()->length(); |
| 2413 List<ShadowTarget*> shadows(1 + nof_escapes); | 2413 List<ShadowTarget*> shadows(1 + nof_escapes); |
| 2414 | 2414 |
| 2415 // Add the shadow target for the function return. | 2415 // Add the shadow target for the function return. |
| 2416 static const int kReturnShadowIndex = 0; | 2416 static const int kReturnShadowIndex = 0; |
| 2417 shadows.Add(new ShadowTarget(&function_return_)); | 2417 shadows.Add(new ShadowTarget(&function_return_)); |
| 2418 bool function_return_was_shadowed = function_return_is_shadowed_; | 2418 bool function_return_was_shadowed = function_return_is_shadowed_; |
| 2419 function_return_is_shadowed_ = true; | 2419 function_return_is_shadowed_ = true; |
| 2420 ASSERT(shadows[kReturnShadowIndex]->original_target() == &function_return_); | 2420 ASSERT(shadows[kReturnShadowIndex]->other_target() == &function_return_); |
| 2421 | 2421 |
| 2422 // Add the remaining shadow targets. | 2422 // Add the remaining shadow targets. |
| 2423 for (int i = 0; i < nof_escapes; i++) { | 2423 for (int i = 0; i < nof_escapes; i++) { |
| 2424 shadows.Add(new ShadowTarget(node->escaping_targets()->at(i))); | 2424 shadows.Add(new ShadowTarget(node->escaping_targets()->at(i))); |
| 2425 } | 2425 } |
| 2426 | 2426 |
| 2427 // Generate code for the statements in the try block. | 2427 // Generate code for the statements in the try block. |
| 2428 VisitStatementsAndSpill(node->try_block()->statements()); | 2428 VisitStatementsAndSpill(node->try_block()->statements()); |
| 2429 | 2429 |
| 2430 // Stop the introduced shadowing and count the number of required unlinks. | 2430 // Stop the introduced shadowing and count the number of required unlinks. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 __ lea(esp, Operand(edx, kNextOffset)); | 2479 __ lea(esp, Operand(edx, kNextOffset)); |
| 2480 frame_->Forget(frame_->height() - handler_height); | 2480 frame_->Forget(frame_->height() - handler_height); |
| 2481 | 2481 |
| 2482 frame_->EmitPop(Operand::StaticVariable(handler_address)); | 2482 frame_->EmitPop(Operand::StaticVariable(handler_address)); |
| 2483 frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); | 2483 frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); |
| 2484 // next_sp popped. | 2484 // next_sp popped. |
| 2485 | 2485 |
| 2486 if (!function_return_is_shadowed_ && i == kReturnShadowIndex) { | 2486 if (!function_return_is_shadowed_ && i == kReturnShadowIndex) { |
| 2487 frame_->PrepareForReturn(); | 2487 frame_->PrepareForReturn(); |
| 2488 } | 2488 } |
| 2489 shadows[i]->original_target()->Jump(); | 2489 shadows[i]->other_target()->Jump(); |
| 2490 } | 2490 } |
| 2491 } | 2491 } |
| 2492 | 2492 |
| 2493 exit.Bind(); | 2493 exit.Bind(); |
| 2494 } | 2494 } |
| 2495 | 2495 |
| 2496 | 2496 |
| 2497 void CodeGenerator::VisitTryFinally(TryFinally* node) { | 2497 void CodeGenerator::VisitTryFinally(TryFinally* node) { |
| 2498 ASSERT(!in_spilled_code()); | 2498 ASSERT(!in_spilled_code()); |
| 2499 VirtualFrame::SpilledScope spilled_scope(this); | 2499 VirtualFrame::SpilledScope spilled_scope(this); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2531 // We should probably try to unify the escaping targets and the return | 2531 // We should probably try to unify the escaping targets and the return |
| 2532 // target. | 2532 // target. |
| 2533 int nof_escapes = node->escaping_targets()->length(); | 2533 int nof_escapes = node->escaping_targets()->length(); |
| 2534 List<ShadowTarget*> shadows(1 + nof_escapes); | 2534 List<ShadowTarget*> shadows(1 + nof_escapes); |
| 2535 | 2535 |
| 2536 // Add the shadow target for the function return. | 2536 // Add the shadow target for the function return. |
| 2537 static const int kReturnShadowIndex = 0; | 2537 static const int kReturnShadowIndex = 0; |
| 2538 shadows.Add(new ShadowTarget(&function_return_)); | 2538 shadows.Add(new ShadowTarget(&function_return_)); |
| 2539 bool function_return_was_shadowed = function_return_is_shadowed_; | 2539 bool function_return_was_shadowed = function_return_is_shadowed_; |
| 2540 function_return_is_shadowed_ = true; | 2540 function_return_is_shadowed_ = true; |
| 2541 ASSERT(shadows[kReturnShadowIndex]->original_target() == &function_return_); | 2541 ASSERT(shadows[kReturnShadowIndex]->other_target() == &function_return_); |
| 2542 | 2542 |
| 2543 // Add the remaining shadow targets. | 2543 // Add the remaining shadow targets. |
| 2544 for (int i = 0; i < nof_escapes; i++) { | 2544 for (int i = 0; i < nof_escapes; i++) { |
| 2545 shadows.Add(new ShadowTarget(node->escaping_targets()->at(i))); | 2545 shadows.Add(new ShadowTarget(node->escaping_targets()->at(i))); |
| 2546 } | 2546 } |
| 2547 | 2547 |
| 2548 // Generate code for the statements in the try block. | 2548 // Generate code for the statements in the try block. |
| 2549 VisitStatementsAndSpill(node->try_block()->statements()); | 2549 VisitStatementsAndSpill(node->try_block()->statements()); |
| 2550 | 2550 |
| 2551 // Stop the introduced shadowing and count the number of required unlinks. | 2551 // Stop the introduced shadowing and count the number of required unlinks. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2628 if (has_valid_frame()) { | 2628 if (has_valid_frame()) { |
| 2629 JumpTarget exit(this); | 2629 JumpTarget exit(this); |
| 2630 // Restore state and return value or faked TOS. | 2630 // Restore state and return value or faked TOS. |
| 2631 frame_->EmitPop(ecx); | 2631 frame_->EmitPop(ecx); |
| 2632 frame_->EmitPop(eax); | 2632 frame_->EmitPop(eax); |
| 2633 | 2633 |
| 2634 // Generate code to jump to the right destination for all used | 2634 // Generate code to jump to the right destination for all used |
| 2635 // formerly shadowing targets. | 2635 // formerly shadowing targets. |
| 2636 for (int i = 0; i <= nof_escapes; i++) { | 2636 for (int i = 0; i <= nof_escapes; i++) { |
| 2637 if (shadows[i]->is_bound()) { | 2637 if (shadows[i]->is_bound()) { |
| 2638 JumpTarget* original = shadows[i]->original_target(); | 2638 JumpTarget* original = shadows[i]->other_target(); |
| 2639 __ cmp(Operand(ecx), Immediate(Smi::FromInt(JUMPING + i))); | 2639 __ cmp(Operand(ecx), Immediate(Smi::FromInt(JUMPING + i))); |
| 2640 if (!function_return_is_shadowed_ && i == kReturnShadowIndex) { | 2640 if (!function_return_is_shadowed_ && i == kReturnShadowIndex) { |
| 2641 JumpTarget skip(this); | 2641 JumpTarget skip(this); |
| 2642 skip.Branch(not_equal); | 2642 skip.Branch(not_equal); |
| 2643 frame_->PrepareForReturn(); | 2643 frame_->PrepareForReturn(); |
| 2644 original->Jump(); | 2644 original->Jump(); |
| 2645 skip.Bind(); | 2645 skip.Bind(); |
| 2646 } else { | 2646 } else { |
| 2647 original->Branch(equal); | 2647 original->Branch(equal); |
| 2648 } | 2648 } |
| (...skipping 3495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6144 | 6144 |
| 6145 // Slow-case: Go through the JavaScript implementation. | 6145 // Slow-case: Go through the JavaScript implementation. |
| 6146 __ bind(&slow); | 6146 __ bind(&slow); |
| 6147 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 6147 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
| 6148 } | 6148 } |
| 6149 | 6149 |
| 6150 | 6150 |
| 6151 #undef __ | 6151 #undef __ |
| 6152 | 6152 |
| 6153 } } // namespace v8::internal | 6153 } } // namespace v8::internal |
| OLD | NEW |