Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 1010883002: Switch full-codegen from StackHandlers to handler table. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-isolate-dead-code
Patch Set: Fix debugger-pause-on-promise-rejection. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // o edi: the JS function object being called (i.e. ourselves) 88 // o edi: the JS function object being called (i.e. ourselves)
89 // o esi: our context 89 // o esi: our context
90 // o ebp: our caller's frame pointer 90 // o ebp: our caller's frame pointer
91 // o esp: stack pointer (pointing to return address) 91 // o esp: stack pointer (pointing to return address)
92 // 92 //
93 // The function builds a JS frame. Please see JavaScriptFrameConstants in 93 // The function builds a JS frame. Please see JavaScriptFrameConstants in
94 // frames-ia32.h for its layout. 94 // frames-ia32.h for its layout.
95 void FullCodeGenerator::Generate() { 95 void FullCodeGenerator::Generate() {
96 CompilationInfo* info = info_; 96 CompilationInfo* info = info_;
97 handler_table_ = 97 handler_table_ =
98 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); 98 Handle<HandlerTable>::cast(isolate()->factory()->NewFixedArray(
99 HandlerTable::LengthForRange(function()->handler_count()), TENURED));
99 100
100 profiling_counter_ = isolate()->factory()->NewCell( 101 profiling_counter_ = isolate()->factory()->NewCell(
101 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); 102 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate()));
102 SetFunctionPosition(function()); 103 SetFunctionPosition(function());
103 Comment cmnt(masm_, "[ function compiled by full code generator"); 104 Comment cmnt(masm_, "[ function compiled by full code generator");
104 105
105 ProfileEntryHookStub::MaybeCallEntryHook(masm_); 106 ProfileEntryHookStub::MaybeCallEntryHook(masm_);
106 107
107 #ifdef DEBUG 108 #ifdef DEBUG
108 if (strlen(FLAG_stop_at) > 0 && 109 if (strlen(FLAG_stop_at) > 0 &&
(...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 Label l_next, l_call, l_loop; 2115 Label l_next, l_call, l_loop;
2115 Register load_receiver = LoadDescriptor::ReceiverRegister(); 2116 Register load_receiver = LoadDescriptor::ReceiverRegister();
2116 Register load_name = LoadDescriptor::NameRegister(); 2117 Register load_name = LoadDescriptor::NameRegister();
2117 2118
2118 // Initial send value is undefined. 2119 // Initial send value is undefined.
2119 __ mov(eax, isolate()->factory()->undefined_value()); 2120 __ mov(eax, isolate()->factory()->undefined_value());
2120 __ jmp(&l_next); 2121 __ jmp(&l_next);
2121 2122
2122 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } 2123 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; }
2123 __ bind(&l_catch); 2124 __ bind(&l_catch);
2124 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos()));
2125 __ mov(load_name, isolate()->factory()->throw_string()); // "throw" 2125 __ mov(load_name, isolate()->factory()->throw_string()); // "throw"
2126 __ push(load_name); // "throw" 2126 __ push(load_name); // "throw"
2127 __ push(Operand(esp, 2 * kPointerSize)); // iter 2127 __ push(Operand(esp, 2 * kPointerSize)); // iter
2128 __ push(eax); // exception 2128 __ push(eax); // exception
2129 __ jmp(&l_call); 2129 __ jmp(&l_call);
2130 2130
2131 // try { received = %yield result } 2131 // try { received = %yield result }
2132 // Shuffle the received result above a try handler and yield it without 2132 // Shuffle the received result above a try handler and yield it without
2133 // re-boxing. 2133 // re-boxing.
2134 __ bind(&l_try); 2134 __ bind(&l_try);
2135 __ pop(eax); // result 2135 __ pop(eax); // result
2136 __ PushTryHandler(StackHandler::CATCH, expr->index()); 2136 EnterTryBlock(expr->index(), &l_catch);
2137 const int handler_size = StackHandlerConstants::kSize; 2137 const int try_block_size = TryCatch::kElementCount * kPointerSize;
2138 __ push(eax); // result 2138 __ push(eax); // result
2139 __ jmp(&l_suspend); 2139 __ jmp(&l_suspend);
2140 __ bind(&l_continuation); 2140 __ bind(&l_continuation);
2141 __ jmp(&l_resume); 2141 __ jmp(&l_resume);
2142 __ bind(&l_suspend); 2142 __ bind(&l_suspend);
2143 const int generator_object_depth = kPointerSize + handler_size; 2143 const int generator_object_depth = kPointerSize + try_block_size;
2144 __ mov(eax, Operand(esp, generator_object_depth)); 2144 __ mov(eax, Operand(esp, generator_object_depth));
2145 __ push(eax); // g 2145 __ push(eax); // g
2146 __ push(Immediate(Smi::FromInt(expr->index()))); // handler-index
2146 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); 2147 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos()));
2147 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), 2148 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset),
2148 Immediate(Smi::FromInt(l_continuation.pos()))); 2149 Immediate(Smi::FromInt(l_continuation.pos())));
2149 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); 2150 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi);
2150 __ mov(ecx, esi); 2151 __ mov(ecx, esi);
2151 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, 2152 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx,
2152 kDontSaveFPRegs); 2153 kDontSaveFPRegs);
2153 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); 2154 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2);
2154 __ mov(context_register(), 2155 __ mov(context_register(),
2155 Operand(ebp, StandardFrameConstants::kContextOffset)); 2156 Operand(ebp, StandardFrameConstants::kContextOffset));
2156 __ pop(eax); // result 2157 __ pop(eax); // result
2157 EmitReturnSequence(); 2158 EmitReturnSequence();
2158 __ bind(&l_resume); // received in eax 2159 __ bind(&l_resume); // received in eax
2159 __ PopTryHandler(); 2160 ExitTryBlock(expr->index());
2160 2161
2161 // receiver = iter; f = iter.next; arg = received; 2162 // receiver = iter; f = iter.next; arg = received;
2162 __ bind(&l_next); 2163 __ bind(&l_next);
2163 2164
2164 __ mov(load_name, isolate()->factory()->next_string()); 2165 __ mov(load_name, isolate()->factory()->next_string());
2165 __ push(load_name); // "next" 2166 __ push(load_name); // "next"
2166 __ push(Operand(esp, 2 * kPointerSize)); // iter 2167 __ push(Operand(esp, 2 * kPointerSize)); // iter
2167 __ push(eax); // received 2168 __ push(eax); // received
2168 2169
2169 // result = receiver[f](arg); 2170 // result = receiver[f](arg);
(...skipping 3106 matching lines...) Expand 10 before | Expand all | Expand 10 after
5276 // Uncook return address. 5277 // Uncook return address.
5277 __ pop(edx); 5278 __ pop(edx);
5278 __ SmiUntag(edx); 5279 __ SmiUntag(edx);
5279 __ add(edx, Immediate(masm_->CodeObject())); 5280 __ add(edx, Immediate(masm_->CodeObject()));
5280 __ jmp(edx); 5281 __ jmp(edx);
5281 } 5282 }
5282 5283
5283 5284
5284 #undef __ 5285 #undef __
5285 5286
5286 #define __ ACCESS_MASM(masm())
5287
5288 FullCodeGenerator::NestedStatement* FullCodeGenerator::TryFinally::Exit(
5289 int* stack_depth,
5290 int* context_length) {
5291 // The macros used here must preserve the result register.
5292
5293 // Because the handler block contains the context of the finally
5294 // code, we can restore it directly from there for the finally code
5295 // rather than iteratively unwinding contexts via their previous
5296 // links.
5297 __ Drop(*stack_depth); // Down to the handler block.
5298 if (*context_length > 0) {
5299 // Restore the context to its dedicated register and the stack.
5300 __ mov(esi, Operand(esp, StackHandlerConstants::kContextOffset));
5301 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), esi);
5302 }
5303 __ PopTryHandler();
5304 __ call(finally_entry_);
5305
5306 *stack_depth = 0;
5307 *context_length = 0;
5308 return previous_;
5309 }
5310
5311 #undef __
5312
5313 5287
5314 static const byte kJnsInstruction = 0x79; 5288 static const byte kJnsInstruction = 0x79;
5315 static const byte kJnsOffset = 0x11; 5289 static const byte kJnsOffset = 0x11;
5316 static const byte kNopByteOne = 0x66; 5290 static const byte kNopByteOne = 0x66;
5317 static const byte kNopByteTwo = 0x90; 5291 static const byte kNopByteTwo = 0x90;
5318 #ifdef DEBUG 5292 #ifdef DEBUG
5319 static const byte kCallInstruction = 0xe8; 5293 static const byte kCallInstruction = 0xe8;
5320 #endif 5294 #endif
5321 5295
5322 5296
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
5384 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5358 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5385 Assembler::target_address_at(call_target_address, 5359 Assembler::target_address_at(call_target_address,
5386 unoptimized_code)); 5360 unoptimized_code));
5387 return OSR_AFTER_STACK_CHECK; 5361 return OSR_AFTER_STACK_CHECK;
5388 } 5362 }
5389 5363
5390 5364
5391 } } // namespace v8::internal 5365 } } // namespace v8::internal
5392 5366
5393 #endif // V8_TARGET_ARCH_IA32 5367 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698