| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 void Branch(bool if_true, Label* L); | 292 void Branch(bool if_true, Label* L); |
| 293 void CheckStack(); | 293 void CheckStack(); |
| 294 void CleanStack(int num_bytes); | 294 void CleanStack(int num_bytes); |
| 295 | 295 |
| 296 // Node visitors | 296 // Node visitors |
| 297 #define DEF_VISIT(type) \ | 297 #define DEF_VISIT(type) \ |
| 298 virtual void Visit##type(type* node); | 298 virtual void Visit##type(type* node); |
| 299 NODE_LIST(DEF_VISIT) | 299 NODE_LIST(DEF_VISIT) |
| 300 #undef DEF_VISIT | 300 #undef DEF_VISIT |
| 301 | 301 |
| 302 // Fast-case switch |
| 303 static const int kFastCaseSwitchMaxOverheadFactor = 10; |
| 304 static const int kFastCaseSwitchMinCaseCount = 5; |
| 305 virtual int FastCaseSwitchMaxOverheadFactor(); |
| 306 virtual int FastCaseSwitchMinCaseCount(); |
| 307 virtual void GenerateFastCaseSwitchJumpTable( |
| 308 SwitchStatement* node, int min_index, int range, Label *fail_label, |
| 309 SmartPointer<Label*> &case_targets, SmartPointer<Label> &case_labels); |
| 310 |
| 302 void RecordStatementPosition(Node* node); | 311 void RecordStatementPosition(Node* node); |
| 303 | 312 |
| 304 // Activation frames | 313 // Activation frames |
| 305 void EnterJSFrame(); | 314 void EnterJSFrame(); |
| 306 void ExitJSFrame(); | 315 void ExitJSFrame(); |
| 307 | 316 |
| 308 virtual void GenerateIsSmi(ZoneList<Expression*>* args); | 317 virtual void GenerateIsSmi(ZoneList<Expression*>* args); |
| 309 virtual void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args); | 318 virtual void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args); |
| 310 virtual void GenerateIsArray(ZoneList<Expression*>* args); | 319 virtual void GenerateIsArray(ZoneList<Expression*>* args); |
| 311 | 320 |
| (...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2737 | 2746 |
| 2738 void ArmCodeGenerator::VisitWithExitStatement(WithExitStatement* node) { | 2747 void ArmCodeGenerator::VisitWithExitStatement(WithExitStatement* node) { |
| 2739 Comment cmnt(masm_, "[ WithExitStatement"); | 2748 Comment cmnt(masm_, "[ WithExitStatement"); |
| 2740 // Pop context. | 2749 // Pop context. |
| 2741 __ ldr(cp, ContextOperand(cp, Context::PREVIOUS_INDEX)); | 2750 __ ldr(cp, ContextOperand(cp, Context::PREVIOUS_INDEX)); |
| 2742 // Update context local. | 2751 // Update context local. |
| 2743 __ str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2752 __ str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2744 } | 2753 } |
| 2745 | 2754 |
| 2746 | 2755 |
| 2756 int ArmCodeGenerator::FastCaseSwitchMaxOverheadFactor() { |
| 2757 return kFastCaseSwitchMaxOverheadFactor; |
| 2758 } |
| 2759 |
| 2760 int ArmCodeGenerator::FastCaseSwitchMinCaseCount() { |
| 2761 return kFastCaseSwitchMinCaseCount; |
| 2762 } |
| 2763 |
| 2764 |
| 2765 void ArmCodeGenerator::GenerateFastCaseSwitchJumpTable( |
| 2766 SwitchStatement* node, int min_index, int range, Label *fail_label, |
| 2767 SmartPointer<Label*> &case_targets, SmartPointer<Label> &case_labels) { |
| 2768 |
| 2769 ASSERT(kSmiTag == 0 && kSmiTagSize <= 2); |
| 2770 |
| 2771 __ pop(r0); |
| 2772 if (min_index != 0) { |
| 2773 // small positive numbers can be immediate operands. |
| 2774 if (min_index < 0) { |
| 2775 __ add(r0, r0, Operand(Smi::FromInt(-min_index))); |
| 2776 } else { |
| 2777 __ sub(r0, r0, Operand(Smi::FromInt(min_index))); |
| 2778 } |
| 2779 } |
| 2780 __ tst(r0, Operand(0x80000000 | kSmiTagMask)); |
| 2781 __ b(ne, fail_label); |
| 2782 __ cmp(r0, Operand(Smi::FromInt(range))); |
| 2783 __ b(ge, fail_label); |
| 2784 __ add(pc, pc, Operand(r0, LSL, 2 - kSmiTagSize)); |
| 2785 // One extra instruction offsets the table, so the table's start address is |
| 2786 // the pc-register at the above add. |
| 2787 __ stop("Unreachable: Switch table alignment"); |
| 2788 |
| 2789 // table containing branch operations. |
| 2790 for (int i = 0; i < range; i++) { |
| 2791 __ b(case_targets[i]); |
| 2792 } |
| 2793 |
| 2794 GenerateFastCaseSwitchCases(node, case_labels); |
| 2795 } |
| 2796 |
| 2797 |
| 2747 void ArmCodeGenerator::VisitSwitchStatement(SwitchStatement* node) { | 2798 void ArmCodeGenerator::VisitSwitchStatement(SwitchStatement* node) { |
| 2748 Comment cmnt(masm_, "[ SwitchStatement"); | 2799 Comment cmnt(masm_, "[ SwitchStatement"); |
| 2749 if (FLAG_debug_info) RecordStatementPosition(node); | 2800 if (FLAG_debug_info) RecordStatementPosition(node); |
| 2750 node->set_break_stack_height(break_stack_height_); | 2801 node->set_break_stack_height(break_stack_height_); |
| 2751 | 2802 |
| 2752 Load(node->tag()); | 2803 Load(node->tag()); |
| 2753 | 2804 |
| 2805 if (TryGenerateFastCaseSwitchStatement(node)) { |
| 2806 return; |
| 2807 } |
| 2808 |
| 2754 Label next, fall_through, default_case; | 2809 Label next, fall_through, default_case; |
| 2755 ZoneList<CaseClause*>* cases = node->cases(); | 2810 ZoneList<CaseClause*>* cases = node->cases(); |
| 2756 int length = cases->length(); | 2811 int length = cases->length(); |
| 2757 | 2812 |
| 2758 for (int i = 0; i < length; i++) { | 2813 for (int i = 0; i < length; i++) { |
| 2759 CaseClause* clause = cases->at(i); | 2814 CaseClause* clause = cases->at(i); |
| 2760 | 2815 |
| 2761 Comment cmnt(masm_, "[ case clause"); | 2816 Comment cmnt(masm_, "[ case clause"); |
| 2762 | 2817 |
| 2763 if (clause->is_default()) { | 2818 if (clause->is_default()) { |
| (...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4582 bool is_eval) { | 4637 bool is_eval) { |
| 4583 Handle<Code> code = ArmCodeGenerator::MakeCode(fun, script, is_eval); | 4638 Handle<Code> code = ArmCodeGenerator::MakeCode(fun, script, is_eval); |
| 4584 if (!code.is_null()) { | 4639 if (!code.is_null()) { |
| 4585 Counters::total_compiled_code_size.Increment(code->instruction_size()); | 4640 Counters::total_compiled_code_size.Increment(code->instruction_size()); |
| 4586 } | 4641 } |
| 4587 return code; | 4642 return code; |
| 4588 } | 4643 } |
| 4589 | 4644 |
| 4590 | 4645 |
| 4591 } } // namespace v8::internal | 4646 } } // namespace v8::internal |
| OLD | NEW |