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

Side by Side Diff: src/bootstrapper.cc

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: 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 | « src/ast.cc ('k') | src/builtins.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 24 matching lines...) Expand all
35 #include "execution.h" 35 #include "execution.h"
36 #include "global-handles.h" 36 #include "global-handles.h"
37 #include "isolate-inl.h" 37 #include "isolate-inl.h"
38 #include "macro-assembler.h" 38 #include "macro-assembler.h"
39 #include "natives.h" 39 #include "natives.h"
40 #include "objects-visiting.h" 40 #include "objects-visiting.h"
41 #include "platform.h" 41 #include "platform.h"
42 #include "snapshot.h" 42 #include "snapshot.h"
43 #include "trig-table.h" 43 #include "trig-table.h"
44 #include "extensions/externalize-string-extension.h" 44 #include "extensions/externalize-string-extension.h"
45 #include "extensions/free-buffer-extension.h"
45 #include "extensions/gc-extension.h" 46 #include "extensions/gc-extension.h"
46 #include "extensions/statistics-extension.h" 47 #include "extensions/statistics-extension.h"
48 #include "extensions/trigger-failure-extension.h"
47 #include "code-stubs.h" 49 #include "code-stubs.h"
48 50
49 namespace v8 { 51 namespace v8 {
50 namespace internal { 52 namespace internal {
51 53
52 54
53 NativesExternalStringResource::NativesExternalStringResource( 55 NativesExternalStringResource::NativesExternalStringResource(
54 Bootstrapper* bootstrapper, 56 Bootstrapper* bootstrapper,
55 const char* source, 57 const char* source,
56 size_t length) 58 size_t length)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return Handle<String>::cast(cached_source); 95 return Handle<String>::cast(cached_source);
94 } 96 }
95 97
96 98
97 void Bootstrapper::Initialize(bool create_heap_objects) { 99 void Bootstrapper::Initialize(bool create_heap_objects) {
98 extensions_cache_.Initialize(isolate_, create_heap_objects); 100 extensions_cache_.Initialize(isolate_, create_heap_objects);
99 } 101 }
100 102
101 103
102 void Bootstrapper::InitializeOncePerProcess() { 104 void Bootstrapper::InitializeOncePerProcess() {
105 #ifdef ADDRESS_SANITIZER
106 FreeBufferExtension::Register();
107 #endif
103 GCExtension::Register(); 108 GCExtension::Register();
104 ExternalizeStringExtension::Register(); 109 ExternalizeStringExtension::Register();
105 StatisticsExtension::Register(); 110 StatisticsExtension::Register();
111 TriggerFailureExtension::Register();
106 } 112 }
107 113
108 114
109 char* Bootstrapper::AllocateAutoDeletedArray(int bytes) { 115 char* Bootstrapper::AllocateAutoDeletedArray(int bytes) {
110 char* memory = new char[bytes]; 116 char* memory = new char[bytes];
111 if (memory != NULL) { 117 if (memory != NULL) {
112 if (delete_these_arrays_on_tear_down_ == NULL) { 118 if (delete_these_arrays_on_tear_down_ == NULL) {
113 delete_these_arrays_on_tear_down_ = new List<char*>(2); 119 delete_these_arrays_on_tear_down_ = new List<char*>(2);
114 } 120 }
115 delete_these_arrays_on_tear_down_->Add(memory); 121 delete_these_arrays_on_tear_down_->Add(memory);
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 INSTALL_NATIVE(JSFunction, "ConfigureTemplateInstance", 1574 INSTALL_NATIVE(JSFunction, "ConfigureTemplateInstance",
1569 configure_instance_fun); 1575 configure_instance_fun);
1570 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun); 1576 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun);
1571 INSTALL_NATIVE(JSObject, "functionCache", function_cache); 1577 INSTALL_NATIVE(JSObject, "functionCache", function_cache);
1572 INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor", 1578 INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor",
1573 to_complete_property_descriptor); 1579 to_complete_property_descriptor);
1574 } 1580 }
1575 1581
1576 1582
1577 void Genesis::InstallExperimentalNativeFunctions() { 1583 void Genesis::InstallExperimentalNativeFunctions() {
1584 INSTALL_NATIVE(JSFunction, "RunMicrotasks", run_microtasks);
1578 if (FLAG_harmony_proxies) { 1585 if (FLAG_harmony_proxies) {
1579 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); 1586 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap);
1580 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); 1587 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
1581 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); 1588 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap);
1582 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); 1589 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate);
1583 } 1590 }
1584 if (FLAG_harmony_observation) { 1591 if (FLAG_harmony_observation) {
1585 INSTALL_NATIVE(JSFunction, "NotifyChange", observers_notify_change); 1592 INSTALL_NATIVE(JSFunction, "NotifyChange", observers_notify_change);
1586 INSTALL_NATIVE(JSFunction, "EnqueueSpliceRecord", observers_enqueue_splice); 1593 INSTALL_NATIVE(JSFunction, "EnqueueSpliceRecord", observers_enqueue_splice);
1587 INSTALL_NATIVE(JSFunction, "BeginPerformSplice", 1594 INSTALL_NATIVE(JSFunction, "BeginPerformSplice",
1588 observers_begin_perform_splice); 1595 observers_begin_perform_splice);
1589 INSTALL_NATIVE(JSFunction, "EndPerformSplice", 1596 INSTALL_NATIVE(JSFunction, "EndPerformSplice",
1590 observers_end_perform_splice); 1597 observers_end_perform_splice);
1591 INSTALL_NATIVE(JSFunction, "DeliverChangeRecords",
1592 observers_deliver_changes);
1593 } 1598 }
1594 } 1599 }
1595 1600
1596 #undef INSTALL_NATIVE 1601 #undef INSTALL_NATIVE
1597 1602
1598 1603
1599 Handle<JSFunction> Genesis::InstallInternalArray( 1604 Handle<JSFunction> Genesis::InstallInternalArray(
1600 Handle<JSBuiltinsObject> builtins, 1605 Handle<JSBuiltinsObject> builtins,
1601 const char* name, 1606 const char* name,
1602 ElementsKind elements_kind) { 1607 ElementsKind elements_kind) {
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 } 2018 }
2014 2019
2015 #ifdef VERIFY_HEAP 2020 #ifdef VERIFY_HEAP
2016 builtins->Verify(); 2021 builtins->Verify();
2017 #endif 2022 #endif
2018 2023
2019 return true; 2024 return true;
2020 } 2025 }
2021 2026
2022 2027
2028 #define INSTALL_EXPERIMENTAL_NATIVE(i, flag, file) \
2029 if (FLAG_harmony_##flag && \
2030 strcmp(ExperimentalNatives::GetScriptName(i).start(), \
2031 "native " file) == 0) { \
2032 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \
2033 }
2034
2035
2023 bool Genesis::InstallExperimentalNatives() { 2036 bool Genesis::InstallExperimentalNatives() {
2024 for (int i = ExperimentalNatives::GetDebuggerCount(); 2037 for (int i = ExperimentalNatives::GetDebuggerCount();
2025 i < ExperimentalNatives::GetBuiltinsCount(); 2038 i < ExperimentalNatives::GetBuiltinsCount();
2026 i++) { 2039 i++) {
2027 if (FLAG_harmony_symbols && 2040 INSTALL_EXPERIMENTAL_NATIVE(i, symbols, "symbol.js")
2028 strcmp(ExperimentalNatives::GetScriptName(i).start(), 2041 INSTALL_EXPERIMENTAL_NATIVE(i, proxies, "proxy.js")
2029 "native symbol.js") == 0) { 2042 INSTALL_EXPERIMENTAL_NATIVE(i, collections, "collection.js")
2030 if (!CompileExperimentalBuiltin(isolate(), i)) return false; 2043 INSTALL_EXPERIMENTAL_NATIVE(i, observation, "object-observe.js")
2031 } 2044 INSTALL_EXPERIMENTAL_NATIVE(i, promises, "promise.js")
2032 if (FLAG_harmony_proxies && 2045 INSTALL_EXPERIMENTAL_NATIVE(i, generators, "generator.js")
2033 strcmp(ExperimentalNatives::GetScriptName(i).start(), 2046 INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "array-iterator.js")
2034 "native proxy.js") == 0) { 2047 INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js")
2035 if (!CompileExperimentalBuiltin(isolate(), i)) return false; 2048 INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js")
2036 } 2049 INSTALL_EXPERIMENTAL_NATIVE(i, maths, "harmony-math.js")
2037 if (FLAG_harmony_collections &&
2038 strcmp(ExperimentalNatives::GetScriptName(i).start(),
2039 "native collection.js") == 0) {
2040 if (!CompileExperimentalBuiltin(isolate(), i)) return false;
2041 }
2042 if (FLAG_harmony_observation &&
2043 strcmp(ExperimentalNatives::GetScriptName(i).start(),
2044 "native object-observe.js") == 0) {
2045 if (!CompileExperimentalBuiltin(isolate(), i)) return false;
2046 }
2047 if (FLAG_harmony_generators &&
2048 strcmp(ExperimentalNatives::GetScriptName(i).start(),
2049 "native generator.js") == 0) {
2050 if (!CompileExperimentalBuiltin(isolate(), i)) return false;
2051 }
2052 if (FLAG_harmony_iteration &&
2053 strcmp(ExperimentalNatives::GetScriptName(i).start(),
2054 "native array-iterator.js") == 0) {
2055 if (!CompileExperimentalBuiltin(isolate(), i)) return false;
2056 }
2057 if (FLAG_harmony_strings &&
2058 strcmp(ExperimentalNatives::GetScriptName(i).start(),
2059 "native harmony-string.js") == 0) {
2060 if (!CompileExperimentalBuiltin(isolate(), i)) return false;
2061 }
2062 if (FLAG_harmony_arrays &&
2063 strcmp(ExperimentalNatives::GetScriptName(i).start(),
2064 "native harmony-array.js") == 0) {
2065 if (!CompileExperimentalBuiltin(isolate(), i)) return false;
2066 }
2067 if (FLAG_harmony_maths &&
2068 strcmp(ExperimentalNatives::GetScriptName(i).start(),
2069 "native harmony-math.js") == 0) {
2070 if (!CompileExperimentalBuiltin(isolate(), i)) return false;
2071 }
2072 } 2050 }
2073 2051
2074 InstallExperimentalNativeFunctions(); 2052 InstallExperimentalNativeFunctions();
2075 2053
2076 return true; 2054 return true;
2077 } 2055 }
2078 2056
2079 2057
2080 static Handle<JSObject> ResolveBuiltinIdHolder( 2058 static Handle<JSObject> ResolveBuiltinIdHolder(
2081 Handle<Context> native_context, 2059 Handle<Context> native_context,
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 Isolate* isolate = native_context->GetIsolate(); 2249 Isolate* isolate = native_context->GetIsolate();
2272 ExtensionStates extension_states; // All extensions have state UNVISITED. 2250 ExtensionStates extension_states; // All extensions have state UNVISITED.
2273 // Install auto extensions. 2251 // Install auto extensions.
2274 v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension(); 2252 v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension();
2275 while (current != NULL) { 2253 while (current != NULL) {
2276 if (current->extension()->auto_enable()) 2254 if (current->extension()->auto_enable())
2277 InstallExtension(isolate, current, &extension_states); 2255 InstallExtension(isolate, current, &extension_states);
2278 current = current->next(); 2256 current = current->next();
2279 } 2257 }
2280 2258
2259 #ifdef ADDRESS_SANITIZER
2260 if (FLAG_expose_free_buffer) {
2261 InstallExtension(isolate, "v8/free-buffer", &extension_states);
2262 }
2263 #endif
2281 if (FLAG_expose_gc) InstallExtension(isolate, "v8/gc", &extension_states); 2264 if (FLAG_expose_gc) InstallExtension(isolate, "v8/gc", &extension_states);
2282 if (FLAG_expose_externalize_string) { 2265 if (FLAG_expose_externalize_string) {
2283 InstallExtension(isolate, "v8/externalize", &extension_states); 2266 InstallExtension(isolate, "v8/externalize", &extension_states);
2284 } 2267 }
2285 if (FLAG_track_gc_object_stats) { 2268 if (FLAG_track_gc_object_stats) {
2286 InstallExtension(isolate, "v8/statistics", &extension_states); 2269 InstallExtension(isolate, "v8/statistics", &extension_states);
2287 } 2270 }
2271 if (FLAG_expose_trigger_failure) {
2272 InstallExtension(isolate, "v8/trigger-failure", &extension_states);
2273 }
2288 2274
2289 if (extensions == NULL) return true; 2275 if (extensions == NULL) return true;
2290 // Install required extensions 2276 // Install required extensions
2291 int count = v8::ImplementationUtilities::GetNameCount(extensions); 2277 int count = v8::ImplementationUtilities::GetNameCount(extensions);
2292 const char** names = v8::ImplementationUtilities::GetNames(extensions); 2278 const char** names = v8::ImplementationUtilities::GetNames(extensions);
2293 for (int i = 0; i < count; i++) { 2279 for (int i = 0; i < count; i++) {
2294 if (!InstallExtension(isolate, names[i], &extension_states)) 2280 if (!InstallExtension(isolate, names[i], &extension_states))
2295 return false; 2281 return false;
2296 } 2282 }
2297 2283
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 // Initially seed the per-context random number generator using the 2625 // Initially seed the per-context random number generator using the
2640 // per-isolate random number generator. 2626 // per-isolate random number generator.
2641 const int num_elems = 2; 2627 const int num_elems = 2;
2642 const int num_bytes = num_elems * sizeof(uint32_t); 2628 const int num_bytes = num_elems * sizeof(uint32_t);
2643 uint32_t* state = reinterpret_cast<uint32_t*>(malloc(num_bytes)); 2629 uint32_t* state = reinterpret_cast<uint32_t*>(malloc(num_bytes));
2644 2630
2645 do { 2631 do {
2646 isolate->random_number_generator()->NextBytes(state, num_bytes); 2632 isolate->random_number_generator()->NextBytes(state, num_bytes);
2647 } while (state[0] == 0 || state[1] == 0); 2633 } while (state[0] == 0 || state[1] == 0);
2648 2634
2649 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(state, num_bytes); 2635 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(
2636 reinterpret_cast<v8::Isolate*>(isolate), state, num_bytes);
2650 Utils::OpenHandle(*buffer)->set_should_be_freed(true); 2637 Utils::OpenHandle(*buffer)->set_should_be_freed(true);
2651 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); 2638 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems);
2652 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); 2639 Handle<JSBuiltinsObject> builtins(native_context()->builtins());
2653 ForceSetProperty(builtins, 2640 ForceSetProperty(builtins,
2654 factory()->InternalizeOneByteString( 2641 factory()->InternalizeOneByteString(
2655 STATIC_ASCII_VECTOR("rngstate")), 2642 STATIC_ASCII_VECTOR("rngstate")),
2656 Utils::OpenHandle(*ta), 2643 Utils::OpenHandle(*ta),
2657 NONE); 2644 NONE);
2658 2645
2659 // Initialize trigonometric lookup tables and constants. 2646 // Initialize trigonometric lookup tables and constants.
2660 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); 2647 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes();
2661 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( 2648 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New(
2649 reinterpret_cast<v8::Isolate*>(isolate),
2662 TrigonometricLookupTable::sin_table(), table_num_bytes); 2650 TrigonometricLookupTable::sin_table(), table_num_bytes);
2663 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( 2651 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New(
2652 reinterpret_cast<v8::Isolate*>(isolate),
2664 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); 2653 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes);
2665 v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New( 2654 v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New(
2666 sin_buffer, 0, TrigonometricLookupTable::table_size()); 2655 sin_buffer, 0, TrigonometricLookupTable::table_size());
2667 v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New( 2656 v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New(
2668 cos_buffer, 0, TrigonometricLookupTable::table_size()); 2657 cos_buffer, 0, TrigonometricLookupTable::table_size());
2669 2658
2670 ForceSetProperty(builtins, 2659 ForceSetProperty(builtins,
2671 factory()->InternalizeOneByteString( 2660 factory()->InternalizeOneByteString(
2672 STATIC_ASCII_VECTOR("kSinTable")), 2661 STATIC_ASCII_VECTOR("kSinTable")),
2673 Utils::OpenHandle(*sin_table), 2662 Utils::OpenHandle(*sin_table),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2717 return from + sizeof(NestingCounterType); 2706 return from + sizeof(NestingCounterType);
2718 } 2707 }
2719 2708
2720 2709
2721 // Called when the top-level V8 mutex is destroyed. 2710 // Called when the top-level V8 mutex is destroyed.
2722 void Bootstrapper::FreeThreadResources() { 2711 void Bootstrapper::FreeThreadResources() {
2723 ASSERT(!IsActive()); 2712 ASSERT(!IsActive());
2724 } 2713 }
2725 2714
2726 } } // namespace v8::internal 2715 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698