Chromium Code Reviews| 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 "var", | 589 "var", |
| 590 "void", | 590 "void", |
| 591 "volatile", | 591 "volatile", |
| 592 "while", | 592 "while", |
| 593 "with", | 593 "with", |
| 594 0 | 594 0 |
| 595 }; | 595 }; |
| 596 | 596 |
| 597 | 597 |
| 598 static void CheckInternalizedStrings(const char** strings) { | 598 static void CheckInternalizedStrings(const char** strings) { |
| 599 Isolate* isolate = CcTest::i_isolate(); | |
| 599 for (const char* string = *strings; *strings != 0; string = *strings++) { | 600 for (const char* string = *strings; *strings != 0; string = *strings++) { |
| 600 Object* a; | 601 HandleScope scope(isolate); |
| 601 MaybeObject* maybe_a = CcTest::heap()->InternalizeUtf8String(string); | 602 Handle<String> a = |
| 603 isolate->factory()->InternalizeUtf8String(CStrVector(string)); | |
| 602 // InternalizeUtf8String may return a failure if a GC is needed. | 604 // InternalizeUtf8String may return a failure if a GC is needed. |
| 603 if (!maybe_a->ToObject(&a)) continue; | |
| 604 CHECK(a->IsInternalizedString()); | 605 CHECK(a->IsInternalizedString()); |
| 605 Object* b; | 606 Handle<String> b = |
| 606 MaybeObject* maybe_b = CcTest::heap()->InternalizeUtf8String(string); | 607 isolate->factory()->InternalizeUtf8String(CStrVector(string)); |
| 607 if (!maybe_b->ToObject(&b)) continue; | 608 CHECK_EQ(*b, *a); |
| 608 CHECK_EQ(b, a); | 609 CHECK(String::cast(*b)->IsUtf8EqualTo(CStrVector(string))); |
|
Michael Starzinger
2014/04/29 13:15:09
nit: The "String::cast" here is obsolete, "b" is a
| |
| 609 CHECK(String::cast(b)->IsUtf8EqualTo(CStrVector(string))); | |
| 610 } | 610 } |
| 611 } | 611 } |
| 612 | 612 |
| 613 | 613 |
| 614 TEST(StringTable) { | 614 TEST(StringTable) { |
| 615 CcTest::InitializeVM(); | 615 CcTest::InitializeVM(); |
| 616 | 616 |
| 617 CheckInternalizedStrings(not_so_random_string_table); | 617 CheckInternalizedStrings(not_so_random_string_table); |
| 618 CheckInternalizedStrings(not_so_random_string_table); | 618 CheckInternalizedStrings(not_so_random_string_table); |
| 619 } | 619 } |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 974 | 974 |
| 975 static int LenFromSize(int size) { | 975 static int LenFromSize(int size) { |
| 976 return (size - FixedArray::kHeaderSize) / kPointerSize; | 976 return (size - FixedArray::kHeaderSize) / kPointerSize; |
| 977 } | 977 } |
| 978 | 978 |
| 979 | 979 |
| 980 TEST(Regression39128) { | 980 TEST(Regression39128) { |
| 981 // Test case for crbug.com/39128. | 981 // Test case for crbug.com/39128. |
| 982 CcTest::InitializeVM(); | 982 CcTest::InitializeVM(); |
| 983 Isolate* isolate = CcTest::i_isolate(); | 983 Isolate* isolate = CcTest::i_isolate(); |
| 984 Heap* heap = isolate->heap(); | 984 TestHeap* heap = CcTest::test_heap(); |
| 985 | 985 |
| 986 // Increase the chance of 'bump-the-pointer' allocation in old space. | 986 // Increase the chance of 'bump-the-pointer' allocation in old space. |
| 987 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 987 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
| 988 | 988 |
| 989 v8::HandleScope scope(CcTest::isolate()); | 989 v8::HandleScope scope(CcTest::isolate()); |
| 990 | 990 |
| 991 // The plan: create JSObject which references objects in new space. | 991 // The plan: create JSObject which references objects in new space. |
| 992 // Then clone this object (forcing it to go into old space) and check | 992 // Then clone this object (forcing it to go into old space) and check |
| 993 // that region dirty marks are updated correctly. | 993 // that region dirty marks are updated correctly. |
| 994 | 994 |
| (...skipping 3199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4194 v8::Context::Scope cscope(context); | 4194 v8::Context::Scope cscope(context); |
| 4195 | 4195 |
| 4196 v8::Local<v8::Value> result = CompileRun( | 4196 v8::Local<v8::Value> result = CompileRun( |
| 4197 "var locals = '';" | 4197 "var locals = '';" |
| 4198 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" | 4198 "for (var i = 0; i < 512; i++) locals += 'var v' + i + '= 42;';" |
| 4199 "eval('function f() {' + locals + 'return function() { return v0; }; }');" | 4199 "eval('function f() {' + locals + 'return function() { return v0; }; }');" |
| 4200 "interrupt();" // This triggers a fake stack overflow in f. | 4200 "interrupt();" // This triggers a fake stack overflow in f. |
| 4201 "f()()"); | 4201 "f()()"); |
| 4202 CHECK_EQ(42.0, result->ToNumber()->Value()); | 4202 CHECK_EQ(42.0, result->ToNumber()->Value()); |
| 4203 } | 4203 } |
| OLD | NEW |