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

Side by Side Diff: src/builtins/builtins.cc

Issue 2498073002: [refactoring] Split CodeAssemblerState out of CodeAssembler (Closed)
Patch Set: one more attempt Created 4 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
« no previous file with comments | « src/builtins/builtins.h ('k') | src/builtins/builtins-array.cc » ('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 // 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/code-stub-assembler.h" 7 #include "src/compiler/code-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
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)(CodeStubAssembler*); 45 typedef void (*CodeAssemblerGenerator)(compiler::CodeAssemblerState*);
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
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 CodeStubAssembler assembler(isolate, &zone, argc_with_recv, flags, name); 89 compiler::CodeAssemblerState state(isolate, &zone, argc_with_recv, flags,
90 generator(&assembler); 90 name);
91 Handle<Code> code = assembler.GenerateCode(); 91 generator(&state);
92 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state);
92 PostBuildProfileAndTracing(isolate, *code, name); 93 PostBuildProfileAndTracing(isolate, *code, name);
93 return *code; 94 return *code;
94 } 95 }
95 96
96 // Builder for builtins implemented in TurboFan with CallStub linkage. 97 // Builder for builtins implemented in TurboFan with CallStub linkage.
97 Code* BuildWithCodeStubAssemblerCS(Isolate* isolate, 98 Code* BuildWithCodeStubAssemblerCS(Isolate* isolate,
98 CodeAssemblerGenerator generator, 99 CodeAssemblerGenerator generator,
99 CallDescriptors::Key interface_descriptor, 100 CallDescriptors::Key interface_descriptor,
100 Code::Flags flags, const char* name) { 101 Code::Flags flags, const char* name) {
101 HandleScope scope(isolate); 102 HandleScope scope(isolate);
102 Zone zone(isolate->allocator(), ZONE_NAME); 103 Zone zone(isolate->allocator(), ZONE_NAME);
103 // The interface descriptor with given key must be initialized at this point 104 // The interface descriptor with given key must be initialized at this point
104 // and this construction just queries the details from the descriptors table. 105 // and this construction just queries the details from the descriptors table.
105 CallInterfaceDescriptor descriptor(isolate, interface_descriptor); 106 CallInterfaceDescriptor descriptor(isolate, interface_descriptor);
106 // Ensure descriptor is already initialized. 107 // Ensure descriptor is already initialized.
107 DCHECK_LE(0, descriptor.GetRegisterParameterCount()); 108 DCHECK_LE(0, descriptor.GetRegisterParameterCount());
108 CodeStubAssembler assembler(isolate, &zone, descriptor, flags, name); 109 compiler::CodeAssemblerState state(isolate, &zone, descriptor, flags, name);
109 generator(&assembler); 110 generator(&state);
110 Handle<Code> code = assembler.GenerateCode(); 111 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state);
111 PostBuildProfileAndTracing(isolate, *code, name); 112 PostBuildProfileAndTracing(isolate, *code, name);
112 return *code; 113 return *code;
113 } 114 }
114 } // anonymous namespace 115 } // anonymous namespace
115 116
116 void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) { 117 void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) {
117 DCHECK(!initialized_); 118 DCHECK(!initialized_);
118 119
119 // Create a scope for the handles in the builtins. 120 // Create a scope for the handles in the builtins.
120 HandleScope scope(isolate); 121 HandleScope scope(isolate);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // TODO(jochen): Remove this. 289 // TODO(jochen): Remove this.
289 if (responsible_context.is_null()) { 290 if (responsible_context.is_null()) {
290 return true; 291 return true;
291 } 292 }
292 if (*responsible_context == target->context()) return true; 293 if (*responsible_context == target->context()) return true;
293 return isolate->MayAccess(responsible_context, target_global_proxy); 294 return isolate->MayAccess(responsible_context, target_global_proxy);
294 } 295 }
295 296
296 } // namespace internal 297 } // namespace internal
297 } // namespace v8 298 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins.h ('k') | src/builtins/builtins-array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698