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

Side by Side Diff: src/isolate.cc

Issue 10574013: Snapshots: Add --extra-code flag to mksnapshot which lets you specify a file (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 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/isolate.h ('k') | src/mksnapshot.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 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 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData(); 1540 PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData();
1541 Isolate* saved_isolate = UncheckedCurrent(); 1541 Isolate* saved_isolate = UncheckedCurrent();
1542 SetIsolateThreadLocals(this, NULL); 1542 SetIsolateThreadLocals(this, NULL);
1543 1543
1544 Deinit(); 1544 Deinit();
1545 1545
1546 { ScopedLock lock(process_wide_mutex_); 1546 { ScopedLock lock(process_wide_mutex_);
1547 thread_data_table_->RemoveAllThreads(this); 1547 thread_data_table_->RemoveAllThreads(this);
1548 } 1548 }
1549 1549
1550 if (serialize_partial_snapshot_cache_ != NULL) {
1551 delete[] serialize_partial_snapshot_cache_;
1552 serialize_partial_snapshot_cache_ = NULL;
1553 }
1554
1550 if (!IsDefaultIsolate()) { 1555 if (!IsDefaultIsolate()) {
1551 delete this; 1556 delete this;
1552 } 1557 }
1553 1558
1554 // Restore the previous current isolate. 1559 // Restore the previous current isolate.
1555 SetIsolateThreadLocals(saved_isolate, saved_data); 1560 SetIsolateThreadLocals(saved_isolate, saved_data);
1556 } 1561 }
1557 1562
1558 1563
1559 void Isolate::Deinit() { 1564 void Isolate::Deinit() {
(...skipping 28 matching lines...) Expand all
1588 } 1593 }
1589 heap_.TearDown(); 1594 heap_.TearDown();
1590 logger_->TearDown(); 1595 logger_->TearDown();
1591 1596
1592 // The default isolate is re-initializable due to legacy API. 1597 // The default isolate is re-initializable due to legacy API.
1593 state_ = UNINITIALIZED; 1598 state_ = UNINITIALIZED;
1594 } 1599 }
1595 } 1600 }
1596 1601
1597 1602
1603 void Isolate::PushToPartialSnapshotCache(Object* obj) {
1604 int length = serialize_partial_snapshot_cache_length();
1605 int capacity = serialize_partial_snapshot_cache_capacity();
1606
1607 if (length >= capacity) {
1608 int new_capacity = (capacity + 10) * 1.2;
1609 Object** new_array = new Object*[new_capacity];
1610 for (int i = 0; i < length; i++) {
1611 new_array[i] = serialize_partial_snapshot_cache()[i];
1612 }
1613 if (capacity != 0) delete[] serialize_partial_snapshot_cache();
1614 set_serialize_partial_snapshot_cache(new_array);
1615 set_serialize_partial_snapshot_cache_capacity(new_capacity);
1616 }
1617
1618 serialize_partial_snapshot_cache()[length] = obj;
1619 set_serialize_partial_snapshot_cache_length(length + 1);
1620 }
1621
1622
1598 void Isolate::SetIsolateThreadLocals(Isolate* isolate, 1623 void Isolate::SetIsolateThreadLocals(Isolate* isolate,
1599 PerIsolateThreadData* data) { 1624 PerIsolateThreadData* data) {
1600 Thread::SetThreadLocal(isolate_key_, isolate); 1625 Thread::SetThreadLocal(isolate_key_, isolate);
1601 Thread::SetThreadLocal(per_isolate_thread_data_key_, data); 1626 Thread::SetThreadLocal(per_isolate_thread_data_key_, data);
1602 } 1627 }
1603 1628
1604 1629
1605 Isolate::~Isolate() { 1630 Isolate::~Isolate() {
1606 TRACE_ISOLATE(destructor); 1631 TRACE_ISOLATE(destructor);
1607 1632
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 } 1830 }
1806 1831
1807 // SetUp the object heap. 1832 // SetUp the object heap.
1808 const bool create_heap_objects = (des == NULL); 1833 const bool create_heap_objects = (des == NULL);
1809 ASSERT(!heap_.HasBeenSetUp()); 1834 ASSERT(!heap_.HasBeenSetUp());
1810 if (!heap_.SetUp(create_heap_objects)) { 1835 if (!heap_.SetUp(create_heap_objects)) {
1811 V8::SetFatalError(); 1836 V8::SetFatalError();
1812 return false; 1837 return false;
1813 } 1838 }
1814 1839
1840 if (create_heap_objects) {
1841 // Terminate the cache array with the sentinel so we can iterate.
1842 PushToPartialSnapshotCache(heap_.undefined_value());
1843 }
1844
1815 InitializeThreadLocal(); 1845 InitializeThreadLocal();
1816 1846
1817 bootstrapper_->Initialize(create_heap_objects); 1847 bootstrapper_->Initialize(create_heap_objects);
1818 builtins_.SetUp(create_heap_objects); 1848 builtins_.SetUp(create_heap_objects);
1819 1849
1820 // Only preallocate on the first initialization. 1850 // Only preallocate on the first initialization.
1821 if (FLAG_preallocate_message_memory && preallocated_message_space_ == NULL) { 1851 if (FLAG_preallocate_message_memory && preallocated_message_space_ == NULL) {
1822 // Start the thread which will set aside some memory. 1852 // Start the thread which will set aside some memory.
1823 PreallocatedMemoryThreadStart(); 1853 PreallocatedMemoryThreadStart();
1824 preallocated_message_space_ = 1854 preallocated_message_space_ =
1825 new NoAllocationStringAllocator( 1855 new NoAllocationStringAllocator(
1826 preallocated_memory_thread_->data(), 1856 preallocated_memory_thread_->data(),
1827 preallocated_memory_thread_->length()); 1857 preallocated_memory_thread_->length());
1828 PreallocatedStorageInit(preallocated_memory_thread_->length() / 4); 1858 PreallocatedStorageInit(preallocated_memory_thread_->length() / 4);
1829 } 1859 }
1830 1860
1831 if (FLAG_preemption) { 1861 if (FLAG_preemption) {
1832 v8::Locker locker; 1862 v8::Locker locker;
1833 v8::Locker::StartPreemption(100); 1863 v8::Locker::StartPreemption(100);
1834 } 1864 }
1835 1865
1836 #ifdef ENABLE_DEBUGGER_SUPPORT 1866 #ifdef ENABLE_DEBUGGER_SUPPORT
1837 debug_->SetUp(create_heap_objects); 1867 debug_->SetUp(create_heap_objects);
1838 #endif 1868 #endif
1839 1869
1840 // If we are deserializing, read the state into the now-empty heap. 1870 // If we are deserializing, read the state into the now-empty heap.
1841 if (des != NULL) { 1871 if (!create_heap_objects) {
1842 des->Deserialize(); 1872 des->Deserialize();
1843 } 1873 }
1844 stub_cache_->Initialize(); 1874 stub_cache_->Initialize();
1845 1875
1846 // Finish initialization of ThreadLocal after deserialization is done. 1876 // Finish initialization of ThreadLocal after deserialization is done.
1847 clear_pending_exception(); 1877 clear_pending_exception();
1848 clear_pending_message(); 1878 clear_pending_message();
1849 clear_scheduled_exception(); 1879 clear_scheduled_exception();
1850 1880
1851 // Deserializing may put strange things in the root array's copy of the 1881 // Deserializing may put strange things in the root array's copy of the
1852 // stack guard. 1882 // stack guard.
1853 heap_.SetStackLimits(); 1883 heap_.SetStackLimits();
1854 1884
1855 // Quiet the heap NaN if needed on target platform. 1885 // Quiet the heap NaN if needed on target platform.
1856 if (des != NULL) Assembler::QuietNaN(heap_.nan_value()); 1886 if (create_heap_objects) Assembler::QuietNaN(heap_.nan_value());
1857 1887
1858 deoptimizer_data_ = new DeoptimizerData; 1888 deoptimizer_data_ = new DeoptimizerData;
1859 runtime_profiler_ = new RuntimeProfiler(this); 1889 runtime_profiler_ = new RuntimeProfiler(this);
1860 runtime_profiler_->SetUp(); 1890 runtime_profiler_->SetUp();
1861 1891
1862 // If we are deserializing, log non-function code objects and compiled 1892 // If we are deserializing, log non-function code objects and compiled
1863 // functions found in the snapshot. 1893 // functions found in the snapshot.
1864 if (des != NULL && (FLAG_log_code || FLAG_ll_prof)) { 1894 if (create_heap_objects && (FLAG_log_code || FLAG_ll_prof)) {
1865 HandleScope scope; 1895 HandleScope scope;
1866 LOG(this, LogCodeObjects()); 1896 LOG(this, LogCodeObjects());
1867 LOG(this, LogCompiledFunctions()); 1897 LOG(this, LogCompiledFunctions());
1868 } 1898 }
1869 1899
1870 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, state_)), 1900 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, state_)),
1871 Internals::kIsolateStateOffset); 1901 Internals::kIsolateStateOffset);
1872 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, embedder_data_)), 1902 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, embedder_data_)),
1873 Internals::kIsolateEmbedderDataOffset); 1903 Internals::kIsolateEmbedderDataOffset);
1874 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.roots_)), 1904 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.roots_)),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 1991
1962 #ifdef DEBUG 1992 #ifdef DEBUG
1963 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 1993 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
1964 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 1994 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
1965 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 1995 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
1966 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 1996 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
1967 #undef ISOLATE_FIELD_OFFSET 1997 #undef ISOLATE_FIELD_OFFSET
1968 #endif 1998 #endif
1969 1999
1970 } } // namespace v8::internal 2000 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/mksnapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698