| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 generating_stub_(false), | 47 generating_stub_(false), |
| 48 allow_stub_calls_(true), | 48 allow_stub_calls_(true), |
| 49 has_frame_(false) { | 49 has_frame_(false) { |
| 50 if (isolate() != NULL) { | 50 if (isolate() != NULL) { |
| 51 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), | 51 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), |
| 52 isolate()); | 52 isolate()); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 void MacroAssembler::LoadRoot(Register destination, Heap::RootListIndex index) { |
| 58 if (isolate()->heap()->RootCanBeTreatedAsConstant(index)) { |
| 59 Handle<Object> value(&isolate()->heap()->roots_array_start()[index]); |
| 60 mov(destination, value); |
| 61 return; |
| 62 } |
| 63 ExternalReference roots_array_start = |
| 64 ExternalReference::roots_array_start(isolate()); |
| 65 mov(destination, Immediate(index)); |
| 66 mov(destination, Operand::StaticArray(destination, |
| 67 times_pointer_size, |
| 68 roots_array_start)); |
| 69 } |
| 70 |
| 71 |
| 72 void MacroAssembler::StoreRoot(Register source, |
| 73 Register scratch, |
| 74 Heap::RootListIndex index) { |
| 75 ASSERT(Heap::RootCanBeWrittenAfterInitialization(index)); |
| 76 ExternalReference roots_array_start = |
| 77 ExternalReference::roots_array_start(isolate()); |
| 78 mov(scratch, Immediate(index)); |
| 79 mov(Operand::StaticArray(scratch, times_pointer_size, roots_array_start), |
| 80 source); |
| 81 } |
| 82 |
| 83 |
| 84 void MacroAssembler::CompareRoot(Register with, |
| 85 Register scratch, |
| 86 Heap::RootListIndex index) { |
| 87 ExternalReference roots_array_start = |
| 88 ExternalReference::roots_array_start(isolate()); |
| 89 mov(scratch, Immediate(index)); |
| 90 cmp(with, Operand::StaticArray(scratch, |
| 91 times_pointer_size, |
| 92 roots_array_start)); |
| 93 } |
| 94 |
| 95 |
| 96 void MacroAssembler::CompareRoot(Register with, Heap::RootListIndex index) { |
| 97 ASSERT(isolate()->heap()->RootCanBeTreatedAsConstant(index)); |
| 98 Handle<Object> value(&isolate()->heap()->roots_array_start()[index]); |
| 99 cmp(with, value); |
| 100 } |
| 101 |
| 102 |
| 103 void MacroAssembler::CompareRoot(const Operand& with, |
| 104 Heap::RootListIndex index) { |
| 105 ASSERT(isolate()->heap()->RootCanBeTreatedAsConstant(index)); |
| 106 Handle<Object> value(&isolate()->heap()->roots_array_start()[index]); |
| 107 cmp(with, value); |
| 108 } |
| 109 |
| 110 |
| 57 void MacroAssembler::InNewSpace( | 111 void MacroAssembler::InNewSpace( |
| 58 Register object, | 112 Register object, |
| 59 Register scratch, | 113 Register scratch, |
| 60 Condition cc, | 114 Condition cc, |
| 61 Label* condition_met, | 115 Label* condition_met, |
| 62 Label::Distance condition_met_distance) { | 116 Label::Distance condition_met_distance) { |
| 63 ASSERT(cc == equal || cc == not_equal); | 117 ASSERT(cc == equal || cc == not_equal); |
| 64 if (scratch.is(object)) { | 118 if (scratch.is(object)) { |
| 65 and_(scratch, Immediate(~Page::kPageAlignmentMask)); | 119 and_(scratch, Immediate(~Page::kPageAlignmentMask)); |
| 66 } else { | 120 } else { |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 void MacroAssembler::SafePush(const Immediate& x) { | 479 void MacroAssembler::SafePush(const Immediate& x) { |
| 426 if (IsUnsafeImmediate(x) && jit_cookie() != 0) { | 480 if (IsUnsafeImmediate(x) && jit_cookie() != 0) { |
| 427 push(Immediate(x.x_ ^ jit_cookie())); | 481 push(Immediate(x.x_ ^ jit_cookie())); |
| 428 xor_(Operand(esp, 0), Immediate(jit_cookie())); | 482 xor_(Operand(esp, 0), Immediate(jit_cookie())); |
| 429 } else { | 483 } else { |
| 430 push(x); | 484 push(x); |
| 431 } | 485 } |
| 432 } | 486 } |
| 433 | 487 |
| 434 | 488 |
| 435 void MacroAssembler::CompareRoot(Register with, Heap::RootListIndex index) { | |
| 436 // see ROOT_ACCESSOR macro in factory.h | |
| 437 Handle<Object> value(&isolate()->heap()->roots_array_start()[index]); | |
| 438 cmp(with, value); | |
| 439 } | |
| 440 | |
| 441 | |
| 442 void MacroAssembler::CompareRoot(const Operand& with, | |
| 443 Heap::RootListIndex index) { | |
| 444 // see ROOT_ACCESSOR macro in factory.h | |
| 445 Handle<Object> value(&isolate()->heap()->roots_array_start()[index]); | |
| 446 cmp(with, value); | |
| 447 } | |
| 448 | |
| 449 | |
| 450 void MacroAssembler::CmpObjectType(Register heap_object, | 489 void MacroAssembler::CmpObjectType(Register heap_object, |
| 451 InstanceType type, | 490 InstanceType type, |
| 452 Register map) { | 491 Register map) { |
| 453 mov(map, FieldOperand(heap_object, HeapObject::kMapOffset)); | 492 mov(map, FieldOperand(heap_object, HeapObject::kMapOffset)); |
| 454 CmpInstanceType(map, type); | 493 CmpInstanceType(map, type); |
| 455 } | 494 } |
| 456 | 495 |
| 457 | 496 |
| 458 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) { | 497 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) { |
| 459 cmpb(FieldOperand(map, Map::kInstanceTypeOffset), | 498 cmpb(FieldOperand(map, Map::kInstanceTypeOffset), |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 } | 1300 } |
| 1262 } | 1301 } |
| 1263 jmp(gc_required); | 1302 jmp(gc_required); |
| 1264 return; | 1303 return; |
| 1265 } | 1304 } |
| 1266 ASSERT(!result.is(result_end)); | 1305 ASSERT(!result.is(result_end)); |
| 1267 | 1306 |
| 1268 // Load address of new object into result. | 1307 // Load address of new object into result. |
| 1269 LoadAllocationTopHelper(result, scratch, flags); | 1308 LoadAllocationTopHelper(result, scratch, flags); |
| 1270 | 1309 |
| 1310 ExternalReference allocation_limit = |
| 1311 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 1312 |
| 1271 // Align the next allocation. Storing the filler map without checking top is | 1313 // Align the next allocation. Storing the filler map without checking top is |
| 1272 // always safe because the limit of the heap is always aligned. | 1314 // safe in new-space because the limit of the heap is aligned there. |
| 1273 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 1315 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 1274 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); | 1316 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); |
| 1275 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); | 1317 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); |
| 1276 Label aligned; | 1318 Label aligned; |
| 1277 test(result, Immediate(kDoubleAlignmentMask)); | 1319 test(result, Immediate(kDoubleAlignmentMask)); |
| 1278 j(zero, &aligned, Label::kNear); | 1320 j(zero, &aligned, Label::kNear); |
| 1321 if ((flags & PRETENURE_OLD_DATA_SPACE) != 0) { |
| 1322 cmp(result, Operand::StaticVariable(allocation_limit)); |
| 1323 j(above_equal, gc_required); |
| 1324 } |
| 1279 mov(Operand(result, 0), | 1325 mov(Operand(result, 0), |
| 1280 Immediate(isolate()->factory()->one_pointer_filler_map())); | 1326 Immediate(isolate()->factory()->one_pointer_filler_map())); |
| 1281 add(result, Immediate(kDoubleSize / 2)); | 1327 add(result, Immediate(kDoubleSize / 2)); |
| 1282 bind(&aligned); | 1328 bind(&aligned); |
| 1283 } | 1329 } |
| 1284 | 1330 |
| 1331 // Calculate new top and bail out if space is exhausted. |
| 1285 Register top_reg = result_end.is_valid() ? result_end : result; | 1332 Register top_reg = result_end.is_valid() ? result_end : result; |
| 1286 | |
| 1287 // Calculate new top and bail out if space is exhausted. | |
| 1288 ExternalReference allocation_limit = | |
| 1289 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | |
| 1290 | |
| 1291 if (!top_reg.is(result)) { | 1333 if (!top_reg.is(result)) { |
| 1292 mov(top_reg, result); | 1334 mov(top_reg, result); |
| 1293 } | 1335 } |
| 1294 add(top_reg, Immediate(object_size)); | 1336 add(top_reg, Immediate(object_size)); |
| 1295 j(carry, gc_required); | 1337 j(carry, gc_required); |
| 1296 cmp(top_reg, Operand::StaticVariable(allocation_limit)); | 1338 cmp(top_reg, Operand::StaticVariable(allocation_limit)); |
| 1297 j(above, gc_required); | 1339 j(above, gc_required); |
| 1298 | 1340 |
| 1299 // Update allocation top. | 1341 // Update allocation top. |
| 1300 UpdateAllocationTopHelper(top_reg, scratch, flags); | 1342 UpdateAllocationTopHelper(top_reg, scratch, flags); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 // Register element_count is not modified by the function. | 1377 // Register element_count is not modified by the function. |
| 1336 } | 1378 } |
| 1337 jmp(gc_required); | 1379 jmp(gc_required); |
| 1338 return; | 1380 return; |
| 1339 } | 1381 } |
| 1340 ASSERT(!result.is(result_end)); | 1382 ASSERT(!result.is(result_end)); |
| 1341 | 1383 |
| 1342 // Load address of new object into result. | 1384 // Load address of new object into result. |
| 1343 LoadAllocationTopHelper(result, scratch, flags); | 1385 LoadAllocationTopHelper(result, scratch, flags); |
| 1344 | 1386 |
| 1387 ExternalReference allocation_limit = |
| 1388 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 1389 |
| 1345 // Align the next allocation. Storing the filler map without checking top is | 1390 // Align the next allocation. Storing the filler map without checking top is |
| 1346 // always safe because the limit of the heap is always aligned. | 1391 // safe in new-space because the limit of the heap is aligned there. |
| 1347 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 1392 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 1348 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); | 1393 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); |
| 1349 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); | 1394 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); |
| 1350 Label aligned; | 1395 Label aligned; |
| 1351 test(result, Immediate(kDoubleAlignmentMask)); | 1396 test(result, Immediate(kDoubleAlignmentMask)); |
| 1352 j(zero, &aligned, Label::kNear); | 1397 j(zero, &aligned, Label::kNear); |
| 1398 if ((flags & PRETENURE_OLD_DATA_SPACE) != 0) { |
| 1399 cmp(result, Operand::StaticVariable(allocation_limit)); |
| 1400 j(above_equal, gc_required); |
| 1401 } |
| 1353 mov(Operand(result, 0), | 1402 mov(Operand(result, 0), |
| 1354 Immediate(isolate()->factory()->one_pointer_filler_map())); | 1403 Immediate(isolate()->factory()->one_pointer_filler_map())); |
| 1355 add(result, Immediate(kDoubleSize / 2)); | 1404 add(result, Immediate(kDoubleSize / 2)); |
| 1356 bind(&aligned); | 1405 bind(&aligned); |
| 1357 } | 1406 } |
| 1358 | 1407 |
| 1359 // Calculate new top and bail out if space is exhausted. | 1408 // Calculate new top and bail out if space is exhausted. |
| 1360 ExternalReference allocation_limit = | |
| 1361 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | |
| 1362 | |
| 1363 // We assume that element_count*element_size + header_size does not | 1409 // We assume that element_count*element_size + header_size does not |
| 1364 // overflow. | 1410 // overflow. |
| 1365 if (element_count_type == REGISTER_VALUE_IS_SMI) { | 1411 if (element_count_type == REGISTER_VALUE_IS_SMI) { |
| 1366 STATIC_ASSERT(static_cast<ScaleFactor>(times_2 - 1) == times_1); | 1412 STATIC_ASSERT(static_cast<ScaleFactor>(times_2 - 1) == times_1); |
| 1367 STATIC_ASSERT(static_cast<ScaleFactor>(times_4 - 1) == times_2); | 1413 STATIC_ASSERT(static_cast<ScaleFactor>(times_4 - 1) == times_2); |
| 1368 STATIC_ASSERT(static_cast<ScaleFactor>(times_8 - 1) == times_4); | 1414 STATIC_ASSERT(static_cast<ScaleFactor>(times_8 - 1) == times_4); |
| 1369 ASSERT(element_size >= times_2); | 1415 ASSERT(element_size >= times_2); |
| 1370 ASSERT(kSmiTagSize == 1); | 1416 ASSERT(kSmiTagSize == 1); |
| 1371 element_size = static_cast<ScaleFactor>(element_size - 1); | 1417 element_size = static_cast<ScaleFactor>(element_size - 1); |
| 1372 } else { | 1418 } else { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 // object_size is left unchanged by this function. | 1452 // object_size is left unchanged by this function. |
| 1407 } | 1453 } |
| 1408 jmp(gc_required); | 1454 jmp(gc_required); |
| 1409 return; | 1455 return; |
| 1410 } | 1456 } |
| 1411 ASSERT(!result.is(result_end)); | 1457 ASSERT(!result.is(result_end)); |
| 1412 | 1458 |
| 1413 // Load address of new object into result. | 1459 // Load address of new object into result. |
| 1414 LoadAllocationTopHelper(result, scratch, flags); | 1460 LoadAllocationTopHelper(result, scratch, flags); |
| 1415 | 1461 |
| 1462 ExternalReference allocation_limit = |
| 1463 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 1464 |
| 1416 // Align the next allocation. Storing the filler map without checking top is | 1465 // Align the next allocation. Storing the filler map without checking top is |
| 1417 // always safe because the limit of the heap is always aligned. | 1466 // safe in new-space because the limit of the heap is aligned there. |
| 1418 if ((flags & DOUBLE_ALIGNMENT) != 0) { | 1467 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 1419 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); | 1468 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); |
| 1420 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); | 1469 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); |
| 1421 Label aligned; | 1470 Label aligned; |
| 1422 test(result, Immediate(kDoubleAlignmentMask)); | 1471 test(result, Immediate(kDoubleAlignmentMask)); |
| 1423 j(zero, &aligned, Label::kNear); | 1472 j(zero, &aligned, Label::kNear); |
| 1473 if ((flags & PRETENURE_OLD_DATA_SPACE) != 0) { |
| 1474 cmp(result, Operand::StaticVariable(allocation_limit)); |
| 1475 j(above_equal, gc_required); |
| 1476 } |
| 1424 mov(Operand(result, 0), | 1477 mov(Operand(result, 0), |
| 1425 Immediate(isolate()->factory()->one_pointer_filler_map())); | 1478 Immediate(isolate()->factory()->one_pointer_filler_map())); |
| 1426 add(result, Immediate(kDoubleSize / 2)); | 1479 add(result, Immediate(kDoubleSize / 2)); |
| 1427 bind(&aligned); | 1480 bind(&aligned); |
| 1428 } | 1481 } |
| 1429 | 1482 |
| 1430 // Calculate new top and bail out if space is exhausted. | 1483 // Calculate new top and bail out if space is exhausted. |
| 1431 ExternalReference allocation_limit = | |
| 1432 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | |
| 1433 | |
| 1434 if (!object_size.is(result_end)) { | 1484 if (!object_size.is(result_end)) { |
| 1435 mov(result_end, object_size); | 1485 mov(result_end, object_size); |
| 1436 } | 1486 } |
| 1437 add(result_end, result); | 1487 add(result_end, result); |
| 1438 j(carry, gc_required); | 1488 j(carry, gc_required); |
| 1439 cmp(result_end, Operand::StaticVariable(allocation_limit)); | 1489 cmp(result_end, Operand::StaticVariable(allocation_limit)); |
| 1440 j(above, gc_required); | 1490 j(above, gc_required); |
| 1441 | 1491 |
| 1442 // Tag result if requested. | 1492 // Tag result if requested. |
| 1443 if ((flags & TAG_OBJECT) != 0) { | 1493 if ((flags & TAG_OBJECT) != 0) { |
| (...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3187 j(greater, &no_memento_available); | 3237 j(greater, &no_memento_available); |
| 3188 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize), | 3238 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize), |
| 3189 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map()))); | 3239 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map()))); |
| 3190 bind(&no_memento_available); | 3240 bind(&no_memento_available); |
| 3191 } | 3241 } |
| 3192 | 3242 |
| 3193 | 3243 |
| 3194 } } // namespace v8::internal | 3244 } } // namespace v8::internal |
| 3195 | 3245 |
| 3196 #endif // V8_TARGET_ARCH_IA32 | 3246 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |