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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 static inline v8::Local<v8::Script> v8_compile(const char* x) { | 306 static inline v8::Local<v8::Script> v8_compile(const char* x) { |
307 return v8::Script::Compile(v8_str(x)); | 307 return v8::Script::Compile(v8_str(x)); |
308 } | 308 } |
309 | 309 |
310 | 310 |
311 static inline v8::Local<v8::Script> v8_compile(v8::Local<v8::String> x) { | 311 static inline v8::Local<v8::Script> v8_compile(v8::Local<v8::String> x) { |
312 return v8::Script::Compile(x); | 312 return v8::Script::Compile(x); |
313 } | 313 } |
314 | 314 |
315 | 315 |
| 316 static inline v8::Local<v8::Script> CompileWithOrigin( |
| 317 v8::Local<v8::String> source, v8::Local<v8::String> origin_url) { |
| 318 v8::ScriptOrigin origin(origin_url); |
| 319 return v8::ScriptCompiler::CompileContextBound( |
| 320 v8::Isolate::GetCurrent(), v8::ScriptCompiler::Source(source, origin)); |
| 321 } |
| 322 |
| 323 |
| 324 static inline v8::Local<v8::Script> CompileWithOrigin( |
| 325 v8::Local<v8::String> source, const char* origin_url) { |
| 326 return CompileWithOrigin(source, v8_str(origin_url)); |
| 327 } |
| 328 |
| 329 |
316 static inline v8::Local<v8::Script> CompileWithOrigin(const char* source, | 330 static inline v8::Local<v8::Script> CompileWithOrigin(const char* source, |
317 const char* origin_url) { | 331 const char* origin_url) { |
318 v8::ScriptOrigin origin(v8_str(origin_url)); | 332 return CompileWithOrigin(v8_str(source), v8_str(origin_url)); |
319 return v8::Script::Compile(v8_str(source), &origin); | |
320 } | 333 } |
321 | 334 |
322 | 335 |
323 static inline v8::Local<v8::Script> CompileWithOrigin( | |
324 v8::Local<v8::String> source, const char* origin_url) { | |
325 v8::ScriptOrigin origin(v8_str(origin_url)); | |
326 return v8::Script::Compile(source, &origin); | |
327 } | |
328 | |
329 | |
330 // Helper functions that compile and run the source. | 336 // Helper functions that compile and run the source. |
331 static inline v8::Local<v8::Value> CompileRun(const char* source) { | 337 static inline v8::Local<v8::Value> CompileRun(const char* source) { |
332 return v8::Script::Compile(v8_str(source))->Run(); | 338 return v8::Script::Compile(v8_str(source))->Run(); |
333 } | 339 } |
334 | 340 |
335 | 341 |
336 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) { | 342 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) { |
337 return v8::Script::Compile(source)->Run(); | 343 return v8::Script::Compile(source)->Run(); |
338 } | 344 } |
339 | 345 |
340 | 346 |
341 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) { | 347 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) { |
342 v8::Local<v8::String> script_source = | 348 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
343 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source); | 349 v8::Local<v8::String> source_string = |
344 v8::ScriptData* preparse = v8::ScriptData::PreCompile(script_source); | 350 v8::String::NewFromUtf8(isolate, source); |
345 v8::Local<v8::Script> script = | 351 v8::ScriptData* preparse = v8::ScriptData::PreCompile(source_string); |
346 v8::Script::Compile(script_source, NULL, preparse); | 352 v8::ScriptCompiler::Source script_source( |
| 353 source_string, v8::ScriptCompiler::CachedData( |
| 354 reinterpret_cast<const uint8_t*>(preparse->Data()), |
| 355 preparse->Length())); |
| 356 v8::Local<v8::Script> script = v8::ScriptCompiler::CompileContextBound( |
| 357 isolate, v8::ScriptCompiler::Source(script_source)); |
347 v8::Local<v8::Value> result = script->Run(); | 358 v8::Local<v8::Value> result = script->Run(); |
348 delete preparse; | 359 delete preparse; |
349 return result; | 360 return result; |
350 } | 361 } |
351 | 362 |
352 | 363 |
353 // Helper functions that compile and run the source with given origin. | 364 // Helper functions that compile and run the source with given origin. |
354 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, | 365 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, |
355 const char* origin_url, | 366 const char* origin_url, |
356 int line_number, | 367 int line_number, |
357 int column_number) { | 368 int column_number) { |
358 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 369 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
359 v8::ScriptOrigin origin(v8_str(origin_url), | 370 v8::ScriptOrigin origin(v8_str(origin_url), |
360 v8::Integer::New(isolate, line_number), | 371 v8::Integer::New(isolate, line_number), |
361 v8::Integer::New(isolate, column_number)); | 372 v8::Integer::New(isolate, column_number)); |
362 return v8::Script::Compile(v8_str(source), &origin)->Run(); | 373 return v8::ScriptCompiler::CompileContextBound( |
| 374 isolate, v8::ScriptCompiler::Source(v8_str(source), origin)) |
| 375 ->Run(); |
| 376 } |
| 377 |
| 378 |
| 379 static inline v8::Local<v8::Value> CompileRunWithOrigin( |
| 380 v8::Local<v8::String> source, const char* origin_url) { |
| 381 v8::ScriptOrigin origin(v8_str(origin_url)); |
| 382 return v8::ScriptCompiler::CompileContextBound( |
| 383 v8::Isolate::GetCurrent(), |
| 384 v8::ScriptCompiler::Source(source, origin))->Run(); |
363 } | 385 } |
364 | 386 |
365 | 387 |
366 static inline v8::Local<v8::Value> CompileRunWithOrigin( | 388 static inline v8::Local<v8::Value> CompileRunWithOrigin( |
367 const char* source, const char* origin_url) { | 389 const char* source, const char* origin_url) { |
368 v8::ScriptOrigin origin(v8_str(origin_url)); | 390 return CompileRunWithOrigin(v8_str(source), origin_url); |
369 return v8::Script::Compile(v8_str(source), &origin)->Run(); | |
370 } | 391 } |
371 | 392 |
372 | 393 |
373 // Pick a slightly different port to allow tests to be run in parallel. | 394 // Pick a slightly different port to allow tests to be run in parallel. |
374 static inline int FlagDependentPortOffset() { | 395 static inline int FlagDependentPortOffset() { |
375 return ::v8::internal::FLAG_crankshaft == false ? 100 : | 396 return ::v8::internal::FLAG_crankshaft == false ? 100 : |
376 ::v8::internal::FLAG_always_opt ? 200 : 0; | 397 ::v8::internal::FLAG_always_opt ? 200 : 0; |
377 } | 398 } |
378 | 399 |
379 | 400 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); | 433 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); |
413 heap_profiler_->StopHeapObjectsTracking(); | 434 heap_profiler_->StopHeapObjectsTracking(); |
414 } | 435 } |
415 | 436 |
416 private: | 437 private: |
417 i::HeapProfiler* heap_profiler_; | 438 i::HeapProfiler* heap_profiler_; |
418 }; | 439 }; |
419 | 440 |
420 | 441 |
421 #endif // ifndef CCTEST_H_ | 442 #endif // ifndef CCTEST_H_ |
OLD | NEW |