| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 783 |
| 784 | 784 |
| 785 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { | 785 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { |
| 786 // The variable in the declaration always resides in the current function | 786 // The variable in the declaration always resides in the current function |
| 787 // context. | 787 // context. |
| 788 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); | 788 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); |
| 789 if (generate_debug_code_) { | 789 if (generate_debug_code_) { |
| 790 // Check that we're not inside a with or catch context. | 790 // Check that we're not inside a with or catch context. |
| 791 __ Ldr(x1, FieldMemOperand(cp, HeapObject::kMapOffset)); | 791 __ Ldr(x1, FieldMemOperand(cp, HeapObject::kMapOffset)); |
| 792 __ CompareRoot(x1, Heap::kWithContextMapRootIndex); | 792 __ CompareRoot(x1, Heap::kWithContextMapRootIndex); |
| 793 __ Check(ne, "Declaration in with context."); | 793 __ Check(ne, kDeclarationInWithContext); |
| 794 __ CompareRoot(x1, Heap::kCatchContextMapRootIndex); | 794 __ CompareRoot(x1, Heap::kCatchContextMapRootIndex); |
| 795 __ Check(ne, "Declaration in catch context."); | 795 __ Check(ne, kDeclarationInCatchContext); |
| 796 } | 796 } |
| 797 } | 797 } |
| 798 | 798 |
| 799 | 799 |
| 800 void FullCodeGenerator::VisitVariableDeclaration( | 800 void FullCodeGenerator::VisitVariableDeclaration( |
| 801 VariableDeclaration* declaration) { | 801 VariableDeclaration* declaration) { |
| 802 // If it was not possible to allocate the variable at compile time, we | 802 // If it was not possible to allocate the variable at compile time, we |
| 803 // need to "declare" it at runtime to make sure it actually exists in the | 803 // need to "declare" it at runtime to make sure it actually exists in the |
| 804 // local context. | 804 // local context. |
| 805 VariableProxy* proxy = declaration->proxy(); | 805 VariableProxy* proxy = declaration->proxy(); |
| (...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2232 } | 2232 } |
| 2233 | 2233 |
| 2234 } else if (!var->is_const_mode() || op == Token::INIT_CONST_HARMONY) { | 2234 } else if (!var->is_const_mode() || op == Token::INIT_CONST_HARMONY) { |
| 2235 // Assignment to var or initializing assignment to let/const | 2235 // Assignment to var or initializing assignment to let/const |
| 2236 // in harmony mode. | 2236 // in harmony mode. |
| 2237 if (var->IsStackAllocated() || var->IsContextSlot()) { | 2237 if (var->IsStackAllocated() || var->IsContextSlot()) { |
| 2238 MemOperand location = VarOperand(var, x1); | 2238 MemOperand location = VarOperand(var, x1); |
| 2239 if (FLAG_debug_code && op == Token::INIT_LET) { | 2239 if (FLAG_debug_code && op == Token::INIT_LET) { |
| 2240 __ Ldr(x10, location); | 2240 __ Ldr(x10, location); |
| 2241 __ CompareRoot(x10, Heap::kTheHoleValueRootIndex); | 2241 __ CompareRoot(x10, Heap::kTheHoleValueRootIndex); |
| 2242 __ Check(eq, "Let binding re-initialization."); | 2242 __ Check(eq, kLetBindingReInitialization); |
| 2243 } | 2243 } |
| 2244 // Perform the assignment. | 2244 // Perform the assignment. |
| 2245 __ Str(x0, location); | 2245 __ Str(x0, location); |
| 2246 if (var->IsContextSlot()) { | 2246 if (var->IsContextSlot()) { |
| 2247 __ Mov(x10, x0); | 2247 __ Mov(x10, x0); |
| 2248 int offset = Context::SlotOffset(var->index()); | 2248 int offset = Context::SlotOffset(var->index()); |
| 2249 __ RecordWriteContextSlot( | 2249 __ RecordWriteContextSlot( |
| 2250 x1, offset, x10, x11, kLRHasBeenSaved, kDontSaveFPRegs); | 2250 x1, offset, x10, x11, kLRHasBeenSaved, kDontSaveFPRegs); |
| 2251 } | 2251 } |
| 2252 } else { | 2252 } else { |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3216 | 3216 |
| 3217 | 3217 |
| 3218 void FullCodeGenerator::EmitSeqStringSetCharCheck(Register string, | 3218 void FullCodeGenerator::EmitSeqStringSetCharCheck(Register string, |
| 3219 Register index, | 3219 Register index, |
| 3220 Register value, | 3220 Register value, |
| 3221 uint32_t encoding_mask) { | 3221 uint32_t encoding_mask) { |
| 3222 // TODO(jbramley): Use a safer scratch register. | 3222 // TODO(jbramley): Use a safer scratch register. |
| 3223 Register scratch = __ Tmp1(); | 3223 Register scratch = __ Tmp1(); |
| 3224 ASSERT(!AreAliased(string, index, value, scratch)); | 3224 ASSERT(!AreAliased(string, index, value, scratch)); |
| 3225 | 3225 |
| 3226 __ AssertSmi(index, "Non-smi index"); | 3226 __ AssertSmi(index); |
| 3227 __ AssertSmi(value, "Non-smi value"); | 3227 __ AssertSmi(value); |
| 3228 | 3228 |
| 3229 __ Ldr(scratch, FieldMemOperand(string, String::kLengthOffset)); | 3229 __ Ldr(scratch, FieldMemOperand(string, String::kLengthOffset)); |
| 3230 __ Cmp(index, scratch); | 3230 __ Cmp(index, scratch); |
| 3231 __ Check(lt, "Index is too large"); | 3231 __ Check(lt, kIndexIsTooLarge); |
| 3232 | 3232 |
| 3233 __ Cmp(index, Operand(Smi::FromInt(0))); | 3233 __ Cmp(index, Operand(Smi::FromInt(0))); |
| 3234 __ Check(ge, "Index is negative"); | 3234 __ Check(ge, kIndexIsNegative); |
| 3235 | 3235 |
| 3236 __ Ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset)); | 3236 __ Ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 3237 __ Ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | 3237 __ Ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); |
| 3238 __ And(scratch, scratch, kStringRepresentationMask | kStringEncodingMask); | 3238 __ And(scratch, scratch, kStringRepresentationMask | kStringEncodingMask); |
| 3239 | 3239 |
| 3240 __ Cmp(scratch, encoding_mask); | 3240 __ Cmp(scratch, encoding_mask); |
| 3241 __ Check(eq, "Unexpected string type"); | 3241 __ Check(eq, kUnexpectedStringType); |
| 3242 } | 3242 } |
| 3243 | 3243 |
| 3244 | 3244 |
| 3245 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { | 3245 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { |
| 3246 ZoneList<Expression*>* args = expr->arguments(); | 3246 ZoneList<Expression*>* args = expr->arguments(); |
| 3247 ASSERT_EQ(3, args->length()); | 3247 ASSERT_EQ(3, args->length()); |
| 3248 | 3248 |
| 3249 Register string = x0; | 3249 Register string = x0; |
| 3250 Register index = x1; | 3250 Register index = x1; |
| 3251 Register value = x2; | 3251 Register value = x2; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3594 | 3594 |
| 3595 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { | 3595 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { |
| 3596 ZoneList<Expression*>* args = expr->arguments(); | 3596 ZoneList<Expression*>* args = expr->arguments(); |
| 3597 ASSERT_EQ(2, args->length()); | 3597 ASSERT_EQ(2, args->length()); |
| 3598 ASSERT_NE(NULL, args->at(0)->AsLiteral()); | 3598 ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
| 3599 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->value()))->value(); | 3599 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->value()))->value(); |
| 3600 | 3600 |
| 3601 Handle<FixedArray> jsfunction_result_caches( | 3601 Handle<FixedArray> jsfunction_result_caches( |
| 3602 isolate()->native_context()->jsfunction_result_caches()); | 3602 isolate()->native_context()->jsfunction_result_caches()); |
| 3603 if (jsfunction_result_caches->length() <= cache_id) { | 3603 if (jsfunction_result_caches->length() <= cache_id) { |
| 3604 __ Abort("Attempt to use undefined cache."); | 3604 __ Abort(kAttemptToUseUndefinedCache); |
| 3605 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex); | 3605 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex); |
| 3606 context()->Plug(x0); | 3606 context()->Plug(x0); |
| 3607 return; | 3607 return; |
| 3608 } | 3608 } |
| 3609 | 3609 |
| 3610 VisitForAccumulatorValue(args->at(1)); | 3610 VisitForAccumulatorValue(args->at(1)); |
| 3611 | 3611 |
| 3612 Register key = x0; | 3612 Register key = x0; |
| 3613 Register cache = x1; | 3613 Register cache = x1; |
| 3614 __ Ldr(cache, GlobalObjectMemOperand()); | 3614 __ Ldr(cache, GlobalObjectMemOperand()); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3784 // Loop condition: while (element < elements_end). | 3784 // Loop condition: while (element < elements_end). |
| 3785 // Live values in registers: | 3785 // Live values in registers: |
| 3786 // elements: Fixed array of strings. | 3786 // elements: Fixed array of strings. |
| 3787 // array_length: Length of the fixed array of strings (not smi) | 3787 // array_length: Length of the fixed array of strings (not smi) |
| 3788 // separator: Separator string | 3788 // separator: Separator string |
| 3789 // string_length: Accumulated sum of string lengths (not smi). | 3789 // string_length: Accumulated sum of string lengths (not smi). |
| 3790 // element: Current array element. | 3790 // element: Current array element. |
| 3791 // elements_end: Array end. | 3791 // elements_end: Array end. |
| 3792 if (FLAG_debug_code) { | 3792 if (FLAG_debug_code) { |
| 3793 __ Cmp(array_length, Operand(0)); | 3793 __ Cmp(array_length, Operand(0)); |
| 3794 __ Assert(gt, "No empty arrays here in EmitFastAsciiArrayJoin"); | 3794 __ Assert(gt, kNoEmptyArraysHereInEmitFastAsciiArrayJoin); |
| 3795 } | 3795 } |
| 3796 __ Bind(&loop); | 3796 __ Bind(&loop); |
| 3797 __ Ldr(string, MemOperand(element, kPointerSize, PostIndex)); | 3797 __ Ldr(string, MemOperand(element, kPointerSize, PostIndex)); |
| 3798 __ JumpIfSmi(string, &bailout); | 3798 __ JumpIfSmi(string, &bailout); |
| 3799 __ Ldr(scratch1, FieldMemOperand(string, HeapObject::kMapOffset)); | 3799 __ Ldr(scratch1, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 3800 __ Ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); | 3800 __ Ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); |
| 3801 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); | 3801 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); |
| 3802 __ Ldrsw(scratch1, | 3802 __ Ldrsw(scratch1, |
| 3803 UntagSmiFieldMemOperand(string, SeqOneByteString::kLengthOffset)); | 3803 UntagSmiFieldMemOperand(string, SeqOneByteString::kLengthOffset)); |
| 3804 __ Adds(string_length, string_length, scratch1); | 3804 __ Adds(string_length, string_length, scratch1); |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4994 return previous_; | 4994 return previous_; |
| 4995 } | 4995 } |
| 4996 | 4996 |
| 4997 | 4997 |
| 4998 #undef __ | 4998 #undef __ |
| 4999 | 4999 |
| 5000 | 5000 |
| 5001 } } // namespace v8::internal | 5001 } } // namespace v8::internal |
| 5002 | 5002 |
| 5003 #endif // V8_TARGET_ARCH_A64 | 5003 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |