OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 230 } |
231 | 231 |
232 | 232 |
233 static StaticResource<SafeStringInputBuffer> safe_string_input_buffer; | 233 static StaticResource<SafeStringInputBuffer> safe_string_input_buffer; |
234 | 234 |
235 | 235 |
236 Handle<JSFunction> Compiler::Compile(Handle<String> source, | 236 Handle<JSFunction> Compiler::Compile(Handle<String> source, |
237 Handle<Object> script_name, | 237 Handle<Object> script_name, |
238 int line_offset, int column_offset, | 238 int line_offset, int column_offset, |
239 v8::Extension* extension, | 239 v8::Extension* extension, |
240 ScriptDataImpl* input_pre_data) { | 240 ScriptDataImpl* input_pre_data, |
| 241 Handle<Object> script_data) { |
241 int source_length = source->length(); | 242 int source_length = source->length(); |
242 Counters::total_load_size.Increment(source_length); | 243 Counters::total_load_size.Increment(source_length); |
243 Counters::total_compile_size.Increment(source_length); | 244 Counters::total_compile_size.Increment(source_length); |
244 | 245 |
245 // The VM is in the COMPILER state until exiting this function. | 246 // The VM is in the COMPILER state until exiting this function. |
246 VMState state(COMPILER); | 247 VMState state(COMPILER); |
247 | 248 |
248 // Do a lookup in the compilation cache but not for extensions. | 249 // Do a lookup in the compilation cache but not for extensions. |
249 Handle<JSFunction> result; | 250 Handle<JSFunction> result; |
250 if (extension == NULL) { | 251 if (extension == NULL) { |
(...skipping 13 matching lines...) Expand all Loading... |
264 } | 265 } |
265 | 266 |
266 // Create a script object describing the script to be compiled. | 267 // Create a script object describing the script to be compiled. |
267 Handle<Script> script = Factory::NewScript(source); | 268 Handle<Script> script = Factory::NewScript(source); |
268 if (!script_name.is_null()) { | 269 if (!script_name.is_null()) { |
269 script->set_name(*script_name); | 270 script->set_name(*script_name); |
270 script->set_line_offset(Smi::FromInt(line_offset)); | 271 script->set_line_offset(Smi::FromInt(line_offset)); |
271 script->set_column_offset(Smi::FromInt(column_offset)); | 272 script->set_column_offset(Smi::FromInt(column_offset)); |
272 } | 273 } |
273 | 274 |
| 275 script->set_data(script_data.is_null() ? Heap::undefined_value() |
| 276 : *script_data); |
| 277 |
274 // Compile the function and add it to the cache. | 278 // Compile the function and add it to the cache. |
275 result = MakeFunction(true, | 279 result = MakeFunction(true, |
276 false, | 280 false, |
277 DONT_VALIDATE_JSON, | 281 DONT_VALIDATE_JSON, |
278 script, | 282 script, |
279 Handle<Context>::null(), | 283 Handle<Context>::null(), |
280 extension, | 284 extension, |
281 pre_data); | 285 pre_data); |
282 if (extension == NULL && !result.is_null()) { | 286 if (extension == NULL && !result.is_null()) { |
283 CompilationCache::PutScript(source, result); | 287 CompilationCache::PutScript(source, result); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 LOG(CodeCreateEvent(tag, *code, *func_name)); | 561 LOG(CodeCreateEvent(tag, *code, *func_name)); |
558 OProfileAgent::CreateNativeCodeRegion(*func_name, | 562 OProfileAgent::CreateNativeCodeRegion(*func_name, |
559 code->instruction_start(), | 563 code->instruction_start(), |
560 code->instruction_size()); | 564 code->instruction_size()); |
561 } | 565 } |
562 } | 566 } |
563 } | 567 } |
564 #endif | 568 #endif |
565 | 569 |
566 } } // namespace v8::internal | 570 } } // namespace v8::internal |
OLD | NEW |