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

Side by Side Diff: src/api.cc

Issue 13940003: Move context retrieval method around. Use delegation for implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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 | « include/v8.h ('k') | test/cctest/test-api.cc » ('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 4989 matching lines...) Expand 10 before | Expand all | Expand 10 after
5000 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); 5000 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last);
5001 return Utils::ToLocal(context); 5001 return Utils::ToLocal(context);
5002 } 5002 }
5003 5003
5004 5004
5005 v8::Local<v8::Context> Context::GetCurrent() { 5005 v8::Local<v8::Context> Context::GetCurrent() {
5006 i::Isolate* isolate = i::Isolate::Current(); 5006 i::Isolate* isolate = i::Isolate::Current();
5007 if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) { 5007 if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) {
5008 return Local<Context>(); 5008 return Local<Context>();
5009 } 5009 }
5010 i::Handle<i::Object> current = isolate->native_context(); 5010 return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext();
5011 if (current.is_null()) return Local<Context>();
5012 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current);
5013 return Utils::ToLocal(context);
5014 } 5011 }
5015 5012
5016 5013
5017 v8::Local<v8::Context> Context::GetCurrent(Isolate* exported_isolate) {
5018 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate);
5019 ASSERT(isolate == i::Isolate::Current());
5020 i::Handle<i::Object> current = isolate->native_context();
5021 if (current.is_null()) return Local<Context>();
5022 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current);
5023 return Utils::ToLocal(context);
5024 }
5025
5026
5027 v8::Local<v8::Context> Context::GetCalling() { 5014 v8::Local<v8::Context> Context::GetCalling() {
5028 i::Isolate* isolate = i::Isolate::Current(); 5015 i::Isolate* isolate = i::Isolate::Current();
5029 if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) { 5016 if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) {
5030 return Local<Context>(); 5017 return Local<Context>();
5031 } 5018 }
5032 i::Handle<i::Object> calling = 5019 i::Handle<i::Object> calling =
5033 isolate->GetCallingNativeContext(); 5020 isolate->GetCallingNativeContext();
5034 if (calling.is_null()) return Local<Context>(); 5021 if (calling.is_null()) return Local<Context>();
5035 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling); 5022 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling);
5036 return Utils::ToLocal(context); 5023 return Utils::ToLocal(context);
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
5818 } 5805 }
5819 5806
5820 5807
5821 CpuProfiler* Isolate::GetCpuProfiler() { 5808 CpuProfiler* Isolate::GetCpuProfiler() {
5822 i::CpuProfiler* cpu_profiler = 5809 i::CpuProfiler* cpu_profiler =
5823 reinterpret_cast<i::Isolate*>(this)->cpu_profiler(); 5810 reinterpret_cast<i::Isolate*>(this)->cpu_profiler();
5824 return reinterpret_cast<CpuProfiler*>(cpu_profiler); 5811 return reinterpret_cast<CpuProfiler*>(cpu_profiler);
5825 } 5812 }
5826 5813
5827 5814
5815 v8::Local<v8::Context> Isolate::GetCurrentContext() {
5816 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
5817 i::Handle<i::Object> current = internal_isolate->native_context();
5818 if (current.is_null()) return Local<Context>();
5819 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current);
5820 return Utils::ToLocal(context);
5821 }
5822
5823
5828 void V8::SetGlobalGCPrologueCallback(GCCallback callback) { 5824 void V8::SetGlobalGCPrologueCallback(GCCallback callback) {
5829 i::Isolate* isolate = i::Isolate::Current(); 5825 i::Isolate* isolate = i::Isolate::Current();
5830 if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCPrologueCallback()")) return; 5826 if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCPrologueCallback()")) return;
5831 isolate->heap()->SetGlobalGCPrologueCallback(callback); 5827 isolate->heap()->SetGlobalGCPrologueCallback(callback);
5832 } 5828 }
5833 5829
5834 5830
5835 void V8::SetGlobalGCEpilogueCallback(GCCallback callback) { 5831 void V8::SetGlobalGCEpilogueCallback(GCCallback callback) {
5836 i::Isolate* isolate = i::Isolate::Current(); 5832 i::Isolate* isolate = i::Isolate::Current();
5837 if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCEpilogueCallback()")) return; 5833 if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCEpilogueCallback()")) return;
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after
7225 7221
7226 v->VisitPointers(blocks_.first(), first_block_limit_); 7222 v->VisitPointers(blocks_.first(), first_block_limit_);
7227 7223
7228 for (int i = 1; i < blocks_.length(); i++) { 7224 for (int i = 1; i < blocks_.length(); i++) {
7229 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 7225 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
7230 } 7226 }
7231 } 7227 }
7232 7228
7233 7229
7234 } } // namespace v8::internal 7230 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698