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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 #ifdef ENABLE_DISASSEMBLER | 127 #ifdef ENABLE_DISASSEMBLER |
128 AllowDeferredHandleDereference allow_deference_for_print_code; | 128 AllowDeferredHandleDereference allow_deference_for_print_code; |
129 bool print_code = info->isolate()->bootstrapper()->IsActive() | 129 bool print_code = info->isolate()->bootstrapper()->IsActive() |
130 ? FLAG_print_builtin_code | 130 ? FLAG_print_builtin_code |
131 : (FLAG_print_code || | 131 : (FLAG_print_code || |
132 (info->IsStub() && FLAG_print_code_stubs) || | 132 (info->IsStub() && FLAG_print_code_stubs) || |
133 (info->IsOptimizing() && FLAG_print_opt_code)); | 133 (info->IsOptimizing() && FLAG_print_opt_code)); |
134 if (print_code) { | 134 if (print_code) { |
135 // Print the source code if available. | 135 // Print the source code if available. |
136 FunctionLiteral* function = info->function(); | 136 FunctionLiteral* function = info->function(); |
137 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | 137 bool print_source = code->kind() == Code::OPTIMIZED_FUNCTION || |
138 code->kind() == Code::FUNCTION; | |
Michael Starzinger
2013/10/18 13:04:21
nit: Indentation is off.
danno
2013/10/19 17:11:40
Done.
| |
139 if (print_source) { | |
138 Handle<Script> script = info->script(); | 140 Handle<Script> script = info->script(); |
139 if (!script->IsUndefined() && !script->source()->IsUndefined()) { | 141 if (!script->IsUndefined() && !script->source()->IsUndefined()) { |
140 PrintF("--- Raw source ---\n"); | 142 PrintF("--- Raw source ---\n"); |
141 ConsStringIteratorOp op; | 143 ConsStringIteratorOp op; |
142 StringCharacterStream stream(String::cast(script->source()), | 144 StringCharacterStream stream(String::cast(script->source()), |
143 &op, | 145 &op, |
144 function->start_position()); | 146 function->start_position()); |
145 // fun->end_position() points to the last character in the stream. We | 147 // fun->end_position() points to the last character in the stream. We |
146 // need to compensate by adding one to calculate the length. | 148 // need to compensate by adding one to calculate the length. |
147 int source_len = | 149 int source_len = |
148 function->end_position() - function->start_position() + 1; | 150 function->end_position() - function->start_position() + 1; |
149 for (int i = 0; i < source_len; i++) { | 151 for (int i = 0; i < source_len; i++) { |
150 if (stream.HasMore()) PrintF("%c", stream.GetNext()); | 152 if (stream.HasMore()) PrintF("%c", stream.GetNext()); |
151 } | 153 } |
152 PrintF("\n\n"); | 154 PrintF("\n\n"); |
153 } | 155 } |
154 } | 156 } |
155 if (info->IsOptimizing()) { | 157 if (info->IsOptimizing()) { |
156 if (FLAG_print_unopt_code) { | 158 if (FLAG_print_unopt_code) { |
157 PrintF("--- Unoptimized code ---\n"); | 159 PrintF("--- Unoptimized code ---\n"); |
158 info->closure()->shared()->code()->Disassemble( | 160 info->closure()->shared()->code()->Disassemble( |
159 *function->debug_name()->ToCString()); | 161 *function->debug_name()->ToCString()); |
160 } | 162 } |
161 PrintF("--- Optimized code ---\n"); | 163 PrintF("--- Optimized code ---\n"); |
162 } else { | 164 } else { |
163 PrintF("--- Code ---\n"); | 165 PrintF("--- Code ---\n"); |
164 } | 166 } |
167 if (print_source) { | |
168 PrintF("source_position = %d\n", function->start_position()); | |
169 } | |
165 if (info->IsStub()) { | 170 if (info->IsStub()) { |
166 CodeStub::Major major_key = info->code_stub()->MajorKey(); | 171 CodeStub::Major major_key = info->code_stub()->MajorKey(); |
167 code->Disassemble(CodeStub::MajorName(major_key, false)); | 172 code->Disassemble(CodeStub::MajorName(major_key, false)); |
168 } else { | 173 } else { |
169 code->Disassemble(*function->debug_name()->ToCString()); | 174 code->Disassemble(*function->debug_name()->ToCString()); |
170 } | 175 } |
176 PrintF("--- End code ---\n"); | |
171 } | 177 } |
172 #endif // ENABLE_DISASSEMBLER | 178 #endif // ENABLE_DISASSEMBLER |
173 } | 179 } |
174 | 180 |
175 | 181 |
176 bool CodeGenerator::ShouldGenerateLog(Isolate* isolate, Expression* type) { | 182 bool CodeGenerator::ShouldGenerateLog(Isolate* isolate, Expression* type) { |
177 ASSERT(type != NULL); | 183 ASSERT(type != NULL); |
178 if (!isolate->logger()->is_logging() && | 184 if (!isolate->logger()->is_logging() && |
179 !isolate->cpu_profiler()->is_profiling()) { | 185 !isolate->cpu_profiler()->is_profiling()) { |
180 return false; | 186 return false; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 ASSERT(result_size_ == 1 || result_size_ == 2); | 231 ASSERT(result_size_ == 1 || result_size_ == 2); |
226 #ifdef _WIN64 | 232 #ifdef _WIN64 |
227 return result | ((result_size_ == 1) ? 0 : 2); | 233 return result | ((result_size_ == 1) ? 0 : 2); |
228 #else | 234 #else |
229 return result; | 235 return result; |
230 #endif | 236 #endif |
231 } | 237 } |
232 | 238 |
233 | 239 |
234 } } // namespace v8::internal | 240 } } // namespace v8::internal |
OLD | NEW |