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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "scanner-character-streams.h" | 47 #include "scanner-character-streams.h" |
48 #include "scopeinfo.h" | 48 #include "scopeinfo.h" |
49 #include "scopes.h" | 49 #include "scopes.h" |
50 #include "vm-state-inl.h" | 50 #include "vm-state-inl.h" |
51 | 51 |
52 namespace v8 { | 52 namespace v8 { |
53 namespace internal { | 53 namespace internal { |
54 | 54 |
55 | 55 |
56 CompilationInfo::CompilationInfo(Handle<Script> script, | 56 CompilationInfo::CompilationInfo(Handle<Script> script, |
57 Zone* zone, | 57 Zone* zone) |
58 Zone* phase_zone) | |
59 : flags_(LanguageModeField::encode(CLASSIC_MODE)), | 58 : flags_(LanguageModeField::encode(CLASSIC_MODE)), |
60 script_(script), | 59 script_(script), |
61 osr_ast_id_(BailoutId::None()) { | 60 osr_ast_id_(BailoutId::None()) { |
62 Initialize(script->GetIsolate(), BASE, zone, phase_zone); | 61 Initialize(script->GetIsolate(), BASE, zone); |
63 } | 62 } |
64 | 63 |
65 | 64 |
66 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info, | 65 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info, |
67 Zone* zone, | 66 Zone* zone) |
68 Zone* phase_zone) | |
69 : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)), | 67 : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)), |
70 shared_info_(shared_info), | 68 shared_info_(shared_info), |
71 script_(Handle<Script>(Script::cast(shared_info->script()))), | 69 script_(Handle<Script>(Script::cast(shared_info->script()))), |
72 osr_ast_id_(BailoutId::None()) { | 70 osr_ast_id_(BailoutId::None()) { |
73 Initialize(script_->GetIsolate(), BASE, zone, phase_zone); | 71 Initialize(script_->GetIsolate(), BASE, zone); |
74 } | 72 } |
75 | 73 |
76 | 74 |
77 CompilationInfo::CompilationInfo(Handle<JSFunction> closure, | 75 CompilationInfo::CompilationInfo(Handle<JSFunction> closure, |
78 Zone* zone, | 76 Zone* zone) |
79 Zone* phase_zone) | |
80 : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)), | 77 : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)), |
81 closure_(closure), | 78 closure_(closure), |
82 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), | 79 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), |
83 script_(Handle<Script>(Script::cast(shared_info_->script()))), | 80 script_(Handle<Script>(Script::cast(shared_info_->script()))), |
84 context_(closure->context()), | 81 context_(closure->context()), |
85 osr_ast_id_(BailoutId::None()) { | 82 osr_ast_id_(BailoutId::None()) { |
86 Initialize(script_->GetIsolate(), BASE, zone, phase_zone); | 83 Initialize(script_->GetIsolate(), BASE, zone); |
87 } | 84 } |
88 | 85 |
89 | 86 |
90 CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, | 87 CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, |
91 Isolate* isolate, | 88 Isolate* isolate, |
92 Zone* zone, | 89 Zone* zone) |
93 Zone* phase_zone) | |
94 : flags_(LanguageModeField::encode(CLASSIC_MODE) | | 90 : flags_(LanguageModeField::encode(CLASSIC_MODE) | |
95 IsLazy::encode(true)), | 91 IsLazy::encode(true)), |
96 osr_ast_id_(BailoutId::None()) { | 92 osr_ast_id_(BailoutId::None()) { |
97 Initialize(isolate, STUB, zone, phase_zone); | 93 Initialize(isolate, STUB, zone); |
98 code_stub_ = stub; | 94 code_stub_ = stub; |
99 } | 95 } |
100 | 96 |
101 | 97 |
102 void CompilationInfo::Initialize(Isolate* isolate, | 98 void CompilationInfo::Initialize(Isolate* isolate, |
103 Mode mode, | 99 Mode mode, |
104 Zone* zone, | 100 Zone* zone) { |
105 Zone* phase_zone) { | |
106 isolate_ = isolate; | 101 isolate_ = isolate; |
107 function_ = NULL; | 102 function_ = NULL; |
108 scope_ = NULL; | 103 scope_ = NULL; |
109 global_scope_ = NULL; | 104 global_scope_ = NULL; |
110 extension_ = NULL; | 105 extension_ = NULL; |
111 pre_parse_data_ = NULL; | 106 pre_parse_data_ = NULL; |
112 zone_ = zone; | 107 zone_ = zone; |
113 phase_zone_ = phase_zone; | |
114 deferred_handles_ = NULL; | 108 deferred_handles_ = NULL; |
115 code_stub_ = NULL; | 109 code_stub_ = NULL; |
116 prologue_offset_ = kPrologueOffsetNotSet; | 110 prologue_offset_ = kPrologueOffsetNotSet; |
117 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); | 111 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); |
118 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() | 112 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() |
119 ? new List<OffsetRange>(2) : NULL; | 113 ? new List<OffsetRange>(2) : NULL; |
120 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 114 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
121 dependencies_[i] = NULL; | 115 dependencies_[i] = NULL; |
122 } | 116 } |
123 if (mode == STUB) { | 117 if (mode == STUB) { |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 } | 1215 } |
1222 } | 1216 } |
1223 | 1217 |
1224 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1218 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
1225 Handle<Script>(info->script()), | 1219 Handle<Script>(info->script()), |
1226 Handle<Code>(info->code()), | 1220 Handle<Code>(info->code()), |
1227 info)); | 1221 info)); |
1228 } | 1222 } |
1229 | 1223 |
1230 | 1224 |
1231 CompilationPhase::CompilationPhase(const char* name, | 1225 CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info) |
1232 Isolate* isolate, | 1226 : name_(name), info_(info), zone_(info->isolate()) { |
1233 Zone* zone) | |
1234 : name_(name), isolate_(isolate), zone_(zone) { | |
1235 if (FLAG_hydrogen_stats) { | 1227 if (FLAG_hydrogen_stats) { |
1236 start_allocation_size_ = zone->allocation_size(); | 1228 info_zone_start_allocation_size_ = info->zone()->allocation_size(); |
1237 start_ticks_ = OS::Ticks(); | 1229 start_ticks_ = OS::Ticks(); |
1238 } | 1230 } |
1239 } | 1231 } |
1240 | 1232 |
1241 | 1233 |
1242 CompilationPhase::~CompilationPhase() { | 1234 CompilationPhase::~CompilationPhase() { |
1243 if (FLAG_hydrogen_stats) { | 1235 if (FLAG_hydrogen_stats) { |
1244 unsigned size = zone()->allocation_size() - start_allocation_size_; | 1236 unsigned size = zone()->allocation_size(); |
| 1237 size += info_->zone()->allocation_size() - info_zone_start_allocation_size_; |
1245 int64_t ticks = OS::Ticks() - start_ticks_; | 1238 int64_t ticks = OS::Ticks() - start_ticks_; |
1246 isolate_->GetHStatistics()->SaveTiming(name_, ticks, size); | 1239 isolate()->GetHStatistics()->SaveTiming(name_, ticks, size); |
1247 } | 1240 } |
1248 } | 1241 } |
1249 | 1242 |
1250 | 1243 |
1251 bool CompilationPhase::ShouldProduceTraceOutput() const { | 1244 bool CompilationPhase::ShouldProduceTraceOutput() const { |
1252 // Produce trace output if flag is set so that the first letter of the | 1245 // Produce trace output if flag is set so that the first letter of the |
1253 // phase name matches the command line parameter FLAG_trace_phase. | 1246 // phase name matches the command line parameter FLAG_trace_phase. |
1254 return (FLAG_trace_hydrogen && | 1247 return (FLAG_trace_hydrogen && |
1255 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1248 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1256 } | 1249 } |
1257 | 1250 |
1258 } } // namespace v8::internal | 1251 } } // namespace v8::internal |
OLD | NEW |