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 #undef BAILOUT_ID |
| 36 default: |
| 37 UNIMPLEMENTED(); |
| 38 } |
| 39 } |
| 40 |
| 41 Builtins::Name Builtins::GetBuiltinFromBailoutId(BailoutId id) { |
| 42 switch (id.ToInt()) { |
| 43 #define BAILOUT_ID(NAME, ...) \ |
| 44 case BailoutId::kFirstBuiltinContinuationId + k##NAME: \ |
| 45 return k##NAME; |
| 46 BUILTIN_LIST_TFJ(BAILOUT_ID) |
| 47 #undef BAILOUT_ID |
| 48 default: |
| 49 UNIMPLEMENTED(); |
| 50 } |
| 51 } |
| 52 |
29 void Builtins::TearDown() { initialized_ = false; } | 53 void Builtins::TearDown() { initialized_ = false; } |
30 | 54 |
31 void Builtins::IterateBuiltins(RootVisitor* v) { | 55 void Builtins::IterateBuiltins(RootVisitor* v) { |
32 v->VisitRootPointers(Root::kBuiltins, &builtins_[0], | 56 v->VisitRootPointers(Root::kBuiltins, &builtins_[0], |
33 &builtins_[0] + builtin_count); | 57 &builtins_[0] + builtin_count); |
34 } | 58 } |
35 | 59 |
36 const char* Builtins::Lookup(byte* pc) { | 60 const char* Builtins::Lookup(byte* pc) { |
37 // may be called during initialization (disassembler!) | 61 // may be called during initialization (disassembler!) |
38 if (initialized_) { | 62 if (initialized_) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 auto descriptor = Builtin_##Name##_InterfaceDescriptor(isolate); \ | 148 auto descriptor = Builtin_##Name##_InterfaceDescriptor(isolate); \ |
125 return Callable(code, descriptor); \ | 149 return Callable(code, descriptor); \ |
126 } | 150 } |
127 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE, CASE, | 151 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, CASE, CASE, |
128 CASE, IGNORE_BUILTIN, IGNORE_BUILTIN) | 152 CASE, IGNORE_BUILTIN, IGNORE_BUILTIN) |
129 #undef CASE | 153 #undef CASE |
130 case kConsoleAssert: { | 154 case kConsoleAssert: { |
131 Handle<Code> code = isolate->builtins()->ConsoleAssert(); | 155 Handle<Code> code = isolate->builtins()->ConsoleAssert(); |
132 return Callable(code, BuiltinDescriptor(isolate)); | 156 return Callable(code, BuiltinDescriptor(isolate)); |
133 } | 157 } |
| 158 case kArrayForEach: { |
| 159 Handle<Code> code = isolate->builtins()->ArrayForEach(); |
| 160 return Callable(code, BuiltinDescriptor(isolate)); |
| 161 } |
| 162 case kArrayForEachLoopEagerDeoptContinuation: { |
| 163 Handle<Code> code = |
| 164 isolate->builtins()->ArrayForEachLoopEagerDeoptContinuation(); |
| 165 return Callable(code, BuiltinDescriptor(isolate)); |
| 166 } |
| 167 case kArrayForEachLoopLazyDeoptContinuation: { |
| 168 Handle<Code> code = |
| 169 isolate->builtins()->ArrayForEachLoopLazyDeoptContinuation(); |
| 170 return Callable(code, BuiltinDescriptor(isolate)); |
| 171 } |
134 default: | 172 default: |
135 UNREACHABLE(); | 173 UNREACHABLE(); |
136 return Callable(Handle<Code>::null(), VoidDescriptor(isolate)); | 174 return Callable(Handle<Code>::null(), VoidDescriptor(isolate)); |
137 } | 175 } |
138 } | 176 } |
139 | 177 |
140 // static | 178 // static |
| 179 int Builtins::GetStackParameterCount(Isolate* isolate, Name name) { |
| 180 switch (name) { |
| 181 #define CASE(Name, Count, ...) \ |
| 182 case k##Name: { \ |
| 183 return Count; \ |
| 184 } |
| 185 BUILTIN_LIST_TFJ(CASE) |
| 186 #undef CASE |
| 187 default: |
| 188 UNREACHABLE(); |
| 189 return 0; |
| 190 } |
| 191 } |
| 192 |
| 193 // static |
141 const char* Builtins::name(int index) { | 194 const char* Builtins::name(int index) { |
142 switch (index) { | 195 switch (index) { |
143 #define CASE(Name, ...) \ | 196 #define CASE(Name, ...) \ |
144 case k##Name: \ | 197 case k##Name: \ |
145 return #Name; | 198 return #Name; |
146 BUILTIN_LIST_ALL(CASE) | 199 BUILTIN_LIST_ALL(CASE) |
147 #undef CASE | 200 #undef CASE |
148 default: | 201 default: |
149 UNREACHABLE(); | 202 UNREACHABLE(); |
150 break; | 203 break; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // TODO(jochen): Remove this. | 292 // TODO(jochen): Remove this. |
240 if (responsible_context.is_null()) { | 293 if (responsible_context.is_null()) { |
241 return true; | 294 return true; |
242 } | 295 } |
243 if (*responsible_context == target->context()) return true; | 296 if (*responsible_context == target->context()) return true; |
244 return isolate->MayAccess(responsible_context, target_global_proxy); | 297 return isolate->MayAccess(responsible_context, target_global_proxy); |
245 } | 298 } |
246 | 299 |
247 } // namespace internal | 300 } // namespace internal |
248 } // namespace v8 | 301 } // namespace v8 |
OLD | NEW |