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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 LocalContext(v8::ExtensionConfiguration* extensions = 0, | 248 LocalContext(v8::ExtensionConfiguration* extensions = 0, |
249 v8::Handle<v8::ObjectTemplate> global_template = | 249 v8::Handle<v8::ObjectTemplate> global_template = |
250 v8::Handle<v8::ObjectTemplate>(), | 250 v8::Handle<v8::ObjectTemplate>(), |
251 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) { | 251 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) { |
252 Initialize(CcTest::isolate(), extensions, global_template, global_object); | 252 Initialize(CcTest::isolate(), extensions, global_template, global_object); |
253 } | 253 } |
254 | 254 |
255 virtual ~LocalContext() { | 255 virtual ~LocalContext() { |
256 v8::HandleScope scope(isolate_); | 256 v8::HandleScope scope(isolate_); |
257 v8::Local<v8::Context>::New(isolate_, context_)->Exit(); | 257 v8::Local<v8::Context>::New(isolate_, context_)->Exit(); |
258 context_.Dispose(); | 258 context_.Reset(); |
259 } | 259 } |
260 | 260 |
261 v8::Context* operator->() { | 261 v8::Context* operator->() { |
262 return *reinterpret_cast<v8::Context**>(&context_); | 262 return *reinterpret_cast<v8::Context**>(&context_); |
263 } | 263 } |
264 v8::Context* operator*() { return operator->(); } | 264 v8::Context* operator*() { return operator->(); } |
265 bool IsReady() { return !context_.IsEmpty(); } | 265 bool IsReady() { return !context_.IsEmpty(); } |
266 | 266 |
267 v8::Local<v8::Context> local() { | 267 v8::Local<v8::Context> local() { |
268 return v8::Local<v8::Context>::New(isolate_, context_); | 268 return v8::Local<v8::Context>::New(isolate_, context_); |
(...skipping 18 matching lines...) Expand all Loading... |
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(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::New(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(v8::String::New(source))->Run(); | 308 return v8::Script::Compile( |
| 309 v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run(); |
309 } | 310 } |
310 | 311 |
311 | 312 |
312 // Helper function that compiles and runs the source with given origin. | 313 // Helper function that compiles and runs the source with given origin. |
313 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, | 314 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, |
314 const char* origin_url, | 315 const char* origin_url, |
315 int line_number, | 316 int line_number, |
316 int column_number) { | 317 int column_number) { |
317 v8::ScriptOrigin origin(v8::String::New(origin_url), | 318 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 319 v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, origin_url), |
318 v8::Integer::New(line_number), | 320 v8::Integer::New(line_number), |
319 v8::Integer::New(column_number)); | 321 v8::Integer::New(column_number)); |
320 return v8::Script::Compile(v8::String::New(source), &origin)->Run(); | 322 return v8::Script::Compile(v8::String::NewFromUtf8(isolate, source), &origin) |
| 323 ->Run(); |
321 } | 324 } |
322 | 325 |
323 | 326 |
324 // 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. |
325 static inline int FlagDependentPortOffset() { | 328 static inline int FlagDependentPortOffset() { |
326 return ::v8::internal::FLAG_crankshaft == false ? 100 : | 329 return ::v8::internal::FLAG_crankshaft == false ? 100 : |
327 ::v8::internal::FLAG_always_opt ? 200 : 0; | 330 ::v8::internal::FLAG_always_opt ? 200 : 0; |
328 } | 331 } |
329 | 332 |
330 | 333 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 CHECK_EQ(0, heap_profiler_->FindUntrackedObjects()); | 366 CHECK_EQ(0, heap_profiler_->FindUntrackedObjects()); |
364 heap_profiler_->StopHeapAllocationsRecording(); | 367 heap_profiler_->StopHeapAllocationsRecording(); |
365 } | 368 } |
366 | 369 |
367 private: | 370 private: |
368 i::HeapProfiler* heap_profiler_; | 371 i::HeapProfiler* heap_profiler_; |
369 }; | 372 }; |
370 | 373 |
371 | 374 |
372 #endif // ifndef CCTEST_H_ | 375 #endif // ifndef CCTEST_H_ |
OLD | NEW |