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

Side by Side Diff: src/api.cc

Issue 101733002: Fixed global object leak (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: spacing Created 7 years 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 | « include/v8.h ('k') | src/bootstrapper.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 5392 matching lines...) Expand 10 before | Expand all | Expand 10 after
5403 v8::Local<v8::Context> Context::GetCalling() { 5403 v8::Local<v8::Context> Context::GetCalling() {
5404 i::Isolate* isolate = i::Isolate::Current(); 5404 i::Isolate* isolate = i::Isolate::Current();
5405 return reinterpret_cast<Isolate*>(isolate)->GetCallingContext(); 5405 return reinterpret_cast<Isolate*>(isolate)->GetCallingContext();
5406 } 5406 }
5407 5407
5408 5408
5409 v8::Local<v8::Object> Context::Global() { 5409 v8::Local<v8::Object> Context::Global() {
5410 i::Handle<i::Context> context = Utils::OpenHandle(this); 5410 i::Handle<i::Context> context = Utils::OpenHandle(this);
5411 i::Isolate* isolate = context->GetIsolate(); 5411 i::Isolate* isolate = context->GetIsolate();
5412 i::Handle<i::Object> global(context->global_proxy(), isolate); 5412 i::Handle<i::Object> global(context->global_proxy(), isolate);
5413 // TODO(dcarney): This should always return the global proxy
5414 // but can't presently as calls to GetProtoype will return the wrong result.
5415 if (i::Handle<i::JSGlobalProxy>::cast(
5416 global)->IsDetachedFrom(context->global_object())) {
5417 global = i::Handle<i::Object>(context->global_object(), isolate);
haraken 2016/05/18 05:58:32 It looks like that this is doing something dangero
Toon Verwaest 2016/05/30 21:34:12 Yes. We should never leak the naked global object
5418 }
5413 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); 5419 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global));
5414 } 5420 }
5415 5421
5416 5422
5417 void Context::DetachGlobal() { 5423 void Context::DetachGlobal() {
5418 i::Handle<i::Context> context = Utils::OpenHandle(this); 5424 i::Handle<i::Context> context = Utils::OpenHandle(this);
5419 i::Isolate* isolate = context->GetIsolate(); 5425 i::Isolate* isolate = context->GetIsolate();
5420 ENTER_V8(isolate); 5426 ENTER_V8(isolate);
5421 isolate->bootstrapper()->DetachGlobal(context); 5427 isolate->bootstrapper()->DetachGlobal(context);
5422 } 5428 }
5423 5429
5424 5430
5425 void Context::ReattachGlobal(Handle<Object> global_object) {
5426 i::Handle<i::Context> context = Utils::OpenHandle(this);
5427 i::Isolate* isolate = context->GetIsolate();
5428 ENTER_V8(isolate);
5429 i::Handle<i::JSGlobalProxy> global_proxy =
5430 i::Handle<i::JSGlobalProxy>::cast(Utils::OpenHandle(*global_object));
5431 isolate->bootstrapper()->ReattachGlobal(context, global_proxy);
5432 }
5433
5434
5435 void Context::AllowCodeGenerationFromStrings(bool allow) { 5431 void Context::AllowCodeGenerationFromStrings(bool allow) {
5436 i::Handle<i::Context> context = Utils::OpenHandle(this); 5432 i::Handle<i::Context> context = Utils::OpenHandle(this);
5437 i::Isolate* isolate = context->GetIsolate(); 5433 i::Isolate* isolate = context->GetIsolate();
5438 ENTER_V8(isolate); 5434 ENTER_V8(isolate);
5439 context->set_allow_code_gen_from_strings( 5435 context->set_allow_code_gen_from_strings(
5440 allow ? isolate->heap()->true_value() : isolate->heap()->false_value()); 5436 allow ? isolate->heap()->true_value() : isolate->heap()->false_value());
5441 } 5437 }
5442 5438
5443 5439
5444 bool Context::IsCodeGenerationFromStringsAllowed() { 5440 bool Context::IsCodeGenerationFromStringsAllowed() {
(...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after
7780 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7776 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7781 Address callback_address = 7777 Address callback_address =
7782 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7778 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7783 VMState<EXTERNAL> state(isolate); 7779 VMState<EXTERNAL> state(isolate);
7784 ExternalCallbackScope call_scope(isolate, callback_address); 7780 ExternalCallbackScope call_scope(isolate, callback_address);
7785 callback(info); 7781 callback(info);
7786 } 7782 }
7787 7783
7788 7784
7789 } } // namespace v8::internal 7785 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698