Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 110573004: Merge bleeding_edge 17696:18016. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 int token_offset = Context::kHeaderSize + 1405 int token_offset = Context::kHeaderSize +
1406 Context::SECURITY_TOKEN_INDEX * kPointerSize; 1406 Context::SECURITY_TOKEN_INDEX * kPointerSize;
1407 mov(scratch1, FieldOperand(scratch1, token_offset)); 1407 mov(scratch1, FieldOperand(scratch1, token_offset));
1408 cmp(scratch1, FieldOperand(scratch2, token_offset)); 1408 cmp(scratch1, FieldOperand(scratch2, token_offset));
1409 j(not_equal, miss); 1409 j(not_equal, miss);
1410 1410
1411 bind(&same_contexts); 1411 bind(&same_contexts);
1412 } 1412 }
1413 1413
1414 1414
1415 // Compute the hash code from the untagged key. This must be kept in sync 1415 // Compute the hash code from the untagged key. This must be kept in sync with
1416 // with ComputeIntegerHash in utils.h. 1416 // ComputeIntegerHash in utils.h and KeyedLoadGenericElementStub in
1417 // code-stub-hydrogen.cc
1417 // 1418 //
1418 // Note: r0 will contain hash code 1419 // Note: r0 will contain hash code
1419 void MacroAssembler::GetNumberHash(Register r0, Register scratch) { 1420 void MacroAssembler::GetNumberHash(Register r0, Register scratch) {
1420 // Xor original key with a seed. 1421 // Xor original key with a seed.
1421 if (Serializer::enabled()) { 1422 if (Serializer::enabled()) {
1422 ExternalReference roots_array_start = 1423 ExternalReference roots_array_start =
1423 ExternalReference::roots_array_start(isolate()); 1424 ExternalReference::roots_array_start(isolate());
1424 mov(scratch, Immediate(Heap::kHashSeedRootIndex)); 1425 mov(scratch, Immediate(Heap::kHashSeedRootIndex));
1425 mov(scratch, 1426 mov(scratch,
1426 Operand::StaticArray(scratch, times_pointer_size, roots_array_start)); 1427 Operand::StaticArray(scratch, times_pointer_size, roots_array_start));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 Label done; 1483 Label done;
1483 1484
1484 GetNumberHash(r0, r1); 1485 GetNumberHash(r0, r1);
1485 1486
1486 // Compute capacity mask. 1487 // Compute capacity mask.
1487 mov(r1, FieldOperand(elements, SeededNumberDictionary::kCapacityOffset)); 1488 mov(r1, FieldOperand(elements, SeededNumberDictionary::kCapacityOffset));
1488 shr(r1, kSmiTagSize); // convert smi to int 1489 shr(r1, kSmiTagSize); // convert smi to int
1489 dec(r1); 1490 dec(r1);
1490 1491
1491 // Generate an unrolled loop that performs a few probes before giving up. 1492 // Generate an unrolled loop that performs a few probes before giving up.
1492 const int kProbes = 4; 1493 for (int i = 0; i < kNumberDictionaryProbes; i++) {
1493 for (int i = 0; i < kProbes; i++) {
1494 // Use r2 for index calculations and keep the hash intact in r0. 1494 // Use r2 for index calculations and keep the hash intact in r0.
1495 mov(r2, r0); 1495 mov(r2, r0);
1496 // Compute the masked index: (hash + i + i * i) & mask. 1496 // Compute the masked index: (hash + i + i * i) & mask.
1497 if (i > 0) { 1497 if (i > 0) {
1498 add(r2, Immediate(SeededNumberDictionary::GetProbeOffset(i))); 1498 add(r2, Immediate(SeededNumberDictionary::GetProbeOffset(i)));
1499 } 1499 }
1500 and_(r2, r1); 1500 and_(r2, r1);
1501 1501
1502 // Scale the index by multiplying by the entry size. 1502 // Scale the index by multiplying by the entry size.
1503 ASSERT(SeededNumberDictionary::kEntrySize == 3); 1503 ASSERT(SeededNumberDictionary::kEntrySize == 3);
1504 lea(r2, Operand(r2, r2, times_2, 0)); // r2 = r2 * 3 1504 lea(r2, Operand(r2, r2, times_2, 0)); // r2 = r2 * 3
1505 1505
1506 // Check if the key matches. 1506 // Check if the key matches.
1507 cmp(key, FieldOperand(elements, 1507 cmp(key, FieldOperand(elements,
1508 r2, 1508 r2,
1509 times_pointer_size, 1509 times_pointer_size,
1510 SeededNumberDictionary::kElementsStartOffset)); 1510 SeededNumberDictionary::kElementsStartOffset));
1511 if (i != (kProbes - 1)) { 1511 if (i != (kNumberDictionaryProbes - 1)) {
1512 j(equal, &done); 1512 j(equal, &done);
1513 } else { 1513 } else {
1514 j(not_equal, miss); 1514 j(not_equal, miss);
1515 } 1515 }
1516 } 1516 }
1517 1517
1518 bind(&done); 1518 bind(&done);
1519 // Check that the value is a normal propety. 1519 // Check that the value is a normal propety.
1520 const int kDetailsOffset = 1520 const int kDetailsOffset =
1521 SeededNumberDictionary::kElementsStartOffset + 2 * kPointerSize; 1521 SeededNumberDictionary::kElementsStartOffset + 2 * kPointerSize;
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 FrameScope scope(this, StackFrame::NONE); 3058 FrameScope scope(this, StackFrame::NONE);
3059 CallRuntime(Runtime::kAbort, 2); 3059 CallRuntime(Runtime::kAbort, 2);
3060 } else { 3060 } else {
3061 CallRuntime(Runtime::kAbort, 2); 3061 CallRuntime(Runtime::kAbort, 2);
3062 } 3062 }
3063 // will not return here 3063 // will not return here
3064 int3(); 3064 int3();
3065 } 3065 }
3066 3066
3067 3067
3068 void MacroAssembler::Throw(BailoutReason reason) {
3069 #ifdef DEBUG
3070 const char* msg = GetBailoutReason(reason);
3071 if (msg != NULL) {
3072 RecordComment("Throw message: ");
3073 RecordComment(msg);
3074 }
3075 #endif
3076
3077 push(eax);
3078 push(Immediate(Smi::FromInt(reason)));
3079 // Disable stub call restrictions to always allow calls to throw.
3080 if (!has_frame_) {
3081 // We don't actually want to generate a pile of code for this, so just
3082 // claim there is a stack frame, without generating one.
3083 FrameScope scope(this, StackFrame::NONE);
3084 CallRuntime(Runtime::kThrowMessage, 1);
3085 } else {
3086 CallRuntime(Runtime::kThrowMessage, 1);
3087 }
3088 // will not return here
3089 int3();
3090 }
3091
3092
3093 void MacroAssembler::ThrowIf(Condition cc, BailoutReason reason) {
3094 Label L;
3095 j(NegateCondition(cc), &L);
3096 Throw(reason);
3097 // will not return here
3098 bind(&L);
3099 }
3100
3101
3068 void MacroAssembler::LoadInstanceDescriptors(Register map, 3102 void MacroAssembler::LoadInstanceDescriptors(Register map,
3069 Register descriptors) { 3103 Register descriptors) {
3070 mov(descriptors, FieldOperand(map, Map::kDescriptorsOffset)); 3104 mov(descriptors, FieldOperand(map, Map::kDescriptorsOffset));
3071 } 3105 }
3072 3106
3073 3107
3074 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) { 3108 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) {
3075 mov(dst, FieldOperand(map, Map::kBitField3Offset)); 3109 mov(dst, FieldOperand(map, Map::kBitField3Offset));
3076 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst); 3110 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst);
3077 } 3111 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3223 Label succeed; 3257 Label succeed;
3224 test(operand, Immediate(kIsNotStringMask | kIsNotInternalizedMask)); 3258 test(operand, Immediate(kIsNotStringMask | kIsNotInternalizedMask));
3225 j(zero, &succeed); 3259 j(zero, &succeed);
3226 cmpb(operand, static_cast<uint8_t>(SYMBOL_TYPE)); 3260 cmpb(operand, static_cast<uint8_t>(SYMBOL_TYPE));
3227 j(not_equal, not_unique_name, distance); 3261 j(not_equal, not_unique_name, distance);
3228 3262
3229 bind(&succeed); 3263 bind(&succeed);
3230 } 3264 }
3231 3265
3232 3266
3267 void MacroAssembler::EmitSeqStringSetCharCheck(Register string,
3268 Register index,
3269 Register value,
3270 uint32_t encoding_mask) {
3271 Label is_object;
3272 JumpIfNotSmi(string, &is_object, Label::kNear);
3273 Throw(kNonObject);
3274 bind(&is_object);
3275
3276 push(value);
3277 mov(value, FieldOperand(string, HeapObject::kMapOffset));
3278 movzx_b(value, FieldOperand(value, Map::kInstanceTypeOffset));
3279
3280 and_(value, Immediate(kStringRepresentationMask | kStringEncodingMask));
3281 cmp(value, Immediate(encoding_mask));
3282 pop(value);
3283 ThrowIf(not_equal, kUnexpectedStringType);
3284
3285 // The index is assumed to be untagged coming in, tag it to compare with the
3286 // string length without using a temp register, it is restored at the end of
3287 // this function.
3288 SmiTag(index);
3289 // Can't use overflow here directly, compiler can't seem to disambiguate.
3290 ThrowIf(NegateCondition(no_overflow), kIndexIsTooLarge);
3291
3292 cmp(index, FieldOperand(string, String::kLengthOffset));
3293 ThrowIf(greater_equal, kIndexIsTooLarge);
3294
3295 cmp(index, Immediate(Smi::FromInt(0)));
3296 ThrowIf(less, kIndexIsNegative);
3297
3298 // Restore the index
3299 SmiUntag(index);
3300 }
3301
3302
3233 void MacroAssembler::PrepareCallCFunction(int num_arguments, Register scratch) { 3303 void MacroAssembler::PrepareCallCFunction(int num_arguments, Register scratch) {
3234 int frame_alignment = OS::ActivationFrameAlignment(); 3304 int frame_alignment = OS::ActivationFrameAlignment();
3235 if (frame_alignment != 0) { 3305 if (frame_alignment != 0) {
3236 // Make stack end at alignment and make room for num_arguments words 3306 // Make stack end at alignment and make room for num_arguments words
3237 // and the original value of esp. 3307 // and the original value of esp.
3238 mov(scratch, esp); 3308 mov(scratch, esp);
3239 sub(esp, Immediate((num_arguments + 1) * kPointerSize)); 3309 sub(esp, Immediate((num_arguments + 1) * kPointerSize));
3240 ASSERT(IsPowerOf2(frame_alignment)); 3310 ASSERT(IsPowerOf2(frame_alignment));
3241 and_(esp, -frame_alignment); 3311 and_(esp, -frame_alignment);
3242 mov(Operand(esp, num_arguments * kPointerSize), scratch); 3312 mov(Operand(esp, num_arguments * kPointerSize), scratch);
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
3539 3609
3540 void MacroAssembler::CheckEnumCache(Label* call_runtime) { 3610 void MacroAssembler::CheckEnumCache(Label* call_runtime) {
3541 Label next, start; 3611 Label next, start;
3542 mov(ecx, eax); 3612 mov(ecx, eax);
3543 3613
3544 // Check if the enum length field is properly initialized, indicating that 3614 // Check if the enum length field is properly initialized, indicating that
3545 // there is an enum cache. 3615 // there is an enum cache.
3546 mov(ebx, FieldOperand(ecx, HeapObject::kMapOffset)); 3616 mov(ebx, FieldOperand(ecx, HeapObject::kMapOffset));
3547 3617
3548 EnumLength(edx, ebx); 3618 EnumLength(edx, ebx);
3549 cmp(edx, Immediate(Smi::FromInt(Map::kInvalidEnumCache))); 3619 cmp(edx, Immediate(Smi::FromInt(kInvalidEnumCacheSentinel)));
3550 j(equal, call_runtime); 3620 j(equal, call_runtime);
3551 3621
3552 jmp(&start); 3622 jmp(&start);
3553 3623
3554 bind(&next); 3624 bind(&next);
3555 mov(ebx, FieldOperand(ecx, HeapObject::kMapOffset)); 3625 mov(ebx, FieldOperand(ecx, HeapObject::kMapOffset));
3556 3626
3557 // For all objects but the receiver, check that the cache is empty. 3627 // For all objects but the receiver, check that the cache is empty.
3558 EnumLength(edx, ebx); 3628 EnumLength(edx, ebx);
3559 cmp(edx, Immediate(Smi::FromInt(0))); 3629 cmp(edx, Immediate(Smi::FromInt(0)));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3615 cmp(scratch1, Immediate(DICTIONARY_ELEMENTS)); 3685 cmp(scratch1, Immediate(DICTIONARY_ELEMENTS));
3616 j(equal, found); 3686 j(equal, found);
3617 mov(current, FieldOperand(current, Map::kPrototypeOffset)); 3687 mov(current, FieldOperand(current, Map::kPrototypeOffset));
3618 cmp(current, Immediate(factory->null_value())); 3688 cmp(current, Immediate(factory->null_value()));
3619 j(not_equal, &loop_again); 3689 j(not_equal, &loop_again);
3620 } 3690 }
3621 3691
3622 } } // namespace v8::internal 3692 } } // namespace v8::internal
3623 3693
3624 #endif // V8_TARGET_ARCH_IA32 3694 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698