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

Side by Side Diff: src/mark-compact.cc

Issue 17162002: Version 3.19.17. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 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/lithium.h ('k') | src/mips/code-stubs-mips.h » ('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 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 1488
1489 static void UpdateRegExpCodeAgeAndFlush(Heap* heap, 1489 static void UpdateRegExpCodeAgeAndFlush(Heap* heap,
1490 JSRegExp* re, 1490 JSRegExp* re,
1491 bool is_ascii) { 1491 bool is_ascii) {
1492 // Make sure that the fixed array is in fact initialized on the RegExp. 1492 // Make sure that the fixed array is in fact initialized on the RegExp.
1493 // We could potentially trigger a GC when initializing the RegExp. 1493 // We could potentially trigger a GC when initializing the RegExp.
1494 if (HeapObject::cast(re->data())->map()->instance_type() != 1494 if (HeapObject::cast(re->data())->map()->instance_type() !=
1495 FIXED_ARRAY_TYPE) return; 1495 FIXED_ARRAY_TYPE) return;
1496 1496
1497 // Make sure this is a RegExp that actually contains code. 1497 // Make sure this is a RegExp that actually contains code.
1498 if (re->TypeTag() != JSRegExp::IRREGEXP) return; 1498 if (re->TypeTagUnchecked() != JSRegExp::IRREGEXP) return;
1499 1499
1500 Object* code = re->DataAt(JSRegExp::code_index(is_ascii)); 1500 Object* code = re->DataAtUnchecked(JSRegExp::code_index(is_ascii));
1501 if (!code->IsSmi() && 1501 if (!code->IsSmi() &&
1502 HeapObject::cast(code)->map()->instance_type() == CODE_TYPE) { 1502 HeapObject::cast(code)->map()->instance_type() == CODE_TYPE) {
1503 // Save a copy that can be reinstated if we need the code again. 1503 // Save a copy that can be reinstated if we need the code again.
1504 re->SetDataAt(JSRegExp::saved_code_index(is_ascii), code); 1504 re->SetDataAtUnchecked(JSRegExp::saved_code_index(is_ascii),
1505 code,
1506 heap);
1505 1507
1506 // Saving a copy might create a pointer into compaction candidate 1508 // Saving a copy might create a pointer into compaction candidate
1507 // that was not observed by marker. This might happen if JSRegExp data 1509 // that was not observed by marker. This might happen if JSRegExp data
1508 // was marked through the compilation cache before marker reached JSRegExp 1510 // was marked through the compilation cache before marker reached JSRegExp
1509 // object. 1511 // object.
1510 FixedArray* data = FixedArray::cast(re->data()); 1512 FixedArray* data = FixedArray::cast(re->data());
1511 Object** slot = data->data_start() + JSRegExp::saved_code_index(is_ascii); 1513 Object** slot = data->data_start() + JSRegExp::saved_code_index(is_ascii);
1512 heap->mark_compact_collector()-> 1514 heap->mark_compact_collector()->
1513 RecordSlot(slot, slot, code); 1515 RecordSlot(slot, slot, code);
1514 1516
1515 // Set a number in the 0-255 range to guarantee no smi overflow. 1517 // Set a number in the 0-255 range to guarantee no smi overflow.
1516 re->SetDataAt(JSRegExp::code_index(is_ascii), 1518 re->SetDataAtUnchecked(JSRegExp::code_index(is_ascii),
1517 Smi::FromInt(heap->sweep_generation() & 0xff)); 1519 Smi::FromInt(heap->sweep_generation() & 0xff),
1520 heap);
1518 } else if (code->IsSmi()) { 1521 } else if (code->IsSmi()) {
1519 int value = Smi::cast(code)->value(); 1522 int value = Smi::cast(code)->value();
1520 // The regexp has not been compiled yet or there was a compilation error. 1523 // The regexp has not been compiled yet or there was a compilation error.
1521 if (value == JSRegExp::kUninitializedValue || 1524 if (value == JSRegExp::kUninitializedValue ||
1522 value == JSRegExp::kCompilationErrorValue) { 1525 value == JSRegExp::kCompilationErrorValue) {
1523 return; 1526 return;
1524 } 1527 }
1525 1528
1526 // Check if we should flush now. 1529 // Check if we should flush now.
1527 if (value == ((heap->sweep_generation() - kRegExpCodeThreshold) & 0xff)) { 1530 if (value == ((heap->sweep_generation() - kRegExpCodeThreshold) & 0xff)) {
1528 re->SetDataAt(JSRegExp::code_index(is_ascii), 1531 re->SetDataAtUnchecked(JSRegExp::code_index(is_ascii),
1529 Smi::FromInt(JSRegExp::kUninitializedValue)); 1532 Smi::FromInt(JSRegExp::kUninitializedValue),
1530 re->SetDataAt(JSRegExp::saved_code_index(is_ascii), 1533 heap);
1531 Smi::FromInt(JSRegExp::kUninitializedValue)); 1534 re->SetDataAtUnchecked(JSRegExp::saved_code_index(is_ascii),
1535 Smi::FromInt(JSRegExp::kUninitializedValue),
1536 heap);
1532 } 1537 }
1533 } 1538 }
1534 } 1539 }
1535 1540
1536 1541
1537 // Works by setting the current sweep_generation (as a smi) in the 1542 // Works by setting the current sweep_generation (as a smi) in the
1538 // code object place in the data array of the RegExp and keeps a copy 1543 // code object place in the data array of the RegExp and keeps a copy
1539 // around that can be reinstated if we reuse the RegExp before flushing. 1544 // around that can be reinstated if we reuse the RegExp before flushing.
1540 // If we did not use the code for kRegExpCodeThreshold mark sweep GCs 1545 // If we did not use the code for kRegExpCodeThreshold mark sweep GCs
1541 // we flush the code. 1546 // we flush the code.
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
2436 if (map->IsFreeSpace()) continue; 2441 if (map->IsFreeSpace()) continue;
2437 2442
2438 ASSERT(map->IsMap()); 2443 ASSERT(map->IsMap());
2439 if (!map->CanTransition()) continue; 2444 if (!map->CanTransition()) continue;
2440 2445
2441 if (map_mark.Get() && 2446 if (map_mark.Get() &&
2442 map->attached_to_shared_function_info()) { 2447 map->attached_to_shared_function_info()) {
2443 // This map is used for inobject slack tracking and has been detached 2448 // This map is used for inobject slack tracking and has been detached
2444 // from SharedFunctionInfo during the mark phase. 2449 // from SharedFunctionInfo during the mark phase.
2445 // Since it survived the GC, reattach it now. 2450 // Since it survived the GC, reattach it now.
2446 JSFunction::cast(map->constructor())->shared()->AttachInitialMap(map); 2451 map->unchecked_constructor()->shared()->AttachInitialMap(map);
2447 } 2452 }
2448 2453
2449 ClearNonLivePrototypeTransitions(map); 2454 ClearNonLivePrototypeTransitions(map);
2450 ClearNonLiveMapTransitions(map, map_mark); 2455 ClearNonLiveMapTransitions(map, map_mark);
2451 2456
2452 if (map_mark.Get()) { 2457 if (map_mark.Get()) {
2453 ClearNonLiveDependentCode(map); 2458 ClearNonLiveDependentCode(map);
2454 } else { 2459 } else {
2455 ClearAndDeoptimizeDependentCode(map); 2460 ClearAndDeoptimizeDependentCode(map);
2456 } 2461 }
(...skipping 10 matching lines...) Expand all
2467 const int proto_offset = header + Map::kProtoTransitionPrototypeOffset; 2472 const int proto_offset = header + Map::kProtoTransitionPrototypeOffset;
2468 const int map_offset = header + Map::kProtoTransitionMapOffset; 2473 const int map_offset = header + Map::kProtoTransitionMapOffset;
2469 const int step = Map::kProtoTransitionElementsPerEntry; 2474 const int step = Map::kProtoTransitionElementsPerEntry;
2470 for (int i = 0; i < number_of_transitions; i++) { 2475 for (int i = 0; i < number_of_transitions; i++) {
2471 Object* prototype = prototype_transitions->get(proto_offset + i * step); 2476 Object* prototype = prototype_transitions->get(proto_offset + i * step);
2472 Object* cached_map = prototype_transitions->get(map_offset + i * step); 2477 Object* cached_map = prototype_transitions->get(map_offset + i * step);
2473 if (IsMarked(prototype) && IsMarked(cached_map)) { 2478 if (IsMarked(prototype) && IsMarked(cached_map)) {
2474 int proto_index = proto_offset + new_number_of_transitions * step; 2479 int proto_index = proto_offset + new_number_of_transitions * step;
2475 int map_index = map_offset + new_number_of_transitions * step; 2480 int map_index = map_offset + new_number_of_transitions * step;
2476 if (new_number_of_transitions != i) { 2481 if (new_number_of_transitions != i) {
2477 prototype_transitions->set( 2482 prototype_transitions->set_unchecked(
2483 heap_,
2478 proto_index, 2484 proto_index,
2479 prototype, 2485 prototype,
2480 UPDATE_WRITE_BARRIER); 2486 UPDATE_WRITE_BARRIER);
2481 prototype_transitions->set( 2487 prototype_transitions->set_unchecked(
2488 heap_,
2482 map_index, 2489 map_index,
2483 cached_map, 2490 cached_map,
2484 SKIP_WRITE_BARRIER); 2491 SKIP_WRITE_BARRIER);
2485 } 2492 }
2486 Object** slot = 2493 Object** slot =
2487 HeapObject::RawField(prototype_transitions, 2494 HeapObject::RawField(prototype_transitions,
2488 FixedArray::OffsetOfElementAt(proto_index)); 2495 FixedArray::OffsetOfElementAt(proto_index));
2489 RecordSlot(slot, slot, prototype); 2496 RecordSlot(slot, slot, prototype);
2490 new_number_of_transitions++; 2497 new_number_of_transitions++;
2491 } 2498 }
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after
4310 while (buffer != NULL) { 4317 while (buffer != NULL) {
4311 SlotsBuffer* next_buffer = buffer->next(); 4318 SlotsBuffer* next_buffer = buffer->next();
4312 DeallocateBuffer(buffer); 4319 DeallocateBuffer(buffer);
4313 buffer = next_buffer; 4320 buffer = next_buffer;
4314 } 4321 }
4315 *buffer_address = NULL; 4322 *buffer_address = NULL;
4316 } 4323 }
4317 4324
4318 4325
4319 } } // namespace v8::internal 4326 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lithium.h ('k') | src/mips/code-stubs-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698