| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // Add a label for checking the size of the code used for returning. | 303 // Add a label for checking the size of the code used for returning. |
| 304 Label check_exit_codesize; | 304 Label check_exit_codesize; |
| 305 masm_->bind(&check_exit_codesize); | 305 masm_->bind(&check_exit_codesize); |
| 306 #endif | 306 #endif |
| 307 SetSourcePosition(function()->end_position() - 1); | 307 SetSourcePosition(function()->end_position() - 1); |
| 308 __ RecordJSReturn(); | 308 __ RecordJSReturn(); |
| 309 // Do not use the leave instruction here because it is too short to | 309 // Do not use the leave instruction here because it is too short to |
| 310 // patch with the code required by the debugger. | 310 // patch with the code required by the debugger. |
| 311 __ mov(esp, ebp); | 311 __ mov(esp, ebp); |
| 312 __ pop(ebp); | 312 __ pop(ebp); |
| 313 __ ret((scope()->num_parameters() + 1) * kPointerSize); | 313 |
| 314 int arguments_bytes = (scope()->num_parameters() + 1) * kPointerSize; |
| 315 __ Ret(arguments_bytes, ecx); |
| 314 #ifdef ENABLE_DEBUGGER_SUPPORT | 316 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 315 // Check that the size of the code used for returning matches what is | 317 // Check that the size of the code used for returning is large enough |
| 316 // expected by the debugger. | 318 // for the debugger's requirements. |
| 317 ASSERT_EQ(Assembler::kJSReturnSequenceLength, | 319 ASSERT(Assembler::kJSReturnSequenceLength <= |
| 318 masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); | 320 masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); |
| 319 #endif | 321 #endif |
| 320 } | 322 } |
| 321 } | 323 } |
| 322 | 324 |
| 323 | 325 |
| 324 FullCodeGenerator::ConstantOperand FullCodeGenerator::GetConstantOperand( | 326 FullCodeGenerator::ConstantOperand FullCodeGenerator::GetConstantOperand( |
| 325 Token::Value op, Expression* left, Expression* right) { | 327 Token::Value op, Expression* left, Expression* right) { |
| 326 ASSERT(ShouldInlineSmiCase(op)); | 328 ASSERT(ShouldInlineSmiCase(op)); |
| 327 if (op == Token::DIV || op == Token::MOD || op == Token::MUL) { | 329 if (op == Token::DIV || op == Token::MOD || op == Token::MUL) { |
| 328 // We never generate inlined constant smi operations for these. | 330 // We never generate inlined constant smi operations for these. |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 __ push(Immediate(Smi::FromInt(0))); // No initial value! | 712 __ push(Immediate(Smi::FromInt(0))); // No initial value! |
| 711 } | 713 } |
| 712 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 714 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
| 713 break; | 715 break; |
| 714 } | 716 } |
| 715 } | 717 } |
| 716 | 718 |
| 717 } else if (prop != NULL) { | 719 } else if (prop != NULL) { |
| 718 if (function != NULL || mode == Variable::CONST) { | 720 if (function != NULL || mode == Variable::CONST) { |
| 719 // We are declaring a function or constant that rewrites to a | 721 // We are declaring a function or constant that rewrites to a |
| 720 // property. Use (keyed) IC to set the initial value. | 722 // property. Use (keyed) IC to set the initial value. We cannot |
| 721 VisitForStackValue(prop->obj()); | 723 // visit the rewrite because it's shared and we risk recording |
| 724 // duplicate AST IDs for bailouts from optimized code. |
| 725 ASSERT(prop->obj()->AsVariableProxy() != NULL); |
| 726 { AccumulatorValueContext for_object(this); |
| 727 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); |
| 728 } |
| 729 |
| 722 if (function != NULL) { | 730 if (function != NULL) { |
| 723 VisitForStackValue(prop->key()); | 731 __ push(eax); |
| 724 VisitForAccumulatorValue(function); | 732 VisitForAccumulatorValue(function); |
| 725 __ pop(ecx); | 733 __ pop(edx); |
| 726 } else { | 734 } else { |
| 727 VisitForAccumulatorValue(prop->key()); | 735 __ mov(edx, eax); |
| 728 __ mov(ecx, result_register()); | 736 __ mov(eax, Factory::the_hole_value()); |
| 729 __ mov(result_register(), Factory::the_hole_value()); | |
| 730 } | 737 } |
| 731 __ pop(edx); | 738 ASSERT(prop->key()->AsLiteral() != NULL && |
| 739 prop->key()->AsLiteral()->handle()->IsSmi()); |
| 740 __ Set(ecx, Immediate(prop->key()->AsLiteral()->handle())); |
| 732 | 741 |
| 733 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | 742 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); |
| 734 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 743 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
| 735 } | 744 } |
| 736 } | 745 } |
| 737 } | 746 } |
| 738 | 747 |
| 739 | 748 |
| 740 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { | 749 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { |
| 741 EmitDeclaration(decl->proxy()->var(), decl->mode(), decl->fun()); | 750 EmitDeclaration(decl->proxy()->var(), decl->mode(), decl->fun()); |
| (...skipping 3200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3942 __ add(Operand(eax), Immediate(Smi::FromInt(1))); | 3951 __ add(Operand(eax), Immediate(Smi::FromInt(1))); |
| 3943 } | 3952 } |
| 3944 } | 3953 } |
| 3945 | 3954 |
| 3946 // Record position before stub call. | 3955 // Record position before stub call. |
| 3947 SetSourcePosition(expr->position()); | 3956 SetSourcePosition(expr->position()); |
| 3948 | 3957 |
| 3949 // Call stub for +1/-1. | 3958 // Call stub for +1/-1. |
| 3950 __ mov(edx, eax); | 3959 __ mov(edx, eax); |
| 3951 __ mov(eax, Immediate(Smi::FromInt(1))); | 3960 __ mov(eax, Immediate(Smi::FromInt(1))); |
| 3952 TypeRecordingBinaryOpStub stub(expr->binary_op(), | 3961 TypeRecordingBinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); |
| 3953 NO_OVERWRITE); | |
| 3954 EmitCallIC(stub.GetCode(), &patch_site); | 3962 EmitCallIC(stub.GetCode(), &patch_site); |
| 3955 __ bind(&done); | 3963 __ bind(&done); |
| 3956 | 3964 |
| 3957 // Store the value returned in eax. | 3965 // Store the value returned in eax. |
| 3958 switch (assign_type) { | 3966 switch (assign_type) { |
| 3959 case VARIABLE: | 3967 case VARIABLE: |
| 3960 if (expr->is_postfix()) { | 3968 if (expr->is_postfix()) { |
| 3961 // Perform the assignment as if via '='. | 3969 // Perform the assignment as if via '='. |
| 3962 { EffectContext context(this); | 3970 { EffectContext context(this); |
| 3963 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3971 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4393 // And return. | 4401 // And return. |
| 4394 __ ret(0); | 4402 __ ret(0); |
| 4395 } | 4403 } |
| 4396 | 4404 |
| 4397 | 4405 |
| 4398 #undef __ | 4406 #undef __ |
| 4399 | 4407 |
| 4400 } } // namespace v8::internal | 4408 } } // namespace v8::internal |
| 4401 | 4409 |
| 4402 #endif // V8_TARGET_ARCH_IA32 | 4410 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |