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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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-x87.h for its layout. | 92 // frames-x87.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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 Operand(ebp, StandardFrameConstants::kCallerSPOffset + offset)); | 311 Operand(ebp, StandardFrameConstants::kCallerSPOffset + offset)); |
312 __ push(edx); | 312 __ push(edx); |
313 __ push(Immediate(Smi::FromInt(num_parameters))); | 313 __ push(Immediate(Smi::FromInt(num_parameters))); |
314 // Arguments to ArgumentsAccessStub: | 314 // Arguments to ArgumentsAccessStub: |
315 // function, receiver address, parameter count. | 315 // function, receiver address, parameter count. |
316 // The stub will rewrite receiver and parameter count if the previous | 316 // The stub will rewrite receiver and parameter count if the previous |
317 // stack frame was an arguments adapter frame. | 317 // stack frame was an arguments adapter frame. |
318 ArgumentsAccessStub::Type type; | 318 ArgumentsAccessStub::Type type; |
319 if (is_strict(language_mode()) || !has_simple_parameters()) { | 319 if (is_strict(language_mode()) || !has_simple_parameters()) { |
320 type = ArgumentsAccessStub::NEW_STRICT; | 320 type = ArgumentsAccessStub::NEW_STRICT; |
321 } else if (function()->has_duplicate_parameters()) { | 321 } else if (literal()->has_duplicate_parameters()) { |
322 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; | 322 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; |
323 } else { | 323 } else { |
324 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; | 324 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; |
325 } | 325 } |
326 | 326 |
327 ArgumentsAccessStub stub(isolate(), type); | 327 ArgumentsAccessStub stub(isolate(), type); |
328 __ CallStub(&stub); | 328 __ CallStub(&stub); |
329 | 329 |
330 SetVar(arguments, eax, ebx, edx); | 330 SetVar(arguments, eax, ebx, edx); |
331 } | 331 } |
(...skipping 25 matching lines...) Expand all Loading... |
357 ExternalReference stack_limit | 357 ExternalReference stack_limit |
358 = ExternalReference::address_of_stack_limit(isolate()); | 358 = ExternalReference::address_of_stack_limit(isolate()); |
359 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 359 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
360 __ j(above_equal, &ok, Label::kNear); | 360 __ j(above_equal, &ok, Label::kNear); |
361 __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); | 361 __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); |
362 __ bind(&ok); | 362 __ bind(&ok); |
363 } | 363 } |
364 | 364 |
365 { Comment cmnt(masm_, "[ Body"); | 365 { Comment cmnt(masm_, "[ Body"); |
366 DCHECK(loop_depth() == 0); | 366 DCHECK(loop_depth() == 0); |
367 VisitStatements(function()->body()); | 367 VisitStatements(literal()->body()); |
368 DCHECK(loop_depth() == 0); | 368 DCHECK(loop_depth() == 0); |
369 } | 369 } |
370 } | 370 } |
371 | 371 |
372 // Always emit a 'return undefined' in case control fell off the end of | 372 // Always emit a 'return undefined' in case control fell off the end of |
373 // the body. | 373 // the body. |
374 { Comment cmnt(masm_, "[ return <undefined>;"); | 374 { Comment cmnt(masm_, "[ return <undefined>;"); |
375 __ mov(eax, isolate()->factory()->undefined_value()); | 375 __ mov(eax, isolate()->factory()->undefined_value()); |
376 EmitReturnSequence(); | 376 EmitReturnSequence(); |
377 } | 377 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 EmitProfilingCounterDecrement(weight); | 450 EmitProfilingCounterDecrement(weight); |
451 Label ok; | 451 Label ok; |
452 __ j(positive, &ok, Label::kNear); | 452 __ j(positive, &ok, Label::kNear); |
453 __ push(eax); | 453 __ push(eax); |
454 __ call(isolate()->builtins()->InterruptCheck(), | 454 __ call(isolate()->builtins()->InterruptCheck(), |
455 RelocInfo::CODE_TARGET); | 455 RelocInfo::CODE_TARGET); |
456 __ pop(eax); | 456 __ pop(eax); |
457 EmitProfilingCounterReset(); | 457 EmitProfilingCounterReset(); |
458 __ bind(&ok); | 458 __ bind(&ok); |
459 | 459 |
460 SetReturnPosition(function()); | 460 SetReturnPosition(literal()); |
461 int no_frame_start = masm_->pc_offset(); | 461 int no_frame_start = masm_->pc_offset(); |
462 __ leave(); | 462 __ leave(); |
463 | 463 |
464 int arg_count = info_->scope()->num_parameters() + 1; | 464 int arg_count = info_->scope()->num_parameters() + 1; |
465 int arguments_bytes = arg_count * kPointerSize; | 465 int arguments_bytes = arg_count * kPointerSize; |
466 __ Ret(arguments_bytes, ecx); | 466 __ Ret(arguments_bytes, ecx); |
467 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 467 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
468 } | 468 } |
469 } | 469 } |
470 | 470 |
(...skipping 4811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5282 Assembler::target_address_at(call_target_address, | 5282 Assembler::target_address_at(call_target_address, |
5283 unoptimized_code)); | 5283 unoptimized_code)); |
5284 return OSR_AFTER_STACK_CHECK; | 5284 return OSR_AFTER_STACK_CHECK; |
5285 } | 5285 } |
5286 | 5286 |
5287 | 5287 |
5288 } // namespace internal | 5288 } // namespace internal |
5289 } // namespace v8 | 5289 } // namespace v8 |
5290 | 5290 |
5291 #endif // V8_TARGET_ARCH_X87 | 5291 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |