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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // Get rid of the pre-parsing data (if necessary). | 195 // Get rid of the pre-parsing data (if necessary). |
196 if (input_pre_data == NULL && pre_data != NULL) { | 196 if (input_pre_data == NULL && pre_data != NULL) { |
197 delete pre_data; | 197 delete pre_data; |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 return result; | 201 return result; |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 Handle<JSFunction> Compiler::CompileEval(bool is_global, | 205 Handle<JSFunction> Compiler::CompileEval(Handle<String> source, |
206 Handle<String> source) { | 206 int line_offset, |
| 207 bool is_global) { |
207 Counters::total_eval_size.Increment(source->length()); | 208 Counters::total_eval_size.Increment(source->length()); |
208 Counters::total_compile_size.Increment(source->length()); | 209 Counters::total_compile_size.Increment(source->length()); |
209 | 210 |
210 // The VM is in the COMPILER state until exiting this function. | 211 // The VM is in the COMPILER state until exiting this function. |
211 VMState state(COMPILER); | 212 VMState state(COMPILER); |
212 CompilationCache::Entry entry = is_global | 213 CompilationCache::Entry entry = is_global |
213 ? CompilationCache::EVAL_GLOBAL | 214 ? CompilationCache::EVAL_GLOBAL |
214 : CompilationCache::EVAL_CONTEXTUAL; | 215 : CompilationCache::EVAL_CONTEXTUAL; |
215 | 216 |
216 // Do a lookup in the compilation cache; if the entry is not there, | 217 // Do a lookup in the compilation cache; if the entry is not there, |
217 // invoke the compiler and add the result to the cache. | 218 // invoke the compiler and add the result to the cache. |
218 Handle<JSFunction> result = CompilationCache::LookupEval(source, entry); | 219 Handle<JSFunction> result = CompilationCache::LookupEval(source, entry); |
219 if (result.is_null()) { | 220 if (result.is_null()) { |
220 // Create a script object describing the script to be compiled. | 221 // Create a script object describing the script to be compiled. |
221 Handle<Script> script = Factory::NewScript(source); | 222 Handle<Script> script = Factory::NewScript(source); |
| 223 script->set_line_offset(Smi::FromInt(line_offset)); |
222 result = MakeFunction(is_global, true, script, NULL, NULL); | 224 result = MakeFunction(is_global, true, script, NULL, NULL); |
223 if (!result.is_null()) { | 225 if (!result.is_null()) { |
224 CompilationCache::Associate(source, entry, result); | 226 CompilationCache::Associate(source, entry, result); |
225 } | 227 } |
226 } | 228 } |
227 return result; | 229 return result; |
228 } | 230 } |
229 | 231 |
230 | 232 |
231 bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared) { | 233 bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // Set the expected number of properties for instances. | 285 // Set the expected number of properties for instances. |
284 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 286 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
285 | 287 |
286 // Check the function has compiled code. | 288 // Check the function has compiled code. |
287 ASSERT(shared->is_compiled()); | 289 ASSERT(shared->is_compiled()); |
288 return true; | 290 return true; |
289 } | 291 } |
290 | 292 |
291 | 293 |
292 } } // namespace v8::internal | 294 } } // namespace v8::internal |
OLD | NEW |