OLD | NEW |
---|---|
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 Loading... | |
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 4982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5035 // Obscure semantics for undefined, but somehow checked in our unit tests... | 5038 // Obscure semantics for undefined, but somehow checked in our unit tests... |
5036 if (obj->IsUndefined()) return NULL; | 5039 if (obj->IsUndefined()) return NULL; |
5037 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); | 5040 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); |
5038 return i::Foreign::cast(foreign)->foreign_address(); | 5041 return i::Foreign::cast(foreign)->foreign_address(); |
5039 } | 5042 } |
5040 | 5043 |
5041 | 5044 |
5042 // --- E n v i r o n m e n t --- | 5045 // --- E n v i r o n m e n t --- |
5043 | 5046 |
5044 | 5047 |
5048 namespace { | |
5049 | |
5050 Platform* g_platform = NULL; | |
5051 | |
5052 } // namespace | |
5053 | |
5054 | |
5055 void Platform::Initialize(Platform* platform) { | |
5056 #ifdef V8_USE_DEFAULT_PLATFORM | |
5057 FATAL("Can't override v8::Platform when using default implementation"); | |
5058 #else | |
5059 ASSERT(!g_platform); | |
5060 g_platform = platform; | |
5061 #endif | |
5062 } | |
5063 | |
5064 | |
5065 void Platform::Shutdown() { | |
5066 #ifdef V8_USE_DEFAULT_PLATFORM | |
5067 FATAL("Can't override v8::Platform when using default implementation"); | |
5068 #else | |
5069 ASSERT(g_platform); | |
5070 g_platform = NULL; | |
5071 #endif | |
5072 } | |
5073 | |
5074 | |
5075 Platform* Platform::GetCurrent() { | |
5076 ASSERT(g_platform); | |
5077 return g_platform; | |
5078 } | |
5079 | |
5080 | |
5045 bool v8::V8::Initialize() { | 5081 bool v8::V8::Initialize() { |
5046 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 5082 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
5047 if (isolate != NULL && isolate->IsInitialized()) { | 5083 if (isolate != NULL && isolate->IsInitialized()) { |
5048 return true; | 5084 return true; |
5049 } | 5085 } |
5086 #ifdef V8_USE_DEFAULT_PLATFORM | |
5087 g_platform = new i::DefaultPlatform; | |
Benedikt Meurer
2013/11/18 15:34:44
I think platform initialization should be first in
jochen (gone - plz use gerrit)
2013/11/18 16:27:56
Done (except for the default magic)
| |
5088 #endif | |
5050 return InitializeHelper(isolate); | 5089 return InitializeHelper(isolate); |
5051 } | 5090 } |
5052 | 5091 |
5053 | 5092 |
5054 void v8::V8::SetEntropySource(EntropySource entropy_source) { | 5093 void v8::V8::SetEntropySource(EntropySource entropy_source) { |
5055 i::RandomNumberGenerator::SetEntropySource(entropy_source); | 5094 i::RandomNumberGenerator::SetEntropySource(entropy_source); |
5056 } | 5095 } |
5057 | 5096 |
5058 | 5097 |
5059 void v8::V8::SetReturnAddressLocationResolver( | 5098 void v8::V8::SetReturnAddressLocationResolver( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5104 | 5143 |
5105 | 5144 |
5106 bool v8::V8::Dispose() { | 5145 bool v8::V8::Dispose() { |
5107 i::Isolate* isolate = i::Isolate::Current(); | 5146 i::Isolate* isolate = i::Isolate::Current(); |
5108 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), | 5147 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), |
5109 "v8::V8::Dispose()", | 5148 "v8::V8::Dispose()", |
5110 "Use v8::Isolate::Dispose() for a non-default isolate.")) { | 5149 "Use v8::Isolate::Dispose() for a non-default isolate.")) { |
5111 return false; | 5150 return false; |
5112 } | 5151 } |
5113 i::V8::TearDown(); | 5152 i::V8::TearDown(); |
5153 #ifdef V8_USE_DEFAULT_PLATFORM | |
5154 i::DefaultPlatform* platform = static_cast<i::DefaultPlatform*>(g_platform); | |
5155 g_platform = NULL; | |
5156 delete platform; | |
5157 #endif | |
5114 return true; | 5158 return true; |
5115 } | 5159 } |
5116 | 5160 |
5117 | 5161 |
5118 HeapStatistics::HeapStatistics(): total_heap_size_(0), | 5162 HeapStatistics::HeapStatistics(): total_heap_size_(0), |
5119 total_heap_size_executable_(0), | 5163 total_heap_size_executable_(0), |
5120 total_physical_size_(0), | 5164 total_physical_size_(0), |
5121 used_heap_size_(0), | 5165 used_heap_size_(0), |
5122 heap_size_limit_(0) { } | 5166 heap_size_limit_(0) { } |
5123 | 5167 |
(...skipping 2533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7657 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7701 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7658 Address callback_address = | 7702 Address callback_address = |
7659 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7703 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7660 VMState<EXTERNAL> state(isolate); | 7704 VMState<EXTERNAL> state(isolate); |
7661 ExternalCallbackScope call_scope(isolate, callback_address); | 7705 ExternalCallbackScope call_scope(isolate, callback_address); |
7662 callback(info); | 7706 callback(info); |
7663 } | 7707 } |
7664 | 7708 |
7665 | 7709 |
7666 } } // namespace v8::internal | 7710 } } // namespace v8::internal |
OLD | NEW |