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

Side by Side Diff: src/builtins.h

Issue 2840018: [Isolates] Moved more compilation-related globals (builtins, runtime, &c.)... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: rebase Created 10 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 V(CALL_NON_FUNCTION_AS_CONSTRUCTOR, 0) \ 161 V(CALL_NON_FUNCTION_AS_CONSTRUCTOR, 0) \
162 V(TO_OBJECT, 0) \ 162 V(TO_OBJECT, 0) \
163 V(TO_NUMBER, 0) \ 163 V(TO_NUMBER, 0) \
164 V(TO_STRING, 0) \ 164 V(TO_STRING, 0) \
165 V(STRING_ADD_LEFT, 1) \ 165 V(STRING_ADD_LEFT, 1) \
166 V(STRING_ADD_RIGHT, 1) \ 166 V(STRING_ADD_RIGHT, 1) \
167 V(APPLY_PREPARE, 1) \ 167 V(APPLY_PREPARE, 1) \
168 V(APPLY_OVERFLOW, 1) 168 V(APPLY_OVERFLOW, 1)
169 169
170 170
171 class BuiltinFunctionTable;
171 class ObjectVisitor; 172 class ObjectVisitor;
172 173
173 174
174 class Builtins : public AllStatic { 175 class Builtins {
175 public: 176 public:
177 ~Builtins();
178
176 // Generate all builtin code objects. Should be called once during 179 // Generate all builtin code objects. Should be called once during
177 // VM initialization. 180 // isolate initialization.
178 static void Setup(bool create_heap_objects); 181 void Setup(bool create_heap_objects);
179 static void TearDown(); 182 void TearDown();
180 183
181 // Garbage collection support. 184 // Garbage collection support.
182 static void IterateBuiltins(ObjectVisitor* v); 185 void IterateBuiltins(ObjectVisitor* v);
183 186
184 // Disassembler support. 187 // Disassembler support.
185 static const char* Lookup(byte* pc); 188 const char* Lookup(byte* pc);
186 189
187 enum Name { 190 enum Name {
188 #define DEF_ENUM_C(name, ignore) name, 191 #define DEF_ENUM_C(name, ignore) name,
189 #define DEF_ENUM_A(name, kind, state) name, 192 #define DEF_ENUM_A(name, kind, state) name,
190 BUILTIN_LIST_C(DEF_ENUM_C) 193 BUILTIN_LIST_C(DEF_ENUM_C)
191 BUILTIN_LIST_A(DEF_ENUM_A) 194 BUILTIN_LIST_A(DEF_ENUM_A)
192 BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) 195 BUILTIN_LIST_DEBUG_A(DEF_ENUM_A)
193 #undef DEF_ENUM_C 196 #undef DEF_ENUM_C
194 #undef DEF_ENUM_A 197 #undef DEF_ENUM_A
195 builtin_count 198 builtin_count
196 }; 199 };
197 200
198 enum CFunctionId { 201 enum CFunctionId {
199 #define DEF_ENUM_C(name, ignore) c_##name, 202 #define DEF_ENUM_C(name, ignore) c_##name,
200 BUILTIN_LIST_C(DEF_ENUM_C) 203 BUILTIN_LIST_C(DEF_ENUM_C)
201 #undef DEF_ENUM_C 204 #undef DEF_ENUM_C
202 cfunction_count 205 cfunction_count
203 }; 206 };
204 207
205 enum JavaScript { 208 enum JavaScript {
206 #define DEF_ENUM(name, ignore) name, 209 #define DEF_ENUM(name, ignore) name,
207 BUILTINS_LIST_JS(DEF_ENUM) 210 BUILTINS_LIST_JS(DEF_ENUM)
208 #undef DEF_ENUM 211 #undef DEF_ENUM
209 id_count 212 id_count
210 }; 213 };
211 214
212 static Code* builtin(Name name) { 215 Code* builtin(Name name) {
213 // Code::cast cannot be used here since we access builtins 216 // Code::cast cannot be used here since we access builtins
214 // during the marking phase of mark sweep. See IC::Clear. 217 // during the marking phase of mark sweep. See IC::Clear.
215 return reinterpret_cast<Code*>(builtins_[name]); 218 return reinterpret_cast<Code*>(builtins_[name]);
216 } 219 }
217 220
218 static Address builtin_address(Name name) { 221 Address builtin_address(Name name) {
219 return reinterpret_cast<Address>(&builtins_[name]); 222 return reinterpret_cast<Address>(&builtins_[name]);
220 } 223 }
221 224
222 static Address c_function_address(CFunctionId id) { 225 static Address c_function_address(CFunctionId id) {
223 return c_functions_[id]; 226 return c_functions_[id];
224 } 227 }
225 228
226 static const char* GetName(JavaScript id) { return javascript_names_[id]; } 229 static const char* GetName(JavaScript id) { return javascript_names_[id]; }
227 static int GetArgumentsCount(JavaScript id) { return javascript_argc_[id]; } 230 static int GetArgumentsCount(JavaScript id) { return javascript_argc_[id]; }
228 static Handle<Code> GetCode(JavaScript id, bool* resolved); 231 Handle<Code> GetCode(JavaScript id, bool* resolved);
229 static int NumberOfJavaScriptBuiltins() { return id_count; } 232 static int NumberOfJavaScriptBuiltins() { return id_count; }
230 233
234 bool is_initialized() const { return initialized_; }
235
231 private: 236 private:
237 Builtins();
238
232 // The external C++ functions called from the code. 239 // The external C++ functions called from the code.
233 static Address c_functions_[cfunction_count]; 240 static Address const c_functions_[cfunction_count];
234 241
235 // Note: These are always Code objects, but to conform with 242 // Note: These are always Code objects, but to conform with
236 // IterateBuiltins() above which assumes Object**'s for the callback 243 // IterateBuiltins() above which assumes Object**'s for the callback
237 // function f, we use an Object* array here. 244 // function f, we use an Object* array here.
238 static Object* builtins_[builtin_count]; 245 Object* builtins_[builtin_count];
239 static const char* names_[builtin_count]; 246 const char* names_[builtin_count];
240 static const char* javascript_names_[id_count]; 247 static const char* const javascript_names_[id_count];
241 static int javascript_argc_[id_count]; 248 static int const javascript_argc_[id_count];
242 249
243 static void Generate_Adaptor(MacroAssembler* masm, 250 static void Generate_Adaptor(MacroAssembler* masm,
244 CFunctionId id, 251 CFunctionId id,
245 BuiltinExtraArguments extra_args); 252 BuiltinExtraArguments extra_args);
246 static void Generate_JSConstructCall(MacroAssembler* masm); 253 static void Generate_JSConstructCall(MacroAssembler* masm);
247 static void Generate_JSConstructStubGeneric(MacroAssembler* masm); 254 static void Generate_JSConstructStubGeneric(MacroAssembler* masm);
248 static void Generate_JSConstructStubApi(MacroAssembler* masm); 255 static void Generate_JSConstructStubApi(MacroAssembler* masm);
249 static void Generate_JSEntryTrampoline(MacroAssembler* masm); 256 static void Generate_JSEntryTrampoline(MacroAssembler* masm);
250 static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm); 257 static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm);
251 static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm); 258 static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm);
252 259
253 static void Generate_FunctionCall(MacroAssembler* masm); 260 static void Generate_FunctionCall(MacroAssembler* masm);
254 static void Generate_FunctionApply(MacroAssembler* masm); 261 static void Generate_FunctionApply(MacroAssembler* masm);
255 262
256 static void Generate_ArrayCode(MacroAssembler* masm); 263 static void Generate_ArrayCode(MacroAssembler* masm);
257 static void Generate_ArrayConstructCode(MacroAssembler* masm); 264 static void Generate_ArrayConstructCode(MacroAssembler* masm);
265
266 static void InitBuiltinFunctionTable();
267
268 bool initialized_;
269
270 friend class BuiltinFunctionTable;
271 friend class Isolate;
272
273 DISALLOW_COPY_AND_ASSIGN(Builtins);
258 }; 274 };
259 275
260 } } // namespace v8::internal 276 } } // namespace v8::internal
261 277
262 #endif // V8_BUILTINS_H_ 278 #endif // V8_BUILTINS_H_
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/builtins.cc » ('j') | src/runtime.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698