| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 static inline v8::Local<v8::Value> CompileRun(const char* source) { | 312 return v8::Script::Compile(x); |
| 313 return v8::Script::Compile( | |
| 314 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run(); | |
| 315 } | 313 } |
| 316 | 314 |
| 317 | 315 |
| 316 static inline v8::Local<v8::Script> CompileWithOrigin(const char* source, |
| 317 const char* origin_url) { |
| 318 v8::ScriptOrigin origin(v8_str(origin_url)); |
| 319 return v8::Script::Compile(v8_str(source), &origin); |
| 320 } |
| 321 |
| 322 |
| 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. |
| 331 static inline v8::Local<v8::Value> CompileRun(const char* source) { |
| 332 return v8::Script::Compile(v8_str(source))->Run(); |
| 333 } |
| 334 |
| 335 |
| 336 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) { |
| 337 return v8::Script::Compile(source)->Run(); |
| 338 } |
| 339 |
| 340 |
| 318 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) { | 341 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) { |
| 319 v8::Local<v8::String> script_source = | 342 v8::Local<v8::String> script_source = |
| 320 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source); | 343 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source); |
| 321 v8::ScriptData* preparse = v8::ScriptData::PreCompile(script_source); | 344 v8::ScriptData* preparse = v8::ScriptData::PreCompile(script_source); |
| 322 v8::Local<v8::Script> script = | 345 v8::Local<v8::Script> script = |
| 323 v8::Script::Compile(script_source, NULL, preparse); | 346 v8::Script::Compile(script_source, NULL, preparse); |
| 324 v8::Local<v8::Value> result = script->Run(); | 347 v8::Local<v8::Value> result = script->Run(); |
| 325 delete preparse; | 348 delete preparse; |
| 326 return result; | 349 return result; |
| 327 } | 350 } |
| 328 | 351 |
| 329 | 352 |
| 330 // Helper function that compiles and runs the source with given origin. | 353 // Helper functions that compile and run the source with given origin. |
| 331 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, | 354 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, |
| 332 const char* origin_url, | 355 const char* origin_url, |
| 333 int line_number, | 356 int line_number, |
| 334 int column_number) { | 357 int column_number) { |
| 335 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 358 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 336 v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, origin_url), | 359 v8::ScriptOrigin origin(v8_str(origin_url), |
| 337 v8::Integer::New(isolate, line_number), | 360 v8::Integer::New(isolate, line_number), |
| 338 v8::Integer::New(isolate, column_number)); | 361 v8::Integer::New(isolate, column_number)); |
| 339 return v8::Script::Compile(v8::String::NewFromUtf8(isolate, source), &origin) | 362 return v8::Script::Compile(v8_str(source), &origin)->Run(); |
| 340 ->Run(); | |
| 341 } | 363 } |
| 342 | 364 |
| 343 | 365 |
| 366 static inline v8::Local<v8::Value> CompileRunWithOrigin( |
| 367 const char* source, const char* origin_url) { |
| 368 v8::ScriptOrigin origin(v8_str(origin_url)); |
| 369 return v8::Script::Compile(v8_str(source), &origin)->Run(); |
| 370 } |
| 371 |
| 372 |
| 344 // 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. |
| 345 static inline int FlagDependentPortOffset() { | 374 static inline int FlagDependentPortOffset() { |
| 346 return ::v8::internal::FLAG_crankshaft == false ? 100 : | 375 return ::v8::internal::FLAG_crankshaft == false ? 100 : |
| 347 ::v8::internal::FLAG_always_opt ? 200 : 0; | 376 ::v8::internal::FLAG_always_opt ? 200 : 0; |
| 348 } | 377 } |
| 349 | 378 |
| 350 | 379 |
| 351 // Helper function that simulates a full new-space in the heap. | 380 // Helper function that simulates a full new-space in the heap. |
| 352 static inline void SimulateFullSpace(v8::internal::NewSpace* space) { | 381 static inline void SimulateFullSpace(v8::internal::NewSpace* space) { |
| 353 int new_linear_size = static_cast<int>( | 382 int new_linear_size = static_cast<int>( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 383 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); | 412 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); |
| 384 heap_profiler_->StopHeapObjectsTracking(); | 413 heap_profiler_->StopHeapObjectsTracking(); |
| 385 } | 414 } |
| 386 | 415 |
| 387 private: | 416 private: |
| 388 i::HeapProfiler* heap_profiler_; | 417 i::HeapProfiler* heap_profiler_; |
| 389 }; | 418 }; |
| 390 | 419 |
| 391 | 420 |
| 392 #endif // ifndef CCTEST_H_ | 421 #endif // ifndef CCTEST_H_ |
| OLD | NEW |