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

Side by Side Diff: src/d8.cc

Issue 24345003: remove Isolate::GetCurrent from Context api functions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments Created 7 years, 3 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/api.cc ('k') | test/cctest/cctest.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 256 }
257 } 257 }
258 } 258 }
259 259
260 260
261 PerIsolateData::RealmScope::RealmScope(PerIsolateData* data) : data_(data) { 261 PerIsolateData::RealmScope::RealmScope(PerIsolateData* data) : data_(data) {
262 data_->realm_count_ = 1; 262 data_->realm_count_ = 1;
263 data_->realm_current_ = 0; 263 data_->realm_current_ = 0;
264 data_->realm_switch_ = 0; 264 data_->realm_switch_ = 0;
265 data_->realms_ = new Persistent<Context>[1]; 265 data_->realms_ = new Persistent<Context>[1];
266 data_->realms_[0].Reset(data_->isolate_, Context::GetEntered()); 266 data_->realms_[0].Reset(data_->isolate_,
267 data_->isolate_->GetEnteredContext());
267 data_->realm_shared_.Clear(); 268 data_->realm_shared_.Clear();
268 } 269 }
269 270
270 271
271 PerIsolateData::RealmScope::~RealmScope() { 272 PerIsolateData::RealmScope::~RealmScope() {
272 // Drop realms to avoid keeping them alive. 273 // Drop realms to avoid keeping them alive.
273 for (int i = 0; i < data_->realm_count_; ++i) 274 for (int i = 0; i < data_->realm_count_; ++i)
274 data_->realms_[i].Dispose(); 275 data_->realms_[i].Dispose();
275 delete[] data_->realms_; 276 delete[] data_->realms_;
276 if (!data_->realm_shared_.IsEmpty()) 277 if (!data_->realm_shared_.IsEmpty())
277 data_->realm_shared_.Dispose(); 278 data_->realm_shared_.Dispose();
278 } 279 }
279 280
280 281
281 int PerIsolateData::RealmFind(Handle<Context> context) { 282 int PerIsolateData::RealmFind(Handle<Context> context) {
282 for (int i = 0; i < realm_count_; ++i) { 283 for (int i = 0; i < realm_count_; ++i) {
283 if (realms_[i] == context) return i; 284 if (realms_[i] == context) return i;
284 } 285 }
285 return -1; 286 return -1;
286 } 287 }
287 288
288 289
289 // Realm.current() returns the index of the currently active realm. 290 // Realm.current() returns the index of the currently active realm.
290 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { 291 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) {
291 Isolate* isolate = args.GetIsolate(); 292 Isolate* isolate = args.GetIsolate();
292 PerIsolateData* data = PerIsolateData::Get(isolate); 293 PerIsolateData* data = PerIsolateData::Get(isolate);
293 int index = data->RealmFind(Context::GetEntered()); 294 int index = data->RealmFind(isolate->GetEnteredContext());
294 if (index == -1) return; 295 if (index == -1) return;
295 args.GetReturnValue().Set(index); 296 args.GetReturnValue().Set(index);
296 } 297 }
297 298
298 299
299 // Realm.owner(o) returns the index of the realm that created o. 300 // Realm.owner(o) returns the index of the realm that created o.
300 void Shell::RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args) { 301 void Shell::RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args) {
301 Isolate* isolate = args.GetIsolate(); 302 Isolate* isolate = args.GetIsolate();
302 PerIsolateData* data = PerIsolateData::Get(isolate); 303 PerIsolateData* data = PerIsolateData::Get(isolate);
303 if (args.Length() < 1 || !args[0]->IsObject()) { 304 if (args.Length() < 1 || !args[0]->IsObject()) {
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 } 1726 }
1726 1727
1727 } // namespace v8 1728 } // namespace v8
1728 1729
1729 1730
1730 #ifndef GOOGLE3 1731 #ifndef GOOGLE3
1731 int main(int argc, char* argv[]) { 1732 int main(int argc, char* argv[]) {
1732 return v8::Shell::Main(argc, argv); 1733 return v8::Shell::Main(argc, argv);
1733 } 1734 }
1734 #endif 1735 #endif
OLDNEW
« no previous file with comments | « src/api.cc ('k') | test/cctest/cctest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698