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

Side by Side Diff: src/bootstrapper.cc

Issue 1421703004: Initialize maths result array in JS. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | src/js/prologue.js » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // The native context has a ScriptContextTable that store declarative bindings 190 // The native context has a ScriptContextTable that store declarative bindings
191 // made in script scopes. Add a "this" binding to that table pointing to the 191 // made in script scopes. Add a "this" binding to that table pointing to the
192 // global proxy. 192 // global proxy.
193 void InstallGlobalThisBinding(); 193 void InstallGlobalThisBinding();
194 void HookUpGlobalThisBinding(Handle<FixedArray> outdated_contexts); 194 void HookUpGlobalThisBinding(Handle<FixedArray> outdated_contexts);
195 // New context initialization. Used for creating a context from scratch. 195 // New context initialization. Used for creating a context from scratch.
196 void InitializeGlobal(Handle<GlobalObject> global_object, 196 void InitializeGlobal(Handle<GlobalObject> global_object,
197 Handle<JSFunction> empty_function, 197 Handle<JSFunction> empty_function,
198 ContextType context_type); 198 ContextType context_type);
199 void InitializeExperimentalGlobal(); 199 void InitializeExperimentalGlobal();
200 // Typed arrays are not serializable and have to initialized afterwards.
201 bool InitializeBuiltinTypedArrays();
202 // Depending on the situation, expose and/or get rid of the utils object. 200 // Depending on the situation, expose and/or get rid of the utils object.
203 void ConfigureUtilsObject(ContextType context_type); 201 void ConfigureUtilsObject(ContextType context_type);
204 202
205 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \ 203 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \
206 void InitializeGlobal_##id(); 204 void InitializeGlobal_##id();
207 205
208 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) 206 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION)
209 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) 207 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION)
210 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) 208 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION)
211 #undef DECLARE_FEATURE_INITIALIZATION 209 #undef DECLARE_FEATURE_INITIALIZATION
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 *data = reinterpret_cast<Data*>( 1780 *data = reinterpret_cast<Data*>(
1783 isolate->array_buffer_allocator()->Allocate(byte_length)); 1781 isolate->array_buffer_allocator()->Allocate(byte_length));
1784 } 1782 }
1785 JSArrayBuffer::Setup(buffer, isolate, is_external, *data, byte_length, 1783 JSArrayBuffer::Setup(buffer, isolate, is_external, *data, byte_length,
1786 SharedFlag::kNotShared); 1784 SharedFlag::kNotShared);
1787 return isolate->factory()->NewJSTypedArray(type, buffer, 0, num_elements, 1785 return isolate->factory()->NewJSTypedArray(type, buffer, 0, num_elements,
1788 TENURED); 1786 TENURED);
1789 } 1787 }
1790 1788
1791 1789
1792 bool Genesis::InitializeBuiltinTypedArrays() {
1793 HandleScope scope(isolate());
1794 const size_t num_elements = 2;
1795 double* data = NULL;
1796 Handle<JSTypedArray> rempio2result =
1797 CreateTypedArray(isolate(), kExternalFloat64Array, num_elements, &data);
1798 for (size_t i = 0; i < num_elements; i++) data[i] = 0;
1799
1800 Handle<JSObject> utils =
1801 Handle<JSObject>::cast(isolate()->natives_utils_object());
1802 Handle<String> name_string = isolate()->factory()->NewStringFromAsciiChecked(
1803 "InitializeBuiltinTypedArrays");
1804 Handle<Object> fun = JSObject::GetDataProperty(utils, name_string);
1805 Handle<Object> receiver = isolate()->factory()->undefined_value();
1806 Handle<Object> args[] = {utils, rempio2result};
1807 return !Execution::Call(isolate(), fun, receiver, arraysize(args), args)
1808 .is_null();
1809 }
1810
1811
1812 void Genesis::ConfigureUtilsObject(ContextType context_type) { 1790 void Genesis::ConfigureUtilsObject(ContextType context_type) {
1813 switch (context_type) { 1791 switch (context_type) {
1814 // We still need the utils object to find debug functions. 1792 // We still need the utils object to find debug functions.
1815 case DEBUG_CONTEXT: 1793 case DEBUG_CONTEXT:
1816 return; 1794 return;
1817 // Expose the natives in global if a valid name for it is specified. 1795 // Expose the natives in global if a valid name for it is specified.
1818 case FULL_CONTEXT: { 1796 case FULL_CONTEXT: {
1819 // We still need the utils object after deserialization. 1797 // We still need the utils object after deserialization.
1820 if (isolate()->serializer_enabled()) return; 1798 if (isolate()->serializer_enabled()) return;
1821 if (FLAG_expose_natives_as == NULL) break; 1799 if (FLAG_expose_natives_as == NULL) break;
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after
3246 if (!InstallExtraNatives()) return; 3224 if (!InstallExtraNatives()) return;
3247 if (!ConfigureGlobalObjects(global_proxy_template)) return; 3225 if (!ConfigureGlobalObjects(global_proxy_template)) return;
3248 } 3226 }
3249 isolate->counters()->contexts_created_from_scratch()->Increment(); 3227 isolate->counters()->contexts_created_from_scratch()->Increment();
3250 } 3228 }
3251 3229
3252 // Install experimental natives. Do not include them into the 3230 // Install experimental natives. Do not include them into the
3253 // snapshot as we should be able to turn them off at runtime. Re-installing 3231 // snapshot as we should be able to turn them off at runtime. Re-installing
3254 // them after they have already been deserialized would also fail. 3232 // them after they have already been deserialized would also fail.
3255 if (context_type == FULL_CONTEXT) { 3233 if (context_type == FULL_CONTEXT) {
3256 if (!InitializeBuiltinTypedArrays()) return;
3257 if (!isolate->serializer_enabled()) { 3234 if (!isolate->serializer_enabled()) {
3258 InitializeExperimentalGlobal(); 3235 InitializeExperimentalGlobal();
3259 if (!InstallExperimentalNatives()) return; 3236 if (!InstallExperimentalNatives()) return;
3260 3237
3261 if (FLAG_experimental_extras) { 3238 if (FLAG_experimental_extras) {
3262 if (!InstallExperimentalExtraNatives()) return; 3239 if (!InstallExperimentalExtraNatives()) return;
3263 } 3240 }
3264 } 3241 }
3265 // The serializer cannot serialize typed arrays. Reset those typed arrays 3242 // The serializer cannot serialize typed arrays. Reset those typed arrays
3266 // for each new context. 3243 // for each new context.
3267 } else if (context_type == DEBUG_CONTEXT) { 3244 } else if (context_type == DEBUG_CONTEXT) {
3268 DCHECK(!isolate->serializer_enabled()); 3245 DCHECK(!isolate->serializer_enabled());
3269 if (!InitializeBuiltinTypedArrays()) return;
3270 InitializeExperimentalGlobal(); 3246 InitializeExperimentalGlobal();
3271 if (!InstallDebuggerNatives()) return; 3247 if (!InstallDebuggerNatives()) return;
3272 } 3248 }
3273 3249
3274 ConfigureUtilsObject(context_type); 3250 ConfigureUtilsObject(context_type);
3275 3251
3276 // Check that the script context table is empty except for the 'this' binding. 3252 // Check that the script context table is empty except for the 'this' binding.
3277 // We do not need script contexts for native scripts. 3253 // We do not need script contexts for native scripts.
3278 if (!FLAG_global_var_shortcuts) { 3254 if (!FLAG_global_var_shortcuts) {
3279 DCHECK_EQ(1, native_context()->script_context_table()->used()); 3255 DCHECK_EQ(1, native_context()->script_context_table()->used());
(...skipping 26 matching lines...) Expand all
3306 } 3282 }
3307 3283
3308 3284
3309 // Called when the top-level V8 mutex is destroyed. 3285 // Called when the top-level V8 mutex is destroyed.
3310 void Bootstrapper::FreeThreadResources() { 3286 void Bootstrapper::FreeThreadResources() {
3311 DCHECK(!IsActive()); 3287 DCHECK(!IsActive());
3312 } 3288 }
3313 3289
3314 } // namespace internal 3290 } // namespace internal
3315 } // namespace v8 3291 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/js/prologue.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698