| 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/codegen.h" | 5 #include "src/codegen.h" |
| 6 | 6 |
| 7 #if defined(V8_OS_AIX) | 7 #if defined(V8_OS_AIX) |
| 8 #include <fenv.h> // NOLINT(build/c++11) | 8 #include <fenv.h> // NOLINT(build/c++11) |
| 9 #endif | 9 #endif |
| 10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
| 11 #include "src/bootstrapper.h" | 11 #include "src/bootstrapper.h" |
| 12 #include "src/compiler.h" | 12 #include "src/compiler.h" |
| 13 #include "src/debug/debug.h" | 13 #include "src/debug/debug.h" |
| 14 #include "src/eh-frame.h" |
| 14 #include "src/parsing/parser.h" | 15 #include "src/parsing/parser.h" |
| 15 #include "src/runtime/runtime.h" | 16 #include "src/runtime/runtime.h" |
| 16 | 17 |
| 17 namespace v8 { | 18 namespace v8 { |
| 18 namespace internal { | 19 namespace internal { |
| 19 | 20 |
| 20 | 21 |
| 21 #if defined(V8_OS_WIN) | 22 #if defined(V8_OS_WIN) |
| 22 double modulo(double x, double y) { | 23 double modulo(double x, double y) { |
| 23 // Workaround MS fmod bugs. ECMA-262 says: | 24 // Workaround MS fmod bugs. ECMA-262 says: |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 104 |
| 104 #ifdef DEBUG | 105 #ifdef DEBUG |
| 105 if (info->parse_info() && print_ast) { | 106 if (info->parse_info() && print_ast) { |
| 106 PrintF("--- AST ---\n%s\n", | 107 PrintF("--- AST ---\n%s\n", |
| 107 AstPrinter(info->isolate()).PrintProgram(info->literal())); | 108 AstPrinter(info->isolate()).PrintProgram(info->literal())); |
| 108 } | 109 } |
| 109 #endif // DEBUG | 110 #endif // DEBUG |
| 110 } | 111 } |
| 111 | 112 |
| 112 Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm, | 113 Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm, |
| 114 EhFrameWriter* eh_frame_writer, |
| 113 CompilationInfo* info, | 115 CompilationInfo* info, |
| 114 Handle<Object> self_reference) { | 116 Handle<Object> self_reference) { |
| 115 Isolate* isolate = info->isolate(); | 117 Isolate* isolate = info->isolate(); |
| 116 | 118 |
| 117 // Allocate and install the code. | 119 // Allocate and install the code. |
| 118 CodeDesc desc; | 120 CodeDesc desc; |
| 119 Code::Flags flags = info->code_flags(); | 121 Code::Flags flags = info->code_flags(); |
| 120 bool is_crankshafted = | 122 bool is_crankshafted = |
| 121 Code::ExtractKindFromFlags(flags) == Code::OPTIMIZED_FUNCTION || | 123 Code::ExtractKindFromFlags(flags) == Code::OPTIMIZED_FUNCTION || |
| 122 info->IsStub(); | 124 info->IsStub(); |
| 123 masm->GetCode(&desc); | 125 masm->GetCode(&desc); |
| 126 if (eh_frame_writer) eh_frame_writer->GetEhFrame(&desc); |
| 127 |
| 124 Handle<Code> code = isolate->factory()->NewCode( | 128 Handle<Code> code = isolate->factory()->NewCode( |
| 125 desc, flags, self_reference, false, is_crankshafted, | 129 desc, flags, self_reference, false, is_crankshafted, |
| 126 info->prologue_offset(), info->is_debug() && !is_crankshafted); | 130 info->prologue_offset(), info->is_debug() && !is_crankshafted); |
| 127 isolate->counters()->total_compiled_code_size()->Increment( | 131 isolate->counters()->total_compiled_code_size()->Increment( |
| 128 code->instruction_size()); | 132 code->instruction_size()); |
| 129 isolate->heap()->IncrementCodeGeneratedBytes(is_crankshafted, | 133 isolate->heap()->IncrementCodeGeneratedBytes(is_crankshafted, |
| 130 code->instruction_size()); | 134 code->instruction_size()); |
| 131 return code; | 135 return code; |
| 132 } | 136 } |
| 133 | 137 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 os << "source_position = " << shared->start_position() << "\n"; | 188 os << "source_position = " << shared->start_position() << "\n"; |
| 185 } | 189 } |
| 186 code->Disassemble(debug_name.get(), os); | 190 code->Disassemble(debug_name.get(), os); |
| 187 os << "--- End code ---\n"; | 191 os << "--- End code ---\n"; |
| 188 } | 192 } |
| 189 #endif // ENABLE_DISASSEMBLER | 193 #endif // ENABLE_DISASSEMBLER |
| 190 } | 194 } |
| 191 | 195 |
| 192 } // namespace internal | 196 } // namespace internal |
| 193 } // namespace v8 | 197 } // namespace v8 |
| OLD | NEW |