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

Side by Side Diff: src/heap.cc

Issue 9181: Push string shape fixes to trunk (version 0.4.3.1). (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 12 years, 1 month 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/heap.h ('k') | src/jsregexp.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 // Call the slow part of scavenge object. 776 // Call the slow part of scavenge object.
777 return ScavengeObjectSlow(p, object); 777 return ScavengeObjectSlow(p, object);
778 } 778 }
779 779
780 780
781 static inline bool IsShortcutCandidate(HeapObject* object, Map* map) { 781 static inline bool IsShortcutCandidate(HeapObject* object, Map* map) {
782 // A ConsString object with Heap::empty_string() as the right side 782 // A ConsString object with Heap::empty_string() as the right side
783 // is a candidate for being shortcut by the scavenger. 783 // is a candidate for being shortcut by the scavenger.
784 ASSERT(object->map() == map); 784 ASSERT(object->map() == map);
785 if (map->instance_type() >= FIRST_NONSTRING_TYPE) return false; 785 if (map->instance_type() >= FIRST_NONSTRING_TYPE) return false;
786 StringShape shape(map); 786 return (StringShape(map).representation_tag() == kConsStringTag) &&
787 return (shape.representation_tag() == kConsStringTag) &&
788 (ConsString::cast(object)->unchecked_second() == Heap::empty_string()); 787 (ConsString::cast(object)->unchecked_second() == Heap::empty_string());
789 } 788 }
790 789
791 790
792 void Heap::ScavengeObjectSlow(HeapObject** p, HeapObject* object) { 791 void Heap::ScavengeObjectSlow(HeapObject** p, HeapObject* object) {
793 ASSERT(InFromSpace(object)); 792 ASSERT(InFromSpace(object));
794 MapWord first_word = object->map_word(); 793 MapWord first_word = object->map_word();
795 ASSERT(!first_word.IsForwardingAddress()); 794 ASSERT(!first_word.IsForwardingAddress());
796 795
797 // Optimization: Bypass flattened ConsString objects. 796 // Optimization: Bypass flattened ConsString objects.
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 share->set_function_data(undefined_value()); 1339 share->set_function_data(undefined_value());
1341 share->set_lazy_load_data(undefined_value()); 1340 share->set_lazy_load_data(undefined_value());
1342 share->set_script(undefined_value()); 1341 share->set_script(undefined_value());
1343 share->set_start_position_and_type(0); 1342 share->set_start_position_and_type(0);
1344 share->set_debug_info(undefined_value()); 1343 share->set_debug_info(undefined_value());
1345 return result; 1344 return result;
1346 } 1345 }
1347 1346
1348 1347
1349 Object* Heap::AllocateConsString(String* first, 1348 Object* Heap::AllocateConsString(String* first,
1350 StringShape first_shape, 1349 String* second) {
1351 String* second, 1350 StringShape first_shape(first);
1352 StringShape second_shape) { 1351 StringShape second_shape(second);
1353 int first_length = first->length(first_shape); 1352 int first_length = first->length(first_shape);
1354 int second_length = second->length(second_shape); 1353 int second_length = second->length(second_shape);
1355 int length = first_length + second_length; 1354 int length = first_length + second_length;
1356 bool is_ascii = first_shape.IsAsciiRepresentation() 1355 bool is_ascii = first_shape.IsAsciiRepresentation()
1357 && second_shape.IsAsciiRepresentation(); 1356 && second_shape.IsAsciiRepresentation();
1358 1357
1359 // If the resulting string is small make a flat string. 1358 // If the resulting string is small make a flat string.
1360 if (length < String::kMinNonFlatLength) { 1359 if (length < String::kMinNonFlatLength) {
1361 ASSERT(first->IsFlat(first_shape)); 1360 ASSERT(first->IsFlat(first_shape));
1362 ASSERT(second->IsFlat(second_shape)); 1361 ASSERT(second->IsFlat(second_shape));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 ASSERT(InNewSpace(result)); 1403 ASSERT(InNewSpace(result));
1405 ConsString* cons_string = ConsString::cast(result); 1404 ConsString* cons_string = ConsString::cast(result);
1406 cons_string->set_first(first, SKIP_WRITE_BARRIER); 1405 cons_string->set_first(first, SKIP_WRITE_BARRIER);
1407 cons_string->set_second(second, SKIP_WRITE_BARRIER); 1406 cons_string->set_second(second, SKIP_WRITE_BARRIER);
1408 cons_string->set_length(length); 1407 cons_string->set_length(length);
1409 return result; 1408 return result;
1410 } 1409 }
1411 1410
1412 1411
1413 Object* Heap::AllocateSlicedString(String* buffer, 1412 Object* Heap::AllocateSlicedString(String* buffer,
1414 StringShape buffer_shape,
1415 int start, 1413 int start,
1416 int end) { 1414 int end) {
1415 StringShape buffer_shape(buffer);
1417 int length = end - start; 1416 int length = end - start;
1418 1417
1419 // If the resulting string is small make a sub string. 1418 // If the resulting string is small make a sub string.
1420 if (end - start <= String::kMinNonFlatLength) { 1419 if (end - start <= String::kMinNonFlatLength) {
1421 return Heap::AllocateSubString(buffer, buffer_shape, start, end); 1420 return Heap::AllocateSubString(buffer, buffer_shape, start, end);
1422 } 1421 }
1423 1422
1424 Map* map; 1423 Map* map;
1425 if (length <= String::kMaxShortStringSize) { 1424 if (length <= String::kMaxShortStringSize) {
1426 map = buffer_shape.IsAsciiRepresentation() ? 1425 map = buffer_shape.IsAsciiRepresentation() ?
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after
3252 #ifdef DEBUG 3251 #ifdef DEBUG
3253 bool Heap::GarbageCollectionGreedyCheck() { 3252 bool Heap::GarbageCollectionGreedyCheck() {
3254 ASSERT(FLAG_gc_greedy); 3253 ASSERT(FLAG_gc_greedy);
3255 if (Bootstrapper::IsActive()) return true; 3254 if (Bootstrapper::IsActive()) return true;
3256 if (disallow_allocation_failure()) return true; 3255 if (disallow_allocation_failure()) return true;
3257 return CollectGarbage(0, NEW_SPACE); 3256 return CollectGarbage(0, NEW_SPACE);
3258 } 3257 }
3259 #endif 3258 #endif
3260 3259
3261 } } // namespace v8::internal 3260 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698