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

Side by Side Diff: src/api.cc

Issue 75283002: Introduce a v8::Platform class that bundles embedder callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 7 years, 1 month 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-platform.h ('k') | src/default-platform.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 22 matching lines...) Expand all
33 #include "../include/v8-profiler.h" 33 #include "../include/v8-profiler.h"
34 #include "../include/v8-testing.h" 34 #include "../include/v8-testing.h"
35 #include "assert-scope.h" 35 #include "assert-scope.h"
36 #include "bootstrapper.h" 36 #include "bootstrapper.h"
37 #include "code-stubs.h" 37 #include "code-stubs.h"
38 #include "compiler.h" 38 #include "compiler.h"
39 #include "conversions-inl.h" 39 #include "conversions-inl.h"
40 #include "counters.h" 40 #include "counters.h"
41 #include "cpu-profiler.h" 41 #include "cpu-profiler.h"
42 #include "debug.h" 42 #include "debug.h"
43 #ifdef V8_USE_DEFAULT_PLATFORM
44 #include "default-platform.h"
45 #endif
43 #include "deoptimizer.h" 46 #include "deoptimizer.h"
44 #include "execution.h" 47 #include "execution.h"
45 #include "global-handles.h" 48 #include "global-handles.h"
46 #include "heap-profiler.h" 49 #include "heap-profiler.h"
47 #include "heap-snapshot-generator-inl.h" 50 #include "heap-snapshot-generator-inl.h"
48 #include "icu_util.h" 51 #include "icu_util.h"
49 #include "json-parser.h" 52 #include "json-parser.h"
50 #include "messages.h" 53 #include "messages.h"
51 #ifdef COMPRESS_STARTUP_DATA_BZ2 54 #ifdef COMPRESS_STARTUP_DATA_BZ2
52 #include "natives.h" 55 #include "natives.h"
(...skipping 4987 matching lines...) Expand 10 before | Expand all | Expand 10 after
5040 // Obscure semantics for undefined, but somehow checked in our unit tests... 5043 // Obscure semantics for undefined, but somehow checked in our unit tests...
5041 if (obj->IsUndefined()) return NULL; 5044 if (obj->IsUndefined()) return NULL;
5042 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); 5045 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0);
5043 return i::Foreign::cast(foreign)->foreign_address(); 5046 return i::Foreign::cast(foreign)->foreign_address();
5044 } 5047 }
5045 5048
5046 5049
5047 // --- E n v i r o n m e n t --- 5050 // --- E n v i r o n m e n t ---
5048 5051
5049 5052
5053 void v8::V8::InitializePlatform(Platform* platform) {
5054 #ifdef V8_USE_DEFAULT_PLATFORM
5055 FATAL("Can't override v8::Platform when using default implementation");
5056 #else
5057 i::V8::InitializePlatform(platform);
5058 #endif
5059 }
5060
5061
5062 void v8::V8::ShutdownPlatform() {
5063 #ifdef V8_USE_DEFAULT_PLATFORM
5064 FATAL("Can't override v8::Platform when using default implementation");
5065 #else
5066 i::V8::ShutdownPlatform();
5067 #endif
5068 }
5069
5070
5050 bool v8::V8::Initialize() { 5071 bool v8::V8::Initialize() {
5051 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 5072 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
5052 if (isolate != NULL && isolate->IsInitialized()) { 5073 if (isolate != NULL && isolate->IsInitialized()) {
5053 return true; 5074 return true;
5054 } 5075 }
5076 #ifdef V8_USE_DEFAULT_PLATFORM
5077 i::V8::InitializePlatform(new i::DefaultPlatform);
5078 #endif
5055 return InitializeHelper(isolate); 5079 return InitializeHelper(isolate);
5056 } 5080 }
5057 5081
5058 5082
5059 void v8::V8::SetEntropySource(EntropySource entropy_source) { 5083 void v8::V8::SetEntropySource(EntropySource entropy_source) {
5060 i::RandomNumberGenerator::SetEntropySource(entropy_source); 5084 i::RandomNumberGenerator::SetEntropySource(entropy_source);
5061 } 5085 }
5062 5086
5063 5087
5064 void v8::V8::SetReturnAddressLocationResolver( 5088 void v8::V8::SetReturnAddressLocationResolver(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5109 5133
5110 5134
5111 bool v8::V8::Dispose() { 5135 bool v8::V8::Dispose() {
5112 i::Isolate* isolate = i::Isolate::Current(); 5136 i::Isolate* isolate = i::Isolate::Current();
5113 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), 5137 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(),
5114 "v8::V8::Dispose()", 5138 "v8::V8::Dispose()",
5115 "Use v8::Isolate::Dispose() for a non-default isolate.")) { 5139 "Use v8::Isolate::Dispose() for a non-default isolate.")) {
5116 return false; 5140 return false;
5117 } 5141 }
5118 i::V8::TearDown(); 5142 i::V8::TearDown();
5143 #ifdef V8_USE_DEFAULT_PLATFORM
5144 i::DefaultPlatform* platform =
5145 static_cast<i::DefaultPlatform*>(i::V8::GetCurrentPlatform());
5146 i::V8::ShutdownPlatform();
5147 delete platform;
5148 #endif
5119 return true; 5149 return true;
5120 } 5150 }
5121 5151
5122 5152
5123 HeapStatistics::HeapStatistics(): total_heap_size_(0), 5153 HeapStatistics::HeapStatistics(): total_heap_size_(0),
5124 total_heap_size_executable_(0), 5154 total_heap_size_executable_(0),
5125 total_physical_size_(0), 5155 total_physical_size_(0),
5126 used_heap_size_(0), 5156 used_heap_size_(0),
5127 heap_size_limit_(0) { } 5157 heap_size_limit_(0) { }
5128 5158
(...skipping 2533 matching lines...) Expand 10 before | Expand all | Expand 10 after
7662 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7692 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7663 Address callback_address = 7693 Address callback_address =
7664 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7694 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7665 VMState<EXTERNAL> state(isolate); 7695 VMState<EXTERNAL> state(isolate);
7666 ExternalCallbackScope call_scope(isolate, callback_address); 7696 ExternalCallbackScope call_scope(isolate, callback_address);
7667 callback(info); 7697 callback(info);
7668 } 7698 }
7669 7699
7670 7700
7671 } } // namespace v8::internal 7701 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8-platform.h ('k') | src/default-platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698