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

Side by Side Diff: src/heap.cc

Issue 3144002: Copy-on-write arrays. (Closed)
Patch Set: Review fixes. Created 10 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
« no previous file with comments | « src/heap.h ('k') | src/ia32/codegen-ia32.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 // Fix prototype object for existing maps. 1450 // Fix prototype object for existing maps.
1451 meta_map()->set_prototype(null_value()); 1451 meta_map()->set_prototype(null_value());
1452 meta_map()->set_constructor(null_value()); 1452 meta_map()->set_constructor(null_value());
1453 1453
1454 fixed_array_map()->set_prototype(null_value()); 1454 fixed_array_map()->set_prototype(null_value());
1455 fixed_array_map()->set_constructor(null_value()); 1455 fixed_array_map()->set_constructor(null_value());
1456 1456
1457 oddball_map()->set_prototype(null_value()); 1457 oddball_map()->set_prototype(null_value());
1458 oddball_map()->set_constructor(null_value()); 1458 oddball_map()->set_constructor(null_value());
1459 1459
1460 obj = AllocateMap(FIXED_ARRAY_TYPE, FixedArray::kHeaderSize);
1461 if (obj->IsFailure()) return false;
1462 set_fixed_cow_array_map(Map::cast(obj));
1463 ASSERT(fixed_array_map() != fixed_cow_array_map());
1464
1460 obj = AllocateMap(HEAP_NUMBER_TYPE, HeapNumber::kSize); 1465 obj = AllocateMap(HEAP_NUMBER_TYPE, HeapNumber::kSize);
1461 if (obj->IsFailure()) return false; 1466 if (obj->IsFailure()) return false;
1462 set_heap_number_map(Map::cast(obj)); 1467 set_heap_number_map(Map::cast(obj));
1463 1468
1464 obj = AllocateMap(PROXY_TYPE, Proxy::kSize); 1469 obj = AllocateMap(PROXY_TYPE, Proxy::kSize);
1465 if (obj->IsFailure()) return false; 1470 if (obj->IsFailure()) return false;
1466 set_proxy_map(Map::cast(obj)); 1471 set_proxy_map(Map::cast(obj));
1467 1472
1468 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) { 1473 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) {
1469 const StringTypeTable& entry = string_type_table[i]; 1474 const StringTypeTable& entry = string_type_table[i];
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2903 // the contents without worrying about updating the write barrier. 2908 // the contents without worrying about updating the write barrier.
2904 CopyBlock(HeapObject::cast(clone)->address(), 2909 CopyBlock(HeapObject::cast(clone)->address(),
2905 source->address(), 2910 source->address(),
2906 object_size); 2911 object_size);
2907 } 2912 }
2908 2913
2909 FixedArray* elements = FixedArray::cast(source->elements()); 2914 FixedArray* elements = FixedArray::cast(source->elements());
2910 FixedArray* properties = FixedArray::cast(source->properties()); 2915 FixedArray* properties = FixedArray::cast(source->properties());
2911 // Update elements if necessary. 2916 // Update elements if necessary.
2912 if (elements->length() > 0) { 2917 if (elements->length() > 0) {
2913 Object* elem = CopyFixedArray(elements); 2918 Object* elem =
2919 (elements->map() == fixed_cow_array_map()) ?
2920 elements : CopyFixedArray(elements);
2914 if (elem->IsFailure()) return elem; 2921 if (elem->IsFailure()) return elem;
2915 JSObject::cast(clone)->set_elements(FixedArray::cast(elem)); 2922 JSObject::cast(clone)->set_elements(FixedArray::cast(elem));
2916 } 2923 }
2917 // Update properties if necessary. 2924 // Update properties if necessary.
2918 if (properties->length() > 0) { 2925 if (properties->length() > 0) {
2919 Object* prop = CopyFixedArray(properties); 2926 Object* prop = CopyFixedArray(properties);
2920 if (prop->IsFailure()) return prop; 2927 if (prop->IsFailure()) return prop;
2921 JSObject::cast(clone)->set_properties(FixedArray::cast(prop)); 2928 JSObject::cast(clone)->set_properties(FixedArray::cast(prop));
2922 } 2929 }
2923 // Return the new clone. 2930 // Return the new clone.
(...skipping 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after
4958 void ExternalStringTable::TearDown() { 4965 void ExternalStringTable::TearDown() {
4959 new_space_strings_.Free(); 4966 new_space_strings_.Free();
4960 old_space_strings_.Free(); 4967 old_space_strings_.Free();
4961 } 4968 }
4962 4969
4963 4970
4964 List<Object*> ExternalStringTable::new_space_strings_; 4971 List<Object*> ExternalStringTable::new_space_strings_;
4965 List<Object*> ExternalStringTable::old_space_strings_; 4972 List<Object*> ExternalStringTable::old_space_strings_;
4966 4973
4967 } } // namespace v8::internal 4974 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698