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

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

Issue 23242006: Fix invalid out-of-bounds store in MacroAssembler::Allocate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix typo for MIPS. Created 7 years, 4 months 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
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/mips/macro-assembler-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 } 1300 }
1301 } 1301 }
1302 jmp(gc_required); 1302 jmp(gc_required);
1303 return; 1303 return;
1304 } 1304 }
1305 ASSERT(!result.is(result_end)); 1305 ASSERT(!result.is(result_end));
1306 1306
1307 // Load address of new object into result. 1307 // Load address of new object into result.
1308 LoadAllocationTopHelper(result, scratch, flags); 1308 LoadAllocationTopHelper(result, scratch, flags);
1309 1309
1310 ExternalReference allocation_limit =
1311 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
1312
1310 // 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
1311 // 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.
1312 if ((flags & DOUBLE_ALIGNMENT) != 0) { 1315 if ((flags & DOUBLE_ALIGNMENT) != 0) {
1313 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); 1316 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
1314 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); 1317 ASSERT(kPointerAlignment * 2 == kDoubleAlignment);
1315 Label aligned; 1318 Label aligned;
1316 test(result, Immediate(kDoubleAlignmentMask)); 1319 test(result, Immediate(kDoubleAlignmentMask));
1317 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 }
1318 mov(Operand(result, 0), 1325 mov(Operand(result, 0),
1319 Immediate(isolate()->factory()->one_pointer_filler_map())); 1326 Immediate(isolate()->factory()->one_pointer_filler_map()));
1320 add(result, Immediate(kDoubleSize / 2)); 1327 add(result, Immediate(kDoubleSize / 2));
1321 bind(&aligned); 1328 bind(&aligned);
1322 } 1329 }
1323 1330
1331 // Calculate new top and bail out if space is exhausted.
1324 Register top_reg = result_end.is_valid() ? result_end : result; 1332 Register top_reg = result_end.is_valid() ? result_end : result;
1325
1326 // Calculate new top and bail out if space is exhausted.
1327 ExternalReference allocation_limit =
1328 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
1329
1330 if (!top_reg.is(result)) { 1333 if (!top_reg.is(result)) {
1331 mov(top_reg, result); 1334 mov(top_reg, result);
1332 } 1335 }
1333 add(top_reg, Immediate(object_size)); 1336 add(top_reg, Immediate(object_size));
1334 j(carry, gc_required); 1337 j(carry, gc_required);
1335 cmp(top_reg, Operand::StaticVariable(allocation_limit)); 1338 cmp(top_reg, Operand::StaticVariable(allocation_limit));
1336 j(above, gc_required); 1339 j(above, gc_required);
1337 1340
1338 // Update allocation top. 1341 // Update allocation top.
1339 UpdateAllocationTopHelper(top_reg, scratch, flags); 1342 UpdateAllocationTopHelper(top_reg, scratch, flags);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 // Register element_count is not modified by the function. 1377 // Register element_count is not modified by the function.
1375 } 1378 }
1376 jmp(gc_required); 1379 jmp(gc_required);
1377 return; 1380 return;
1378 } 1381 }
1379 ASSERT(!result.is(result_end)); 1382 ASSERT(!result.is(result_end));
1380 1383
1381 // Load address of new object into result. 1384 // Load address of new object into result.
1382 LoadAllocationTopHelper(result, scratch, flags); 1385 LoadAllocationTopHelper(result, scratch, flags);
1383 1386
1387 ExternalReference allocation_limit =
1388 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
1389
1384 // 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
1385 // 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.
1386 if ((flags & DOUBLE_ALIGNMENT) != 0) { 1392 if ((flags & DOUBLE_ALIGNMENT) != 0) {
1387 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); 1393 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
1388 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); 1394 ASSERT(kPointerAlignment * 2 == kDoubleAlignment);
1389 Label aligned; 1395 Label aligned;
1390 test(result, Immediate(kDoubleAlignmentMask)); 1396 test(result, Immediate(kDoubleAlignmentMask));
1391 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 }
1392 mov(Operand(result, 0), 1402 mov(Operand(result, 0),
1393 Immediate(isolate()->factory()->one_pointer_filler_map())); 1403 Immediate(isolate()->factory()->one_pointer_filler_map()));
1394 add(result, Immediate(kDoubleSize / 2)); 1404 add(result, Immediate(kDoubleSize / 2));
1395 bind(&aligned); 1405 bind(&aligned);
1396 } 1406 }
1397 1407
1398 // Calculate new top and bail out if space is exhausted. 1408 // Calculate new top and bail out if space is exhausted.
1399 ExternalReference allocation_limit =
1400 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
1401
1402 // We assume that element_count*element_size + header_size does not 1409 // We assume that element_count*element_size + header_size does not
1403 // overflow. 1410 // overflow.
1404 if (element_count_type == REGISTER_VALUE_IS_SMI) { 1411 if (element_count_type == REGISTER_VALUE_IS_SMI) {
1405 STATIC_ASSERT(static_cast<ScaleFactor>(times_2 - 1) == times_1); 1412 STATIC_ASSERT(static_cast<ScaleFactor>(times_2 - 1) == times_1);
1406 STATIC_ASSERT(static_cast<ScaleFactor>(times_4 - 1) == times_2); 1413 STATIC_ASSERT(static_cast<ScaleFactor>(times_4 - 1) == times_2);
1407 STATIC_ASSERT(static_cast<ScaleFactor>(times_8 - 1) == times_4); 1414 STATIC_ASSERT(static_cast<ScaleFactor>(times_8 - 1) == times_4);
1408 ASSERT(element_size >= times_2); 1415 ASSERT(element_size >= times_2);
1409 ASSERT(kSmiTagSize == 1); 1416 ASSERT(kSmiTagSize == 1);
1410 element_size = static_cast<ScaleFactor>(element_size - 1); 1417 element_size = static_cast<ScaleFactor>(element_size - 1);
1411 } else { 1418 } else {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 // object_size is left unchanged by this function. 1452 // object_size is left unchanged by this function.
1446 } 1453 }
1447 jmp(gc_required); 1454 jmp(gc_required);
1448 return; 1455 return;
1449 } 1456 }
1450 ASSERT(!result.is(result_end)); 1457 ASSERT(!result.is(result_end));
1451 1458
1452 // Load address of new object into result. 1459 // Load address of new object into result.
1453 LoadAllocationTopHelper(result, scratch, flags); 1460 LoadAllocationTopHelper(result, scratch, flags);
1454 1461
1462 ExternalReference allocation_limit =
1463 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
1464
1455 // 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
1456 // 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.
1457 if ((flags & DOUBLE_ALIGNMENT) != 0) { 1467 if ((flags & DOUBLE_ALIGNMENT) != 0) {
1458 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); 1468 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
1459 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); 1469 ASSERT(kPointerAlignment * 2 == kDoubleAlignment);
1460 Label aligned; 1470 Label aligned;
1461 test(result, Immediate(kDoubleAlignmentMask)); 1471 test(result, Immediate(kDoubleAlignmentMask));
1462 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 }
1463 mov(Operand(result, 0), 1477 mov(Operand(result, 0),
1464 Immediate(isolate()->factory()->one_pointer_filler_map())); 1478 Immediate(isolate()->factory()->one_pointer_filler_map()));
1465 add(result, Immediate(kDoubleSize / 2)); 1479 add(result, Immediate(kDoubleSize / 2));
1466 bind(&aligned); 1480 bind(&aligned);
1467 } 1481 }
1468 1482
1469 // Calculate new top and bail out if space is exhausted. 1483 // Calculate new top and bail out if space is exhausted.
1470 ExternalReference allocation_limit =
1471 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
1472
1473 if (!object_size.is(result_end)) { 1484 if (!object_size.is(result_end)) {
1474 mov(result_end, object_size); 1485 mov(result_end, object_size);
1475 } 1486 }
1476 add(result_end, result); 1487 add(result_end, result);
1477 j(carry, gc_required); 1488 j(carry, gc_required);
1478 cmp(result_end, Operand::StaticVariable(allocation_limit)); 1489 cmp(result_end, Operand::StaticVariable(allocation_limit));
1479 j(above, gc_required); 1490 j(above, gc_required);
1480 1491
1481 // Tag result if requested. 1492 // Tag result if requested.
1482 if ((flags & TAG_OBJECT) != 0) { 1493 if ((flags & TAG_OBJECT) != 0) {
(...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after
3226 j(greater, &no_memento_available); 3237 j(greater, &no_memento_available);
3227 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize), 3238 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize),
3228 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map()))); 3239 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map())));
3229 bind(&no_memento_available); 3240 bind(&no_memento_available);
3230 } 3241 }
3231 3242
3232 3243
3233 } } // namespace v8::internal 3244 } } // namespace v8::internal
3234 3245
3235 #endif // V8_TARGET_ARCH_IA32 3246 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/mips/macro-assembler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698