OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 // Defined when linking against shared lib on Windows. | 6 // Defined when linking against shared lib on Windows. |
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) | 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) |
8 #define V8_SHARED | 8 #define V8_SHARED |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 #endif // V8_SHARED | 30 #endif // V8_SHARED |
31 | 31 |
32 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 32 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
33 #include "src/third_party/vtune/v8-vtune.h" | 33 #include "src/third_party/vtune/v8-vtune.h" |
34 #endif | 34 #endif |
35 | 35 |
36 #include "src/d8.h" | 36 #include "src/d8.h" |
37 | 37 |
38 #ifndef V8_SHARED | 38 #ifndef V8_SHARED |
39 #include "src/api.h" | 39 #include "src/api.h" |
40 #include "src/checks.h" | 40 #include "src/base/cpu.h" |
41 #include "src/cpu.h" | 41 #include "src/base/logging.h" |
| 42 #include "src/base/platform/platform.h" |
42 #include "src/d8-debug.h" | 43 #include "src/d8-debug.h" |
43 #include "src/debug.h" | 44 #include "src/debug.h" |
44 #include "src/natives.h" | 45 #include "src/natives.h" |
45 #include "src/platform.h" | |
46 #include "src/v8.h" | 46 #include "src/v8.h" |
47 #endif // !V8_SHARED | 47 #endif // !V8_SHARED |
48 | 48 |
49 #if !defined(_WIN32) && !defined(_WIN64) | 49 #if !defined(_WIN32) && !defined(_WIN64) |
50 #include <unistd.h> // NOLINT | 50 #include <unistd.h> // NOLINT |
51 #endif | 51 #endif |
52 | 52 |
53 #ifndef ASSERT | 53 #ifndef ASSERT |
54 #define ASSERT(condition) assert(condition) | 54 #define ASSERT(condition) assert(condition) |
55 #endif | 55 #endif |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Native Client libc is used to being embedded in Chrome and | 127 // Native Client libc is used to being embedded in Chrome and |
128 // has trouble recognizing when to flush. | 128 // has trouble recognizing when to flush. |
129 fflush(stdout); | 129 fflush(stdout); |
130 #endif | 130 #endif |
131 return Shell::ReadFromStdin(isolate_); | 131 return Shell::ReadFromStdin(isolate_); |
132 } | 132 } |
133 | 133 |
134 | 134 |
135 #ifndef V8_SHARED | 135 #ifndef V8_SHARED |
136 CounterMap* Shell::counter_map_; | 136 CounterMap* Shell::counter_map_; |
137 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; | 137 base::OS::MemoryMappedFile* Shell::counters_file_ = NULL; |
138 CounterCollection Shell::local_counters_; | 138 CounterCollection Shell::local_counters_; |
139 CounterCollection* Shell::counters_ = &local_counters_; | 139 CounterCollection* Shell::counters_ = &local_counters_; |
140 i::Mutex Shell::context_mutex_; | 140 base::Mutex Shell::context_mutex_; |
141 const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow(); | 141 const base::TimeTicks Shell::kInitialTicks = |
| 142 base::TimeTicks::HighResolutionNow(); |
142 Persistent<Context> Shell::utility_context_; | 143 Persistent<Context> Shell::utility_context_; |
143 #endif // !V8_SHARED | 144 #endif // !V8_SHARED |
144 | 145 |
145 Persistent<Context> Shell::evaluation_context_; | 146 Persistent<Context> Shell::evaluation_context_; |
146 ShellOptions Shell::options; | 147 ShellOptions Shell::options; |
147 const char* Shell::kPrompt = "d8> "; | 148 const char* Shell::kPrompt = "d8> "; |
148 | 149 |
149 | 150 |
150 #ifndef V8_SHARED | 151 #ifndef V8_SHARED |
151 const int MB = 1024 * 1024; | 152 const int MB = 1024 * 1024; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // performance.now() returns a time stamp as double, measured in milliseconds. | 293 // performance.now() returns a time stamp as double, measured in milliseconds. |
293 // When FLAG_verify_predictable mode is enabled it returns current value | 294 // When FLAG_verify_predictable mode is enabled it returns current value |
294 // of Heap::allocations_count(). | 295 // of Heap::allocations_count(). |
295 void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) { | 296 void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) { |
296 if (i::FLAG_verify_predictable) { | 297 if (i::FLAG_verify_predictable) { |
297 Isolate* v8_isolate = args.GetIsolate(); | 298 Isolate* v8_isolate = args.GetIsolate(); |
298 i::Heap* heap = reinterpret_cast<i::Isolate*>(v8_isolate)->heap(); | 299 i::Heap* heap = reinterpret_cast<i::Isolate*>(v8_isolate)->heap(); |
299 args.GetReturnValue().Set(heap->synthetic_time()); | 300 args.GetReturnValue().Set(heap->synthetic_time()); |
300 | 301 |
301 } else { | 302 } else { |
302 i::TimeDelta delta = i::TimeTicks::HighResolutionNow() - kInitialTicks; | 303 base::TimeDelta delta = |
| 304 base::TimeTicks::HighResolutionNow() - kInitialTicks; |
303 args.GetReturnValue().Set(delta.InMillisecondsF()); | 305 args.GetReturnValue().Set(delta.InMillisecondsF()); |
304 } | 306 } |
305 } | 307 } |
306 #endif // !V8_SHARED | 308 #endif // !V8_SHARED |
307 | 309 |
308 | 310 |
309 // Realm.current() returns the index of the currently active realm. | 311 // Realm.current() returns the index of the currently active realm. |
310 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { | 312 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { |
311 Isolate* isolate = args.GetIsolate(); | 313 Isolate* isolate = args.GetIsolate(); |
312 PerIsolateData* data = PerIsolateData::Get(isolate); | 314 PerIsolateData* data = PerIsolateData::Get(isolate); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 } | 670 } |
669 | 671 |
670 | 672 |
671 Counter* CounterCollection::GetNextCounter() { | 673 Counter* CounterCollection::GetNextCounter() { |
672 if (counters_in_use_ == kMaxCounters) return NULL; | 674 if (counters_in_use_ == kMaxCounters) return NULL; |
673 return &counters_[counters_in_use_++]; | 675 return &counters_[counters_in_use_++]; |
674 } | 676 } |
675 | 677 |
676 | 678 |
677 void Shell::MapCounters(const char* name) { | 679 void Shell::MapCounters(const char* name) { |
678 counters_file_ = i::OS::MemoryMappedFile::create( | 680 counters_file_ = base::OS::MemoryMappedFile::create( |
679 name, sizeof(CounterCollection), &local_counters_); | 681 name, sizeof(CounterCollection), &local_counters_); |
680 void* memory = (counters_file_ == NULL) ? | 682 void* memory = (counters_file_ == NULL) ? |
681 NULL : counters_file_->memory(); | 683 NULL : counters_file_->memory(); |
682 if (memory == NULL) { | 684 if (memory == NULL) { |
683 printf("Could not map counters file %s\n", name); | 685 printf("Could not map counters file %s\n", name); |
684 Exit(1); | 686 Exit(1); |
685 } | 687 } |
686 counters_ = static_cast<CounterCollection*>(memory); | 688 counters_ = static_cast<CounterCollection*>(memory); |
687 V8::SetCounterFunction(LookupCounter); | 689 V8::SetCounterFunction(LookupCounter); |
688 V8::SetCreateHistogramFunction(CreateHistogram); | 690 V8::SetCreateHistogramFunction(CreateHistogram); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); | 913 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); |
912 utility_context_.Reset(isolate, | 914 utility_context_.Reset(isolate, |
913 Context::New(isolate, NULL, global_template)); | 915 Context::New(isolate, NULL, global_template)); |
914 #endif // !V8_SHARED | 916 #endif // !V8_SHARED |
915 } | 917 } |
916 | 918 |
917 | 919 |
918 Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { | 920 Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { |
919 #ifndef V8_SHARED | 921 #ifndef V8_SHARED |
920 // This needs to be a critical section since this is not thread-safe | 922 // This needs to be a critical section since this is not thread-safe |
921 i::LockGuard<i::Mutex> lock_guard(&context_mutex_); | 923 base::LockGuard<base::Mutex> lock_guard(&context_mutex_); |
922 #endif // !V8_SHARED | 924 #endif // !V8_SHARED |
923 // Initialize the global objects | 925 // Initialize the global objects |
924 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); | 926 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); |
925 EscapableHandleScope handle_scope(isolate); | 927 EscapableHandleScope handle_scope(isolate); |
926 Local<Context> context = Context::New(isolate, NULL, global_template); | 928 Local<Context> context = Context::New(isolate, NULL, global_template); |
927 ASSERT(!context.IsEmpty()); | 929 ASSERT(!context.IsEmpty()); |
928 Context::Scope scope(context); | 930 Context::Scope scope(context); |
929 | 931 |
930 #ifndef V8_SHARED | 932 #ifndef V8_SHARED |
931 i::Factory* factory = reinterpret_cast<i::Isolate*>(isolate)->factory(); | 933 i::Factory* factory = reinterpret_cast<i::Isolate*>(isolate)->factory(); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 char* chars = ReadChars(isolate, name, &size); | 1183 char* chars = ReadChars(isolate, name, &size); |
1182 if (chars == NULL) return Handle<String>(); | 1184 if (chars == NULL) return Handle<String>(); |
1183 Handle<String> result = | 1185 Handle<String> result = |
1184 String::NewFromUtf8(isolate, chars, String::kNormalString, size); | 1186 String::NewFromUtf8(isolate, chars, String::kNormalString, size); |
1185 delete[] chars; | 1187 delete[] chars; |
1186 return result; | 1188 return result; |
1187 } | 1189 } |
1188 | 1190 |
1189 | 1191 |
1190 #ifndef V8_SHARED | 1192 #ifndef V8_SHARED |
1191 i::Thread::Options SourceGroup::GetThreadOptions() { | 1193 base::Thread::Options SourceGroup::GetThreadOptions() { |
1192 // On some systems (OSX 10.6) the stack size default is 0.5Mb or less | 1194 // On some systems (OSX 10.6) the stack size default is 0.5Mb or less |
1193 // which is not enough to parse the big literal expressions used in tests. | 1195 // which is not enough to parse the big literal expressions used in tests. |
1194 // The stack size should be at least StackGuard::kLimitSize + some | 1196 // The stack size should be at least StackGuard::kLimitSize + some |
1195 // OS-specific padding for thread startup code. 2Mbytes seems to be enough. | 1197 // OS-specific padding for thread startup code. 2Mbytes seems to be enough. |
1196 return i::Thread::Options("IsolateThread", 2 * MB); | 1198 return base::Thread::Options("IsolateThread", 2 * MB); |
1197 } | 1199 } |
1198 | 1200 |
1199 | 1201 |
1200 void SourceGroup::ExecuteInThread() { | 1202 void SourceGroup::ExecuteInThread() { |
1201 Isolate* isolate = Isolate::New(); | 1203 Isolate* isolate = Isolate::New(); |
1202 do { | 1204 do { |
1203 next_semaphore_.Wait(); | 1205 next_semaphore_.Wait(); |
1204 { | 1206 { |
1205 Isolate::Scope iscope(isolate); | 1207 Isolate::Scope iscope(isolate); |
1206 { | 1208 { |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 MockArrayBufferAllocator mock_arraybuffer_allocator; | 1558 MockArrayBufferAllocator mock_arraybuffer_allocator; |
1557 if (options.mock_arraybuffer_allocator) { | 1559 if (options.mock_arraybuffer_allocator) { |
1558 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator); | 1560 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator); |
1559 } else { | 1561 } else { |
1560 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); | 1562 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); |
1561 } | 1563 } |
1562 int result = 0; | 1564 int result = 0; |
1563 Isolate* isolate = Isolate::New(); | 1565 Isolate* isolate = Isolate::New(); |
1564 #ifndef V8_SHARED | 1566 #ifndef V8_SHARED |
1565 v8::ResourceConstraints constraints; | 1567 v8::ResourceConstraints constraints; |
1566 constraints.ConfigureDefaults(i::OS::TotalPhysicalMemory(), | 1568 constraints.ConfigureDefaults(base::OS::TotalPhysicalMemory(), |
1567 i::OS::MaxVirtualMemory(), | 1569 base::OS::MaxVirtualMemory(), |
1568 i::OS::NumberOfProcessorsOnline()); | 1570 base::OS::NumberOfProcessorsOnline()); |
1569 v8::SetResourceConstraints(isolate, &constraints); | 1571 v8::SetResourceConstraints(isolate, &constraints); |
1570 #endif | 1572 #endif |
1571 DumbLineEditor dumb_line_editor(isolate); | 1573 DumbLineEditor dumb_line_editor(isolate); |
1572 { | 1574 { |
1573 Isolate::Scope scope(isolate); | 1575 Isolate::Scope scope(isolate); |
1574 Initialize(isolate); | 1576 Initialize(isolate); |
1575 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 1577 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
1576 vTune::InitializeVtuneForV8(); | 1578 vTune::InitializeVtuneForV8(); |
1577 #endif | 1579 #endif |
1578 PerIsolateData data(isolate); | 1580 PerIsolateData data(isolate); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 } | 1633 } |
1632 | 1634 |
1633 } // namespace v8 | 1635 } // namespace v8 |
1634 | 1636 |
1635 | 1637 |
1636 #ifndef GOOGLE3 | 1638 #ifndef GOOGLE3 |
1637 int main(int argc, char* argv[]) { | 1639 int main(int argc, char* argv[]) { |
1638 return v8::Shell::Main(argc, argv); | 1640 return v8::Shell::Main(argc, argv); |
1639 } | 1641 } |
1640 #endif | 1642 #endif |
OLD | NEW |