| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // The stub will rewrite receiver and parameter count if the previous | 257 // The stub will rewrite receiver and parameter count if the previous |
| 258 // stack frame was an arguments adapter frame. | 258 // stack frame was an arguments adapter frame. |
| 259 ArgumentsAccessStub::Type type; | 259 ArgumentsAccessStub::Type type; |
| 260 if (is_strict(language_mode())) { | 260 if (is_strict(language_mode())) { |
| 261 type = ArgumentsAccessStub::NEW_STRICT; | 261 type = ArgumentsAccessStub::NEW_STRICT; |
| 262 } else if (function()->has_duplicate_parameters()) { | 262 } else if (function()->has_duplicate_parameters()) { |
| 263 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; | 263 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; |
| 264 } else { | 264 } else { |
| 265 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; | 265 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; |
| 266 } | 266 } |
| 267 ArgumentsAccessStub::HasNewTarget has_new_target = | 267 ArgumentsAccessStub stub(isolate(), type); |
| 268 IsSubclassConstructor(info->function()->kind()) | |
| 269 ? ArgumentsAccessStub::HAS_NEW_TARGET | |
| 270 : ArgumentsAccessStub::NO_NEW_TARGET; | |
| 271 ArgumentsAccessStub stub(isolate(), type, has_new_target); | |
| 272 __ CallStub(&stub); | 268 __ CallStub(&stub); |
| 273 | 269 |
| 274 SetVar(arguments, eax, ebx, edx); | 270 SetVar(arguments, eax, ebx, edx); |
| 275 } | 271 } |
| 276 | 272 |
| 277 if (FLAG_trace) { | 273 if (FLAG_trace) { |
| 278 __ CallRuntime(Runtime::kTraceEnter, 0); | 274 __ CallRuntime(Runtime::kTraceEnter, 0); |
| 279 } | 275 } |
| 280 | 276 |
| 281 // Visit the declarations and body unless there is an illegal | 277 // Visit the declarations and body unless there is an illegal |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 masm_->bind(&check_exit_codesize); | 406 masm_->bind(&check_exit_codesize); |
| 411 #endif | 407 #endif |
| 412 SetSourcePosition(function()->end_position() - 1); | 408 SetSourcePosition(function()->end_position() - 1); |
| 413 __ RecordJSReturn(); | 409 __ RecordJSReturn(); |
| 414 // Do not use the leave instruction here because it is too short to | 410 // Do not use the leave instruction here because it is too short to |
| 415 // patch with the code required by the debugger. | 411 // patch with the code required by the debugger. |
| 416 __ mov(esp, ebp); | 412 __ mov(esp, ebp); |
| 417 int no_frame_start = masm_->pc_offset(); | 413 int no_frame_start = masm_->pc_offset(); |
| 418 __ pop(ebp); | 414 __ pop(ebp); |
| 419 | 415 |
| 420 int arg_count = info_->scope()->num_parameters() + 1; | 416 int arguments_bytes = (info_->scope()->num_parameters() + 1) * kPointerSize; |
| 421 if (FLAG_experimental_classes && | |
| 422 IsSubclassConstructor(info_->function()->kind())) { | |
| 423 arg_count++; | |
| 424 } | |
| 425 int arguments_bytes = arg_count * kPointerSize; | |
| 426 __ Ret(arguments_bytes, ecx); | 417 __ Ret(arguments_bytes, ecx); |
| 427 // Check that the size of the code used for returning is large enough | 418 // Check that the size of the code used for returning is large enough |
| 428 // for the debugger's requirements. | 419 // for the debugger's requirements. |
| 429 DCHECK(Assembler::kJSReturnSequenceLength <= | 420 DCHECK(Assembler::kJSReturnSequenceLength <= |
| 430 masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); | 421 masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); |
| 431 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 422 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
| 432 } | 423 } |
| 433 } | 424 } |
| 434 | 425 |
| 435 | 426 |
| (...skipping 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3139 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); | 3130 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); |
| 3140 | 3131 |
| 3141 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 3132 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
| 3142 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3133 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3143 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3134 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
| 3144 context()->Plug(eax); | 3135 context()->Plug(eax); |
| 3145 } | 3136 } |
| 3146 | 3137 |
| 3147 | 3138 |
| 3148 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 3139 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
| 3149 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | |
| 3150 GetVar(eax, new_target_var); | |
| 3151 __ push(eax); | |
| 3152 | |
| 3153 SuperReference* super_ref = expr->expression()->AsSuperReference(); | 3140 SuperReference* super_ref = expr->expression()->AsSuperReference(); |
| 3154 EmitLoadSuperConstructor(super_ref); | 3141 EmitLoadSuperConstructor(super_ref); |
| 3155 __ push(result_register()); | 3142 __ push(result_register()); |
| 3156 | 3143 |
| 3157 Variable* this_var = super_ref->this_var()->var(); | 3144 Variable* this_var = super_ref->this_var()->var(); |
| 3158 GetVar(eax, this_var); | 3145 GetVar(eax, this_var); |
| 3159 __ cmp(eax, isolate()->factory()->the_hole_value()); | 3146 __ cmp(eax, isolate()->factory()->the_hole_value()); |
| 3160 Label uninitialized_this; | 3147 Label uninitialized_this; |
| 3161 __ j(equal, &uninitialized_this); | 3148 __ j(equal, &uninitialized_this); |
| 3162 __ push(Immediate(this_var->name())); | 3149 __ push(Immediate(this_var->name())); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3184 /* TODO(dslomov): support pretenuring. | 3171 /* TODO(dslomov): support pretenuring. |
| 3185 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3172 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
| 3186 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == | 3173 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
| 3187 expr->CallNewFeedbackSlot().ToInt() + 1); | 3174 expr->CallNewFeedbackSlot().ToInt() + 1); |
| 3188 */ | 3175 */ |
| 3189 } | 3176 } |
| 3190 | 3177 |
| 3191 __ LoadHeapObject(ebx, FeedbackVector()); | 3178 __ LoadHeapObject(ebx, FeedbackVector()); |
| 3192 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); | 3179 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); |
| 3193 | 3180 |
| 3194 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); | 3181 // TODO(dslomov): use a different stub and propagate new.target. |
| 3182 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
| 3195 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3183 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3196 | 3184 |
| 3197 __ Drop(1); | |
| 3198 | |
| 3199 RecordJSReturnSite(expr); | 3185 RecordJSReturnSite(expr); |
| 3200 | 3186 |
| 3201 EmitVariableAssignment(this_var, Token::INIT_CONST); | 3187 EmitVariableAssignment(this_var, Token::INIT_CONST); |
| 3202 context()->Plug(eax); | 3188 context()->Plug(eax); |
| 3203 } | 3189 } |
| 3204 | 3190 |
| 3205 | 3191 |
| 3206 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3192 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| 3207 ZoneList<Expression*>* args = expr->arguments(); | 3193 ZoneList<Expression*>* args = expr->arguments(); |
| 3208 DCHECK(args->length() == 1); | 3194 DCHECK(args->length() == 1); |
| (...skipping 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5306 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5292 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 5307 Assembler::target_address_at(call_target_address, | 5293 Assembler::target_address_at(call_target_address, |
| 5308 unoptimized_code)); | 5294 unoptimized_code)); |
| 5309 return OSR_AFTER_STACK_CHECK; | 5295 return OSR_AFTER_STACK_CHECK; |
| 5310 } | 5296 } |
| 5311 | 5297 |
| 5312 | 5298 |
| 5313 } } // namespace v8::internal | 5299 } } // namespace v8::internal |
| 5314 | 5300 |
| 5315 #endif // V8_TARGET_ARCH_IA32 | 5301 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |