| 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 404 |
| 405 bind(&fail); | 405 bind(&fail); |
| 406 } | 406 } |
| 407 | 407 |
| 408 | 408 |
| 409 Condition MacroAssembler::IsObjectStringType(Register heap_object, | 409 Condition MacroAssembler::IsObjectStringType(Register heap_object, |
| 410 Register map, | 410 Register map, |
| 411 Register instance_type) { | 411 Register instance_type) { |
| 412 mov(map, FieldOperand(heap_object, HeapObject::kMapOffset)); | 412 mov(map, FieldOperand(heap_object, HeapObject::kMapOffset)); |
| 413 movzx_b(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); | 413 movzx_b(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); |
| 414 ASSERT(kNotStringTag != 0); | 414 STATIC_ASSERT(kNotStringTag != 0); |
| 415 test(instance_type, Immediate(kIsNotStringMask)); | 415 test(instance_type, Immediate(kIsNotStringMask)); |
| 416 return zero; | 416 return zero; |
| 417 } | 417 } |
| 418 | 418 |
| 419 | 419 |
| 420 void MacroAssembler::IsObjectJSObjectType(Register heap_object, | 420 void MacroAssembler::IsObjectJSObjectType(Register heap_object, |
| 421 Register map, | 421 Register map, |
| 422 Register scratch, | 422 Register scratch, |
| 423 Label* fail) { | 423 Label* fail) { |
| 424 mov(map, FieldOperand(heap_object, HeapObject::kMapOffset)); | 424 mov(map, FieldOperand(heap_object, HeapObject::kMapOffset)); |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 // Set the map, length and hash field. | 1250 // Set the map, length and hash field. |
| 1251 mov(FieldOperand(result, HeapObject::kMapOffset), | 1251 mov(FieldOperand(result, HeapObject::kMapOffset), |
| 1252 Immediate(isolate()->factory()->ascii_string_map())); | 1252 Immediate(isolate()->factory()->ascii_string_map())); |
| 1253 mov(FieldOperand(result, String::kLengthOffset), | 1253 mov(FieldOperand(result, String::kLengthOffset), |
| 1254 Immediate(Smi::FromInt(length))); | 1254 Immediate(Smi::FromInt(length))); |
| 1255 mov(FieldOperand(result, String::kHashFieldOffset), | 1255 mov(FieldOperand(result, String::kHashFieldOffset), |
| 1256 Immediate(String::kEmptyHashField)); | 1256 Immediate(String::kEmptyHashField)); |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 | 1259 |
| 1260 void MacroAssembler::AllocateConsString(Register result, | 1260 void MacroAssembler::AllocateTwoByteConsString(Register result, |
| 1261 Register scratch1, | 1261 Register scratch1, |
| 1262 Register scratch2, | 1262 Register scratch2, |
| 1263 Label* gc_required) { | 1263 Label* gc_required) { |
| 1264 // Allocate heap number in new space. | 1264 // Allocate heap number in new space. |
| 1265 AllocateInNewSpace(ConsString::kSize, | 1265 AllocateInNewSpace(ConsString::kSize, |
| 1266 result, | 1266 result, |
| 1267 scratch1, | 1267 scratch1, |
| 1268 scratch2, | 1268 scratch2, |
| 1269 gc_required, | 1269 gc_required, |
| 1270 TAG_OBJECT); | 1270 TAG_OBJECT); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1286 scratch2, | 1286 scratch2, |
| 1287 gc_required, | 1287 gc_required, |
| 1288 TAG_OBJECT); | 1288 TAG_OBJECT); |
| 1289 | 1289 |
| 1290 // Set the map. The other fields are left uninitialized. | 1290 // Set the map. The other fields are left uninitialized. |
| 1291 mov(FieldOperand(result, HeapObject::kMapOffset), | 1291 mov(FieldOperand(result, HeapObject::kMapOffset), |
| 1292 Immediate(isolate()->factory()->cons_ascii_string_map())); | 1292 Immediate(isolate()->factory()->cons_ascii_string_map())); |
| 1293 } | 1293 } |
| 1294 | 1294 |
| 1295 | 1295 |
| 1296 void MacroAssembler::AllocateTwoByteSlicedString(Register result, |
| 1297 Register scratch1, |
| 1298 Register scratch2, |
| 1299 Label* gc_required) { |
| 1300 // Allocate heap number in new space. |
| 1301 AllocateInNewSpace(SlicedString::kSize, |
| 1302 result, |
| 1303 scratch1, |
| 1304 scratch2, |
| 1305 gc_required, |
| 1306 TAG_OBJECT); |
| 1307 |
| 1308 // Set the map. The other fields are left uninitialized. |
| 1309 mov(FieldOperand(result, HeapObject::kMapOffset), |
| 1310 Immediate(isolate()->factory()->sliced_string_map())); |
| 1311 } |
| 1312 |
| 1313 |
| 1314 void MacroAssembler::AllocateAsciiSlicedString(Register result, |
| 1315 Register scratch1, |
| 1316 Register scratch2, |
| 1317 Label* gc_required) { |
| 1318 // Allocate heap number in new space. |
| 1319 AllocateInNewSpace(SlicedString::kSize, |
| 1320 result, |
| 1321 scratch1, |
| 1322 scratch2, |
| 1323 gc_required, |
| 1324 TAG_OBJECT); |
| 1325 |
| 1326 // Set the map. The other fields are left uninitialized. |
| 1327 mov(FieldOperand(result, HeapObject::kMapOffset), |
| 1328 Immediate(isolate()->factory()->sliced_ascii_string_map())); |
| 1329 } |
| 1330 |
| 1331 |
| 1296 // Copy memory, byte-by-byte, from source to destination. Not optimized for | 1332 // Copy memory, byte-by-byte, from source to destination. Not optimized for |
| 1297 // long or aligned copies. The contents of scratch and length are destroyed. | 1333 // long or aligned copies. The contents of scratch and length are destroyed. |
| 1298 // Source and destination are incremented by length. | 1334 // Source and destination are incremented by length. |
| 1299 // Many variants of movsb, loop unrolling, word moves, and indexed operands | 1335 // Many variants of movsb, loop unrolling, word moves, and indexed operands |
| 1300 // have been tried here already, and this is fastest. | 1336 // have been tried here already, and this is fastest. |
| 1301 // A simpler loop is faster on small copies, but 30% slower on large ones. | 1337 // A simpler loop is faster on small copies, but 30% slower on large ones. |
| 1302 // The cld() instruction must have been emitted, to set the direction flag(), | 1338 // The cld() instruction must have been emitted, to set the direction flag(), |
| 1303 // before calling this function. | 1339 // before calling this function. |
| 1304 void MacroAssembler::CopyBytes(Register source, | 1340 void MacroAssembler::CopyBytes(Register source, |
| 1305 Register destination, | 1341 Register destination, |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 j(not_equal, failure); | 2280 j(not_equal, failure); |
| 2245 } | 2281 } |
| 2246 | 2282 |
| 2247 | 2283 |
| 2248 void MacroAssembler::JumpIfNotBothSequentialAsciiStrings(Register object1, | 2284 void MacroAssembler::JumpIfNotBothSequentialAsciiStrings(Register object1, |
| 2249 Register object2, | 2285 Register object2, |
| 2250 Register scratch1, | 2286 Register scratch1, |
| 2251 Register scratch2, | 2287 Register scratch2, |
| 2252 Label* failure) { | 2288 Label* failure) { |
| 2253 // Check that both objects are not smis. | 2289 // Check that both objects are not smis. |
| 2254 ASSERT_EQ(0, kSmiTag); | 2290 STATIC_ASSERT(kSmiTag == 0); |
| 2255 mov(scratch1, Operand(object1)); | 2291 mov(scratch1, Operand(object1)); |
| 2256 and_(scratch1, Operand(object2)); | 2292 and_(scratch1, Operand(object2)); |
| 2257 JumpIfSmi(scratch1, failure); | 2293 JumpIfSmi(scratch1, failure); |
| 2258 | 2294 |
| 2259 // Load instance type for both strings. | 2295 // Load instance type for both strings. |
| 2260 mov(scratch1, FieldOperand(object1, HeapObject::kMapOffset)); | 2296 mov(scratch1, FieldOperand(object1, HeapObject::kMapOffset)); |
| 2261 mov(scratch2, FieldOperand(object2, HeapObject::kMapOffset)); | 2297 mov(scratch2, FieldOperand(object2, HeapObject::kMapOffset)); |
| 2262 movzx_b(scratch1, FieldOperand(scratch1, Map::kInstanceTypeOffset)); | 2298 movzx_b(scratch1, FieldOperand(scratch1, Map::kInstanceTypeOffset)); |
| 2263 movzx_b(scratch2, FieldOperand(scratch2, Map::kInstanceTypeOffset)); | 2299 movzx_b(scratch2, FieldOperand(scratch2, Map::kInstanceTypeOffset)); |
| 2264 | 2300 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2478 | 2514 |
| 2479 // Check for heap-number | 2515 // Check for heap-number |
| 2480 mov(map, FieldOperand(value, HeapObject::kMapOffset)); | 2516 mov(map, FieldOperand(value, HeapObject::kMapOffset)); |
| 2481 cmp(map, FACTORY->heap_number_map()); | 2517 cmp(map, FACTORY->heap_number_map()); |
| 2482 j(not_equal, ¬_heap_number, Label::kNear); | 2518 j(not_equal, ¬_heap_number, Label::kNear); |
| 2483 mov(length, Immediate(HeapNumber::kSize)); | 2519 mov(length, Immediate(HeapNumber::kSize)); |
| 2484 jmp(&is_data_object, Label::kNear); | 2520 jmp(&is_data_object, Label::kNear); |
| 2485 | 2521 |
| 2486 bind(¬_heap_number); | 2522 bind(¬_heap_number); |
| 2487 // Check for strings. | 2523 // Check for strings. |
| 2488 ASSERT(kConsStringTag == 1 && kIsConsStringMask == 1); | 2524 ASSERT(kIsIndirectStringTag == 1 && kIsIndirectStringMask == 1); |
| 2489 ASSERT(kNotStringTag == 0x80 && kIsNotStringMask == 0x80); | 2525 ASSERT(kNotStringTag == 0x80 && kIsNotStringMask == 0x80); |
| 2490 // If it's a string and it's not a cons string then it's an object containing | 2526 // If it's a string and it's not a cons string then it's an object containing |
| 2491 // no GC pointers. | 2527 // no GC pointers. |
| 2492 Register instance_type = ecx; | 2528 Register instance_type = ecx; |
| 2493 movzx_b(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); | 2529 movzx_b(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); |
| 2494 test_b(Operand(instance_type), kIsConsStringMask | kIsNotStringMask); | 2530 test_b(Operand(instance_type), kIsIndirectStringMask | kIsNotStringMask); |
| 2495 j(not_zero, value_is_white_and_not_data); | 2531 j(not_zero, value_is_white_and_not_data); |
| 2496 // It's a non-cons string. | 2532 // It's a non-indirect (non-cons and non-slice) string. |
| 2497 // If it's external, the length is just ExternalString::kSize. | 2533 // If it's external, the length is just ExternalString::kSize. |
| 2498 // Otherwise it's String::kHeaderSize + string->length() * (1 or 2). | 2534 // Otherwise it's String::kHeaderSize + string->length() * (1 or 2). |
| 2499 Label not_external; | 2535 Label not_external; |
| 2500 // External strings are the only ones with the kExternalStringTag bit | 2536 // External strings are the only ones with the kExternalStringTag bit |
| 2501 // set. | 2537 // set. |
| 2502 ASSERT_EQ(0, kSeqStringTag & kExternalStringTag); | 2538 ASSERT_EQ(0, kSeqStringTag & kExternalStringTag); |
| 2503 ASSERT_EQ(0, kConsStringTag & kExternalStringTag); | 2539 ASSERT_EQ(0, kConsStringTag & kExternalStringTag); |
| 2504 test_b(Operand(instance_type), kExternalStringTag); | 2540 test_b(Operand(instance_type), kExternalStringTag); |
| 2505 j(zero, ¬_external, Label::kNear); | 2541 j(zero, ¬_external, Label::kNear); |
| 2506 mov(length, Immediate(ExternalString::kSize)); | 2542 mov(length, Immediate(ExternalString::kSize)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2533 and_(bitmap_scratch, Immediate(~Page::kPageAlignmentMask)); | 2569 and_(bitmap_scratch, Immediate(~Page::kPageAlignmentMask)); |
| 2534 add(Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset), | 2570 add(Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset), |
| 2535 length); | 2571 length); |
| 2536 | 2572 |
| 2537 bind(&done); | 2573 bind(&done); |
| 2538 } | 2574 } |
| 2539 | 2575 |
| 2540 } } // namespace v8::internal | 2576 } } // namespace v8::internal |
| 2541 | 2577 |
| 2542 #endif // V8_TARGET_ARCH_IA32 | 2578 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |