OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/debug.h" | 9 #include "src/debug.h" |
10 #include "src/full-codegen.h" | 10 #include "src/full-codegen.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 Handle<Script> script = info->script(); | 296 Handle<Script> script = info->script(); |
297 if (!script->IsUndefined() && !script->source()->IsUndefined()) { | 297 if (!script->IsUndefined() && !script->source()->IsUndefined()) { |
298 int len = String::cast(script->source())->length(); | 298 int len = String::cast(script->source())->length(); |
299 isolate->counters()->total_full_codegen_source_size()->Increment(len); | 299 isolate->counters()->total_full_codegen_source_size()->Increment(len); |
300 } | 300 } |
301 CodeGenerator::MakeCodePrologue(info, "full"); | 301 CodeGenerator::MakeCodePrologue(info, "full"); |
302 const int kInitialBufferSize = 4 * KB; | 302 const int kInitialBufferSize = 4 * KB; |
303 MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize); | 303 MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize); |
304 if (info->will_serialize()) masm.enable_serializer(); | 304 if (info->will_serialize()) masm.enable_serializer(); |
305 | 305 |
306 #ifdef ENABLE_GDB_JIT_INTERFACE | |
307 masm.positions_recorder()->StartGDBJITLineInfoRecording(); | |
308 #endif | |
309 LOG_CODE_EVENT(isolate, | 306 LOG_CODE_EVENT(isolate, |
310 CodeStartLinePosInfoRecordEvent(masm.positions_recorder())); | 307 CodeStartLinePosInfoRecordEvent(masm.positions_recorder())); |
311 | 308 |
312 FullCodeGenerator cgen(&masm, info); | 309 FullCodeGenerator cgen(&masm, info); |
313 cgen.Generate(); | 310 cgen.Generate(); |
314 if (cgen.HasStackOverflow()) { | 311 if (cgen.HasStackOverflow()) { |
315 ASSERT(!isolate->has_pending_exception()); | 312 ASSERT(!isolate->has_pending_exception()); |
316 return false; | 313 return false; |
317 } | 314 } |
318 unsigned table_offset = cgen.EmitBackEdgeTable(); | 315 unsigned table_offset = cgen.EmitBackEdgeTable(); |
319 | 316 |
320 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION); | 317 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION); |
321 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info); | 318 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info); |
322 code->set_optimizable(info->IsOptimizable() && | 319 code->set_optimizable(info->IsOptimizable() && |
323 !info->function()->dont_optimize() && | 320 !info->function()->dont_optimize() && |
324 info->function()->scope()->AllowsLazyCompilation()); | 321 info->function()->scope()->AllowsLazyCompilation()); |
325 cgen.PopulateDeoptimizationData(code); | 322 cgen.PopulateDeoptimizationData(code); |
326 cgen.PopulateTypeFeedbackInfo(code); | 323 cgen.PopulateTypeFeedbackInfo(code); |
327 code->set_has_deoptimization_support(info->HasDeoptimizationSupport()); | 324 code->set_has_deoptimization_support(info->HasDeoptimizationSupport()); |
328 code->set_handler_table(*cgen.handler_table()); | 325 code->set_handler_table(*cgen.handler_table()); |
329 code->set_compiled_optimizable(info->IsOptimizable()); | 326 code->set_compiled_optimizable(info->IsOptimizable()); |
330 code->set_allow_osr_at_loop_nesting_level(0); | 327 code->set_allow_osr_at_loop_nesting_level(0); |
331 code->set_profiler_ticks(0); | 328 code->set_profiler_ticks(0); |
332 code->set_back_edge_table_offset(table_offset); | 329 code->set_back_edge_table_offset(table_offset); |
333 CodeGenerator::PrintCode(code, info); | 330 CodeGenerator::PrintCode(code, info); |
334 info->SetCode(code); | 331 info->SetCode(code); |
335 #ifdef ENABLE_GDB_JIT_INTERFACE | |
336 if (FLAG_gdbjit) { | |
337 GDBJITLineInfo* lineinfo = | |
338 masm.positions_recorder()->DetachGDBJITLineInfo(); | |
339 GDBJIT(RegisterDetailedLineInfo(*code, lineinfo)); | |
340 } | |
341 #endif | |
342 void* line_info = masm.positions_recorder()->DetachJITHandlerData(); | 332 void* line_info = masm.positions_recorder()->DetachJITHandlerData(); |
343 LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(*code, line_info)); | 333 LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(*code, line_info)); |
344 return true; | 334 return true; |
345 } | 335 } |
346 | 336 |
347 | 337 |
348 unsigned FullCodeGenerator::EmitBackEdgeTable() { | 338 unsigned FullCodeGenerator::EmitBackEdgeTable() { |
349 // The back edge table consists of a length (in number of entries) | 339 // The back edge table consists of a length (in number of entries) |
350 // field, and then a sequence of entries. Each entry is a pair of AST id | 340 // field, and then a sequence of entries. Each entry is a pair of AST id |
351 // and code-relative pc offset. | 341 // and code-relative pc offset. |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 } | 1682 } |
1693 return true; | 1683 return true; |
1694 } | 1684 } |
1695 #endif // DEBUG | 1685 #endif // DEBUG |
1696 | 1686 |
1697 | 1687 |
1698 #undef __ | 1688 #undef __ |
1699 | 1689 |
1700 | 1690 |
1701 } } // namespace v8::internal | 1691 } } // namespace v8::internal |
OLD | NEW |