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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 context->Enter(); | 282 context->Enter(); |
283 // We can't do this later perhaps because of a fatal error. | 283 // We can't do this later perhaps because of a fatal error. |
284 isolate_ = isolate; | 284 isolate_ = isolate; |
285 } | 285 } |
286 | 286 |
287 v8::Persistent<v8::Context> context_; | 287 v8::Persistent<v8::Context> context_; |
288 v8::Isolate* isolate_; | 288 v8::Isolate* isolate_; |
289 }; | 289 }; |
290 | 290 |
291 static inline v8::Local<v8::Value> v8_num(double x) { | 291 static inline v8::Local<v8::Value> v8_num(double x) { |
292 return v8::Number::New(x); | 292 return v8::Number::New(v8::Isolate::GetCurrent(), x); |
293 } | 293 } |
294 | 294 |
295 | 295 |
296 static inline v8::Local<v8::String> v8_str(const char* x) { | 296 static inline v8::Local<v8::String> v8_str(const char* x) { |
297 return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), x); | 297 return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), x); |
298 } | 298 } |
299 | 299 |
300 | 300 |
301 static inline v8::Local<v8::Script> v8_compile(const char* x) { | 301 static inline v8::Local<v8::Script> v8_compile(const char* x) { |
302 return v8::Script::Compile(v8_str(x)); | 302 return v8::Script::Compile(v8_str(x)); |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 // Helper function that compiles and runs the source. | 306 // Helper function that compiles and runs the source. |
307 static inline v8::Local<v8::Value> CompileRun(const char* source) { | 307 static inline v8::Local<v8::Value> CompileRun(const char* source) { |
308 return v8::Script::Compile( | 308 return v8::Script::Compile( |
309 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run(); | 309 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run(); |
310 } | 310 } |
311 | 311 |
312 | 312 |
313 // Helper function that compiles and runs the source with given origin. | 313 // Helper function that compiles and runs the source with given origin. |
314 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, | 314 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, |
315 const char* origin_url, | 315 const char* origin_url, |
316 int line_number, | 316 int line_number, |
317 int column_number) { | 317 int column_number) { |
318 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 318 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
319 v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, origin_url), | 319 v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, origin_url), |
320 v8::Integer::New(line_number), | 320 v8::Integer::New(isolate, line_number), |
321 v8::Integer::New(column_number)); | 321 v8::Integer::New(isolate, column_number)); |
322 return v8::Script::Compile(v8::String::NewFromUtf8(isolate, source), &origin) | 322 return v8::Script::Compile(v8::String::NewFromUtf8(isolate, source), &origin) |
323 ->Run(); | 323 ->Run(); |
324 } | 324 } |
325 | 325 |
326 | 326 |
327 // Pick a slightly different port to allow tests to be run in parallel. | 327 // Pick a slightly different port to allow tests to be run in parallel. |
328 static inline int FlagDependentPortOffset() { | 328 static inline int FlagDependentPortOffset() { |
329 return ::v8::internal::FLAG_crankshaft == false ? 100 : | 329 return ::v8::internal::FLAG_crankshaft == false ? 100 : |
330 ::v8::internal::FLAG_always_opt ? 200 : 0; | 330 ::v8::internal::FLAG_always_opt ? 200 : 0; |
331 } | 331 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); | 366 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); |
367 heap_profiler_->StopHeapObjectsTracking(); | 367 heap_profiler_->StopHeapObjectsTracking(); |
368 } | 368 } |
369 | 369 |
370 private: | 370 private: |
371 i::HeapProfiler* heap_profiler_; | 371 i::HeapProfiler* heap_profiler_; |
372 }; | 372 }; |
373 | 373 |
374 | 374 |
375 #endif // ifndef CCTEST_H_ | 375 #endif // ifndef CCTEST_H_ |
OLD | NEW |