| OLD | NEW |
| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 if (exception_behavior == NULL) { | 117 if (exception_behavior == NULL) { |
| 118 exception_behavior = DefaultFatalErrorHandler; | 118 exception_behavior = DefaultFatalErrorHandler; |
| 119 } | 119 } |
| 120 return exception_behavior; | 120 return exception_behavior; |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 | 124 |
| 125 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. | 125 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. |
| 126 // The default fatal error handler is called and execution is stopped. | 126 // The default fatal error handler is called and execution is stopped. |
| 127 static void ExecuteFatalProcessOutOfMemory(const char* location, | 127 void i::V8::FatalProcessOutOfMemory(const char* location) { |
| 128 i::HeapStats* heap_stats) { | 128 i::HeapStats heap_stats; |
| 129 int start_marker; |
| 130 heap_stats.start_marker = &start_marker; |
| 131 int new_space_size; |
| 132 heap_stats.new_space_size = &new_space_size; |
| 133 int new_space_capacity; |
| 134 heap_stats.new_space_capacity = &new_space_capacity; |
| 135 int old_pointer_space_size; |
| 136 heap_stats.old_pointer_space_size = &old_pointer_space_size; |
| 137 int old_pointer_space_capacity; |
| 138 heap_stats.old_pointer_space_capacity = &old_pointer_space_capacity; |
| 139 int old_data_space_size; |
| 140 heap_stats.old_data_space_size = &old_data_space_size; |
| 141 int old_data_space_capacity; |
| 142 heap_stats.old_data_space_capacity = &old_data_space_capacity; |
| 143 int code_space_size; |
| 144 heap_stats.code_space_size = &code_space_size; |
| 145 int code_space_capacity; |
| 146 heap_stats.code_space_capacity = &code_space_capacity; |
| 147 int map_space_size; |
| 148 heap_stats.map_space_size = &map_space_size; |
| 149 int map_space_capacity; |
| 150 heap_stats.map_space_capacity = &map_space_capacity; |
| 151 int cell_space_size; |
| 152 heap_stats.cell_space_size = &cell_space_size; |
| 153 int cell_space_capacity; |
| 154 heap_stats.cell_space_capacity = &cell_space_capacity; |
| 155 int lo_space_size; |
| 156 heap_stats.lo_space_size = &lo_space_size; |
| 157 int global_handle_count; |
| 158 heap_stats.global_handle_count = &global_handle_count; |
| 159 int weak_global_handle_count; |
| 160 heap_stats.weak_global_handle_count = &weak_global_handle_count; |
| 161 int pending_global_handle_count; |
| 162 heap_stats.pending_global_handle_count = &pending_global_handle_count; |
| 163 int near_death_global_handle_count; |
| 164 heap_stats.near_death_global_handle_count = &near_death_global_handle_count; |
| 165 int destroyed_global_handle_count; |
| 166 heap_stats.destroyed_global_handle_count = &destroyed_global_handle_count; |
| 167 int end_marker; |
| 168 heap_stats.end_marker = &end_marker; |
| 169 i::Heap::RecordStats(&heap_stats); |
| 129 i::V8::SetFatalError(); | 170 i::V8::SetFatalError(); |
| 130 FatalErrorCallback callback = GetFatalErrorHandler(); | 171 FatalErrorCallback callback = GetFatalErrorHandler(); |
| 131 { | 172 { |
| 132 LEAVE_V8; | 173 LEAVE_V8; |
| 133 callback(location, "Allocation failed - process out of memory"); | 174 callback(location, "Allocation failed - process out of memory"); |
| 134 } | 175 } |
| 135 // If the callback returns, we stop execution. | 176 // If the callback returns, we stop execution. |
| 136 UNREACHABLE(); | 177 UNREACHABLE(); |
| 137 } | 178 } |
| 138 | 179 |
| 139 | 180 |
| 140 void i::V8::FatalProcessOutOfMemory(const char* location) { | |
| 141 i::HeapStats heap_stats; | |
| 142 i::Heap::RecordStats(&heap_stats); | |
| 143 ExecuteFatalProcessOutOfMemory(location, &heap_stats); | |
| 144 } | |
| 145 | |
| 146 | |
| 147 void V8::SetFatalErrorHandler(FatalErrorCallback that) { | 181 void V8::SetFatalErrorHandler(FatalErrorCallback that) { |
| 148 exception_behavior = that; | 182 exception_behavior = that; |
| 149 } | 183 } |
| 150 | 184 |
| 151 | 185 |
| 152 bool Utils::ReportApiFailure(const char* location, const char* message) { | 186 bool Utils::ReportApiFailure(const char* location, const char* message) { |
| 153 FatalErrorCallback callback = GetFatalErrorHandler(); | 187 FatalErrorCallback callback = GetFatalErrorHandler(); |
| 154 callback(location, message); | 188 callback(location, message); |
| 155 i::V8::SetFatalError(); | 189 i::V8::SetFatalError(); |
| 156 return false; | 190 return false; |
| (...skipping 3708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3865 | 3899 |
| 3866 | 3900 |
| 3867 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 3901 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 3868 HandleScopeImplementer* thread_local = | 3902 HandleScopeImplementer* thread_local = |
| 3869 reinterpret_cast<HandleScopeImplementer*>(storage); | 3903 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 3870 thread_local->IterateThis(v); | 3904 thread_local->IterateThis(v); |
| 3871 return storage + ArchiveSpacePerThread(); | 3905 return storage + ArchiveSpacePerThread(); |
| 3872 } | 3906 } |
| 3873 | 3907 |
| 3874 } } // namespace v8::internal | 3908 } } // namespace v8::internal |
| OLD | NEW |