| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 } | 746 } |
| 747 | 747 |
| 748 | 748 |
| 749 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { | 749 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { |
| 750 // The variable in the declaration always resides in the current context. | 750 // The variable in the declaration always resides in the current context. |
| 751 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); | 751 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); |
| 752 if (generate_debug_code_) { | 752 if (generate_debug_code_) { |
| 753 // Check that we're not inside a with or catch context. | 753 // Check that we're not inside a with or catch context. |
| 754 __ movq(rbx, FieldOperand(rsi, HeapObject::kMapOffset)); | 754 __ movq(rbx, FieldOperand(rsi, HeapObject::kMapOffset)); |
| 755 __ CompareRoot(rbx, Heap::kWithContextMapRootIndex); | 755 __ CompareRoot(rbx, Heap::kWithContextMapRootIndex); |
| 756 __ Check(not_equal, "Declaration in with context."); | 756 __ Check(not_equal, kDeclarationInWithContext); |
| 757 __ CompareRoot(rbx, Heap::kCatchContextMapRootIndex); | 757 __ CompareRoot(rbx, Heap::kCatchContextMapRootIndex); |
| 758 __ Check(not_equal, "Declaration in catch context."); | 758 __ Check(not_equal, kDeclarationInCatchContext); |
| 759 } | 759 } |
| 760 } | 760 } |
| 761 | 761 |
| 762 | 762 |
| 763 void FullCodeGenerator::VisitVariableDeclaration( | 763 void FullCodeGenerator::VisitVariableDeclaration( |
| 764 VariableDeclaration* declaration) { | 764 VariableDeclaration* declaration) { |
| 765 // If it was not possible to allocate the variable at compile time, we | 765 // If it was not possible to allocate the variable at compile time, we |
| 766 // need to "declare" it at runtime to make sure it actually exists in the | 766 // need to "declare" it at runtime to make sure it actually exists in the |
| 767 // local context. | 767 // local context. |
| 768 VariableProxy* proxy = declaration->proxy(); | 768 VariableProxy* proxy = declaration->proxy(); |
| (...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 __ subq(rdx, Immediate(1)); | 2185 __ subq(rdx, Immediate(1)); |
| 2186 __ j(carry, &call_resume); | 2186 __ j(carry, &call_resume); |
| 2187 __ push(rcx); | 2187 __ push(rcx); |
| 2188 __ jmp(&push_operand_holes); | 2188 __ jmp(&push_operand_holes); |
| 2189 __ bind(&call_resume); | 2189 __ bind(&call_resume); |
| 2190 __ push(rbx); | 2190 __ push(rbx); |
| 2191 __ push(result_register()); | 2191 __ push(result_register()); |
| 2192 __ Push(Smi::FromInt(resume_mode)); | 2192 __ Push(Smi::FromInt(resume_mode)); |
| 2193 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); | 2193 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); |
| 2194 // Not reached: the runtime call returns elsewhere. | 2194 // Not reached: the runtime call returns elsewhere. |
| 2195 __ Abort("Generator failed to resume."); | 2195 __ Abort(kGeneratorFailedToResume); |
| 2196 | 2196 |
| 2197 // Throw error if we attempt to operate on a running generator. | 2197 // Throw error if we attempt to operate on a running generator. |
| 2198 __ bind(&wrong_state); | 2198 __ bind(&wrong_state); |
| 2199 __ push(rbx); | 2199 __ push(rbx); |
| 2200 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); | 2200 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); |
| 2201 | 2201 |
| 2202 __ bind(&done); | 2202 __ bind(&done); |
| 2203 context()->Plug(result_register()); | 2203 context()->Plug(result_register()); |
| 2204 } | 2204 } |
| 2205 | 2205 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 | 2449 |
| 2450 } else if (!var->is_const_mode() || op == Token::INIT_CONST_HARMONY) { | 2450 } else if (!var->is_const_mode() || op == Token::INIT_CONST_HARMONY) { |
| 2451 // Assignment to var or initializing assignment to let/const | 2451 // Assignment to var or initializing assignment to let/const |
| 2452 // in harmony mode. | 2452 // in harmony mode. |
| 2453 if (var->IsStackAllocated() || var->IsContextSlot()) { | 2453 if (var->IsStackAllocated() || var->IsContextSlot()) { |
| 2454 MemOperand location = VarOperand(var, rcx); | 2454 MemOperand location = VarOperand(var, rcx); |
| 2455 if (generate_debug_code_ && op == Token::INIT_LET) { | 2455 if (generate_debug_code_ && op == Token::INIT_LET) { |
| 2456 // Check for an uninitialized let binding. | 2456 // Check for an uninitialized let binding. |
| 2457 __ movq(rdx, location); | 2457 __ movq(rdx, location); |
| 2458 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 2458 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); |
| 2459 __ Check(equal, "Let binding re-initialization."); | 2459 __ Check(equal, kLetBindingReInitialization); |
| 2460 } | 2460 } |
| 2461 // Perform the assignment. | 2461 // Perform the assignment. |
| 2462 __ movq(location, rax); | 2462 __ movq(location, rax); |
| 2463 if (var->IsContextSlot()) { | 2463 if (var->IsContextSlot()) { |
| 2464 __ movq(rdx, rax); | 2464 __ movq(rdx, rax); |
| 2465 __ RecordWriteContextSlot( | 2465 __ RecordWriteContextSlot( |
| 2466 rcx, Context::SlotOffset(var->index()), rdx, rbx, kDontSaveFPRegs); | 2466 rcx, Context::SlotOffset(var->index()), rdx, rbx, kDontSaveFPRegs); |
| 2467 } | 2467 } |
| 2468 } else { | 2468 } else { |
| 2469 ASSERT(var->IsLookupSlot()); | 2469 ASSERT(var->IsLookupSlot()); |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3391 __ CallRuntime(Runtime::kThrowNotDateError, 0); | 3391 __ CallRuntime(Runtime::kThrowNotDateError, 0); |
| 3392 __ bind(&done); | 3392 __ bind(&done); |
| 3393 context()->Plug(rax); | 3393 context()->Plug(rax); |
| 3394 } | 3394 } |
| 3395 | 3395 |
| 3396 | 3396 |
| 3397 void FullCodeGenerator::EmitSeqStringSetCharCheck(Register string, | 3397 void FullCodeGenerator::EmitSeqStringSetCharCheck(Register string, |
| 3398 Register index, | 3398 Register index, |
| 3399 Register value, | 3399 Register value, |
| 3400 uint32_t encoding_mask) { | 3400 uint32_t encoding_mask) { |
| 3401 __ Check(masm()->CheckSmi(index), "Non-smi index"); | 3401 __ Check(masm()->CheckSmi(index), kNonSmiIndex); |
| 3402 __ Check(masm()->CheckSmi(value), "Non-smi value"); | 3402 __ Check(masm()->CheckSmi(value), kNonSmiValue); |
| 3403 | 3403 |
| 3404 __ SmiCompare(index, FieldOperand(string, String::kLengthOffset)); | 3404 __ SmiCompare(index, FieldOperand(string, String::kLengthOffset)); |
| 3405 __ Check(less, "Index is too large"); | 3405 __ Check(less, kIndexIsTooLarge); |
| 3406 | 3406 |
| 3407 __ SmiCompare(index, Smi::FromInt(0)); | 3407 __ SmiCompare(index, Smi::FromInt(0)); |
| 3408 __ Check(greater_equal, "Index is negative"); | 3408 __ Check(greater_equal, kIndexIsNegative); |
| 3409 | 3409 |
| 3410 __ push(value); | 3410 __ push(value); |
| 3411 __ movq(value, FieldOperand(string, HeapObject::kMapOffset)); | 3411 __ movq(value, FieldOperand(string, HeapObject::kMapOffset)); |
| 3412 __ movzxbq(value, FieldOperand(value, Map::kInstanceTypeOffset)); | 3412 __ movzxbq(value, FieldOperand(value, Map::kInstanceTypeOffset)); |
| 3413 | 3413 |
| 3414 __ andb(value, Immediate(kStringRepresentationMask | kStringEncodingMask)); | 3414 __ andb(value, Immediate(kStringRepresentationMask | kStringEncodingMask)); |
| 3415 __ cmpq(value, Immediate(encoding_mask)); | 3415 __ cmpq(value, Immediate(encoding_mask)); |
| 3416 __ Check(equal, "Unexpected string type"); | 3416 __ Check(equal, kUnexpectedStringType); |
| 3417 __ pop(value); | 3417 __ pop(value); |
| 3418 } | 3418 } |
| 3419 | 3419 |
| 3420 | 3420 |
| 3421 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { | 3421 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { |
| 3422 ZoneList<Expression*>* args = expr->arguments(); | 3422 ZoneList<Expression*>* args = expr->arguments(); |
| 3423 ASSERT_EQ(3, args->length()); | 3423 ASSERT_EQ(3, args->length()); |
| 3424 | 3424 |
| 3425 Register string = rax; | 3425 Register string = rax; |
| 3426 Register index = rbx; | 3426 Register index = rbx; |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3770 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { | 3770 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { |
| 3771 ZoneList<Expression*>* args = expr->arguments(); | 3771 ZoneList<Expression*>* args = expr->arguments(); |
| 3772 ASSERT_EQ(2, args->length()); | 3772 ASSERT_EQ(2, args->length()); |
| 3773 | 3773 |
| 3774 ASSERT_NE(NULL, args->at(0)->AsLiteral()); | 3774 ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
| 3775 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->value()))->value(); | 3775 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->value()))->value(); |
| 3776 | 3776 |
| 3777 Handle<FixedArray> jsfunction_result_caches( | 3777 Handle<FixedArray> jsfunction_result_caches( |
| 3778 isolate()->native_context()->jsfunction_result_caches()); | 3778 isolate()->native_context()->jsfunction_result_caches()); |
| 3779 if (jsfunction_result_caches->length() <= cache_id) { | 3779 if (jsfunction_result_caches->length() <= cache_id) { |
| 3780 __ Abort("Attempt to use undefined cache."); | 3780 __ Abort(kAttemptToUseUndefinedCache); |
| 3781 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | 3781 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
| 3782 context()->Plug(rax); | 3782 context()->Plug(rax); |
| 3783 return; | 3783 return; |
| 3784 } | 3784 } |
| 3785 | 3785 |
| 3786 VisitForAccumulatorValue(args->at(1)); | 3786 VisitForAccumulatorValue(args->at(1)); |
| 3787 | 3787 |
| 3788 Register key = rax; | 3788 Register key = rax; |
| 3789 Register cache = rbx; | 3789 Register cache = rbx; |
| 3790 Register tmp = rcx; | 3790 Register tmp = rcx; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3964 | 3964 |
| 3965 // Check that all array elements are sequential ASCII strings, and | 3965 // Check that all array elements are sequential ASCII strings, and |
| 3966 // accumulate the sum of their lengths, as a smi-encoded value. | 3966 // accumulate the sum of their lengths, as a smi-encoded value. |
| 3967 __ Set(index, 0); | 3967 __ Set(index, 0); |
| 3968 __ Set(string_length, 0); | 3968 __ Set(string_length, 0); |
| 3969 // Loop condition: while (index < array_length). | 3969 // Loop condition: while (index < array_length). |
| 3970 // Live loop registers: index(int32), array_length(int32), string(String*), | 3970 // Live loop registers: index(int32), array_length(int32), string(String*), |
| 3971 // scratch, string_length(int32), elements(FixedArray*). | 3971 // scratch, string_length(int32), elements(FixedArray*). |
| 3972 if (generate_debug_code_) { | 3972 if (generate_debug_code_) { |
| 3973 __ cmpq(index, array_length); | 3973 __ cmpq(index, array_length); |
| 3974 __ Assert(below, "No empty arrays here in EmitFastAsciiArrayJoin"); | 3974 __ Assert(below, kNoEmptyArraysHereInEmitFastAsciiArrayJoin); |
| 3975 } | 3975 } |
| 3976 __ bind(&loop); | 3976 __ bind(&loop); |
| 3977 __ movq(string, FieldOperand(elements, | 3977 __ movq(string, FieldOperand(elements, |
| 3978 index, | 3978 index, |
| 3979 times_pointer_size, | 3979 times_pointer_size, |
| 3980 FixedArray::kHeaderSize)); | 3980 FixedArray::kHeaderSize)); |
| 3981 __ JumpIfSmi(string, &bailout); | 3981 __ JumpIfSmi(string, &bailout); |
| 3982 __ movq(scratch, FieldOperand(string, HeapObject::kMapOffset)); | 3982 __ movq(scratch, FieldOperand(string, HeapObject::kMapOffset)); |
| 3983 __ movzxbl(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); | 3983 __ movzxbl(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); |
| 3984 __ andb(scratch, Immediate( | 3984 __ andb(scratch, Immediate( |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4905 *context_length = 0; | 4905 *context_length = 0; |
| 4906 return previous_; | 4906 return previous_; |
| 4907 } | 4907 } |
| 4908 | 4908 |
| 4909 | 4909 |
| 4910 #undef __ | 4910 #undef __ |
| 4911 | 4911 |
| 4912 } } // namespace v8::internal | 4912 } } // namespace v8::internal |
| 4913 | 4913 |
| 4914 #endif // V8_TARGET_ARCH_X64 | 4914 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |