OLD | NEW |
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 }; | 212 }; |
213 | 213 |
214 | 214 |
215 // The V8 compiler | 215 // The V8 compiler |
216 // | 216 // |
217 // General strategy: Source code is translated into an anonymous function w/o | 217 // General strategy: Source code is translated into an anonymous function w/o |
218 // parameters which then can be executed. If the source code contains other | 218 // parameters which then can be executed. If the source code contains other |
219 // functions, they will be compiled and allocated as part of the compilation | 219 // functions, they will be compiled and allocated as part of the compilation |
220 // of the source code. | 220 // of the source code. |
221 | 221 |
222 // Please note this interface returns function boilerplates. | 222 // Please note this interface returns shared function infos. |
223 // This means you need to call Factory::NewFunctionFromBoilerplate | 223 // This means you need to call Factory::NewFunctionFromSharedFunctionInfo |
224 // before you have a real function with context. | 224 // before you have a real function with a context. |
225 | 225 |
226 class Compiler : public AllStatic { | 226 class Compiler : public AllStatic { |
227 public: | 227 public: |
228 enum ValidationState { VALIDATE_JSON, DONT_VALIDATE_JSON }; | 228 enum ValidationState { VALIDATE_JSON, DONT_VALIDATE_JSON }; |
229 | 229 |
230 // All routines return a JSFunction. | 230 // All routines return a JSFunction. |
231 // If an error occurs an exception is raised and | 231 // If an error occurs an exception is raised and |
232 // the return handle contains NULL. | 232 // the return handle contains NULL. |
233 | 233 |
234 // Compile a String source within a context. | 234 // Compile a String source within a context. |
235 static Handle<JSFunction> Compile(Handle<String> source, | 235 static Handle<SharedFunctionInfo> Compile(Handle<String> source, |
236 Handle<Object> script_name, | 236 Handle<Object> script_name, |
237 int line_offset, int column_offset, | 237 int line_offset, |
238 v8::Extension* extension, | 238 int column_offset, |
239 ScriptDataImpl* pre_data, | 239 v8::Extension* extension, |
240 Handle<Object> script_data, | 240 ScriptDataImpl* pre_data, |
241 NativesFlag is_natives_code); | 241 Handle<Object> script_data, |
| 242 NativesFlag is_natives_code); |
242 | 243 |
243 // Compile a String source within a context for Eval. | 244 // Compile a String source within a context for Eval. |
244 static Handle<JSFunction> CompileEval(Handle<String> source, | 245 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, |
245 Handle<Context> context, | 246 Handle<Context> context, |
246 bool is_global, | 247 bool is_global, |
247 ValidationState validation); | 248 ValidationState validation); |
248 | 249 |
249 // Compile from function info (used for lazy compilation). Returns | 250 // Compile from function info (used for lazy compilation). Returns |
250 // true on success and false if the compilation resulted in a stack | 251 // true on success and false if the compilation resulted in a stack |
251 // overflow. | 252 // overflow. |
252 static bool CompileLazy(CompilationInfo* info); | 253 static bool CompileLazy(CompilationInfo* info); |
253 | 254 |
254 // Compile a function boilerplate object (the function is possibly | 255 // Compile a shared function info object (the function is possibly |
255 // lazily compiled). Called recursively from a backend code | 256 // lazily compiled). Called recursively from a backend code |
256 // generator 'caller' to build the boilerplate. | 257 // generator 'caller' to build the shared function info. |
257 static Handle<JSFunction> BuildBoilerplate(FunctionLiteral* node, | 258 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
258 Handle<Script> script, | 259 Handle<Script> script, |
259 AstVisitor* caller); | 260 AstVisitor* caller); |
260 | 261 |
261 // Set the function info for a newly compiled function. | 262 // Set the function info for a newly compiled function. |
262 static void SetFunctionInfo(Handle<JSFunction> fun, | 263 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
263 FunctionLiteral* lit, | 264 FunctionLiteral* lit, |
264 bool is_toplevel, | 265 bool is_toplevel, |
265 Handle<Script> script); | 266 Handle<Script> script); |
266 | 267 |
267 private: | 268 private: |
268 | 269 |
269 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT | 270 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT |
270 static void LogCodeCreateEvent(Logger::LogEventsAndTags tag, | 271 static void LogCodeCreateEvent(Logger::LogEventsAndTags tag, |
271 Handle<String> name, | 272 Handle<String> name, |
272 Handle<String> inferred_name, | 273 Handle<String> inferred_name, |
(...skipping 22 matching lines...) Expand all Loading... |
295 FrameElement::ClearConstantList(); | 296 FrameElement::ClearConstantList(); |
296 Result::ClearConstantList(); | 297 Result::ClearConstantList(); |
297 } | 298 } |
298 } | 299 } |
299 }; | 300 }; |
300 | 301 |
301 | 302 |
302 } } // namespace v8::internal | 303 } } // namespace v8::internal |
303 | 304 |
304 #endif // V8_COMPILER_H_ | 305 #endif // V8_COMPILER_H_ |
OLD | NEW |