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 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 UpdateAllocationTopHelper(result_end, scratch); | 1379 UpdateAllocationTopHelper(result_end, scratch); |
1380 } | 1380 } |
1381 | 1381 |
1382 | 1382 |
1383 void MacroAssembler::AllocateInNewSpace(Register object_size, | 1383 void MacroAssembler::AllocateInNewSpace(Register object_size, |
1384 Register result, | 1384 Register result, |
1385 Register result_end, | 1385 Register result_end, |
1386 Register scratch, | 1386 Register scratch, |
1387 Label* gc_required, | 1387 Label* gc_required, |
1388 AllocationFlags flags) { | 1388 AllocationFlags flags) { |
1389 ASSERT((flags & (DOUBLE_ALIGNMENT | RESULT_CONTAINS_TOP | | 1389 ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0); |
1390 SIZE_IN_WORDS)) == 0); | |
1391 if (!FLAG_inline_new) { | 1390 if (!FLAG_inline_new) { |
1392 if (emit_debug_code()) { | 1391 if (emit_debug_code()) { |
1393 // Trash the registers to simulate an allocation failure. | 1392 // Trash the registers to simulate an allocation failure. |
1394 mov(result, Immediate(0x7091)); | 1393 mov(result, Immediate(0x7091)); |
1395 mov(result_end, Immediate(0x7191)); | 1394 mov(result_end, Immediate(0x7191)); |
1396 if (scratch.is_valid()) { | 1395 if (scratch.is_valid()) { |
1397 mov(scratch, Immediate(0x7291)); | 1396 mov(scratch, Immediate(0x7291)); |
1398 } | 1397 } |
1399 // object_size is left unchanged by this function. | 1398 // object_size is left unchanged by this function. |
1400 } | 1399 } |
1401 jmp(gc_required); | 1400 jmp(gc_required); |
1402 return; | 1401 return; |
1403 } | 1402 } |
1404 ASSERT(!result.is(result_end)); | 1403 ASSERT(!result.is(result_end)); |
1405 | 1404 |
1406 // Load address of new object into result. | 1405 // Load address of new object into result. |
1407 LoadAllocationTopHelper(result, scratch, flags); | 1406 LoadAllocationTopHelper(result, scratch, flags); |
1408 | 1407 |
| 1408 // Align the next allocation. Storing the filler map without checking top is |
| 1409 // always safe because the limit of the heap is always aligned. |
| 1410 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 1411 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); |
| 1412 Label aligned; |
| 1413 test(result, Immediate(kDoubleAlignmentMask)); |
| 1414 j(zero, &aligned, Label::kNear); |
| 1415 mov(Operand(result, 0), |
| 1416 Immediate(isolate()->factory()->one_pointer_filler_map())); |
| 1417 add(result, Immediate(kDoubleSize / 2)); |
| 1418 bind(&aligned); |
| 1419 } |
| 1420 |
1409 // Calculate new top and bail out if new space is exhausted. | 1421 // Calculate new top and bail out if new space is exhausted. |
1410 ExternalReference new_space_allocation_limit = | 1422 ExternalReference new_space_allocation_limit = |
1411 ExternalReference::new_space_allocation_limit_address(isolate()); | 1423 ExternalReference::new_space_allocation_limit_address(isolate()); |
1412 if (!object_size.is(result_end)) { | 1424 if (!object_size.is(result_end)) { |
1413 mov(result_end, object_size); | 1425 mov(result_end, object_size); |
1414 } | 1426 } |
1415 add(result_end, result); | 1427 add(result_end, result); |
1416 j(carry, gc_required); | 1428 j(carry, gc_required); |
1417 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); | 1429 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); |
1418 j(above, gc_required); | 1430 j(above, gc_required); |
1419 | 1431 |
1420 // Tag result if requested. | 1432 // Tag result if requested. |
1421 if ((flags & TAG_OBJECT) != 0) { | 1433 if ((flags & TAG_OBJECT) != 0) { |
1422 lea(result, Operand(result, kHeapObjectTag)); | 1434 ASSERT(kHeapObjectTag == 1); |
| 1435 inc(result); |
1423 } | 1436 } |
1424 | 1437 |
1425 // Update allocation top. | 1438 // Update allocation top. |
1426 UpdateAllocationTopHelper(result_end, scratch); | 1439 UpdateAllocationTopHelper(result_end, scratch); |
1427 } | 1440 } |
1428 | 1441 |
1429 | 1442 |
1430 void MacroAssembler::UndoAllocationInNewSpace(Register object) { | 1443 void MacroAssembler::UndoAllocationInNewSpace(Register object) { |
1431 ExternalReference new_space_allocation_top = | 1444 ExternalReference new_space_allocation_top = |
1432 ExternalReference::new_space_allocation_top_address(isolate()); | 1445 ExternalReference::new_space_allocation_top_address(isolate()); |
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3045 j(not_equal, call_runtime); | 3058 j(not_equal, call_runtime); |
3046 | 3059 |
3047 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); | 3060 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); |
3048 cmp(ecx, isolate()->factory()->null_value()); | 3061 cmp(ecx, isolate()->factory()->null_value()); |
3049 j(not_equal, &next); | 3062 j(not_equal, &next); |
3050 } | 3063 } |
3051 | 3064 |
3052 | 3065 |
3053 void MacroAssembler::TestJSArrayForAllocationSiteInfo( | 3066 void MacroAssembler::TestJSArrayForAllocationSiteInfo( |
3054 Register receiver_reg, | 3067 Register receiver_reg, |
3055 Register scratch_reg, | 3068 Register scratch_reg) { |
3056 Label* allocation_info_present) { | |
3057 Label no_info_available; | 3069 Label no_info_available; |
3058 | 3070 |
3059 ExternalReference new_space_start = | 3071 ExternalReference new_space_start = |
3060 ExternalReference::new_space_start(isolate()); | 3072 ExternalReference::new_space_start(isolate()); |
3061 ExternalReference new_space_allocation_top = | 3073 ExternalReference new_space_allocation_top = |
3062 ExternalReference::new_space_allocation_top_address(isolate()); | 3074 ExternalReference::new_space_allocation_top_address(isolate()); |
3063 | 3075 |
3064 lea(scratch_reg, Operand(receiver_reg, | 3076 lea(scratch_reg, Operand(receiver_reg, |
3065 JSArray::kSize + AllocationSiteInfo::kSize - kHeapObjectTag)); | 3077 JSArray::kSize + AllocationSiteInfo::kSize - kHeapObjectTag)); |
3066 cmp(scratch_reg, Immediate(new_space_start)); | 3078 cmp(scratch_reg, Immediate(new_space_start)); |
3067 j(less, &no_info_available); | 3079 j(less, &no_info_available); |
3068 cmp(scratch_reg, Operand::StaticVariable(new_space_allocation_top)); | 3080 cmp(scratch_reg, Operand::StaticVariable(new_space_allocation_top)); |
3069 j(greater, &no_info_available); | 3081 j(greater, &no_info_available); |
3070 cmp(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), | 3082 cmp(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), |
3071 Immediate(Handle<Map>(isolate()->heap()->allocation_site_info_map()))); | 3083 Immediate(Handle<Map>(isolate()->heap()->allocation_site_info_map()))); |
3072 j(equal, allocation_info_present); | |
3073 bind(&no_info_available); | 3084 bind(&no_info_available); |
3074 } | 3085 } |
3075 | 3086 |
3076 | 3087 |
3077 } } // namespace v8::internal | 3088 } } // namespace v8::internal |
3078 | 3089 |
3079 #endif // V8_TARGET_ARCH_IA32 | 3090 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |