| 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 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 | 1231 |
| 1232 private: | 1232 private: |
| 1233 Handle<SharedFunctionInfo>* sfis_; | 1233 Handle<SharedFunctionInfo>* sfis_; |
| 1234 Handle<Code>* code_objects_; | 1234 Handle<Code>* code_objects_; |
| 1235 int* count_; | 1235 int* count_; |
| 1236 }; | 1236 }; |
| 1237 | 1237 |
| 1238 | 1238 |
| 1239 static int EnumerateCompiledFunctions(Handle<SharedFunctionInfo>* sfis, | 1239 static int EnumerateCompiledFunctions(Handle<SharedFunctionInfo>* sfis, |
| 1240 Handle<Code>* code_objects) { | 1240 Handle<Code>* code_objects) { |
| 1241 HeapIterator iterator; |
| 1241 AssertNoAllocation no_alloc; | 1242 AssertNoAllocation no_alloc; |
| 1242 int compiled_funcs_count = 0; | 1243 int compiled_funcs_count = 0; |
| 1243 | 1244 |
| 1244 // Iterate the heap to find shared function info objects and record | 1245 // Iterate the heap to find shared function info objects and record |
| 1245 // the unoptimized code for them. | 1246 // the unoptimized code for them. |
| 1246 HeapIterator iterator; | 1247 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { |
| 1247 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | |
| 1248 if (!obj->IsSharedFunctionInfo()) continue; | 1248 if (!obj->IsSharedFunctionInfo()) continue; |
| 1249 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj); | 1249 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj); |
| 1250 if (sfi->is_compiled() | 1250 if (sfi->is_compiled() |
| 1251 && (!sfi->script()->IsScript() | 1251 && (!sfi->script()->IsScript() |
| 1252 || Script::cast(sfi->script())->HasValidSource())) { | 1252 || Script::cast(sfi->script())->HasValidSource())) { |
| 1253 if (sfis != NULL) { | 1253 if (sfis != NULL) { |
| 1254 sfis[compiled_funcs_count] = Handle<SharedFunctionInfo>(sfi); | 1254 sfis[compiled_funcs_count] = Handle<SharedFunctionInfo>(sfi); |
| 1255 } | 1255 } |
| 1256 if (code_objects != NULL) { | 1256 if (code_objects != NULL) { |
| 1257 code_objects[compiled_funcs_count] = Handle<Code>(sfi->code()); | 1257 code_objects[compiled_funcs_count] = Handle<Code>(sfi->code()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 int pos = static_cast<int>(ftell(Log::output_code_handle_)); | 1355 int pos = static_cast<int>(ftell(Log::output_code_handle_)); |
| 1356 size_t rv = fwrite(code->instruction_start(), 1, code->instruction_size(), | 1356 size_t rv = fwrite(code->instruction_start(), 1, code->instruction_size(), |
| 1357 Log::output_code_handle_); | 1357 Log::output_code_handle_); |
| 1358 ASSERT(static_cast<size_t>(code->instruction_size()) == rv); | 1358 ASSERT(static_cast<size_t>(code->instruction_size()) == rv); |
| 1359 USE(rv); | 1359 USE(rv); |
| 1360 msg->Append(",%d", pos); | 1360 msg->Append(",%d", pos); |
| 1361 } | 1361 } |
| 1362 | 1362 |
| 1363 | 1363 |
| 1364 void Logger::LogCodeObjects() { | 1364 void Logger::LogCodeObjects() { |
| 1365 HeapIterator iterator; |
| 1365 AssertNoAllocation no_alloc; | 1366 AssertNoAllocation no_alloc; |
| 1366 HeapIterator iterator; | 1367 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { |
| 1367 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | |
| 1368 if (obj->IsCode()) LogCodeObject(obj); | 1368 if (obj->IsCode()) LogCodeObject(obj); |
| 1369 } | 1369 } |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 | 1372 |
| 1373 void Logger::LogCompiledFunctions() { | 1373 void Logger::LogCompiledFunctions() { |
| 1374 HandleScope scope; | 1374 HandleScope scope; |
| 1375 const int compiled_funcs_count = EnumerateCompiledFunctions(NULL, NULL); | 1375 const int compiled_funcs_count = EnumerateCompiledFunctions(NULL, NULL); |
| 1376 ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count); | 1376 ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count); |
| 1377 ScopedVector< Handle<Code> > code_objects(compiled_funcs_count); | 1377 ScopedVector< Handle<Code> > code_objects(compiled_funcs_count); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 } | 1416 } |
| 1417 } else { | 1417 } else { |
| 1418 PROFILE(CodeCreateEvent( | 1418 PROFILE(CodeCreateEvent( |
| 1419 Logger::LAZY_COMPILE_TAG, *code_objects[i], *shared, *func_name)); | 1419 Logger::LAZY_COMPILE_TAG, *code_objects[i], *shared, *func_name)); |
| 1420 } | 1420 } |
| 1421 } | 1421 } |
| 1422 } | 1422 } |
| 1423 | 1423 |
| 1424 | 1424 |
| 1425 void Logger::LogAccessorCallbacks() { | 1425 void Logger::LogAccessorCallbacks() { |
| 1426 HeapIterator iterator; |
| 1426 AssertNoAllocation no_alloc; | 1427 AssertNoAllocation no_alloc; |
| 1427 HeapIterator iterator; | 1428 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { |
| 1428 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | |
| 1429 if (!obj->IsAccessorInfo()) continue; | 1429 if (!obj->IsAccessorInfo()) continue; |
| 1430 AccessorInfo* ai = AccessorInfo::cast(obj); | 1430 AccessorInfo* ai = AccessorInfo::cast(obj); |
| 1431 if (!ai->name()->IsString()) continue; | 1431 if (!ai->name()->IsString()) continue; |
| 1432 String* name = String::cast(ai->name()); | 1432 String* name = String::cast(ai->name()); |
| 1433 Address getter_entry = v8::ToCData<Address>(ai->getter()); | 1433 Address getter_entry = v8::ToCData<Address>(ai->getter()); |
| 1434 if (getter_entry != 0) { | 1434 if (getter_entry != 0) { |
| 1435 PROFILE(GetterCallbackEvent(name, getter_entry)); | 1435 PROFILE(GetterCallbackEvent(name, getter_entry)); |
| 1436 } | 1436 } |
| 1437 Address setter_entry = v8::ToCData<Address>(ai->setter()); | 1437 Address setter_entry = v8::ToCData<Address>(ai->setter()); |
| 1438 if (setter_entry != 0) { | 1438 if (setter_entry != 0) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 } | 1607 } |
| 1608 // Otherwise, if the sliding state window computation has not been | 1608 // Otherwise, if the sliding state window computation has not been |
| 1609 // started we do it now. | 1609 // started we do it now. |
| 1610 if (sliding_state_window_ == NULL) { | 1610 if (sliding_state_window_ == NULL) { |
| 1611 sliding_state_window_ = new SlidingStateWindow(); | 1611 sliding_state_window_ = new SlidingStateWindow(); |
| 1612 } | 1612 } |
| 1613 #endif | 1613 #endif |
| 1614 } | 1614 } |
| 1615 | 1615 |
| 1616 } } // namespace v8::internal | 1616 } } // namespace v8::internal |
| OLD | NEW |