| 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 17 matching lines...) Expand all Loading... |
| 28 #ifndef V8_COMPILER_H_ | 28 #ifndef V8_COMPILER_H_ |
| 29 #define V8_COMPILER_H_ | 29 #define V8_COMPILER_H_ |
| 30 | 30 |
| 31 #include "frame-element.h" | 31 #include "frame-element.h" |
| 32 #include "parser.h" | 32 #include "parser.h" |
| 33 #include "zone.h" | 33 #include "zone.h" |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 // CompilationInfo encapsulates some information known at compile time. |
| 39 class CompilationInfo BASE_EMBEDDED { |
| 40 public: |
| 41 CompilationInfo(Handle<SharedFunctionInfo> shared_info, |
| 42 Handle<Object> receiver, |
| 43 int loop_nesting) |
| 44 : shared_info_(shared_info), |
| 45 receiver_(receiver_), |
| 46 loop_nesting_(loop_nesting) { |
| 47 } |
| 48 |
| 49 Handle<SharedFunctionInfo> shared_info() { return shared_info_; } |
| 50 |
| 51 bool has_receiver() { return !receiver_.is_null(); } |
| 52 Handle<Object> receiver() { return receiver_; } |
| 53 |
| 54 int loop_nesting() { return loop_nesting_; } |
| 55 |
| 56 private: |
| 57 Handle<SharedFunctionInfo> shared_info_; |
| 58 Handle<Object> receiver_; |
| 59 int loop_nesting_; |
| 60 }; |
| 61 |
| 62 |
| 38 // The V8 compiler | 63 // The V8 compiler |
| 39 // | 64 // |
| 40 // General strategy: Source code is translated into an anonymous function w/o | 65 // General strategy: Source code is translated into an anonymous function w/o |
| 41 // parameters which then can be executed. If the source code contains other | 66 // parameters which then can be executed. If the source code contains other |
| 42 // functions, they will be compiled and allocated as part of the compilation | 67 // functions, they will be compiled and allocated as part of the compilation |
| 43 // of the source code. | 68 // of the source code. |
| 44 | 69 |
| 45 // Please note this interface returns function boilerplates. | 70 // Please note this interface returns function boilerplates. |
| 46 // This means you need to call Factory::NewFunctionFromBoilerplate | 71 // This means you need to call Factory::NewFunctionFromBoilerplate |
| 47 // before you have a real function with context. | 72 // before you have a real function with context. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 | 88 |
| 64 // Compile a String source within a context for Eval. | 89 // Compile a String source within a context for Eval. |
| 65 static Handle<JSFunction> CompileEval(Handle<String> source, | 90 static Handle<JSFunction> CompileEval(Handle<String> source, |
| 66 Handle<Context> context, | 91 Handle<Context> context, |
| 67 bool is_global, | 92 bool is_global, |
| 68 ValidationState validation); | 93 ValidationState validation); |
| 69 | 94 |
| 70 // Compile from function info (used for lazy compilation). Returns | 95 // Compile from function info (used for lazy compilation). Returns |
| 71 // true on success and false if the compilation resulted in a stack | 96 // true on success and false if the compilation resulted in a stack |
| 72 // overflow. | 97 // overflow. |
| 73 static bool CompileLazy(Handle<SharedFunctionInfo> shared, | 98 static bool CompileLazy(CompilationInfo* info); |
| 74 Handle<Object> receiver, | |
| 75 int loop_nesting); | |
| 76 | 99 |
| 77 // Compile a function boilerplate object (the function is possibly | 100 // Compile a function boilerplate object (the function is possibly |
| 78 // lazily compiled). Called recursively from a backend code | 101 // lazily compiled). Called recursively from a backend code |
| 79 // generator 'caller' to build the boilerplate. | 102 // generator 'caller' to build the boilerplate. |
| 80 static Handle<JSFunction> BuildBoilerplate(FunctionLiteral* node, | 103 static Handle<JSFunction> BuildBoilerplate(FunctionLiteral* node, |
| 81 Handle<Script> script, | 104 Handle<Script> script, |
| 82 AstVisitor* caller); | 105 AstVisitor* caller); |
| 83 | 106 |
| 84 // Set the function info for a newly compiled function. | 107 // Set the function info for a newly compiled function. |
| 85 static void SetFunctionInfo(Handle<JSFunction> fun, | 108 static void SetFunctionInfo(Handle<JSFunction> fun, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 100 FrameElement::ClearConstantList(); | 123 FrameElement::ClearConstantList(); |
| 101 Result::ClearConstantList(); | 124 Result::ClearConstantList(); |
| 102 } | 125 } |
| 103 } | 126 } |
| 104 }; | 127 }; |
| 105 | 128 |
| 106 | 129 |
| 107 } } // namespace v8::internal | 130 } } // namespace v8::internal |
| 108 | 131 |
| 109 #endif // V8_COMPILER_H_ | 132 #endif // V8_COMPILER_H_ |
| OLD | NEW |