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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 bool print_ast = false; | 64 bool print_ast = false; |
65 const char* ftype; | 65 const char* ftype; |
66 | 66 |
67 if (Isolate::Current()->bootstrapper()->IsActive()) { | 67 if (Isolate::Current()->bootstrapper()->IsActive()) { |
68 print_source = FLAG_print_builtin_source; | 68 print_source = FLAG_print_builtin_source; |
69 print_ast = FLAG_print_builtin_ast; | 69 print_ast = FLAG_print_builtin_ast; |
70 ftype = "builtin"; | 70 ftype = "builtin"; |
71 } else { | 71 } else { |
72 print_source = FLAG_print_source; | 72 print_source = FLAG_print_source; |
73 print_ast = FLAG_print_ast; | 73 print_ast = FLAG_print_ast; |
74 Vector<const char> filter = CStrVector(FLAG_hydrogen_filter); | |
75 if (print_source && !filter.is_empty()) { | |
76 print_source = info->function()->name()->IsEqualTo(filter); | |
77 } | |
78 if (print_ast && !filter.is_empty()) { | |
79 print_ast = info->function()->name()->IsEqualTo(filter); | |
80 } | |
81 ftype = "user-defined"; | 74 ftype = "user-defined"; |
82 } | 75 } |
83 | 76 |
84 if (FLAG_trace_codegen || print_source || print_ast) { | 77 if (FLAG_trace_codegen || print_source || print_ast) { |
85 PrintF("*** Generate code for %s function: ", ftype); | 78 PrintF("*** Generate code for %s function: ", ftype); |
86 info->function()->name()->ShortPrint(); | 79 info->function()->name()->ShortPrint(); |
87 PrintF(" ***\n"); | 80 PrintF(" ***\n"); |
88 } | 81 } |
89 | 82 |
90 if (print_source) { | 83 if (print_source) { |
(...skipping 26 matching lines...) Expand all Loading... |
117 } | 110 } |
118 return code; | 111 return code; |
119 } | 112 } |
120 | 113 |
121 | 114 |
122 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) { | 115 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) { |
123 #ifdef ENABLE_DISASSEMBLER | 116 #ifdef ENABLE_DISASSEMBLER |
124 bool print_code = Isolate::Current()->bootstrapper()->IsActive() | 117 bool print_code = Isolate::Current()->bootstrapper()->IsActive() |
125 ? FLAG_print_builtin_code | 118 ? FLAG_print_builtin_code |
126 : (FLAG_print_code || (info->IsOptimizing() && FLAG_print_opt_code)); | 119 : (FLAG_print_code || (info->IsOptimizing() && FLAG_print_opt_code)); |
127 Vector<const char> filter = CStrVector(FLAG_hydrogen_filter); | 120 if (print_code) { |
128 FunctionLiteral* function = info->function(); | |
129 bool match = filter.is_empty() || function->debug_name()->IsEqualTo(filter); | |
130 if (print_code && match) { | |
131 // Print the source code if available. | 121 // Print the source code if available. |
| 122 FunctionLiteral* function = info->function(); |
132 Handle<Script> script = info->script(); | 123 Handle<Script> script = info->script(); |
133 if (!script->IsUndefined() && !script->source()->IsUndefined()) { | 124 if (!script->IsUndefined() && !script->source()->IsUndefined()) { |
134 PrintF("--- Raw source ---\n"); | 125 PrintF("--- Raw source ---\n"); |
135 StringInputBuffer stream(String::cast(script->source())); | 126 StringInputBuffer stream(String::cast(script->source())); |
136 stream.Seek(function->start_position()); | 127 stream.Seek(function->start_position()); |
137 // fun->end_position() points to the last character in the stream. We | 128 // fun->end_position() points to the last character in the stream. We |
138 // need to compensate by adding one to calculate the length. | 129 // need to compensate by adding one to calculate the length. |
139 int source_len = | 130 int source_len = |
140 function->end_position() - function->start_position() + 1; | 131 function->end_position() - function->start_position() + 1; |
141 for (int i = 0; i < source_len; i++) { | 132 for (int i = 0; i < source_len; i++) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 ASSERT(result_size_ == 1 || result_size_ == 2); | 202 ASSERT(result_size_ == 1 || result_size_ == 2); |
212 #ifdef _WIN64 | 203 #ifdef _WIN64 |
213 return result | ((result_size_ == 1) ? 0 : 2); | 204 return result | ((result_size_ == 1) ? 0 : 2); |
214 #else | 205 #else |
215 return result; | 206 return result; |
216 #endif | 207 #endif |
217 } | 208 } |
218 | 209 |
219 | 210 |
220 } } // namespace v8::internal | 211 } } // namespace v8::internal |
OLD | NEW |