OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 | 2 |
3 // Check that we can traverse very deep stacks of ConsStrings using | 3 // Check that we can traverse very deep stacks of ConsStrings using |
4 // StringCharacterStram. Check that Get(int) works on very deep stacks | 4 // StringCharacterStram. Check that Get(int) works on very deep stacks |
5 // of ConsStrings. These operations may not be very fast, but they | 5 // of ConsStrings. These operations may not be very fast, but they |
6 // should be possible without getting errors due to too deep recursion. | 6 // should be possible without getting errors due to too deep recursion. |
7 | 7 |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include "v8.h" | 10 #include "v8.h" |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 "};" | 993 "};" |
994 "test()"; | 994 "test()"; |
995 CHECK_EQ(0, CompileRun(source)->Int32Value()); | 995 CHECK_EQ(0, CompileRun(source)->Int32Value()); |
996 } | 996 } |
997 | 997 |
998 | 998 |
999 TEST(CachedHashOverflow) { | 999 TEST(CachedHashOverflow) { |
1000 // We incorrectly allowed strings to be tagged as array indices even if their | 1000 // We incorrectly allowed strings to be tagged as array indices even if their |
1001 // values didn't fit in the hash field. | 1001 // values didn't fit in the hash field. |
1002 // See http://code.google.com/p/v8/issues/detail?id=728 | 1002 // See http://code.google.com/p/v8/issues/detail?id=728 |
1003 ZoneScope zone(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT); | 1003 Isolate* isolate = Isolate::Current(); |
| 1004 ZoneScope zone(isolate->runtime_zone(), DELETE_ON_EXIT); |
1004 | 1005 |
1005 InitializeVM(); | 1006 InitializeVM(); |
1006 v8::HandleScope handle_scope; | 1007 v8::HandleScope handle_scope; |
1007 // Lines must be executed sequentially. Combining them into one script | 1008 // Lines must be executed sequentially. Combining them into one script |
1008 // makes the bug go away. | 1009 // makes the bug go away. |
1009 const char* lines[] = { | 1010 const char* lines[] = { |
1010 "var x = [];", | 1011 "var x = [];", |
1011 "x[4] = 42;", | 1012 "x[4] = 42;", |
1012 "var s = \"1073741828\";", | 1013 "var s = \"1073741828\";", |
1013 "x[s];", | 1014 "x[s];", |
1014 "x[s] = 37;", | 1015 "x[s] = 37;", |
1015 "x[4];", | 1016 "x[4];", |
1016 "x[s];", | 1017 "x[s];", |
1017 NULL | 1018 NULL |
1018 }; | 1019 }; |
1019 | 1020 |
1020 Handle<Smi> fortytwo(Smi::FromInt(42)); | 1021 Handle<Smi> fortytwo(Smi::FromInt(42), isolate); |
1021 Handle<Smi> thirtyseven(Smi::FromInt(37)); | 1022 Handle<Smi> thirtyseven(Smi::FromInt(37), isolate); |
1022 Handle<Object> results[] = { | 1023 Handle<Object> results[] = { isolate->factory()->undefined_value(), |
1023 FACTORY->undefined_value(), | 1024 fortytwo, |
1024 fortytwo, | 1025 isolate->factory()->undefined_value(), |
1025 FACTORY->undefined_value(), | 1026 isolate->factory()->undefined_value(), |
1026 FACTORY->undefined_value(), | 1027 thirtyseven, |
1027 thirtyseven, | 1028 fortytwo, |
1028 fortytwo, | 1029 thirtyseven // Bug yielded 42 here. |
1029 thirtyseven // Bug yielded 42 here. | |
1030 }; | 1030 }; |
1031 | 1031 |
1032 const char* line; | 1032 const char* line; |
1033 for (int i = 0; (line = lines[i]); i++) { | 1033 for (int i = 0; (line = lines[i]); i++) { |
1034 printf("%s\n", line); | 1034 printf("%s\n", line); |
1035 v8::Local<v8::Value> result = | 1035 v8::Local<v8::Value> result = |
1036 v8::Script::Compile(v8::String::New(line))->Run(); | 1036 v8::Script::Compile(v8::String::New(line))->Run(); |
1037 CHECK_EQ(results[i]->IsUndefined(), result->IsUndefined()); | 1037 CHECK_EQ(results[i]->IsUndefined(), result->IsUndefined()); |
1038 CHECK_EQ(results[i]->IsNumber(), result->IsNumber()); | 1038 CHECK_EQ(results[i]->IsNumber(), result->IsNumber()); |
1039 if (result->IsNumber()) { | 1039 if (result->IsNumber()) { |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 continue; | 1326 continue; |
1327 } | 1327 } |
1328 if (upper != c && lower != c) { | 1328 if (upper != c && lower != c) { |
1329 CheckCanonicalEquivalence(c, test); | 1329 CheckCanonicalEquivalence(c, test); |
1330 continue; | 1330 continue; |
1331 } | 1331 } |
1332 CHECK_EQ(Min(upper, lower), test); | 1332 CHECK_EQ(Min(upper, lower), test); |
1333 } | 1333 } |
1334 } | 1334 } |
1335 #endif // ENABLE_LATIN_1 | 1335 #endif // ENABLE_LATIN_1 |
OLD | NEW |