OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // The live registers are: | 86 // The live registers are: |
87 // o edi: the JS function object being called (i.e. ourselves) | 87 // o edi: the JS function object being called (i.e. ourselves) |
88 // o esi: our context | 88 // o esi: our context |
89 // o ebp: our caller's frame pointer | 89 // o ebp: our caller's frame pointer |
90 // o esp: stack pointer (pointing to return address) | 90 // o esp: stack pointer (pointing to return address) |
91 // | 91 // |
92 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 92 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
93 // frames-ia32.h for its layout. | 93 // frames-ia32.h for its layout. |
94 void FullCodeGenerator::Generate() { | 94 void FullCodeGenerator::Generate() { |
95 CompilationInfo* info = info_; | 95 CompilationInfo* info = info_; |
96 handler_table_ = | |
97 Handle<HandlerTable>::cast(isolate()->factory()->NewFixedArray( | |
98 HandlerTable::LengthForRange(function()->handler_count()), TENURED)); | |
99 | |
100 profiling_counter_ = isolate()->factory()->NewCell( | 96 profiling_counter_ = isolate()->factory()->NewCell( |
101 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); | 97 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); |
102 SetFunctionPosition(function()); | 98 SetFunctionPosition(function()); |
103 Comment cmnt(masm_, "[ function compiled by full code generator"); | 99 Comment cmnt(masm_, "[ function compiled by full code generator"); |
104 | 100 |
105 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 101 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
106 | 102 |
107 #ifdef DEBUG | 103 #ifdef DEBUG |
108 if (strlen(FLAG_stop_at) > 0 && | 104 if (strlen(FLAG_stop_at) > 0 && |
109 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 105 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
(...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2123 __ push(load_name); // "throw" | 2119 __ push(load_name); // "throw" |
2124 __ push(Operand(esp, 2 * kPointerSize)); // iter | 2120 __ push(Operand(esp, 2 * kPointerSize)); // iter |
2125 __ push(eax); // exception | 2121 __ push(eax); // exception |
2126 __ jmp(&l_call); | 2122 __ jmp(&l_call); |
2127 | 2123 |
2128 // try { received = %yield result } | 2124 // try { received = %yield result } |
2129 // Shuffle the received result above a try handler and yield it without | 2125 // Shuffle the received result above a try handler and yield it without |
2130 // re-boxing. | 2126 // re-boxing. |
2131 __ bind(&l_try); | 2127 __ bind(&l_try); |
2132 __ pop(eax); // result | 2128 __ pop(eax); // result |
2133 EnterTryBlock(expr->index(), &l_catch); | 2129 int handler_index = NewHandlerTableEntry(); |
| 2130 EnterTryBlock(handler_index, &l_catch); |
2134 const int try_block_size = TryCatch::kElementCount * kPointerSize; | 2131 const int try_block_size = TryCatch::kElementCount * kPointerSize; |
2135 __ push(eax); // result | 2132 __ push(eax); // result |
2136 __ jmp(&l_suspend); | 2133 __ jmp(&l_suspend); |
2137 __ bind(&l_continuation); | 2134 __ bind(&l_continuation); |
2138 __ jmp(&l_resume); | 2135 __ jmp(&l_resume); |
2139 __ bind(&l_suspend); | 2136 __ bind(&l_suspend); |
2140 const int generator_object_depth = kPointerSize + try_block_size; | 2137 const int generator_object_depth = kPointerSize + try_block_size; |
2141 __ mov(eax, Operand(esp, generator_object_depth)); | 2138 __ mov(eax, Operand(esp, generator_object_depth)); |
2142 __ push(eax); // g | 2139 __ push(eax); // g |
2143 __ push(Immediate(Smi::FromInt(expr->index()))); // handler-index | 2140 __ push(Immediate(Smi::FromInt(handler_index))); // handler-index |
2144 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | 2141 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
2145 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), | 2142 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), |
2146 Immediate(Smi::FromInt(l_continuation.pos()))); | 2143 Immediate(Smi::FromInt(l_continuation.pos()))); |
2147 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); | 2144 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); |
2148 __ mov(ecx, esi); | 2145 __ mov(ecx, esi); |
2149 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, | 2146 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, |
2150 kDontSaveFPRegs); | 2147 kDontSaveFPRegs); |
2151 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); | 2148 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); |
2152 __ mov(context_register(), | 2149 __ mov(context_register(), |
2153 Operand(ebp, StandardFrameConstants::kContextOffset)); | 2150 Operand(ebp, StandardFrameConstants::kContextOffset)); |
2154 __ pop(eax); // result | 2151 __ pop(eax); // result |
2155 EmitReturnSequence(); | 2152 EmitReturnSequence(); |
2156 __ bind(&l_resume); // received in eax | 2153 __ bind(&l_resume); // received in eax |
2157 ExitTryBlock(expr->index()); | 2154 ExitTryBlock(handler_index); |
2158 | 2155 |
2159 // receiver = iter; f = iter.next; arg = received; | 2156 // receiver = iter; f = iter.next; arg = received; |
2160 __ bind(&l_next); | 2157 __ bind(&l_next); |
2161 | 2158 |
2162 __ mov(load_name, isolate()->factory()->next_string()); | 2159 __ mov(load_name, isolate()->factory()->next_string()); |
2163 __ push(load_name); // "next" | 2160 __ push(load_name); // "next" |
2164 __ push(Operand(esp, 2 * kPointerSize)); // iter | 2161 __ push(Operand(esp, 2 * kPointerSize)); // iter |
2165 __ push(eax); // received | 2162 __ push(eax); // received |
2166 | 2163 |
2167 // result = receiver[f](arg); | 2164 // result = receiver[f](arg); |
(...skipping 3300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5468 Assembler::target_address_at(call_target_address, | 5465 Assembler::target_address_at(call_target_address, |
5469 unoptimized_code)); | 5466 unoptimized_code)); |
5470 return OSR_AFTER_STACK_CHECK; | 5467 return OSR_AFTER_STACK_CHECK; |
5471 } | 5468 } |
5472 | 5469 |
5473 | 5470 |
5474 } // namespace internal | 5471 } // namespace internal |
5475 } // namespace v8 | 5472 } // namespace v8 |
5476 | 5473 |
5477 #endif // V8_TARGET_ARCH_IA32 | 5474 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |