Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: test/cctest/cctest.h

Issue 203353002: New compilation API, part 2. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 316 static inline v8::Local<v8::Script> CompileWithOrigin(
317 v8::Local<v8::String> source, v8::Local<v8::String> origin_url) { 317 v8::Local<v8::String> source, v8::Local<v8::String> origin_url) {
318 v8::ScriptOrigin origin(origin_url); 318 v8::ScriptOrigin origin(origin_url);
319 v8::ScriptCompiler::Source script_source(source, origin);
319 return v8::ScriptCompiler::Compile( 320 return v8::ScriptCompiler::Compile(
320 v8::Isolate::GetCurrent(), v8::ScriptCompiler::Source(source, origin)); 321 v8::Isolate::GetCurrent(), &script_source);
321 } 322 }
322 323
323 324
324 static inline v8::Local<v8::Script> CompileWithOrigin( 325 static inline v8::Local<v8::Script> CompileWithOrigin(
325 v8::Local<v8::String> source, const char* origin_url) { 326 v8::Local<v8::String> source, const char* origin_url) {
326 return CompileWithOrigin(source, v8_str(origin_url)); 327 return CompileWithOrigin(source, v8_str(origin_url));
327 } 328 }
328 329
329 330
330 static inline v8::Local<v8::Script> CompileWithOrigin(const char* source, 331 static inline v8::Local<v8::Script> CompileWithOrigin(const char* source,
(...skipping 12 matching lines...) Expand all
343 return v8::Script::Compile(source)->Run(); 344 return v8::Script::Compile(source)->Run();
344 } 345 }
345 346
346 347
347 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) { 348 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) {
348 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 349 v8::Isolate* isolate = v8::Isolate::GetCurrent();
349 v8::Local<v8::String> source_string = 350 v8::Local<v8::String> source_string =
350 v8::String::NewFromUtf8(isolate, source); 351 v8::String::NewFromUtf8(isolate, source);
351 v8::ScriptData* preparse = v8::ScriptData::PreCompile(source_string); 352 v8::ScriptData* preparse = v8::ScriptData::PreCompile(source_string);
352 v8::ScriptCompiler::Source script_source( 353 v8::ScriptCompiler::Source script_source(
353 source_string, v8::ScriptCompiler::CachedData( 354 source_string, new v8::ScriptCompiler::CachedData(
354 reinterpret_cast<const uint8_t*>(preparse->Data()), 355 reinterpret_cast<const uint8_t*>(preparse->Data()),
355 preparse->Length())); 356 preparse->Length()));
356 v8::Local<v8::Script> script = v8::ScriptCompiler::Compile( 357 v8::Local<v8::Script> script =
357 isolate, v8::ScriptCompiler::Source(script_source)); 358 v8::ScriptCompiler::Compile(isolate, &script_source);
358 v8::Local<v8::Value> result = script->Run(); 359 v8::Local<v8::Value> result = script->Run();
359 delete preparse; 360 delete preparse;
360 return result; 361 return result;
361 } 362 }
362 363
363 364
364 // Helper functions that compile and run the source with given origin. 365 // Helper functions that compile and run the source with given origin.
365 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, 366 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source,
366 const char* origin_url, 367 const char* origin_url,
367 int line_number, 368 int line_number,
368 int column_number) { 369 int column_number) {
369 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 370 v8::Isolate* isolate = v8::Isolate::GetCurrent();
370 v8::ScriptOrigin origin(v8_str(origin_url), 371 v8::ScriptOrigin origin(v8_str(origin_url),
371 v8::Integer::New(isolate, line_number), 372 v8::Integer::New(isolate, line_number),
372 v8::Integer::New(isolate, column_number)); 373 v8::Integer::New(isolate, column_number));
373 return v8::ScriptCompiler::Compile( 374 v8::ScriptCompiler::Source script_source(v8_str(source), origin);
374 isolate, v8::ScriptCompiler::Source(v8_str(source), origin)) 375 return v8::ScriptCompiler::Compile(isolate, &script_source)->Run();
375 ->Run();
376 } 376 }
377 377
378 378
379 static inline v8::Local<v8::Value> CompileRunWithOrigin( 379 static inline v8::Local<v8::Value> CompileRunWithOrigin(
380 v8::Local<v8::String> source, const char* origin_url) { 380 v8::Local<v8::String> source, const char* origin_url) {
381 v8::ScriptOrigin origin(v8_str(origin_url)); 381 v8::ScriptCompiler::Source script_source(
382 return v8::ScriptCompiler::Compile( 382 source, v8::ScriptOrigin(v8_str(origin_url)));
383 v8::Isolate::GetCurrent(), 383 return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &script_source)
384 v8::ScriptCompiler::Source(source, origin))->Run(); 384 ->Run();
385 } 385 }
386 386
387 387
388 static inline v8::Local<v8::Value> CompileRunWithOrigin( 388 static inline v8::Local<v8::Value> CompileRunWithOrigin(
389 const char* source, const char* origin_url) { 389 const char* source, const char* origin_url) {
390 return CompileRunWithOrigin(v8_str(source), origin_url); 390 return CompileRunWithOrigin(v8_str(source), origin_url);
391 } 391 }
392 392
393 393
394 // 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.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); 433 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects());
434 heap_profiler_->StopHeapObjectsTracking(); 434 heap_profiler_->StopHeapObjectsTracking();
435 } 435 }
436 436
437 private: 437 private:
438 i::HeapProfiler* heap_profiler_; 438 i::HeapProfiler* heap_profiler_;
439 }; 439 };
440 440
441 441
442 #endif // ifndef CCTEST_H_ 442 #endif // ifndef CCTEST_H_
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698