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 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 | 1247 |
1248 private: | 1248 private: |
1249 Handle<SharedFunctionInfo>* sfis_; | 1249 Handle<SharedFunctionInfo>* sfis_; |
1250 Handle<Code>* code_objects_; | 1250 Handle<Code>* code_objects_; |
1251 int* count_; | 1251 int* count_; |
1252 }; | 1252 }; |
1253 | 1253 |
1254 | 1254 |
1255 static int EnumerateCompiledFunctions(Handle<SharedFunctionInfo>* sfis, | 1255 static int EnumerateCompiledFunctions(Handle<SharedFunctionInfo>* sfis, |
1256 Handle<Code>* code_objects) { | 1256 Handle<Code>* code_objects) { |
| 1257 Heap::EnsureHeapIsIterable(); |
1257 AssertNoAllocation no_alloc; | 1258 AssertNoAllocation no_alloc; |
1258 int compiled_funcs_count = 0; | 1259 int compiled_funcs_count = 0; |
1259 | 1260 |
1260 // Iterate the heap to find shared function info objects and record | 1261 // Iterate the heap to find shared function info objects and record |
1261 // the unoptimized code for them. | 1262 // the unoptimized code for them. |
1262 HeapIterator iterator; | 1263 HeapIterator iterator; |
1263 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1264 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { |
1264 if (!obj->IsSharedFunctionInfo()) continue; | 1265 if (!obj->IsSharedFunctionInfo()) continue; |
1265 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj); | 1266 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj); |
1266 if (sfi->is_compiled() | 1267 if (sfi->is_compiled() |
1267 && (!sfi->script()->IsScript() | 1268 && (!sfi->script()->IsScript() |
1268 || Script::cast(sfi->script())->HasValidSource())) { | 1269 || Script::cast(sfi->script())->HasValidSource())) { |
1269 if (sfis != NULL) { | 1270 if (sfis != NULL) { |
1270 sfis[compiled_funcs_count] = Handle<SharedFunctionInfo>(sfi); | 1271 sfis[compiled_funcs_count] = Handle<SharedFunctionInfo>(sfi); |
1271 } | 1272 } |
1272 if (code_objects != NULL) { | 1273 if (code_objects != NULL) { |
1273 code_objects[compiled_funcs_count] = Handle<Code>(sfi->code()); | 1274 code_objects[compiled_funcs_count] = Handle<Code>(sfi->code()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 int pos = static_cast<int>(ftell(Log::output_code_handle_)); | 1364 int pos = static_cast<int>(ftell(Log::output_code_handle_)); |
1364 size_t rv = fwrite(code->instruction_start(), 1, code->instruction_size(), | 1365 size_t rv = fwrite(code->instruction_start(), 1, code->instruction_size(), |
1365 Log::output_code_handle_); | 1366 Log::output_code_handle_); |
1366 ASSERT(static_cast<size_t>(code->instruction_size()) == rv); | 1367 ASSERT(static_cast<size_t>(code->instruction_size()) == rv); |
1367 USE(rv); | 1368 USE(rv); |
1368 msg->Append(",%d", pos); | 1369 msg->Append(",%d", pos); |
1369 } | 1370 } |
1370 | 1371 |
1371 | 1372 |
1372 void Logger::LogCodeObjects() { | 1373 void Logger::LogCodeObjects() { |
| 1374 Heap::EnsureHeapIsIterable(); |
1373 AssertNoAllocation no_alloc; | 1375 AssertNoAllocation no_alloc; |
1374 HeapIterator iterator; | 1376 HeapIterator iterator; |
1375 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1377 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { |
1376 if (obj->IsCode()) LogCodeObject(obj); | 1378 if (obj->IsCode()) LogCodeObject(obj); |
1377 } | 1379 } |
1378 } | 1380 } |
1379 | 1381 |
1380 | 1382 |
1381 void Logger::LogCompiledFunctions() { | 1383 void Logger::LogCompiledFunctions() { |
1382 HandleScope scope; | 1384 HandleScope scope; |
1383 const int compiled_funcs_count = EnumerateCompiledFunctions(NULL, NULL); | 1385 const int compiled_funcs_count = EnumerateCompiledFunctions(NULL, NULL); |
1384 ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count); | 1386 ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count); |
1385 ScopedVector< Handle<Code> > code_objects(compiled_funcs_count); | 1387 ScopedVector< Handle<Code> > code_objects(compiled_funcs_count); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 } | 1427 } |
1426 } else { | 1428 } else { |
1427 PROFILE(CodeCreateEvent( | 1429 PROFILE(CodeCreateEvent( |
1428 Logger::LAZY_COMPILE_TAG, *code_objects[i], *func_name)); | 1430 Logger::LAZY_COMPILE_TAG, *code_objects[i], *func_name)); |
1429 } | 1431 } |
1430 } | 1432 } |
1431 } | 1433 } |
1432 | 1434 |
1433 | 1435 |
1434 void Logger::LogFunctionObjects() { | 1436 void Logger::LogFunctionObjects() { |
| 1437 Heap::EnsureHeapIsIterable(); |
1435 AssertNoAllocation no_alloc; | 1438 AssertNoAllocation no_alloc; |
1436 HeapIterator iterator; | 1439 HeapIterator iterator; |
1437 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1440 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { |
1438 if (!obj->IsJSFunction()) continue; | 1441 if (!obj->IsJSFunction()) continue; |
1439 JSFunction* jsf = JSFunction::cast(obj); | 1442 JSFunction* jsf = JSFunction::cast(obj); |
1440 if (!jsf->is_compiled()) continue; | 1443 if (!jsf->is_compiled()) continue; |
1441 PROFILE(FunctionCreateEvent(jsf)); | 1444 PROFILE(FunctionCreateEvent(jsf)); |
1442 } | 1445 } |
1443 } | 1446 } |
1444 | 1447 |
1445 | 1448 |
1446 void Logger::LogAccessorCallbacks() { | 1449 void Logger::LogAccessorCallbacks() { |
| 1450 Heap::EnsureHeapIsIterable(); |
1447 AssertNoAllocation no_alloc; | 1451 AssertNoAllocation no_alloc; |
1448 HeapIterator iterator; | 1452 HeapIterator iterator; |
1449 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1453 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { |
1450 if (!obj->IsAccessorInfo()) continue; | 1454 if (!obj->IsAccessorInfo()) continue; |
1451 AccessorInfo* ai = AccessorInfo::cast(obj); | 1455 AccessorInfo* ai = AccessorInfo::cast(obj); |
1452 if (!ai->name()->IsString()) continue; | 1456 if (!ai->name()->IsString()) continue; |
1453 String* name = String::cast(ai->name()); | 1457 String* name = String::cast(ai->name()); |
1454 Address getter_entry = v8::ToCData<Address>(ai->getter()); | 1458 Address getter_entry = v8::ToCData<Address>(ai->getter()); |
1455 if (getter_entry != 0) { | 1459 if (getter_entry != 0) { |
1456 PROFILE(GetterCallbackEvent(name, getter_entry)); | 1460 PROFILE(GetterCallbackEvent(name, getter_entry)); |
1457 } | 1461 } |
1458 Address setter_entry = v8::ToCData<Address>(ai->setter()); | 1462 Address setter_entry = v8::ToCData<Address>(ai->setter()); |
1459 if (setter_entry != 0) { | 1463 if (setter_entry != 0) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 } | 1632 } |
1629 // Otherwise, if the sliding state window computation has not been | 1633 // Otherwise, if the sliding state window computation has not been |
1630 // started we do it now. | 1634 // started we do it now. |
1631 if (sliding_state_window_ == NULL) { | 1635 if (sliding_state_window_ == NULL) { |
1632 sliding_state_window_ = new SlidingStateWindow(); | 1636 sliding_state_window_ = new SlidingStateWindow(); |
1633 } | 1637 } |
1634 #endif | 1638 #endif |
1635 } | 1639 } |
1636 | 1640 |
1637 } } // namespace v8::internal | 1641 } } // namespace v8::internal |
OLD | NEW |