OLD | NEW |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "runtime.h" | 48 #include "runtime.h" |
49 #include "zone.h" | 49 #include "zone.h" |
50 | 50 |
51 namespace v8 { | 51 namespace v8 { |
52 namespace internal { | 52 namespace internal { |
53 | 53 |
54 class Bootstrapper; | 54 class Bootstrapper; |
55 class CodeGenerator; | 55 class CodeGenerator; |
56 class CodeRange; | 56 class CodeRange; |
57 struct CodeStubInterfaceDescriptor; | 57 struct CodeStubInterfaceDescriptor; |
| 58 class CodeTracer; |
58 class CompilationCache; | 59 class CompilationCache; |
59 class ContextSlotCache; | 60 class ContextSlotCache; |
60 class ContextSwitcher; | 61 class ContextSwitcher; |
61 class Counters; | 62 class Counters; |
62 class CpuFeatures; | 63 class CpuFeatures; |
63 class CpuProfiler; | 64 class CpuProfiler; |
64 class DeoptimizerData; | 65 class DeoptimizerData; |
65 class Deserializer; | 66 class Deserializer; |
66 class EmptyStatement; | 67 class EmptyStatement; |
67 class ExternalCallbackScope; | 68 class ExternalCallbackScope; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 /* TODO(isolates): Release this on destruction? */ \ | 371 /* TODO(isolates): Release this on destruction? */ \ |
371 V(int*, irregexp_interpreter_backtrack_stack_cache, NULL) \ | 372 V(int*, irregexp_interpreter_backtrack_stack_cache, NULL) \ |
372 /* Serializer state. */ \ | 373 /* Serializer state. */ \ |
373 V(ExternalReferenceTable*, external_reference_table, NULL) \ | 374 V(ExternalReferenceTable*, external_reference_table, NULL) \ |
374 /* AstNode state. */ \ | 375 /* AstNode state. */ \ |
375 V(int, ast_node_id, 0) \ | 376 V(int, ast_node_id, 0) \ |
376 V(unsigned, ast_node_count, 0) \ | 377 V(unsigned, ast_node_count, 0) \ |
377 V(bool, observer_delivery_pending, false) \ | 378 V(bool, observer_delivery_pending, false) \ |
378 V(HStatistics*, hstatistics, NULL) \ | 379 V(HStatistics*, hstatistics, NULL) \ |
379 V(HTracer*, htracer, NULL) \ | 380 V(HTracer*, htracer, NULL) \ |
| 381 V(CodeTracer*, code_tracer, NULL) \ |
380 ISOLATE_DEBUGGER_INIT_LIST(V) | 382 ISOLATE_DEBUGGER_INIT_LIST(V) |
381 | 383 |
382 class Isolate { | 384 class Isolate { |
383 // These forward declarations are required to make the friend declarations in | 385 // These forward declarations are required to make the friend declarations in |
384 // PerIsolateThreadData work on some older versions of gcc. | 386 // PerIsolateThreadData work on some older versions of gcc. |
385 class ThreadDataTable; | 387 class ThreadDataTable; |
386 class EntryStackItem; | 388 class EntryStackItem; |
387 public: | 389 public: |
388 ~Isolate(); | 390 ~Isolate(); |
389 | 391 |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 static v8::Isolate* GetDefaultIsolateForLocking(); | 1119 static v8::Isolate* GetDefaultIsolateForLocking(); |
1118 | 1120 |
1119 SweeperThread** sweeper_threads() { | 1121 SweeperThread** sweeper_threads() { |
1120 return sweeper_thread_; | 1122 return sweeper_thread_; |
1121 } | 1123 } |
1122 | 1124 |
1123 int id() const { return static_cast<int>(id_); } | 1125 int id() const { return static_cast<int>(id_); } |
1124 | 1126 |
1125 HStatistics* GetHStatistics(); | 1127 HStatistics* GetHStatistics(); |
1126 HTracer* GetHTracer(); | 1128 HTracer* GetHTracer(); |
| 1129 CodeTracer* GetCodeTracer(); |
1127 | 1130 |
1128 FunctionEntryHook function_entry_hook() { return function_entry_hook_; } | 1131 FunctionEntryHook function_entry_hook() { return function_entry_hook_; } |
1129 void set_function_entry_hook(FunctionEntryHook function_entry_hook) { | 1132 void set_function_entry_hook(FunctionEntryHook function_entry_hook) { |
1130 function_entry_hook_ = function_entry_hook; | 1133 function_entry_hook_ = function_entry_hook; |
1131 } | 1134 } |
1132 | 1135 |
1133 void* stress_deopt_count_address() { return &stress_deopt_count_; } | 1136 void* stress_deopt_count_address() { return &stress_deopt_count_; } |
1134 | 1137 |
1135 inline RandomNumberGenerator* random_number_generator(); | 1138 inline RandomNumberGenerator* random_number_generator(); |
1136 | 1139 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 inline bool Context::has_out_of_memory() { | 1501 inline bool Context::has_out_of_memory() { |
1499 return native_context()->out_of_memory()->IsTrue(); | 1502 return native_context()->out_of_memory()->IsTrue(); |
1500 } | 1503 } |
1501 | 1504 |
1502 | 1505 |
1503 // Mark the native context with out of memory. | 1506 // Mark the native context with out of memory. |
1504 inline void Context::mark_out_of_memory() { | 1507 inline void Context::mark_out_of_memory() { |
1505 native_context()->set_out_of_memory(GetIsolate()->heap()->true_value()); | 1508 native_context()->set_out_of_memory(GetIsolate()->heap()->true_value()); |
1506 } | 1509 } |
1507 | 1510 |
| 1511 class CodeTracer V8_FINAL : public Malloced { |
| 1512 public: |
| 1513 explicit CodeTracer(int isolate_id) |
| 1514 : file_(NULL), |
| 1515 scope_depth_(0) { |
| 1516 if (!ShouldRedirect()) { |
| 1517 file_ = stdout; |
| 1518 return; |
| 1519 } |
| 1520 |
| 1521 if (FLAG_redirect_code_traces_to == NULL) { |
| 1522 OS::SNPrintF(filename_, |
| 1523 "code-%d-%d.asm", |
| 1524 OS::GetCurrentProcessId(), |
| 1525 isolate_id); |
| 1526 } else { |
| 1527 OS::StrNCpy(filename_, FLAG_redirect_code_traces_to, filename_.length()); |
| 1528 } |
| 1529 |
| 1530 WriteChars(filename_.start(), "", 0, false); |
| 1531 } |
| 1532 |
| 1533 class Scope { |
| 1534 public: |
| 1535 explicit Scope(CodeTracer* tracer) : tracer_(tracer) { tracer->OpenFile(); } |
| 1536 ~Scope() { tracer_->CloseFile(); } |
| 1537 |
| 1538 FILE* file() const { return tracer_->file(); } |
| 1539 |
| 1540 private: |
| 1541 CodeTracer* tracer_; |
| 1542 }; |
| 1543 |
| 1544 void OpenFile() { |
| 1545 if (!ShouldRedirect()) { |
| 1546 return; |
| 1547 } |
| 1548 |
| 1549 if (file_ == NULL) { |
| 1550 file_ = OS::FOpen(filename_.start(), "a"); |
| 1551 } |
| 1552 |
| 1553 scope_depth_++; |
| 1554 } |
| 1555 |
| 1556 void CloseFile() { |
| 1557 if (!ShouldRedirect()) { |
| 1558 return; |
| 1559 } |
| 1560 |
| 1561 if (--scope_depth_ == 0) { |
| 1562 fclose(file_); |
| 1563 file_ = NULL; |
| 1564 } |
| 1565 } |
| 1566 |
| 1567 FILE* file() const { return file_; } |
| 1568 |
| 1569 private: |
| 1570 static bool ShouldRedirect() { |
| 1571 return FLAG_redirect_code_traces; |
| 1572 } |
| 1573 |
| 1574 EmbeddedVector<char, 128> filename_; |
| 1575 FILE* file_; |
| 1576 int scope_depth_; |
| 1577 }; |
1508 | 1578 |
1509 } } // namespace v8::internal | 1579 } } // namespace v8::internal |
1510 | 1580 |
1511 #endif // V8_ISOLATE_H_ | 1581 #endif // V8_ISOLATE_H_ |
OLD | NEW |