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/api.h" | 6 #include "src/api.h" |
7 #include "src/assembler-inl.h" | 7 #include "src/assembler-inl.h" |
8 #include "src/builtins/builtins-descriptors.h" | 8 #include "src/builtins/builtins-descriptors.h" |
9 #include "src/callable.h" | 9 #include "src/callable.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-inl.h" | 12 #include "src/objects-inl.h" |
13 #include "src/visitors.h" | 13 #include "src/visitors.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 // Forward declarations for C++ builtins. | 18 // Forward declarations for C++ builtins. |
19 #define FORWARD_DECLARE(Name) \ | 19 #define FORWARD_DECLARE(Name) \ |
20 Object* Builtin_##Name(int argc, Object** args, Isolate* isolate); | 20 Object* Builtin_##Name(int argc, Object** args, Isolate* isolate); |
21 BUILTIN_LIST_C(FORWARD_DECLARE) | 21 BUILTIN_LIST_C(FORWARD_DECLARE) |
22 | 22 |
23 Builtins::Builtins() : initialized_(false) { | 23 Builtins::Builtins() : initialized_(false) { |
24 memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count); | 24 memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count); |
25 } | 25 } |
26 | 26 |
27 Builtins::~Builtins() {} | 27 Builtins::~Builtins() {} |
28 | 28 |
| 29 BailoutId Builtins::GetContinuationBailoutId(Name name) { |
| 30 switch (name) { |
| 31 #define BAILOUT_ID(NAME, ...) \ |
| 32 case k##NAME: \ |
| 33 return BailoutId(BailoutId::kFirstBuiltinContinuationId + name); |
| 34 BUILTIN_LIST_TFJ(BAILOUT_ID); |
| 35 BUILTIN_LIST_TFC(BAILOUT_ID); |
| 36 #undef BAILOUT_ID |
| 37 default: |
| 38 UNIMPLEMENTED(); |
| 39 } |
| 40 } |
| 41 |
| 42 Builtins::Name Builtins::GetBuiltinFromBailoutId(BailoutId id) { |
| 43 switch (id.ToInt()) { |
| 44 #define BAILOUT_ID(NAME, ...) \ |
| 45 case BailoutId::kFirstBuiltinContinuationId + k##NAME: \ |
| 46 return k##NAME; |
| 47 BUILTIN_LIST_TFJ(BAILOUT_ID) |
| 48 BUILTIN_LIST_TFC(BAILOUT_ID) |
| 49 #undef BAILOUT_ID |
| 50 default: |
| 51 UNIMPLEMENTED(); |
| 52 } |
| 53 } |
| 54 |
29 void Builtins::TearDown() { initialized_ = false; } | 55 void Builtins::TearDown() { initialized_ = false; } |
30 | 56 |
31 void Builtins::IterateBuiltins(RootVisitor* v) { | 57 void Builtins::IterateBuiltins(RootVisitor* v) { |
32 v->VisitRootPointers(Root::kBuiltins, &builtins_[0], | 58 v->VisitRootPointers(Root::kBuiltins, &builtins_[0], |
33 &builtins_[0] + builtin_count); | 59 &builtins_[0] + builtin_count); |
34 } | 60 } |
35 | 61 |
36 const char* Builtins::Lookup(byte* pc) { | 62 const char* Builtins::Lookup(byte* pc) { |
37 // may be called during initialization (disassembler!) | 63 // may be called during initialization (disassembler!) |
38 if (initialized_) { | 64 if (initialized_) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 136 } |
111 | 137 |
112 // static | 138 // static |
113 Callable Builtins::CallableFor(Isolate* isolate, Name name) { | 139 Callable Builtins::CallableFor(Isolate* isolate, Name name) { |
114 Handle<Code> code( | 140 Handle<Code> code( |
115 reinterpret_cast<Code**>(isolate->builtins()->builtin_address(name))); | 141 reinterpret_cast<Code**>(isolate->builtins()->builtin_address(name))); |
116 CallDescriptors::Key key; | 142 CallDescriptors::Key key; |
117 switch (name) { | 143 switch (name) { |
118 // This macro is deliberately crafted so as to emit very little code, | 144 // This macro is deliberately crafted so as to emit very little code, |
119 // in order to keep binary size of this function under control. | 145 // in order to keep binary size of this function under control. |
120 #define CASE(Name, ...) \ | 146 #define CASE_OTHER(Name, ...) \ |
121 case k##Name: { \ | 147 case k##Name: { \ |
122 key = Builtin_##Name##_InterfaceDescriptor::key(); \ | 148 key = Builtin_##Name##_InterfaceDescriptor::key(); \ |
123 break; \ | 149 break; \ |
124 } | 150 } |
125 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE, CASE, | 151 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE_OTHER, |
126 CASE, IGNORE_BUILTIN, IGNORE_BUILTIN) | 152 CASE_OTHER, CASE_OTHER, IGNORE_BUILTIN, IGNORE_BUILTIN) |
127 #undef CASE | 153 #undef CASE |
128 case kConsoleAssert: { | 154 case kConsoleAssert: { |
129 return Callable(code, BuiltinDescriptor(isolate)); | 155 return Callable(code, BuiltinDescriptor(isolate)); |
130 } | 156 } |
| 157 case kArrayForEach: { |
| 158 Handle<Code> code = isolate->builtins()->ArrayForEach(); |
| 159 return Callable(code, BuiltinDescriptor(isolate)); |
| 160 } |
| 161 case kArrayForEachLoopEagerDeoptContinuation: { |
| 162 Handle<Code> code = |
| 163 isolate->builtins()->ArrayForEachLoopEagerDeoptContinuation(); |
| 164 return Callable(code, BuiltinDescriptor(isolate)); |
| 165 } |
| 166 case kArrayForEachLoopLazyDeoptContinuation: { |
| 167 Handle<Code> code = |
| 168 isolate->builtins()->ArrayForEachLoopLazyDeoptContinuation(); |
| 169 return Callable(code, BuiltinDescriptor(isolate)); |
| 170 } |
131 default: | 171 default: |
132 UNREACHABLE(); | 172 UNREACHABLE(); |
133 return Callable(Handle<Code>::null(), VoidDescriptor(isolate)); | 173 return Callable(Handle<Code>::null(), VoidDescriptor(isolate)); |
134 } | 174 } |
135 CallInterfaceDescriptor descriptor(isolate, key); | 175 CallInterfaceDescriptor descriptor(isolate, key); |
136 return Callable(code, descriptor); | 176 return Callable(code, descriptor); |
137 } | 177 } |
138 | 178 |
139 // static | 179 // static |
| 180 int Builtins::GetStackParameterCount(Isolate* isolate, Name name) { |
| 181 switch (name) { |
| 182 #define CASE(Name, Count, ...) \ |
| 183 case k##Name: { \ |
| 184 return Count; \ |
| 185 } |
| 186 BUILTIN_LIST_TFJ(CASE) |
| 187 #undef CASE |
| 188 default: |
| 189 UNREACHABLE(); |
| 190 return 0; |
| 191 } |
| 192 } |
| 193 |
| 194 // static |
140 const char* Builtins::name(int index) { | 195 const char* Builtins::name(int index) { |
141 switch (index) { | 196 switch (index) { |
142 #define CASE(Name, ...) \ | 197 #define CASE(Name, ...) \ |
143 case k##Name: \ | 198 case k##Name: \ |
144 return #Name; | 199 return #Name; |
145 BUILTIN_LIST_ALL(CASE) | 200 BUILTIN_LIST_ALL(CASE) |
146 #undef CASE | 201 #undef CASE |
147 default: | 202 default: |
148 UNREACHABLE(); | 203 UNREACHABLE(); |
149 break; | 204 break; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // TODO(jochen): Remove this. | 299 // TODO(jochen): Remove this. |
245 if (responsible_context.is_null()) { | 300 if (responsible_context.is_null()) { |
246 return true; | 301 return true; |
247 } | 302 } |
248 if (*responsible_context == target->context()) return true; | 303 if (*responsible_context == target->context()) return true; |
249 return isolate->MayAccess(responsible_context, target_global_proxy); | 304 return isolate->MayAccess(responsible_context, target_global_proxy); |
250 } | 305 } |
251 | 306 |
252 } // namespace internal | 307 } // namespace internal |
253 } // namespace v8 | 308 } // namespace v8 |
OLD | NEW |