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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 auto descriptor = Builtin_##Name##_InterfaceDescriptor(isolate); \ | 150 auto descriptor = Builtin_##Name##_InterfaceDescriptor(isolate); \ |
125 return Callable(code, descriptor); \ | 151 return Callable(code, descriptor); \ |
126 } | 152 } |
127 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE, CASE, | 153 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE, CASE, |
128 CASE, IGNORE_BUILTIN, IGNORE_BUILTIN) | 154 CASE, IGNORE_BUILTIN, IGNORE_BUILTIN) |
129 #undef CASE | 155 #undef CASE |
130 case kConsoleAssert: { | 156 case kConsoleAssert: { |
131 Handle<Code> code = isolate->builtins()->ConsoleAssert(); | 157 Handle<Code> code = isolate->builtins()->ConsoleAssert(); |
132 return Callable(code, BuiltinDescriptor(isolate)); | 158 return Callable(code, BuiltinDescriptor(isolate)); |
133 } | 159 } |
| 160 case kArrayForEach: { |
| 161 Handle<Code> code = isolate->builtins()->ArrayForEach(); |
| 162 return Callable(code, BuiltinDescriptor(isolate)); |
| 163 } |
| 164 case kArrayForEachLoopEagerDeoptContinuation: { |
| 165 Handle<Code> code = |
| 166 isolate->builtins()->ArrayForEachLoopEagerDeoptContinuation(); |
| 167 return Callable(code, BuiltinDescriptor(isolate)); |
| 168 } |
| 169 case kArrayForEachLoopLazyDeoptContinuation: { |
| 170 Handle<Code> code = |
| 171 isolate->builtins()->ArrayForEachLoopLazyDeoptContinuation(); |
| 172 return Callable(code, BuiltinDescriptor(isolate)); |
| 173 } |
134 default: | 174 default: |
135 UNREACHABLE(); | 175 UNREACHABLE(); |
136 return Callable(Handle<Code>::null(), VoidDescriptor(isolate)); | 176 return Callable(Handle<Code>::null(), VoidDescriptor(isolate)); |
137 } | 177 } |
138 } | 178 } |
139 | 179 |
140 // static | 180 // static |
| 181 int Builtins::GetStackParameterCount(Isolate* isolate, Name name) { |
| 182 switch (name) { |
| 183 #define CASE(Name, Count, ...) \ |
| 184 case k##Name: { \ |
| 185 return Count; \ |
| 186 } |
| 187 BUILTIN_LIST_TFJ(CASE) |
| 188 #undef CASE |
| 189 default: |
| 190 UNREACHABLE(); |
| 191 return 0; |
| 192 } |
| 193 } |
| 194 |
| 195 // static |
141 const char* Builtins::name(int index) { | 196 const char* Builtins::name(int index) { |
142 switch (index) { | 197 switch (index) { |
143 #define CASE(Name, ...) \ | 198 #define CASE(Name, ...) \ |
144 case k##Name: \ | 199 case k##Name: \ |
145 return #Name; | 200 return #Name; |
146 BUILTIN_LIST_ALL(CASE) | 201 BUILTIN_LIST_ALL(CASE) |
147 #undef CASE | 202 #undef CASE |
148 default: | 203 default: |
149 UNREACHABLE(); | 204 UNREACHABLE(); |
150 break; | 205 break; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // TODO(jochen): Remove this. | 294 // TODO(jochen): Remove this. |
240 if (responsible_context.is_null()) { | 295 if (responsible_context.is_null()) { |
241 return true; | 296 return true; |
242 } | 297 } |
243 if (*responsible_context == target->context()) return true; | 298 if (*responsible_context == target->context()) return true; |
244 return isolate->MayAccess(responsible_context, target_global_proxy); | 299 return isolate->MayAccess(responsible_context, target_global_proxy); |
245 } | 300 } |
246 | 301 |
247 } // namespace internal | 302 } // namespace internal |
248 } // namespace v8 | 303 } // namespace v8 |
OLD | NEW |