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