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

Side by Side Diff: test/cctest/test-random.cc

Issue 23441029: Move global V8::UseCrankshaft() into the Isolate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Sven Panne. Created 7 years, 3 months 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 | « test/cctest/test-heap.cc ('k') | no next file » | 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 SetSeeds(seeds, state0, state1); 62 SetSeeds(seeds, state0, state1);
63 V8::FillHeapNumberWithRandom(*value, *context); 63 V8::FillHeapNumberWithRandom(*value, *context);
64 double runtime_value = HeapNumber::cast(*value)->value(); 64 double runtime_value = HeapNumber::cast(*value)->value();
65 CHECK_EQ(runtime_value, crankshaft_value); 65 CHECK_EQ(runtime_value, crankshaft_value);
66 } 66 }
67 67
68 68
69 TEST(CrankshaftRandom) { 69 TEST(CrankshaftRandom) {
70 v8::V8::Initialize(); 70 v8::V8::Initialize();
71 // Skip test if crankshaft is disabled. 71 // Skip test if crankshaft is disabled.
72 if (!V8::UseCrankshaft()) return; 72 if (!Isolate::Current()->use_crankshaft()) return;
73 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 73 v8::Isolate* isolate = v8::Isolate::GetCurrent();
74 v8::HandleScope scope(isolate); 74 v8::HandleScope scope(isolate);
75 v8::Context::Scope context_scope(v8::Context::New(isolate)); 75 v8::Context::Scope context_scope(v8::Context::New(isolate));
76 76
77 Handle<Context> context(Isolate::Current()->context()); 77 Handle<Context> context(Isolate::Current()->context());
78 Handle<JSObject> global(context->global_object()); 78 Handle<JSObject> global(context->global_object());
79 Handle<ByteArray> seeds(context->random_seed()); 79 Handle<ByteArray> seeds(context->random_seed());
80 bool has_pending_exception; 80 bool has_pending_exception;
81 81
82 CompileRun("function f() { return Math.random(); }"); 82 CompileRun("function f() { return Math.random(); }");
(...skipping 16 matching lines...) Expand all
99 99
100 // Test that we bail out to runtime when seeds are uninitialized (zeros). 100 // Test that we bail out to runtime when seeds are uninitialized (zeros).
101 SetSeeds(seeds, 0, 0); 101 SetSeeds(seeds, 0, 0);
102 Handle<Object> value = 102 Handle<Object> value =
103 Execution::Call(fun, global, 0, NULL, &has_pending_exception); 103 Execution::Call(fun, global, 0, NULL, &has_pending_exception);
104 CHECK(value->IsHeapNumber()); 104 CHECK(value->IsHeapNumber());
105 CHECK(fun->IsOptimized()); 105 CHECK(fun->IsOptimized());
106 double crankshaft_value = HeapNumber::cast(*value)->value(); 106 double crankshaft_value = HeapNumber::cast(*value)->value();
107 CHECK_NE(0.0, crankshaft_value); 107 CHECK_NE(0.0, crankshaft_value);
108 } 108 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698