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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 | 115 |
116 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) { | 116 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) { |
117 #ifdef ENABLE_DISASSEMBLER | 117 #ifdef ENABLE_DISASSEMBLER |
118 bool print_code = Isolate::Current()->bootstrapper()->IsActive() | 118 bool print_code = Isolate::Current()->bootstrapper()->IsActive() |
119 ? FLAG_print_builtin_code | 119 ? FLAG_print_builtin_code |
120 : (FLAG_print_code || (info->IsOptimizing() && FLAG_print_opt_code)); | 120 : (FLAG_print_code || (info->IsOptimizing() && FLAG_print_opt_code)); |
121 if (print_code) { | 121 if (print_code) { |
122 // Print the source code if available. | 122 // Print the source code if available. |
123 FunctionLiteral* function = info->function(); | 123 FunctionLiteral* function = info->function(); |
124 if (code->kind() != Code::COMPILED_STUB) { | 124 Handle<Script> script = info->script(); |
125 Handle<Script> script = info->script(); | 125 if (!script->IsUndefined() && !script->source()->IsUndefined()) { |
126 if (!script->IsUndefined() && !script->source()->IsUndefined()) { | 126 PrintF("--- Raw source ---\n"); |
127 PrintF("--- Raw source ---\n"); | 127 StringInputBuffer stream(String::cast(script->source())); |
128 StringInputBuffer stream(String::cast(script->source())); | 128 stream.Seek(function->start_position()); |
129 stream.Seek(function->start_position()); | 129 // fun->end_position() points to the last character in the stream. We |
130 // fun->end_position() points to the last character in the stream. We | 130 // need to compensate by adding one to calculate the length. |
131 // need to compensate by adding one to calculate the length. | 131 int source_len = |
132 int source_len = | 132 function->end_position() - function->start_position() + 1; |
133 function->end_position() - function->start_position() + 1; | 133 for (int i = 0; i < source_len; i++) { |
134 for (int i = 0; i < source_len; i++) { | 134 if (stream.has_more()) PrintF("%c", stream.GetNext()); |
135 if (stream.has_more()) PrintF("%c", stream.GetNext()); | |
136 } | |
137 PrintF("\n\n"); | |
138 } | 135 } |
| 136 PrintF("\n\n"); |
139 } | 137 } |
140 if (info->IsOptimizing()) { | 138 if (info->IsOptimizing()) { |
141 if (FLAG_print_unopt_code) { | 139 if (FLAG_print_unopt_code) { |
142 PrintF("--- Unoptimized code ---\n"); | 140 PrintF("--- Unoptimized code ---\n"); |
143 info->closure()->shared()->code()->Disassemble( | 141 info->closure()->shared()->code()->Disassemble( |
144 *function->debug_name()->ToCString()); | 142 *function->debug_name()->ToCString()); |
145 } | 143 } |
146 PrintF("--- Optimized code ---\n"); | 144 PrintF("--- Optimized code ---\n"); |
147 } else { | 145 } else { |
148 PrintF("--- Code ---\n"); | 146 PrintF("--- Code ---\n"); |
149 } | 147 } |
150 if (info->IsStub()) { | 148 code->Disassemble(*function->debug_name()->ToCString()); |
151 CodeStub::Major major_key = info->code_stub()->MajorKey(); | |
152 code->Disassemble(CodeStub::MajorName(major_key, false)); | |
153 } else { | |
154 code->Disassemble(*function->debug_name()->ToCString()); | |
155 } | |
156 } | 149 } |
157 #endif // ENABLE_DISASSEMBLER | 150 #endif // ENABLE_DISASSEMBLER |
158 } | 151 } |
159 | 152 |
160 | 153 |
161 bool CodeGenerator::ShouldGenerateLog(Expression* type) { | 154 bool CodeGenerator::ShouldGenerateLog(Expression* type) { |
162 ASSERT(type != NULL); | 155 ASSERT(type != NULL); |
163 Isolate* isolate = Isolate::Current(); | 156 Isolate* isolate = Isolate::Current(); |
164 if (!isolate->logger()->is_logging() && !CpuProfiler::is_profiling(isolate)) { | 157 if (!isolate->logger()->is_logging() && !CpuProfiler::is_profiling(isolate)) { |
165 return false; | 158 return false; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 ASSERT(result_size_ == 1 || result_size_ == 2); | 203 ASSERT(result_size_ == 1 || result_size_ == 2); |
211 #ifdef _WIN64 | 204 #ifdef _WIN64 |
212 return result | ((result_size_ == 1) ? 0 : 2); | 205 return result | ((result_size_ == 1) ? 0 : 2); |
213 #else | 206 #else |
214 return result; | 207 return result; |
215 #endif | 208 #endif |
216 } | 209 } |
217 | 210 |
218 | 211 |
219 } } // namespace v8::internal | 212 } } // namespace v8::internal |
OLD | NEW |