Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Side by Side Diff: src/codegen.cc

Issue 39973003: Merge bleeding_edge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: again Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/compiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 Isolate* isolate = info->isolate(); 106 Isolate* isolate = info->isolate();
107 107
108 // Allocate and install the code. 108 // Allocate and install the code.
109 CodeDesc desc; 109 CodeDesc desc;
110 bool is_crankshafted = 110 bool is_crankshafted =
111 Code::ExtractKindFromFlags(flags) == Code::OPTIMIZED_FUNCTION || 111 Code::ExtractKindFromFlags(flags) == Code::OPTIMIZED_FUNCTION ||
112 info->IsStub(); 112 info->IsStub();
113 masm->GetCode(&desc); 113 masm->GetCode(&desc);
114 Handle<Code> code = 114 Handle<Code> code =
115 isolate->factory()->NewCode(desc, flags, masm->CodeObject(), 115 isolate->factory()->NewCode(desc, flags, masm->CodeObject(),
116 false, is_crankshafted); 116 false, is_crankshafted,
117 info->prologue_offset());
117 isolate->counters()->total_compiled_code_size()->Increment( 118 isolate->counters()->total_compiled_code_size()->Increment(
118 code->instruction_size()); 119 code->instruction_size());
119 code->set_prologue_offset(info->prologue_offset()); 120 isolate->heap()->IncrementCodeGeneratedBytes(is_crankshafted,
121 code->instruction_size());
120 return code; 122 return code;
121 } 123 }
122 124
123 125
124 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) { 126 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
125 #ifdef ENABLE_DISASSEMBLER 127 #ifdef ENABLE_DISASSEMBLER
126 AllowDeferredHandleDereference allow_deference_for_print_code; 128 AllowDeferredHandleDereference allow_deference_for_print_code;
127 bool print_code = info->isolate()->bootstrapper()->IsActive() 129 bool print_code = info->isolate()->bootstrapper()->IsActive()
128 ? FLAG_print_builtin_code 130 ? FLAG_print_builtin_code
129 : (FLAG_print_code || 131 : (FLAG_print_code ||
130 (info->IsStub() && FLAG_print_code_stubs) || 132 (info->IsStub() && FLAG_print_code_stubs) ||
131 (info->IsOptimizing() && FLAG_print_opt_code)); 133 (info->IsOptimizing() && FLAG_print_opt_code));
132 if (print_code) { 134 if (print_code) {
133 // Print the source code if available. 135 // Print the source code if available.
134 FunctionLiteral* function = info->function(); 136 FunctionLiteral* function = info->function();
135 if (code->kind() == Code::OPTIMIZED_FUNCTION) { 137 bool print_source = code->kind() == Code::OPTIMIZED_FUNCTION ||
138 code->kind() == Code::FUNCTION;
139 if (print_source) {
136 Handle<Script> script = info->script(); 140 Handle<Script> script = info->script();
137 if (!script->IsUndefined() && !script->source()->IsUndefined()) { 141 if (!script->IsUndefined() && !script->source()->IsUndefined()) {
138 PrintF("--- Raw source ---\n"); 142 PrintF("--- Raw source ---\n");
139 ConsStringIteratorOp op; 143 ConsStringIteratorOp op;
140 StringCharacterStream stream(String::cast(script->source()), 144 StringCharacterStream stream(String::cast(script->source()),
141 &op, 145 &op,
142 function->start_position()); 146 function->start_position());
143 // 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
144 // need to compensate by adding one to calculate the length. 148 // need to compensate by adding one to calculate the length.
145 int source_len = 149 int source_len =
146 function->end_position() - function->start_position() + 1; 150 function->end_position() - function->start_position() + 1;
147 for (int i = 0; i < source_len; i++) { 151 for (int i = 0; i < source_len; i++) {
148 if (stream.HasMore()) PrintF("%c", stream.GetNext()); 152 if (stream.HasMore()) PrintF("%c", stream.GetNext());
149 } 153 }
150 PrintF("\n\n"); 154 PrintF("\n\n");
151 } 155 }
152 } 156 }
153 if (info->IsOptimizing()) { 157 if (info->IsOptimizing()) {
154 if (FLAG_print_unopt_code) { 158 if (FLAG_print_unopt_code) {
155 PrintF("--- Unoptimized code ---\n"); 159 PrintF("--- Unoptimized code ---\n");
156 info->closure()->shared()->code()->Disassemble( 160 info->closure()->shared()->code()->Disassemble(
157 *function->debug_name()->ToCString()); 161 *function->debug_name()->ToCString());
158 } 162 }
159 PrintF("--- Optimized code ---\n"); 163 PrintF("--- Optimized code ---\n");
160 } else { 164 } else {
161 PrintF("--- Code ---\n"); 165 PrintF("--- Code ---\n");
162 } 166 }
167 if (print_source) {
168 PrintF("source_position = %d\n", function->start_position());
169 }
163 if (info->IsStub()) { 170 if (info->IsStub()) {
164 CodeStub::Major major_key = info->code_stub()->MajorKey(); 171 CodeStub::Major major_key = info->code_stub()->MajorKey();
165 code->Disassemble(CodeStub::MajorName(major_key, false)); 172 code->Disassemble(CodeStub::MajorName(major_key, false));
166 } else { 173 } else {
167 code->Disassemble(*function->debug_name()->ToCString()); 174 code->Disassemble(*function->debug_name()->ToCString());
168 } 175 }
176 PrintF("--- End code ---\n");
169 } 177 }
170 #endif // ENABLE_DISASSEMBLER 178 #endif // ENABLE_DISASSEMBLER
171 } 179 }
172 180
173 181
174 bool CodeGenerator::ShouldGenerateLog(Isolate* isolate, Expression* type) { 182 bool CodeGenerator::ShouldGenerateLog(Isolate* isolate, Expression* type) {
175 ASSERT(type != NULL); 183 ASSERT(type != NULL);
176 if (!isolate->logger()->is_logging() && 184 if (!isolate->logger()->is_logging() &&
177 !isolate->cpu_profiler()->is_profiling()) { 185 !isolate->cpu_profiler()->is_profiling()) {
178 return false; 186 return false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 ASSERT(result_size_ == 1 || result_size_ == 2); 231 ASSERT(result_size_ == 1 || result_size_ == 2);
224 #ifdef _WIN64 232 #ifdef _WIN64
225 return result | ((result_size_ == 1) ? 0 : 2); 233 return result | ((result_size_ == 1) ? 0 : 2);
226 #else 234 #else
227 return result; 235 return result;
228 #endif 236 #endif
229 } 237 }
230 238
231 239
232 } } // namespace v8::internal 240 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698