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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // o esi: our context | 87 // o esi: our context |
88 // o ebp: our caller's frame pointer | 88 // o ebp: our caller's frame pointer |
89 // o esp: stack pointer (pointing to return address) | 89 // o esp: stack pointer (pointing to return address) |
90 // | 90 // |
91 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 91 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
92 // frames-ia32.h for its layout. | 92 // frames-ia32.h for its layout. |
93 void FullCodeGenerator::Generate() { | 93 void FullCodeGenerator::Generate() { |
94 CompilationInfo* info = info_; | 94 CompilationInfo* info = info_; |
95 profiling_counter_ = isolate()->factory()->NewCell( | 95 profiling_counter_ = isolate()->factory()->NewCell( |
96 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); | 96 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); |
97 SetFunctionPosition(function()); | 97 SetFunctionPosition(literal()); |
98 Comment cmnt(masm_, "[ function compiled by full code generator"); | 98 Comment cmnt(masm_, "[ function compiled by full code generator"); |
99 | 99 |
100 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 100 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
101 | 101 |
102 #ifdef DEBUG | 102 #ifdef DEBUG |
103 if (strlen(FLAG_stop_at) > 0 && | 103 if (strlen(FLAG_stop_at) > 0 && |
104 function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 104 literal()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
105 __ int3(); | 105 __ int3(); |
106 } | 106 } |
107 #endif | 107 #endif |
108 | 108 |
109 // Sloppy mode functions and builtins need to replace the receiver with the | 109 // Sloppy mode functions and builtins need to replace the receiver with the |
110 // global proxy when called as functions (without an explicit receiver | 110 // global proxy when called as functions (without an explicit receiver |
111 // object). | 111 // object). |
112 if (is_sloppy(info->language_mode()) && !info->is_native() && | 112 if (is_sloppy(info->language_mode()) && !info->is_native() && |
113 info->MayUseThis()) { | 113 info->MayUseThis()) { |
114 Label ok; | 114 Label ok; |
(...skipping 17 matching lines...) Expand all Loading... |
132 // the frame (that is done below). | 132 // the frame (that is done below). |
133 FrameScope frame_scope(masm_, StackFrame::MANUAL); | 133 FrameScope frame_scope(masm_, StackFrame::MANUAL); |
134 | 134 |
135 info->set_prologue_offset(masm_->pc_offset()); | 135 info->set_prologue_offset(masm_->pc_offset()); |
136 __ Prologue(info->IsCodePreAgingActive()); | 136 __ Prologue(info->IsCodePreAgingActive()); |
137 info->AddNoFrameRange(0, masm_->pc_offset()); | 137 info->AddNoFrameRange(0, masm_->pc_offset()); |
138 | 138 |
139 { Comment cmnt(masm_, "[ Allocate locals"); | 139 { Comment cmnt(masm_, "[ Allocate locals"); |
140 int locals_count = info->scope()->num_stack_slots(); | 140 int locals_count = info->scope()->num_stack_slots(); |
141 // Generators allocate locals, if any, in context slots. | 141 // Generators allocate locals, if any, in context slots. |
142 DCHECK(!IsGeneratorFunction(function()->kind()) || locals_count == 0); | 142 DCHECK(!IsGeneratorFunction(literal()->kind()) || locals_count == 0); |
143 if (locals_count == 1) { | 143 if (locals_count == 1) { |
144 __ push(Immediate(isolate()->factory()->undefined_value())); | 144 __ push(Immediate(isolate()->factory()->undefined_value())); |
145 } else if (locals_count > 1) { | 145 } else if (locals_count > 1) { |
146 if (locals_count >= 128) { | 146 if (locals_count >= 128) { |
147 Label ok; | 147 Label ok; |
148 __ mov(ecx, esp); | 148 __ mov(ecx, esp); |
149 __ sub(ecx, Immediate(locals_count * kPointerSize)); | 149 __ sub(ecx, Immediate(locals_count * kPointerSize)); |
150 ExternalReference stack_limit = | 150 ExternalReference stack_limit = |
151 ExternalReference::address_of_real_stack_limit(isolate()); | 151 ExternalReference::address_of_real_stack_limit(isolate()); |
152 __ cmp(ecx, Operand::StaticVariable(stack_limit)); | 152 __ cmp(ecx, Operand::StaticVariable(stack_limit)); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 Operand(ebp, StandardFrameConstants::kCallerSPOffset + offset)); | 314 Operand(ebp, StandardFrameConstants::kCallerSPOffset + offset)); |
315 __ push(edx); | 315 __ push(edx); |
316 __ push(Immediate(Smi::FromInt(num_parameters))); | 316 __ push(Immediate(Smi::FromInt(num_parameters))); |
317 // Arguments to ArgumentsAccessStub: | 317 // Arguments to ArgumentsAccessStub: |
318 // function, receiver address, parameter count. | 318 // function, receiver address, parameter count. |
319 // The stub will rewrite receiver and parameter count if the previous | 319 // The stub will rewrite receiver and parameter count if the previous |
320 // stack frame was an arguments adapter frame. | 320 // stack frame was an arguments adapter frame. |
321 ArgumentsAccessStub::Type type; | 321 ArgumentsAccessStub::Type type; |
322 if (is_strict(language_mode()) || !has_simple_parameters()) { | 322 if (is_strict(language_mode()) || !has_simple_parameters()) { |
323 type = ArgumentsAccessStub::NEW_STRICT; | 323 type = ArgumentsAccessStub::NEW_STRICT; |
324 } else if (function()->has_duplicate_parameters()) { | 324 } else if (literal()->has_duplicate_parameters()) { |
325 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; | 325 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; |
326 } else { | 326 } else { |
327 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; | 327 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; |
328 } | 328 } |
329 | 329 |
330 ArgumentsAccessStub stub(isolate(), type); | 330 ArgumentsAccessStub stub(isolate(), type); |
331 __ CallStub(&stub); | 331 __ CallStub(&stub); |
332 | 332 |
333 SetVar(arguments, eax, ebx, edx); | 333 SetVar(arguments, eax, ebx, edx); |
334 } | 334 } |
(...skipping 25 matching lines...) Expand all Loading... |
360 ExternalReference stack_limit | 360 ExternalReference stack_limit |
361 = ExternalReference::address_of_stack_limit(isolate()); | 361 = ExternalReference::address_of_stack_limit(isolate()); |
362 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 362 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
363 __ j(above_equal, &ok, Label::kNear); | 363 __ j(above_equal, &ok, Label::kNear); |
364 __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); | 364 __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); |
365 __ bind(&ok); | 365 __ bind(&ok); |
366 } | 366 } |
367 | 367 |
368 { Comment cmnt(masm_, "[ Body"); | 368 { Comment cmnt(masm_, "[ Body"); |
369 DCHECK(loop_depth() == 0); | 369 DCHECK(loop_depth() == 0); |
370 VisitStatements(function()->body()); | 370 VisitStatements(literal()->body()); |
371 DCHECK(loop_depth() == 0); | 371 DCHECK(loop_depth() == 0); |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 // Always emit a 'return undefined' in case control fell off the end of | 375 // Always emit a 'return undefined' in case control fell off the end of |
376 // the body. | 376 // the body. |
377 { Comment cmnt(masm_, "[ return <undefined>;"); | 377 { Comment cmnt(masm_, "[ return <undefined>;"); |
378 __ mov(eax, isolate()->factory()->undefined_value()); | 378 __ mov(eax, isolate()->factory()->undefined_value()); |
379 EmitReturnSequence(); | 379 EmitReturnSequence(); |
380 } | 380 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 EmitProfilingCounterDecrement(weight); | 453 EmitProfilingCounterDecrement(weight); |
454 Label ok; | 454 Label ok; |
455 __ j(positive, &ok, Label::kNear); | 455 __ j(positive, &ok, Label::kNear); |
456 __ push(eax); | 456 __ push(eax); |
457 __ call(isolate()->builtins()->InterruptCheck(), | 457 __ call(isolate()->builtins()->InterruptCheck(), |
458 RelocInfo::CODE_TARGET); | 458 RelocInfo::CODE_TARGET); |
459 __ pop(eax); | 459 __ pop(eax); |
460 EmitProfilingCounterReset(); | 460 EmitProfilingCounterReset(); |
461 __ bind(&ok); | 461 __ bind(&ok); |
462 | 462 |
463 SetReturnPosition(function()); | 463 SetReturnPosition(literal()); |
464 int no_frame_start = masm_->pc_offset(); | 464 int no_frame_start = masm_->pc_offset(); |
465 __ leave(); | 465 __ leave(); |
466 | 466 |
467 int arg_count = info_->scope()->num_parameters() + 1; | 467 int arg_count = info_->scope()->num_parameters() + 1; |
468 int arguments_bytes = arg_count * kPointerSize; | 468 int arguments_bytes = arg_count * kPointerSize; |
469 __ Ret(arguments_bytes, ecx); | 469 __ Ret(arguments_bytes, ecx); |
470 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 470 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
471 } | 471 } |
472 } | 472 } |
473 | 473 |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 // | 1405 // |
1406 // The condition on the declaration scopes is a conservative check for | 1406 // The condition on the declaration scopes is a conservative check for |
1407 // nested functions that access a binding and are called before the | 1407 // nested functions that access a binding and are called before the |
1408 // binding is initialized: | 1408 // binding is initialized: |
1409 // function() { f(); let x = 1; function f() { x = 2; } } | 1409 // function() { f(); let x = 1; function f() { x = 2; } } |
1410 // | 1410 // |
1411 bool skip_init_check; | 1411 bool skip_init_check; |
1412 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { | 1412 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { |
1413 skip_init_check = false; | 1413 skip_init_check = false; |
1414 } else if (var->is_this()) { | 1414 } else if (var->is_this()) { |
1415 CHECK(function() != nullptr && | 1415 CHECK(literal() != nullptr && |
1416 (function()->kind() & kSubclassConstructor) != 0); | 1416 (literal()->kind() & kSubclassConstructor) != 0); |
1417 // TODO(dslomov): implement 'this' hole check elimination. | 1417 // TODO(dslomov): implement 'this' hole check elimination. |
1418 skip_init_check = false; | 1418 skip_init_check = false; |
1419 } else { | 1419 } else { |
1420 // Check that we always have valid source position. | 1420 // Check that we always have valid source position. |
1421 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); | 1421 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); |
1422 DCHECK(proxy->position() != RelocInfo::kNoPosition); | 1422 DCHECK(proxy->position() != RelocInfo::kNoPosition); |
1423 skip_init_check = var->mode() != CONST_LEGACY && | 1423 skip_init_check = var->mode() != CONST_LEGACY && |
1424 var->initializer_position() < proxy->position(); | 1424 var->initializer_position() < proxy->position(); |
1425 } | 1425 } |
1426 | 1426 |
(...skipping 3864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5291 Assembler::target_address_at(call_target_address, | 5291 Assembler::target_address_at(call_target_address, |
5292 unoptimized_code)); | 5292 unoptimized_code)); |
5293 return OSR_AFTER_STACK_CHECK; | 5293 return OSR_AFTER_STACK_CHECK; |
5294 } | 5294 } |
5295 | 5295 |
5296 | 5296 |
5297 } // namespace internal | 5297 } // namespace internal |
5298 } // namespace v8 | 5298 } // namespace v8 |
5299 | 5299 |
5300 #endif // V8_TARGET_ARCH_IA32 | 5300 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |