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

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

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
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/x64/stub-cache-x64.cc ('k') | test/cctest/cctest.gyp » ('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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 static inline v8::Local<v8::String> v8_str(const char* x) { 301 static inline v8::Local<v8::String> v8_str(const char* x) {
302 return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), x); 302 return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), x);
303 } 303 }
304 304
305 305
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 // Helper function that compiles and runs the source. 311 static inline v8::Local<v8::Script> v8_compile(v8::Local<v8::String> x) {
312 return v8::Script::Compile(x);
313 }
314
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::Compile(
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
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.
312 static inline v8::Local<v8::Value> CompileRun(const char* source) { 337 static inline v8::Local<v8::Value> CompileRun(const char* source) {
313 return v8::Script::Compile( 338 return v8::Script::Compile(v8_str(source))->Run();
314 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run(); 339 }
340
341
342 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) {
343 return v8::Script::Compile(source)->Run();
315 } 344 }
316 345
317 346
318 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) { 347 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) {
319 v8::Local<v8::String> script_source = 348 v8::Isolate* isolate = v8::Isolate::GetCurrent();
320 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source); 349 v8::Local<v8::String> source_string =
321 v8::ScriptData* preparse = v8::ScriptData::PreCompile(script_source); 350 v8::String::NewFromUtf8(isolate, source);
322 v8::Local<v8::Script> script = 351 v8::ScriptData* preparse = v8::ScriptData::PreCompile(source_string);
323 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::Compile(
357 isolate, v8::ScriptCompiler::Source(script_source));
324 v8::Local<v8::Value> result = script->Run(); 358 v8::Local<v8::Value> result = script->Run();
325 delete preparse; 359 delete preparse;
326 return result; 360 return result;
327 } 361 }
328 362
329 363
330 // Helper function that compiles and runs the source with given origin. 364 // Helper functions that compile and run the source with given origin.
331 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, 365 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source,
332 const char* origin_url, 366 const char* origin_url,
333 int line_number, 367 int line_number,
334 int column_number) { 368 int column_number) {
335 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 369 v8::Isolate* isolate = v8::Isolate::GetCurrent();
336 v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, origin_url), 370 v8::ScriptOrigin origin(v8_str(origin_url),
337 v8::Integer::New(isolate, line_number), 371 v8::Integer::New(isolate, line_number),
338 v8::Integer::New(isolate, column_number)); 372 v8::Integer::New(isolate, column_number));
339 return v8::Script::Compile(v8::String::NewFromUtf8(isolate, source), &origin) 373 return v8::ScriptCompiler::Compile(
374 isolate, v8::ScriptCompiler::Source(v8_str(source), origin))
340 ->Run(); 375 ->Run();
341 } 376 }
342 377
343 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 }
386
387
388 static inline v8::Local<v8::Value> CompileRunWithOrigin(
389 const char* source, const char* origin_url) {
390 return CompileRunWithOrigin(v8_str(source), origin_url);
391 }
392
393
344 // 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.
345 static inline int FlagDependentPortOffset() { 395 static inline int FlagDependentPortOffset() {
346 return ::v8::internal::FLAG_crankshaft == false ? 100 : 396 return ::v8::internal::FLAG_crankshaft == false ? 100 :
347 ::v8::internal::FLAG_always_opt ? 200 : 0; 397 ::v8::internal::FLAG_always_opt ? 200 : 0;
348 } 398 }
349 399
350 400
351 // Helper function that simulates a full new-space in the heap. 401 // Helper function that simulates a full new-space in the heap.
352 static inline void SimulateFullSpace(v8::internal::NewSpace* space) { 402 static inline void SimulateFullSpace(v8::internal::NewSpace* space) {
353 int new_linear_size = static_cast<int>( 403 int new_linear_size = static_cast<int>(
(...skipping 29 matching lines...) Expand all
383 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); 433 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects());
384 heap_profiler_->StopHeapObjectsTracking(); 434 heap_profiler_->StopHeapObjectsTracking();
385 } 435 }
386 436
387 private: 437 private:
388 i::HeapProfiler* heap_profiler_; 438 i::HeapProfiler* heap_profiler_;
389 }; 439 };
390 440
391 441
392 #endif // ifndef CCTEST_H_ 442 #endif // ifndef CCTEST_H_
OLDNEW
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698