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_X64 | 7 #if V8_TARGET_ARCH_X64 |
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 rdi: the JS function object being called (i.e. ourselves) | 87 // o rdi: the JS function object being called (i.e. ourselves) |
88 // o rsi: our context | 88 // o rsi: our context |
89 // o rbp: our caller's frame pointer | 89 // o rbp: our caller's frame pointer |
90 // o rsp: stack pointer (pointing to return address) | 90 // o rsp: 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-x64.h for its layout. | 93 // frames-x64.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 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2153 __ Push(load_name); | 2149 __ Push(load_name); |
2154 __ Push(Operand(rsp, 2 * kPointerSize)); // iter | 2150 __ Push(Operand(rsp, 2 * kPointerSize)); // iter |
2155 __ Push(rax); // exception | 2151 __ Push(rax); // exception |
2156 __ jmp(&l_call); | 2152 __ jmp(&l_call); |
2157 | 2153 |
2158 // try { received = %yield result } | 2154 // try { received = %yield result } |
2159 // Shuffle the received result above a try handler and yield it without | 2155 // Shuffle the received result above a try handler and yield it without |
2160 // re-boxing. | 2156 // re-boxing. |
2161 __ bind(&l_try); | 2157 __ bind(&l_try); |
2162 __ Pop(rax); // result | 2158 __ Pop(rax); // result |
2163 EnterTryBlock(expr->index(), &l_catch); | 2159 int handler_index = NewHandlerTableEntry(); |
| 2160 EnterTryBlock(handler_index, &l_catch); |
2164 const int try_block_size = TryCatch::kElementCount * kPointerSize; | 2161 const int try_block_size = TryCatch::kElementCount * kPointerSize; |
2165 __ Push(rax); // result | 2162 __ Push(rax); // result |
2166 __ jmp(&l_suspend); | 2163 __ jmp(&l_suspend); |
2167 __ bind(&l_continuation); | 2164 __ bind(&l_continuation); |
2168 __ jmp(&l_resume); | 2165 __ jmp(&l_resume); |
2169 __ bind(&l_suspend); | 2166 __ bind(&l_suspend); |
2170 const int generator_object_depth = kPointerSize + try_block_size; | 2167 const int generator_object_depth = kPointerSize + try_block_size; |
2171 __ movp(rax, Operand(rsp, generator_object_depth)); | 2168 __ movp(rax, Operand(rsp, generator_object_depth)); |
2172 __ Push(rax); // g | 2169 __ Push(rax); // g |
2173 __ Push(Smi::FromInt(expr->index())); // handler-index | 2170 __ Push(Smi::FromInt(handler_index)); // handler-index |
2174 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | 2171 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
2175 __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset), | 2172 __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset), |
2176 Smi::FromInt(l_continuation.pos())); | 2173 Smi::FromInt(l_continuation.pos())); |
2177 __ movp(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi); | 2174 __ movp(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi); |
2178 __ movp(rcx, rsi); | 2175 __ movp(rcx, rsi); |
2179 __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx, | 2176 __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx, |
2180 kDontSaveFPRegs); | 2177 kDontSaveFPRegs); |
2181 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); | 2178 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); |
2182 __ movp(context_register(), | 2179 __ movp(context_register(), |
2183 Operand(rbp, StandardFrameConstants::kContextOffset)); | 2180 Operand(rbp, StandardFrameConstants::kContextOffset)); |
2184 __ Pop(rax); // result | 2181 __ Pop(rax); // result |
2185 EmitReturnSequence(); | 2182 EmitReturnSequence(); |
2186 __ bind(&l_resume); // received in rax | 2183 __ bind(&l_resume); // received in rax |
2187 ExitTryBlock(expr->index()); | 2184 ExitTryBlock(handler_index); |
2188 | 2185 |
2189 // receiver = iter; f = 'next'; arg = received; | 2186 // receiver = iter; f = 'next'; arg = received; |
2190 __ bind(&l_next); | 2187 __ bind(&l_next); |
2191 | 2188 |
2192 __ LoadRoot(load_name, Heap::knext_stringRootIndex); | 2189 __ LoadRoot(load_name, Heap::knext_stringRootIndex); |
2193 __ Push(load_name); // "next" | 2190 __ Push(load_name); // "next" |
2194 __ Push(Operand(rsp, 2 * kPointerSize)); // iter | 2191 __ Push(Operand(rsp, 2 * kPointerSize)); // iter |
2195 __ Push(rax); // received | 2192 __ Push(rax); // received |
2196 | 2193 |
2197 // result = receiver[f](arg); | 2194 // result = receiver[f](arg); |
(...skipping 3292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5490 Assembler::target_address_at(call_target_address, | 5487 Assembler::target_address_at(call_target_address, |
5491 unoptimized_code)); | 5488 unoptimized_code)); |
5492 return OSR_AFTER_STACK_CHECK; | 5489 return OSR_AFTER_STACK_CHECK; |
5493 } | 5490 } |
5494 | 5491 |
5495 | 5492 |
5496 } // namespace internal | 5493 } // namespace internal |
5497 } // namespace v8 | 5494 } // namespace v8 |
5498 | 5495 |
5499 #endif // V8_TARGET_ARCH_X64 | 5496 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |