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

Side by Side Diff: src/bootstrapper.cc

Issue 110573004: Merge bleeding_edge 17696:18016. (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
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 "compiler.h" 33 #include "compiler.h"
34 #include "debug.h" 34 #include "debug.h"
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 "extensions/externalize-string-extension.h" 44 #include "extensions/externalize-string-extension.h"
44 #include "extensions/gc-extension.h" 45 #include "extensions/gc-extension.h"
45 #include "extensions/statistics-extension.h" 46 #include "extensions/statistics-extension.h"
46 #include "code-stubs.h" 47 #include "code-stubs.h"
47 48
48 namespace v8 { 49 namespace v8 {
49 namespace internal { 50 namespace internal {
50 51
51 52
52 NativesExternalStringResource::NativesExternalStringResource( 53 NativesExternalStringResource::NativesExternalStringResource(
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 native_context()->set_call_as_constructor_delegate(*delegate); 1302 native_context()->set_call_as_constructor_delegate(*delegate);
1302 delegate->shared()->DontAdaptArguments(); 1303 delegate->shared()->DontAdaptArguments();
1303 } 1304 }
1304 1305
1305 // Initialize the out of memory slot. 1306 // Initialize the out of memory slot.
1306 native_context()->set_out_of_memory(heap->false_value()); 1307 native_context()->set_out_of_memory(heap->false_value());
1307 1308
1308 // Initialize the embedder data slot. 1309 // Initialize the embedder data slot.
1309 Handle<FixedArray> embedder_data = factory->NewFixedArray(2); 1310 Handle<FixedArray> embedder_data = factory->NewFixedArray(2);
1310 native_context()->set_embedder_data(*embedder_data); 1311 native_context()->set_embedder_data(*embedder_data);
1311
1312 // Allocate the random seed slot.
1313 Handle<ByteArray> random_seed = factory->NewByteArray(kRandomStateSize);
1314 native_context()->set_random_seed(*random_seed);
1315 } 1312 }
1316 1313
1317 1314
1318 Handle<JSFunction> Genesis::InstallTypedArray( 1315 Handle<JSFunction> Genesis::InstallTypedArray(
1319 const char* name, ElementsKind elementsKind) { 1316 const char* name, ElementsKind elementsKind) {
1320 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); 1317 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
1321 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, 1318 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE,
1322 JSTypedArray::kSize, isolate()->initial_object_prototype(), 1319 JSTypedArray::kSize, isolate()->initial_object_prototype(),
1323 Builtins::kIllegal, false, true); 1320 Builtins::kIllegal, false, true);
1324 1321
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 native_context()->set_initial_array_prototype( 2416 native_context()->set_initial_array_prototype(
2420 JSArray::cast(native_context()->array_function()->prototype())); 2417 JSArray::cast(native_context()->array_function()->prototype()));
2421 2418
2422 return true; 2419 return true;
2423 } 2420 }
2424 2421
2425 2422
2426 bool Genesis::ConfigureApiObject(Handle<JSObject> object, 2423 bool Genesis::ConfigureApiObject(Handle<JSObject> object,
2427 Handle<ObjectTemplateInfo> object_template) { 2424 Handle<ObjectTemplateInfo> object_template) {
2428 ASSERT(!object_template.is_null()); 2425 ASSERT(!object_template.is_null());
2429 ASSERT(object->IsInstanceOf( 2426 ASSERT(FunctionTemplateInfo::cast(object_template->constructor())
2430 FunctionTemplateInfo::cast(object_template->constructor()))); 2427 ->IsTemplateFor(object->map()));;
2431 2428
2432 bool pending_exception = false; 2429 bool pending_exception = false;
2433 Handle<JSObject> obj = 2430 Handle<JSObject> obj =
2434 Execution::InstantiateObject(object_template, &pending_exception); 2431 Execution::InstantiateObject(object_template, &pending_exception);
2435 if (pending_exception) { 2432 if (pending_exception) {
2436 ASSERT(isolate()->has_pending_exception()); 2433 ASSERT(isolate()->has_pending_exception());
2437 isolate()->clear_pending_exception(); 2434 isolate()->clear_pending_exception();
2438 return false; 2435 return false;
2439 } 2436 }
2440 TransferObject(obj, object); 2437 TransferObject(obj, object);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 MakeFunctionInstancePrototypeWritable(); 2625 MakeFunctionInstancePrototypeWritable();
2629 2626
2630 if (!ConfigureGlobalObjects(global_template)) return; 2627 if (!ConfigureGlobalObjects(global_template)) return;
2631 isolate->counters()->contexts_created_from_scratch()->Increment(); 2628 isolate->counters()->contexts_created_from_scratch()->Increment();
2632 } 2629 }
2633 2630
2634 // Initialize experimental globals and install experimental natives. 2631 // Initialize experimental globals and install experimental natives.
2635 InitializeExperimentalGlobal(); 2632 InitializeExperimentalGlobal();
2636 if (!InstallExperimentalNatives()) return; 2633 if (!InstallExperimentalNatives()) return;
2637 2634
2638 // Initially seed the per-context random number generator 2635 // We can't (de-)serialize typed arrays currently, but we are lucky: The state
2639 // using the per-isolate random number generator. 2636 // of the random number generator needs no initialization during snapshot
2640 uint32_t* state = reinterpret_cast<uint32_t*>( 2637 // creation time and we don't need trigonometric functions then.
2641 native_context()->random_seed()->GetDataStartAddress()); 2638 if (!Serializer::enabled()) {
2642 do { 2639 // Initially seed the per-context random number generator using the
2643 isolate->random_number_generator()->NextBytes(state, kRandomStateSize); 2640 // per-isolate random number generator.
2644 } while (state[0] == 0 || state[1] == 0); 2641 const int num_elems = 2;
2642 const int num_bytes = num_elems * sizeof(uint32_t);
2643 uint32_t* state = reinterpret_cast<uint32_t*>(malloc(num_bytes));
2644
2645 do {
2646 isolate->random_number_generator()->NextBytes(state, num_bytes);
2647 } while (state[0] == 0 || state[1] == 0);
2648
2649 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(state, num_bytes);
2650 Utils::OpenHandle(*buffer)->set_should_be_freed(true);
2651 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems);
2652 Handle<JSBuiltinsObject> builtins(native_context()->builtins());
2653 ForceSetProperty(builtins,
2654 factory()->InternalizeOneByteString(
2655 STATIC_ASCII_VECTOR("rngstate")),
2656 Utils::OpenHandle(*ta),
2657 NONE);
2658
2659 // Initialize trigonometric lookup tables and constants.
2660 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes();
2661 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New(
2662 TrigonometricLookupTable::sin_table(), table_num_bytes);
2663 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New(
2664 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes);
2665 v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New(
2666 sin_buffer, 0, TrigonometricLookupTable::table_size());
2667 v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New(
2668 cos_buffer, 0, TrigonometricLookupTable::table_size());
2669
2670 ForceSetProperty(builtins,
2671 factory()->InternalizeOneByteString(
2672 STATIC_ASCII_VECTOR("kSinTable")),
2673 Utils::OpenHandle(*sin_table),
2674 NONE);
2675 ForceSetProperty(builtins,
2676 factory()->InternalizeOneByteString(
2677 STATIC_ASCII_VECTOR("kCosXIntervalTable")),
2678 Utils::OpenHandle(*cos_table),
2679 NONE);
2680 ForceSetProperty(builtins,
2681 factory()->InternalizeOneByteString(
2682 STATIC_ASCII_VECTOR("kSamples")),
2683 factory()->NewHeapNumber(
2684 TrigonometricLookupTable::samples()),
2685 NONE);
2686 ForceSetProperty(builtins,
2687 factory()->InternalizeOneByteString(
2688 STATIC_ASCII_VECTOR("kIndexConvert")),
2689 factory()->NewHeapNumber(
2690 TrigonometricLookupTable::samples_over_pi_half()),
2691 NONE);
2692 }
2645 2693
2646 result_ = native_context(); 2694 result_ = native_context();
2647 } 2695 }
2648 2696
2649 2697
2650 // Support for thread preemption. 2698 // Support for thread preemption.
2651 2699
2652 // Reserve space for statics needing saving and restoring. 2700 // Reserve space for statics needing saving and restoring.
2653 int Bootstrapper::ArchiveSpacePerThread() { 2701 int Bootstrapper::ArchiveSpacePerThread() {
2654 return sizeof(NestingCounterType); 2702 return sizeof(NestingCounterType);
(...skipping 14 matching lines...) Expand all
2669 return from + sizeof(NestingCounterType); 2717 return from + sizeof(NestingCounterType);
2670 } 2718 }
2671 2719
2672 2720
2673 // Called when the top-level V8 mutex is destroyed. 2721 // Called when the top-level V8 mutex is destroyed.
2674 void Bootstrapper::FreeThreadResources() { 2722 void Bootstrapper::FreeThreadResources() {
2675 ASSERT(!IsActive()); 2723 ASSERT(!IsActive());
2676 } 2724 }
2677 2725
2678 } } // namespace v8::internal 2726 } } // namespace v8::internal
OLDNEW
« include/v8-platform.h ('K') | « src/ast.cc ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698