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 2320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 "function c(x) {" | 2331 "function c(x) {" |
2332 " this.x = x;" | 2332 " this.x = x;" |
2333 " for (var i = 0; i < 32; i++) {" | 2333 " for (var i = 0; i < 32; i++) {" |
2334 " this['x' + i] = x;" | 2334 " this['x' + i] = x;" |
2335 " }" | 2335 " }" |
2336 "}" | 2336 "}" |
2337 "function f(x) { return new c(x); };" | 2337 "function f(x) { return new c(x); };" |
2338 "f(1); f(2); f(3);" | 2338 "f(1); f(2); f(3);" |
2339 "%OptimizeFunctionOnNextCall(f);" | 2339 "%OptimizeFunctionOnNextCall(f);" |
2340 "f(4);"); | 2340 "f(4);"); |
2341 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); | 2341 CHECK_EQ( |
| 2342 4, res.As<v8::Object>()->GetRealNamedProperty(v8_str("x"))->Int32Value()); |
2342 | 2343 |
2343 Handle<JSObject> o = | 2344 Handle<JSObject> o = |
2344 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2345 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2345 | 2346 |
2346 CHECK(CcTest::heap()->InNewSpace(*o)); | 2347 CHECK(CcTest::heap()->InNewSpace(*o)); |
2347 } | 2348 } |
2348 | 2349 |
2349 | 2350 |
2350 TEST(OptimizedPretenuringAllocationFolding) { | 2351 TEST(OptimizedPretenuringAllocationFolding) { |
2351 i::FLAG_allow_natives_syntax = true; | 2352 i::FLAG_allow_natives_syntax = true; |
(...skipping 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4290 | 4291 |
4291 // Checks that the value returned by execution of the source is weak. | 4292 // Checks that the value returned by execution of the source is weak. |
4292 void CheckWeakness(const char* source) { | 4293 void CheckWeakness(const char* source) { |
4293 i::FLAG_stress_compaction = false; | 4294 i::FLAG_stress_compaction = false; |
4294 CcTest::InitializeVM(); | 4295 CcTest::InitializeVM(); |
4295 v8::Isolate* isolate = CcTest::isolate(); | 4296 v8::Isolate* isolate = CcTest::isolate(); |
4296 v8::HandleScope scope(isolate); | 4297 v8::HandleScope scope(isolate); |
4297 v8::Persistent<v8::Object> garbage; | 4298 v8::Persistent<v8::Object> garbage; |
4298 { | 4299 { |
4299 v8::HandleScope scope(isolate); | 4300 v8::HandleScope scope(isolate); |
4300 garbage.Reset(isolate, CompileRun(source)->ToObject()); | 4301 garbage.Reset(isolate, CompileRun(source)->ToObject(isolate)); |
4301 } | 4302 } |
4302 weak_ic_cleared = false; | 4303 weak_ic_cleared = false; |
4303 garbage.SetWeak(static_cast<void*>(&garbage), &ClearWeakIC); | 4304 garbage.SetWeak(static_cast<void*>(&garbage), &ClearWeakIC); |
4304 Heap* heap = CcTest::i_isolate()->heap(); | 4305 Heap* heap = CcTest::i_isolate()->heap(); |
4305 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 4306 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
4306 CHECK(weak_ic_cleared); | 4307 CHECK(weak_ic_cleared); |
4307 } | 4308 } |
4308 | 4309 |
4309 | 4310 |
4310 // Each of the following "weak IC" tests creates an IC that embeds a map with | 4311 // Each of the following "weak IC" tests creates an IC that embeds a map with |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4535 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); | 4536 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); |
4536 DCHECK(!context.IsEmpty()); | 4537 DCHECK(!context.IsEmpty()); |
4537 v8::Context::Scope cscope(context); | 4538 v8::Context::Scope cscope(context); |
4538 | 4539 |
4539 v8::Local<v8::Value> result = CompileRun( | 4540 v8::Local<v8::Value> result = CompileRun( |
4540 "var locals = '';" | 4541 "var locals = '';" |
4541 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" | 4542 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" |
4542 "eval('function f() {' + locals + 'return function() { return v0; }; }');" | 4543 "eval('function f() {' + locals + 'return function() { return v0; }; }');" |
4543 "interrupt();" // This triggers a fake stack overflow in f. | 4544 "interrupt();" // This triggers a fake stack overflow in f. |
4544 "f()()"); | 4545 "f()()"); |
4545 CHECK_EQ(42.0, result->ToNumber()->Value()); | 4546 CHECK_EQ(42.0, result->ToNumber(isolate)->Value()); |
4546 } | 4547 } |
4547 | 4548 |
4548 | 4549 |
4549 TEST(ArrayShiftSweeping) { | 4550 TEST(ArrayShiftSweeping) { |
4550 i::FLAG_expose_gc = true; | 4551 i::FLAG_expose_gc = true; |
4551 CcTest::InitializeVM(); | 4552 CcTest::InitializeVM(); |
4552 v8::HandleScope scope(CcTest::isolate()); | 4553 v8::HandleScope scope(CcTest::isolate()); |
4553 Isolate* isolate = CcTest::i_isolate(); | 4554 Isolate* isolate = CcTest::i_isolate(); |
4554 Heap* heap = isolate->heap(); | 4555 Heap* heap = isolate->heap(); |
4555 | 4556 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4754 #ifdef DEBUG | 4755 #ifdef DEBUG |
4755 TEST(PathTracer) { | 4756 TEST(PathTracer) { |
4756 CcTest::InitializeVM(); | 4757 CcTest::InitializeVM(); |
4757 v8::HandleScope scope(CcTest::isolate()); | 4758 v8::HandleScope scope(CcTest::isolate()); |
4758 | 4759 |
4759 v8::Local<v8::Value> result = CompileRun("'abc'"); | 4760 v8::Local<v8::Value> result = CompileRun("'abc'"); |
4760 Handle<Object> o = v8::Utils::OpenHandle(*result); | 4761 Handle<Object> o = v8::Utils::OpenHandle(*result); |
4761 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 4762 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
4762 } | 4763 } |
4763 #endif // DEBUG | 4764 #endif // DEBUG |
OLD | NEW |