45 using ::v8::Extension;
47 using ::v8::HandleScope;
50 using ::v8::ObjectTemplate;
51 using ::v8::Persistent;
62 :
Thread(
"KangarooThread"),
64 context_(isolate, context) {}
70 CHECK_EQ(isolate_, v8::internal::Isolate::Current());
75 Local<Value> v = CompileRun(
"getValue()");
77 CHECK_EQ(30, static_cast<int>(v->NumberValue()));
86 Local<Value> v = CompileRun(
"getValue()");
88 CHECK_EQ(30, static_cast<int>(v->NumberValue()));
95 Persistent<v8::Context> context_;
109 CHECK_EQ(isolate, v8::internal::Isolate::Current());
110 CompileRun(
"function getValue() { return 30; }");
118 static void CalcFibAndCheck() {
119 Local<Value> v = CompileRun(
"function fib(n) {"
120 " if (n <= 2) return 1;"
121 " return fib(n-1) + fib(n-2);"
124 CHECK(v->IsNumber());
125 CHECK_EQ(55, static_cast<int>(v->NumberValue()));
146 virtual void Run() = 0;
152 : Thread(joinable_thread->name_),
153 joinable_thread_(joinable_thread) {
157 joinable_thread_->Run();
158 joinable_thread_->semaphore_.Signal();
166 i::Semaphore semaphore_;
187 CHECK_EQ(isolate_, v8::internal::Isolate::Current());
196 for (
int i = 0; i < threads.length(); i++) {
199 for (
int i = 0; i < threads.length(); i++) {
202 for (
int i = 0; i < threads.length(); i++) {
210 #if V8_TARGET_ARCH_MIPS
211 const int kNThreads = 50;
213 const int kNThreads = 100;
217 for (
int i = 0; i < kNThreads; i++) {
220 StartJoinAndDeleteThreads(threads);
237 CHECK_EQ(isolate, v8::internal::Isolate::Current());
247 TEST(MultithreadedParallelIsolates) {
248 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS
249 const int kNThreads = 10;
251 const int kNThreads = 50;
254 for (
int i = 0; i < kNThreads; i++) {
257 StartJoinAndDeleteThreads(threads);
287 #if V8_TARGET_ARCH_MIPS
288 const int kNThreads = 50;
290 const int kNThreads = 100;
294 for (
int i = 0; i < kNThreads; i++) {
297 StartJoinAndDeleteThreads(threads);
307 isolate1_(isolate1), isolate2_(isolate2) {
328 TEST(SeparateIsolatesLocksNonexclusive) {
329 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS
330 const int kNThreads = 50;
332 const int kNThreads = 100;
337 for (
int i = 0; i < kNThreads; i++) {
341 StartJoinAndDeleteThreads(threads);
352 context_(isolate, context) {
358 HandleScope handle_scope(isolate_);
366 Persistent<v8::Context> context_;
406 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS
407 const int kNThreads = 50;
409 const int kNThreads = 100;
413 for (
int i = 0; i < kNThreads; i++) {
416 StartJoinAndDeleteThreads(threads);
460 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS
461 const int kNThreads = 50;
463 const int kNThreads = 100;
467 for (
int i = 0; i < kNThreads; i++) {
470 StartJoinAndDeleteThreads(threads);
480 isolate2_(isolate2) {
497 isolate1_, context1));
527 TEST(LockAndUnlockDifferentIsolates) {
542 context_(isolate, context) {
582 TEST(LockUnlockLockMultithreaded) {
583 #if V8_TARGET_ARCH_MIPS
584 const int kNThreads = 50;
586 const int kNThreads = 100;
595 for (
int i = 0; i < kNThreads; i++) {
600 StartJoinAndDeleteThreads(threads);
608 context_(
CcTest::isolate(), context) {}
640 TEST(LockUnlockLockDefaultIsolateMultithreaded) {
641 #if V8_TARGET_ARCH_MIPS
642 const int kNThreads = 50;
644 const int kNThreads = 100;
646 Local<v8::Context> context;
653 for (
int i = 0; i < kNThreads; i++) {
657 StartJoinAndDeleteThreads(threads);
662 for (
int i = 0; i < 10; i++) {
680 static const char* kSimpleExtensionSource =
690 extension_names_(extension_names)
697 CHECK(!i::Isolate::Current()->has_installed_extensions());
701 CHECK(i::Isolate::Current()->has_installed_extensions());
707 const char** extension_names_;
714 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS
715 const int kNThreads = 10;
717 const int kNThreads = 40;
720 kSimpleExtensionSource));
722 kSimpleExtensionSource));
724 kSimpleExtensionSource));
726 kSimpleExtensionSource));
728 kSimpleExtensionSource));
730 kSimpleExtensionSource));
732 kSimpleExtensionSource));
734 kSimpleExtensionSource));
735 const char* extension_names[] = {
"test0",
"test1",
736 "test2",
"test3",
"test4",
737 "test5",
"test6",
"test7" };
739 for (
int i = 0; i < kNThreads; i++) {
742 StartJoinAndDeleteThreads(threads);
static V8_INLINE Local< T > New(Isolate *isolate, Handle< T > that)
#define CHECK_EQ(expected, value)
Thread(const Options &options)
LockIsolateAndCalculateFibSharedContextThread(v8::Isolate *isolate, v8::Handle< v8::Context > context)
void V8_EXPORT RegisterExtension(Extension *extension)
IsolateNestedLockingThread(v8::Isolate *isolate)
kSerializedDataOffset Object
virtual ~JoinableThread()
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
static bool IsLocked(Isolate *isolate)
LockAndUnlockDifferentIsolatesThread(v8::Isolate *isolate1, v8::Isolate *isolate2)
IsolateLockingThreadWithLocalContext(v8::Isolate *isolate)
LockerUnlockerThread(v8::Isolate *isolate)
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *script_data=NULL)
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
friend class ThreadWithSemaphore
LockUnlockLockDefaultIsolateThread(v8::Handle< v8::Context > context)
static Local< Context > New(Isolate *isolate, ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
IsolateNonlockingThread()
SeparateIsolatesLocksNonexclusiveThread(v8::Isolate *isolate1, v8::Isolate *isolate2)
JoinableThread(const char *name)
LockTwiceAndUnlockThread(v8::Isolate *isolate)
LockUnlockLockThread(v8::Isolate *isolate, v8::Handle< v8::Context > context)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
KangarooThread(v8::Isolate *isolate, v8::Handle< v8::Context > context)
IsolateGenesisThread(int count, const char *extension_names[])
static v8::Isolate * isolate()
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)