| 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 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1717 function->initialize_elements(); | 1717 function->initialize_elements(); |
| 1718 function->set_shared(shared); | 1718 function->set_shared(shared); |
| 1719 function->set_prototype_or_initial_map(prototype); | 1719 function->set_prototype_or_initial_map(prototype); |
| 1720 function->set_context(undefined_value()); | 1720 function->set_context(undefined_value()); |
| 1721 function->set_literals(empty_fixed_array(), SKIP_WRITE_BARRIER); | 1721 function->set_literals(empty_fixed_array(), SKIP_WRITE_BARRIER); |
| 1722 return function; | 1722 return function; |
| 1723 } | 1723 } |
| 1724 | 1724 |
| 1725 | 1725 |
| 1726 Object* Heap::AllocateFunctionPrototype(JSFunction* function) { | 1726 Object* Heap::AllocateFunctionPrototype(JSFunction* function) { |
| 1727 // Allocate the prototype. | 1727 // Allocate the prototype. Make sure to use the object function |
| 1728 Object* prototype = | 1728 // from the function's context, since the function can be from a |
| 1729 AllocateJSObject(Top::context()->global_context()->object_function()); | 1729 // different context. |
| 1730 JSFunction* object_function = |
| 1731 function->context()->global_context()->object_function(); |
| 1732 Object* prototype = AllocateJSObject(object_function); |
| 1730 if (prototype->IsFailure()) return prototype; | 1733 if (prototype->IsFailure()) return prototype; |
| 1731 // When creating the prototype for the function we must set its | 1734 // When creating the prototype for the function we must set its |
| 1732 // constructor to the function. | 1735 // constructor to the function. |
| 1733 Object* result = | 1736 Object* result = |
| 1734 JSObject::cast(prototype)->SetProperty(constructor_symbol(), | 1737 JSObject::cast(prototype)->SetProperty(constructor_symbol(), |
| 1735 function, | 1738 function, |
| 1736 DONT_ENUM); | 1739 DONT_ENUM); |
| 1737 if (result->IsFailure()) return result; | 1740 if (result->IsFailure()) return result; |
| 1738 return prototype; | 1741 return prototype; |
| 1739 } | 1742 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 for (int offset = JSObject::kHeaderSize; | 1900 for (int offset = JSObject::kHeaderSize; |
| 1898 offset < object_size; | 1901 offset < object_size; |
| 1899 offset += kPointerSize) { | 1902 offset += kPointerSize) { |
| 1900 RecordWrite(clone_address, offset); | 1903 RecordWrite(clone_address, offset); |
| 1901 } | 1904 } |
| 1902 } else { | 1905 } else { |
| 1903 clone = new_space_.AllocateRaw(object_size); | 1906 clone = new_space_.AllocateRaw(object_size); |
| 1904 if (clone->IsFailure()) return clone; | 1907 if (clone->IsFailure()) return clone; |
| 1905 ASSERT(Heap::InNewSpace(clone)); | 1908 ASSERT(Heap::InNewSpace(clone)); |
| 1906 // Since we know the clone is allocated in new space, we can copy | 1909 // Since we know the clone is allocated in new space, we can copy |
| 1907 // the contents without worring about updating the write barrier. | 1910 // the contents without worrying about updating the write barrier. |
| 1908 CopyBlock(reinterpret_cast<Object**>(HeapObject::cast(clone)->address()), | 1911 CopyBlock(reinterpret_cast<Object**>(HeapObject::cast(clone)->address()), |
| 1909 reinterpret_cast<Object**>(source->address()), | 1912 reinterpret_cast<Object**>(source->address()), |
| 1910 object_size); | 1913 object_size); |
| 1911 } | 1914 } |
| 1912 | 1915 |
| 1913 FixedArray* elements = FixedArray::cast(source->elements()); | 1916 FixedArray* elements = FixedArray::cast(source->elements()); |
| 1914 FixedArray* properties = FixedArray::cast(source->properties()); | 1917 FixedArray* properties = FixedArray::cast(source->properties()); |
| 1915 // Update elements if necessary. | 1918 // Update elements if necessary. |
| 1916 if (elements->length()> 0) { | 1919 if (elements->length()> 0) { |
| 1917 Object* elem = CopyFixedArray(elements); | 1920 Object* elem = CopyFixedArray(elements); |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3357 #ifdef DEBUG | 3360 #ifdef DEBUG |
| 3358 bool Heap::GarbageCollectionGreedyCheck() { | 3361 bool Heap::GarbageCollectionGreedyCheck() { |
| 3359 ASSERT(FLAG_gc_greedy); | 3362 ASSERT(FLAG_gc_greedy); |
| 3360 if (Bootstrapper::IsActive()) return true; | 3363 if (Bootstrapper::IsActive()) return true; |
| 3361 if (disallow_allocation_failure()) return true; | 3364 if (disallow_allocation_failure()) return true; |
| 3362 return CollectGarbage(0, NEW_SPACE); | 3365 return CollectGarbage(0, NEW_SPACE); |
| 3363 } | 3366 } |
| 3364 #endif | 3367 #endif |
| 3365 | 3368 |
| 3366 } } // namespace v8::internal | 3369 } } // namespace v8::internal |
| OLD | NEW |