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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 const char* name_; | 200 const char* name_; |
201 }; | 201 }; |
202 | 202 |
203 namespace v8 { | 203 namespace v8 { |
204 // A LocalContext holds a reference to a v8::Context. | 204 // A LocalContext holds a reference to a v8::Context. |
205 class LocalContext { | 205 class LocalContext { |
206 public: | 206 public: |
207 LocalContext(v8::ExtensionConfiguration* extensions = 0, | 207 LocalContext(v8::ExtensionConfiguration* extensions = 0, |
208 v8::Handle<v8::ObjectTemplate> global_template = | 208 v8::Handle<v8::ObjectTemplate> global_template = |
209 v8::Handle<v8::ObjectTemplate>(), | 209 v8::Handle<v8::ObjectTemplate>(), |
210 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) | 210 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) { |
211 : context_(v8::Context::New(extensions, global_template, global_object)) { | 211 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 212 HandleScope scope(isolate); |
| 213 context_.Reset(isolate, |
| 214 Context::New(isolate, |
| 215 extensions, |
| 216 global_template, |
| 217 global_object)); |
212 context_->Enter(); | 218 context_->Enter(); |
213 // We can't do this later perhaps because of a fatal error. | 219 // We can't do this later perhaps because of a fatal error. |
214 isolate_ = context_->GetIsolate(); | 220 isolate_ = context_->GetIsolate(); |
215 } | 221 } |
216 | 222 |
217 virtual ~LocalContext() { | 223 virtual ~LocalContext() { |
218 context_->Exit(); | 224 context_->Exit(); |
219 context_.Dispose(isolate_); | 225 context_.Dispose(isolate_); |
220 } | 226 } |
221 | 227 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { | 294 static inline void SimulateFullSpace(v8::internal::PagedSpace* space) { |
289 int old_linear_size = static_cast<int>(space->limit() - space->top()); | 295 int old_linear_size = static_cast<int>(space->limit() - space->top()); |
290 space->Free(space->top(), old_linear_size); | 296 space->Free(space->top(), old_linear_size); |
291 space->SetTop(space->limit(), space->limit()); | 297 space->SetTop(space->limit(), space->limit()); |
292 space->ResetFreeList(); | 298 space->ResetFreeList(); |
293 space->ClearStats(); | 299 space->ClearStats(); |
294 } | 300 } |
295 | 301 |
296 | 302 |
297 #endif // ifndef CCTEST_H_ | 303 #endif // ifndef CCTEST_H_ |
OLD | NEW |