| 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 2637 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2648     // Initially seed the per-context random number generator using the | 2648     // Initially seed the per-context random number generator using the | 
| 2649     // per-isolate random number generator. | 2649     // per-isolate random number generator. | 
| 2650     const int num_elems = 2; | 2650     const int num_elems = 2; | 
| 2651     const int num_bytes = num_elems * sizeof(uint32_t); | 2651     const int num_bytes = num_elems * sizeof(uint32_t); | 
| 2652     uint32_t* state = reinterpret_cast<uint32_t*>(malloc(num_bytes)); | 2652     uint32_t* state = reinterpret_cast<uint32_t*>(malloc(num_bytes)); | 
| 2653 | 2653 | 
| 2654     do { | 2654     do { | 
| 2655       isolate->random_number_generator()->NextBytes(state, num_bytes); | 2655       isolate->random_number_generator()->NextBytes(state, num_bytes); | 
| 2656     } while (state[0] == 0 || state[1] == 0); | 2656     } while (state[0] == 0 || state[1] == 0); | 
| 2657 | 2657 | 
| 2658     v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(state, num_bytes); | 2658     v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New( | 
|  | 2659         reinterpret_cast<v8::Isolate*>(isolate), state, num_bytes); | 
| 2659     Utils::OpenHandle(*buffer)->set_should_be_freed(true); | 2660     Utils::OpenHandle(*buffer)->set_should_be_freed(true); | 
| 2660     v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); | 2661     v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); | 
| 2661     Handle<JSBuiltinsObject> builtins(native_context()->builtins()); | 2662     Handle<JSBuiltinsObject> builtins(native_context()->builtins()); | 
| 2662     ForceSetProperty(builtins, | 2663     ForceSetProperty(builtins, | 
| 2663                      factory()->InternalizeOneByteString( | 2664                      factory()->InternalizeOneByteString( | 
| 2664                          STATIC_ASCII_VECTOR("rngstate")), | 2665                          STATIC_ASCII_VECTOR("rngstate")), | 
| 2665                      Utils::OpenHandle(*ta), | 2666                      Utils::OpenHandle(*ta), | 
| 2666                      NONE); | 2667                      NONE); | 
| 2667 | 2668 | 
| 2668     // Initialize trigonometric lookup tables and constants. | 2669     // Initialize trigonometric lookup tables and constants. | 
| 2669     const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); | 2670     const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); | 
| 2670     v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( | 2671     v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( | 
|  | 2672         reinterpret_cast<v8::Isolate*>(isolate), | 
| 2671         TrigonometricLookupTable::sin_table(), table_num_bytes); | 2673         TrigonometricLookupTable::sin_table(), table_num_bytes); | 
| 2672     v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( | 2674     v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( | 
|  | 2675         reinterpret_cast<v8::Isolate*>(isolate), | 
| 2673         TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); | 2676         TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); | 
| 2674     v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New( | 2677     v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New( | 
| 2675         sin_buffer, 0, TrigonometricLookupTable::table_size()); | 2678         sin_buffer, 0, TrigonometricLookupTable::table_size()); | 
| 2676     v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New( | 2679     v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New( | 
| 2677         cos_buffer, 0, TrigonometricLookupTable::table_size()); | 2680         cos_buffer, 0, TrigonometricLookupTable::table_size()); | 
| 2678 | 2681 | 
| 2679     ForceSetProperty(builtins, | 2682     ForceSetProperty(builtins, | 
| 2680                      factory()->InternalizeOneByteString( | 2683                      factory()->InternalizeOneByteString( | 
| 2681                          STATIC_ASCII_VECTOR("kSinTable")), | 2684                          STATIC_ASCII_VECTOR("kSinTable")), | 
| 2682                      Utils::OpenHandle(*sin_table), | 2685                      Utils::OpenHandle(*sin_table), | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2726   return from + sizeof(NestingCounterType); | 2729   return from + sizeof(NestingCounterType); | 
| 2727 } | 2730 } | 
| 2728 | 2731 | 
| 2729 | 2732 | 
| 2730 // Called when the top-level V8 mutex is destroyed. | 2733 // Called when the top-level V8 mutex is destroyed. | 
| 2731 void Bootstrapper::FreeThreadResources() { | 2734 void Bootstrapper::FreeThreadResources() { | 
| 2732   ASSERT(!IsActive()); | 2735   ASSERT(!IsActive()); | 
| 2733 } | 2736 } | 
| 2734 | 2737 | 
| 2735 } }  // namespace v8::internal | 2738 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|