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/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
6 #include "src/code-events.h" | 6 #include "src/code-events.h" |
7 #include "src/compiler/code-assembler.h" | 7 #include "src/code-stub-assembler.h" |
8 #include "src/ic/ic-state.h" | 8 #include "src/ic/ic-state.h" |
9 #include "src/interface-descriptors.h" | 9 #include "src/interface-descriptors.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
11 #include "src/macro-assembler.h" | 11 #include "src/macro-assembler.h" |
12 #include "src/objects.h" | 12 #include "src/objects.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 // Forward declarations for C++ builtins. | 17 // Forward declarations for C++ builtins. |
(...skipping 17 matching lines...) Expand all Loading... |
35 CodeTracer::Scope trace_scope(isolate->GetCodeTracer()); | 35 CodeTracer::Scope trace_scope(isolate->GetCodeTracer()); |
36 OFStream os(trace_scope.file()); | 36 OFStream os(trace_scope.file()); |
37 os << "Builtin: " << name << "\n"; | 37 os << "Builtin: " << name << "\n"; |
38 code->Disassemble(name, os); | 38 code->Disassemble(name, os); |
39 os << "\n"; | 39 os << "\n"; |
40 } | 40 } |
41 #endif | 41 #endif |
42 } | 42 } |
43 | 43 |
44 typedef void (*MacroAssemblerGenerator)(MacroAssembler*); | 44 typedef void (*MacroAssemblerGenerator)(MacroAssembler*); |
45 typedef void (*CodeAssemblerGenerator)(compiler::CodeAssemblerState*); | 45 typedef void (*CodeAssemblerGenerator)(CodeStubAssembler*); |
46 | 46 |
47 Code* BuildWithMacroAssembler(Isolate* isolate, | 47 Code* BuildWithMacroAssembler(Isolate* isolate, |
48 MacroAssemblerGenerator generator, | 48 MacroAssemblerGenerator generator, |
49 Code::Flags flags, const char* s_name) { | 49 Code::Flags flags, const char* s_name) { |
50 HandleScope scope(isolate); | 50 HandleScope scope(isolate); |
51 const size_t buffer_size = 32 * KB; | 51 const size_t buffer_size = 32 * KB; |
52 byte buffer[buffer_size]; // NOLINT(runtime/arrays) | 52 byte buffer[buffer_size]; // NOLINT(runtime/arrays) |
53 MacroAssembler masm(isolate, buffer, buffer_size, CodeObjectRequired::kYes); | 53 MacroAssembler masm(isolate, buffer, buffer_size, CodeObjectRequired::kYes); |
54 DCHECK(!masm.has_frame()); | 54 DCHECK(!masm.has_frame()); |
55 generator(&masm); | 55 generator(&masm); |
(...skipping 23 matching lines...) Expand all Loading... |
79 } | 79 } |
80 | 80 |
81 // Builder for builtins implemented in TurboFan with JS linkage. | 81 // Builder for builtins implemented in TurboFan with JS linkage. |
82 Code* BuildWithCodeStubAssemblerJS(Isolate* isolate, | 82 Code* BuildWithCodeStubAssemblerJS(Isolate* isolate, |
83 CodeAssemblerGenerator generator, int argc, | 83 CodeAssemblerGenerator generator, int argc, |
84 Code::Flags flags, const char* name) { | 84 Code::Flags flags, const char* name) { |
85 HandleScope scope(isolate); | 85 HandleScope scope(isolate); |
86 Zone zone(isolate->allocator(), ZONE_NAME); | 86 Zone zone(isolate->allocator(), ZONE_NAME); |
87 const int argc_with_recv = | 87 const int argc_with_recv = |
88 (argc == SharedFunctionInfo::kDontAdaptArgumentsSentinel) ? 0 : argc + 1; | 88 (argc == SharedFunctionInfo::kDontAdaptArgumentsSentinel) ? 0 : argc + 1; |
89 compiler::CodeAssemblerState state(isolate, &zone, argc_with_recv, flags, | 89 CodeStubAssembler assembler(isolate, &zone, argc_with_recv, flags, name); |
90 name); | 90 generator(&assembler); |
91 generator(&state); | 91 Handle<Code> code = assembler.GenerateCode(); |
92 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); | |
93 PostBuildProfileAndTracing(isolate, *code, name); | 92 PostBuildProfileAndTracing(isolate, *code, name); |
94 return *code; | 93 return *code; |
95 } | 94 } |
96 | 95 |
97 // Builder for builtins implemented in TurboFan with CallStub linkage. | 96 // Builder for builtins implemented in TurboFan with CallStub linkage. |
98 Code* BuildWithCodeStubAssemblerCS(Isolate* isolate, | 97 Code* BuildWithCodeStubAssemblerCS(Isolate* isolate, |
99 CodeAssemblerGenerator generator, | 98 CodeAssemblerGenerator generator, |
100 CallDescriptors::Key interface_descriptor, | 99 CallDescriptors::Key interface_descriptor, |
101 Code::Flags flags, const char* name) { | 100 Code::Flags flags, const char* name) { |
102 HandleScope scope(isolate); | 101 HandleScope scope(isolate); |
103 Zone zone(isolate->allocator(), ZONE_NAME); | 102 Zone zone(isolate->allocator(), ZONE_NAME); |
104 // The interface descriptor with given key must be initialized at this point | 103 // The interface descriptor with given key must be initialized at this point |
105 // and this construction just queries the details from the descriptors table. | 104 // and this construction just queries the details from the descriptors table. |
106 CallInterfaceDescriptor descriptor(isolate, interface_descriptor); | 105 CallInterfaceDescriptor descriptor(isolate, interface_descriptor); |
107 // Ensure descriptor is already initialized. | 106 // Ensure descriptor is already initialized. |
108 DCHECK_LE(0, descriptor.GetRegisterParameterCount()); | 107 DCHECK_LE(0, descriptor.GetRegisterParameterCount()); |
109 compiler::CodeAssemblerState state(isolate, &zone, descriptor, flags, name); | 108 CodeStubAssembler assembler(isolate, &zone, descriptor, flags, name); |
110 generator(&state); | 109 generator(&assembler); |
111 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); | 110 Handle<Code> code = assembler.GenerateCode(); |
112 PostBuildProfileAndTracing(isolate, *code, name); | 111 PostBuildProfileAndTracing(isolate, *code, name); |
113 return *code; | 112 return *code; |
114 } | 113 } |
115 } // anonymous namespace | 114 } // anonymous namespace |
116 | 115 |
117 void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) { | 116 void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) { |
118 DCHECK(!initialized_); | 117 DCHECK(!initialized_); |
119 | 118 |
120 // Create a scope for the handles in the builtins. | 119 // Create a scope for the handles in the builtins. |
121 HandleScope scope(isolate); | 120 HandleScope scope(isolate); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // TODO(jochen): Remove this. | 288 // TODO(jochen): Remove this. |
290 if (responsible_context.is_null()) { | 289 if (responsible_context.is_null()) { |
291 return true; | 290 return true; |
292 } | 291 } |
293 if (*responsible_context == target->context()) return true; | 292 if (*responsible_context == target->context()) return true; |
294 return isolate->MayAccess(responsible_context, target_global_proxy); | 293 return isolate->MayAccess(responsible_context, target_global_proxy); |
295 } | 294 } |
296 | 295 |
297 } // namespace internal | 296 } // namespace internal |
298 } // namespace v8 | 297 } // namespace v8 |
OLD | NEW |