OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 308 } |
309 | 309 |
310 | 310 |
311 // Helper function that compiles and runs the source. | 311 // Helper function that compiles and runs the source. |
312 static inline v8::Local<v8::Value> CompileRun(const char* source) { | 312 static inline v8::Local<v8::Value> CompileRun(const char* source) { |
313 return v8::Script::Compile( | 313 return v8::Script::Compile( |
314 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run(); | 314 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run(); |
315 } | 315 } |
316 | 316 |
317 | 317 |
| 318 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) { |
| 319 v8::Local<v8::String> script_source = |
| 320 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source); |
| 321 v8::ScriptData* preparse = v8::ScriptData::PreCompile(script_source); |
| 322 v8::Local<v8::Script> script = |
| 323 v8::Script::Compile(script_source, NULL, preparse); |
| 324 v8::Local<v8::Value> result = script->Run(); |
| 325 delete preparse; |
| 326 return result; |
| 327 } |
| 328 |
| 329 |
318 // Helper function that compiles and runs the source with given origin. | 330 // Helper function that compiles and runs the source with given origin. |
319 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, | 331 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, |
320 const char* origin_url, | 332 const char* origin_url, |
321 int line_number, | 333 int line_number, |
322 int column_number) { | 334 int column_number) { |
323 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 335 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
324 v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, origin_url), | 336 v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, origin_url), |
325 v8::Integer::New(isolate, line_number), | 337 v8::Integer::New(isolate, line_number), |
326 v8::Integer::New(isolate, column_number)); | 338 v8::Integer::New(isolate, column_number)); |
327 return v8::Script::Compile(v8::String::NewFromUtf8(isolate, source), &origin) | 339 return v8::Script::Compile(v8::String::NewFromUtf8(isolate, source), &origin) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); | 383 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); |
372 heap_profiler_->StopHeapObjectsTracking(); | 384 heap_profiler_->StopHeapObjectsTracking(); |
373 } | 385 } |
374 | 386 |
375 private: | 387 private: |
376 i::HeapProfiler* heap_profiler_; | 388 i::HeapProfiler* heap_profiler_; |
377 }; | 389 }; |
378 | 390 |
379 | 391 |
380 #endif // ifndef CCTEST_H_ | 392 #endif // ifndef CCTEST_H_ |
OLD | NEW |