OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 int registers_to_save) | 92 int registers_to_save) |
93 : masm_(new MacroAssembler(NULL, kRegExpCodeSize)), | 93 : masm_(new MacroAssembler(NULL, kRegExpCodeSize)), |
94 constants_(kRegExpConstantsSize), | 94 constants_(kRegExpConstantsSize), |
95 mode_(mode), | 95 mode_(mode), |
96 num_registers_(registers_to_save), | 96 num_registers_(registers_to_save), |
97 num_saved_registers_(registers_to_save), | 97 num_saved_registers_(registers_to_save), |
98 entry_label_(), | 98 entry_label_(), |
99 start_label_(), | 99 start_label_(), |
100 success_label_(), | 100 success_label_(), |
101 backtrack_label_(), | 101 backtrack_label_(), |
102 exit_label_(), | 102 exit_label_() { |
103 self_(Heap::undefined_value()) { | |
104 __ jmp(&entry_label_); // We'll write the entry code later. | 103 __ jmp(&entry_label_); // We'll write the entry code later. |
105 __ bind(&start_label_); // And then continue from here. | 104 __ bind(&start_label_); // And then continue from here. |
106 } | 105 } |
107 | 106 |
108 | 107 |
109 RegExpMacroAssemblerIA32::~RegExpMacroAssemblerIA32() { | 108 RegExpMacroAssemblerIA32::~RegExpMacroAssemblerIA32() { |
110 delete masm_; | 109 delete masm_; |
111 // Unuse labels in case we throw away the assembler without calling GetCode. | 110 // Unuse labels in case we throw away the assembler without calling GetCode. |
112 entry_label_.Unuse(); | 111 entry_label_.Unuse(); |
113 start_label_.Unuse(); | 112 start_label_.Unuse(); |
(...skipping 24 matching lines...) Expand all Loading... |
138 if (by != 0) { | 137 if (by != 0) { |
139 __ add(register_location(reg), Immediate(by)); | 138 __ add(register_location(reg), Immediate(by)); |
140 } | 139 } |
141 } | 140 } |
142 | 141 |
143 | 142 |
144 void RegExpMacroAssemblerIA32::Backtrack() { | 143 void RegExpMacroAssemblerIA32::Backtrack() { |
145 CheckPreemption(); | 144 CheckPreemption(); |
146 // Pop Code* offset from backtrack stack, add Code* and jump to location. | 145 // Pop Code* offset from backtrack stack, add Code* and jump to location. |
147 Pop(ebx); | 146 Pop(ebx); |
148 __ add(Operand(ebx), Immediate(self_)); | 147 __ add(Operand(ebx), Immediate(masm_->CodeObject())); |
149 __ jmp(Operand(ebx)); | 148 __ jmp(Operand(ebx)); |
150 } | 149 } |
151 | 150 |
152 | 151 |
153 void RegExpMacroAssemblerIA32::Bind(Label* label) { | 152 void RegExpMacroAssemblerIA32::Bind(Label* label) { |
154 __ bind(label); | 153 __ bind(label); |
155 } | 154 } |
156 | 155 |
157 | 156 |
158 void RegExpMacroAssemblerIA32::CheckBitmap(uc16 start, | 157 void RegExpMacroAssemblerIA32::CheckBitmap(uc16 start, |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 // the stack limit. | 653 // the stack limit. |
655 __ cmp(ecx, num_registers_ * kPointerSize); | 654 __ cmp(ecx, num_registers_ * kPointerSize); |
656 __ j(above_equal, &stack_ok, taken); | 655 __ j(above_equal, &stack_ok, taken); |
657 // Exit with exception. | 656 // Exit with exception. |
658 __ mov(eax, EXCEPTION); | 657 __ mov(eax, EXCEPTION); |
659 __ jmp(&exit_label_); | 658 __ jmp(&exit_label_); |
660 | 659 |
661 __ bind(&stack_limit_hit); | 660 __ bind(&stack_limit_hit); |
662 int num_arguments = 2; | 661 int num_arguments = 2; |
663 FrameAlign(num_arguments, ebx); | 662 FrameAlign(num_arguments, ebx); |
664 __ mov(Operand(esp, 1 * kPointerSize), Immediate(self_)); | 663 __ mov(Operand(esp, 1 * kPointerSize), Immediate(masm_->CodeObject())); |
665 __ lea(eax, Operand(esp, -kPointerSize)); | 664 __ lea(eax, Operand(esp, -kPointerSize)); |
666 __ mov(Operand(esp, 0 * kPointerSize), eax); | 665 __ mov(Operand(esp, 0 * kPointerSize), eax); |
667 CallCFunction(FUNCTION_ADDR(&CheckStackGuardState), num_arguments); | 666 CallCFunction(FUNCTION_ADDR(&CheckStackGuardState), num_arguments); |
668 __ or_(eax, Operand(eax)); | 667 __ or_(eax, Operand(eax)); |
669 // If returned value is non-zero, the stack guard reports the actual | 668 // If returned value is non-zero, the stack guard reports the actual |
670 // stack limit being hit and an exception has already been raised. | 669 // stack limit being hit and an exception has already been raised. |
671 // Otherwise it was a preemption and we just check the limit again. | 670 // Otherwise it was a preemption and we just check the limit again. |
672 __ j(equal, &retry_stack_check); | 671 __ j(equal, &retry_stack_check); |
673 // Return value was non-zero. Exit with exception. | 672 // Return value was non-zero. Exit with exception. |
674 __ mov(eax, EXCEPTION); | 673 __ mov(eax, EXCEPTION); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 __ bind(&check_preempt_label_); | 776 __ bind(&check_preempt_label_); |
778 | 777 |
779 __ push(backtrack_stackpointer()); | 778 __ push(backtrack_stackpointer()); |
780 __ push(edi); | 779 __ push(edi); |
781 | 780 |
782 Label retry; | 781 Label retry; |
783 | 782 |
784 __ bind(&retry); | 783 __ bind(&retry); |
785 int num_arguments = 2; | 784 int num_arguments = 2; |
786 FrameAlign(num_arguments, ebx); | 785 FrameAlign(num_arguments, ebx); |
787 __ mov(Operand(esp, 1 * kPointerSize), Immediate(self_)); | 786 __ mov(Operand(esp, 1 * kPointerSize), Immediate(masm_->CodeObject())); |
788 __ lea(eax, Operand(esp, -kPointerSize)); | 787 __ lea(eax, Operand(esp, -kPointerSize)); |
789 __ mov(Operand(esp, 0 * kPointerSize), eax); | 788 __ mov(Operand(esp, 0 * kPointerSize), eax); |
790 CallCFunction(FUNCTION_ADDR(&CheckStackGuardState), num_arguments); | 789 CallCFunction(FUNCTION_ADDR(&CheckStackGuardState), num_arguments); |
791 // Return value must be zero. We cannot have a stack overflow at | 790 // Return value must be zero. We cannot have a stack overflow at |
792 // this point, since we checked the stack on entry and haven't | 791 // this point, since we checked the stack on entry and haven't |
793 // pushed anything since, that we haven't also popped again. | 792 // pushed anything since, that we haven't also popped again. |
794 | 793 |
795 ExternalReference stack_guard_limit = | 794 ExternalReference stack_guard_limit = |
796 ExternalReference::address_of_stack_guard_limit(); | 795 ExternalReference::address_of_stack_guard_limit(); |
797 // Check if we are still preempted. | 796 // Check if we are still preempted. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 // Exit with Result EXCEPTION(-1) to signal thrown exception. | 841 // Exit with Result EXCEPTION(-1) to signal thrown exception. |
843 __ mov(eax, EXCEPTION); | 842 __ mov(eax, EXCEPTION); |
844 __ jmp(&exit_label_); | 843 __ jmp(&exit_label_); |
845 } | 844 } |
846 | 845 |
847 CodeDesc code_desc; | 846 CodeDesc code_desc; |
848 masm_->GetCode(&code_desc); | 847 masm_->GetCode(&code_desc); |
849 Handle<Code> code = Factory::NewCode(code_desc, | 848 Handle<Code> code = Factory::NewCode(code_desc, |
850 NULL, | 849 NULL, |
851 Code::ComputeFlags(Code::REGEXP), | 850 Code::ComputeFlags(Code::REGEXP), |
852 self_); | 851 masm_->CodeObject()); |
853 LOG(CodeCreateEvent("RegExp", *code, *(source->ToCString()))); | 852 LOG(CodeCreateEvent("RegExp", *code, *(source->ToCString()))); |
854 return Handle<Object>::cast(code); | 853 return Handle<Object>::cast(code); |
855 } | 854 } |
856 | 855 |
857 | 856 |
858 void RegExpMacroAssemblerIA32::GoTo(Label* to) { | 857 void RegExpMacroAssemblerIA32::GoTo(Label* to) { |
859 BranchOrBacktrack(no_condition, to); | 858 BranchOrBacktrack(no_condition, to); |
860 } | 859 } |
861 | 860 |
862 | 861 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 void RegExpMacroAssemblerIA32::SafeCall(Label* to) { | 1131 void RegExpMacroAssemblerIA32::SafeCall(Label* to) { |
1133 Label return_to; | 1132 Label return_to; |
1134 __ push(Immediate::CodeRelativeOffset(&return_to)); | 1133 __ push(Immediate::CodeRelativeOffset(&return_to)); |
1135 __ jmp(to); | 1134 __ jmp(to); |
1136 __ bind(&return_to); | 1135 __ bind(&return_to); |
1137 } | 1136 } |
1138 | 1137 |
1139 | 1138 |
1140 void RegExpMacroAssemblerIA32::SafeReturn() { | 1139 void RegExpMacroAssemblerIA32::SafeReturn() { |
1141 __ pop(ebx); | 1140 __ pop(ebx); |
1142 __ add(Operand(ebx), Immediate(self_)); | 1141 __ add(Operand(ebx), Immediate(masm_->CodeObject())); |
1143 __ jmp(Operand(ebx)); | 1142 __ jmp(Operand(ebx)); |
1144 } | 1143 } |
1145 | 1144 |
1146 | 1145 |
1147 void RegExpMacroAssemblerIA32::Push(Register source) { | 1146 void RegExpMacroAssemblerIA32::Push(Register source) { |
1148 ASSERT(!source.is(backtrack_stackpointer())); | 1147 ASSERT(!source.is(backtrack_stackpointer())); |
1149 // Notice: This updates flags, unlike normal Push. | 1148 // Notice: This updates flags, unlike normal Push. |
1150 __ sub(Operand(backtrack_stackpointer()), Immediate(kPointerSize)); | 1149 __ sub(Operand(backtrack_stackpointer()), Immediate(kPointerSize)); |
1151 __ mov(Operand(backtrack_stackpointer(), 0), source); | 1150 __ mov(Operand(backtrack_stackpointer(), 0), source); |
1152 } | 1151 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 | 1252 |
1254 | 1253 |
1255 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, | 1254 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, |
1256 ArraySlice* buffer) { | 1255 ArraySlice* buffer) { |
1257 __ mov(reg, buffer->array()); | 1256 __ mov(reg, buffer->array()); |
1258 __ add(Operand(reg), Immediate(buffer->base_offset())); | 1257 __ add(Operand(reg), Immediate(buffer->base_offset())); |
1259 } | 1258 } |
1260 | 1259 |
1261 #undef __ | 1260 #undef __ |
1262 }} // namespace v8::internal | 1261 }} // namespace v8::internal |
OLD | NEW |