| OLD | NEW |
| 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 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 } else if (length <= String::kMaxMediumStringSize) { | 1371 } else if (length <= String::kMaxMediumStringSize) { |
| 1372 map = is_ascii ? medium_cons_ascii_string_map() | 1372 map = is_ascii ? medium_cons_ascii_string_map() |
| 1373 : medium_cons_string_map(); | 1373 : medium_cons_string_map(); |
| 1374 } else { | 1374 } else { |
| 1375 map = is_ascii ? long_cons_ascii_string_map() | 1375 map = is_ascii ? long_cons_ascii_string_map() |
| 1376 : long_cons_string_map(); | 1376 : long_cons_string_map(); |
| 1377 } | 1377 } |
| 1378 | 1378 |
| 1379 Object* result = Allocate(map, NEW_SPACE); | 1379 Object* result = Allocate(map, NEW_SPACE); |
| 1380 if (result->IsFailure()) return result; | 1380 if (result->IsFailure()) return result; |
| 1381 | 1381 ASSERT(InNewSpace(result)); |
| 1382 ConsString* cons_string = ConsString::cast(result); | 1382 ConsString* cons_string = ConsString::cast(result); |
| 1383 cons_string->set_first(first); | 1383 cons_string->set_first(first, SKIP_WRITE_BARRIER); |
| 1384 cons_string->set_second(second); | 1384 cons_string->set_second(second, SKIP_WRITE_BARRIER); |
| 1385 cons_string->set_length(length); | 1385 cons_string->set_length(length); |
| 1386 | |
| 1387 return result; | 1386 return result; |
| 1388 } | 1387 } |
| 1389 | 1388 |
| 1390 | 1389 |
| 1391 Object* Heap::AllocateSlicedString(String* buffer, int start, int end) { | 1390 Object* Heap::AllocateSlicedString(String* buffer, int start, int end) { |
| 1392 int length = end - start; | 1391 int length = end - start; |
| 1393 | 1392 |
| 1394 // If the resulting string is small make a sub string. | 1393 // If the resulting string is small make a sub string. |
| 1395 if (end - start <= String::kMinNonFlatLength) { | 1394 if (end - start <= String::kMinNonFlatLength) { |
| 1396 return Heap::AllocateSubString(buffer, start, end); | 1395 return Heap::AllocateSubString(buffer, start, end); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 | 1607 |
| 1609 Object* Heap::InitializeFunction(JSFunction* function, | 1608 Object* Heap::InitializeFunction(JSFunction* function, |
| 1610 SharedFunctionInfo* shared, | 1609 SharedFunctionInfo* shared, |
| 1611 Object* prototype) { | 1610 Object* prototype) { |
| 1612 ASSERT(!prototype->IsMap()); | 1611 ASSERT(!prototype->IsMap()); |
| 1613 function->initialize_properties(); | 1612 function->initialize_properties(); |
| 1614 function->initialize_elements(); | 1613 function->initialize_elements(); |
| 1615 function->set_shared(shared); | 1614 function->set_shared(shared); |
| 1616 function->set_prototype_or_initial_map(prototype); | 1615 function->set_prototype_or_initial_map(prototype); |
| 1617 function->set_context(undefined_value()); | 1616 function->set_context(undefined_value()); |
| 1618 function->set_literals(empty_fixed_array()); | 1617 function->set_literals(empty_fixed_array(), SKIP_WRITE_BARRIER); |
| 1619 return function; | 1618 return function; |
| 1620 } | 1619 } |
| 1621 | 1620 |
| 1622 | 1621 |
| 1623 Object* Heap::AllocateFunctionPrototype(JSFunction* function) { | 1622 Object* Heap::AllocateFunctionPrototype(JSFunction* function) { |
| 1624 // Allocate the prototype. | 1623 // Allocate the prototype. |
| 1625 Object* prototype = | 1624 Object* prototype = |
| 1626 AllocateJSObject(Top::context()->global_context()->object_function()); | 1625 AllocateJSObject(Top::context()->global_context()->object_function()); |
| 1627 if (prototype->IsFailure()) return prototype; | 1626 if (prototype->IsFailure()) return prototype; |
| 1628 // When creating the prototype for the function we must set its | 1627 // When creating the prototype for the function we must set its |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 object_size); | 1668 object_size); |
| 1670 | 1669 |
| 1671 // Set the two properties. | 1670 // Set the two properties. |
| 1672 JSObject::cast(result)->InObjectPropertyAtPut(arguments_callee_index, | 1671 JSObject::cast(result)->InObjectPropertyAtPut(arguments_callee_index, |
| 1673 callee, | 1672 callee, |
| 1674 SKIP_WRITE_BARRIER); | 1673 SKIP_WRITE_BARRIER); |
| 1675 JSObject::cast(result)->InObjectPropertyAtPut(arguments_length_index, | 1674 JSObject::cast(result)->InObjectPropertyAtPut(arguments_length_index, |
| 1676 Smi::FromInt(length), | 1675 Smi::FromInt(length), |
| 1677 SKIP_WRITE_BARRIER); | 1676 SKIP_WRITE_BARRIER); |
| 1678 | 1677 |
| 1679 // Allocate the elements if needed. | |
| 1680 if (length > 0) { | |
| 1681 // Allocate the fixed array. | |
| 1682 Object* obj = Heap::AllocateFixedArray(length); | |
| 1683 if (obj->IsFailure()) return obj; | |
| 1684 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); | |
| 1685 } | |
| 1686 | |
| 1687 // Check the state of the object | 1678 // Check the state of the object |
| 1688 ASSERT(JSObject::cast(result)->HasFastProperties()); | 1679 ASSERT(JSObject::cast(result)->HasFastProperties()); |
| 1689 ASSERT(JSObject::cast(result)->HasFastElements()); | 1680 ASSERT(JSObject::cast(result)->HasFastElements()); |
| 1690 | 1681 |
| 1691 return result; | 1682 return result; |
| 1692 } | 1683 } |
| 1693 | 1684 |
| 1694 | 1685 |
| 1695 Object* Heap::AllocateInitialMap(JSFunction* fun) { | 1686 Object* Heap::AllocateInitialMap(JSFunction* fun) { |
| 1696 ASSERT(!fun->has_initial_map()); | 1687 ASSERT(!fun->has_initial_map()); |
| (...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3195 #ifdef DEBUG | 3186 #ifdef DEBUG |
| 3196 bool Heap::GarbageCollectionGreedyCheck() { | 3187 bool Heap::GarbageCollectionGreedyCheck() { |
| 3197 ASSERT(FLAG_gc_greedy); | 3188 ASSERT(FLAG_gc_greedy); |
| 3198 if (Bootstrapper::IsActive()) return true; | 3189 if (Bootstrapper::IsActive()) return true; |
| 3199 if (disallow_allocation_failure()) return true; | 3190 if (disallow_allocation_failure()) return true; |
| 3200 return CollectGarbage(0, NEW_SPACE); | 3191 return CollectGarbage(0, NEW_SPACE); |
| 3201 } | 3192 } |
| 3202 #endif | 3193 #endif |
| 3203 | 3194 |
| 3204 } } // namespace v8::internal | 3195 } } // namespace v8::internal |
| OLD | NEW |