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

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

Issue 196793013: Revert "New Compilation API, part 1" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/profile-generator-inl.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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 316 static inline v8::Local<v8::Script> CompileWithOrigin(const char* source,
317 v8::Local<v8::String> source, v8::Local<v8::String> origin_url) { 317 const char* origin_url) {
318 v8::ScriptOrigin origin(origin_url); 318 v8::ScriptOrigin origin(v8_str(origin_url));
319 return v8::ScriptCompiler::Compile( 319 return v8::Script::Compile(v8_str(source), &origin);
320 v8::Isolate::GetCurrent(), v8::ScriptCompiler::Source(source, origin));
321 } 320 }
322 321
323 322
324 static inline v8::Local<v8::Script> CompileWithOrigin( 323 static inline v8::Local<v8::Script> CompileWithOrigin(
325 v8::Local<v8::String> source, const char* origin_url) { 324 v8::Local<v8::String> source, const char* origin_url) {
326 return CompileWithOrigin(source, v8_str(origin_url)); 325 v8::ScriptOrigin origin(v8_str(origin_url));
326 return v8::Script::Compile(source, &origin);
327 } 327 }
328 328
329 329
330 static inline v8::Local<v8::Script> CompileWithOrigin(const char* source,
331 const char* origin_url) {
332 return CompileWithOrigin(v8_str(source), v8_str(origin_url));
333 }
334
335
336 // Helper functions that compile and run the source. 330 // Helper functions that compile and run the source.
337 static inline v8::Local<v8::Value> CompileRun(const char* source) { 331 static inline v8::Local<v8::Value> CompileRun(const char* source) {
338 return v8::Script::Compile(v8_str(source))->Run(); 332 return v8::Script::Compile(v8_str(source))->Run();
339 } 333 }
340 334
341 335
342 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) { 336 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) {
343 return v8::Script::Compile(source)->Run(); 337 return v8::Script::Compile(source)->Run();
344 } 338 }
345 339
346 340
347 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) { 341 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) {
348 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 342 v8::Local<v8::String> script_source =
349 v8::Local<v8::String> source_string = 343 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source);
350 v8::String::NewFromUtf8(isolate, source); 344 v8::ScriptData* preparse = v8::ScriptData::PreCompile(script_source);
351 v8::ScriptData* preparse = v8::ScriptData::PreCompile(source_string); 345 v8::Local<v8::Script> script =
352 v8::ScriptCompiler::Source script_source( 346 v8::Script::Compile(script_source, NULL, preparse);
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::Compile(
357 isolate, v8::ScriptCompiler::Source(script_source));
358 v8::Local<v8::Value> result = script->Run(); 347 v8::Local<v8::Value> result = script->Run();
359 delete preparse; 348 delete preparse;
360 return result; 349 return result;
361 } 350 }
362 351
363 352
364 // Helper functions that compile and run the source with given origin. 353 // Helper functions that compile and run the source with given origin.
365 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, 354 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source,
366 const char* origin_url, 355 const char* origin_url,
367 int line_number, 356 int line_number,
368 int column_number) { 357 int column_number) {
369 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 358 v8::Isolate* isolate = v8::Isolate::GetCurrent();
370 v8::ScriptOrigin origin(v8_str(origin_url), 359 v8::ScriptOrigin origin(v8_str(origin_url),
371 v8::Integer::New(isolate, line_number), 360 v8::Integer::New(isolate, line_number),
372 v8::Integer::New(isolate, column_number)); 361 v8::Integer::New(isolate, column_number));
373 return v8::ScriptCompiler::Compile( 362 return v8::Script::Compile(v8_str(source), &origin)->Run();
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::Compile(
383 v8::Isolate::GetCurrent(),
384 v8::ScriptCompiler::Source(source, origin))->Run();
385 } 363 }
386 364
387 365
388 static inline v8::Local<v8::Value> CompileRunWithOrigin( 366 static inline v8::Local<v8::Value> CompileRunWithOrigin(
389 const char* source, const char* origin_url) { 367 const char* source, const char* origin_url) {
390 return CompileRunWithOrigin(v8_str(source), origin_url); 368 v8::ScriptOrigin origin(v8_str(origin_url));
369 return v8::Script::Compile(v8_str(source), &origin)->Run();
391 } 370 }
392 371
393 372
394 // Pick a slightly different port to allow tests to be run in parallel. 373 // Pick a slightly different port to allow tests to be run in parallel.
395 static inline int FlagDependentPortOffset() { 374 static inline int FlagDependentPortOffset() {
396 return ::v8::internal::FLAG_crankshaft == false ? 100 : 375 return ::v8::internal::FLAG_crankshaft == false ? 100 :
397 ::v8::internal::FLAG_always_opt ? 200 : 0; 376 ::v8::internal::FLAG_always_opt ? 200 : 0;
398 } 377 }
399 378
400 379
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); 412 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects());
434 heap_profiler_->StopHeapObjectsTracking(); 413 heap_profiler_->StopHeapObjectsTracking();
435 } 414 }
436 415
437 private: 416 private:
438 i::HeapProfiler* heap_profiler_; 417 i::HeapProfiler* heap_profiler_;
439 }; 418 };
440 419
441 420
442 #endif // ifndef CCTEST_H_ 421 #endif // ifndef CCTEST_H_
OLDNEW
« no previous file with comments | « src/profile-generator-inl.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698