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

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

Issue 12729023: first step to remove unsafe handles (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: issue with debug build Created 7 years, 7 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-mark-compact.cc ('k') | test/cctest/test-profile-generator.cc » ('j') | 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <string.h> 30 #include <string.h>
31 31
32 // TODO(dcarney): remove
33 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
34
32 #include "v8.h" 35 #include "v8.h"
33 36
34 #include "cctest.h" 37 #include "cctest.h"
35 #include "compiler.h" 38 #include "compiler.h"
36 #include "execution.h" 39 #include "execution.h"
37 #include "isolate.h" 40 #include "isolate.h"
38 #include "parser.h" 41 #include "parser.h"
39 #include "preparser.h" 42 #include "preparser.h"
40 #include "scanner-character-streams.h" 43 #include "scanner-character-streams.h"
41 #include "token.h" 44 #include "token.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 171
169 private: 172 private:
170 const char* data_; 173 const char* data_;
171 size_t length_; 174 size_t length_;
172 }; 175 };
173 176
174 177
175 TEST(Preparsing) { 178 TEST(Preparsing) {
176 v8::HandleScope handles(v8::Isolate::GetCurrent()); 179 v8::HandleScope handles(v8::Isolate::GetCurrent());
177 v8::Persistent<v8::Context> context = v8::Context::New(); 180 v8::Persistent<v8::Context> context = v8::Context::New();
178 v8::Context::Scope context_scope(context); 181 v8::Context::Scope context_scope(v8::Isolate::GetCurrent(), context);
179 int marker; 182 int marker;
180 i::Isolate::Current()->stack_guard()->SetStackLimit( 183 i::Isolate::Current()->stack_guard()->SetStackLimit(
181 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 184 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
182 185
183 // Source containing functions that might be lazily compiled and all types 186 // Source containing functions that might be lazily compiled and all types
184 // of symbols (string, propertyName, regexp). 187 // of symbols (string, propertyName, regexp).
185 const char* source = 188 const char* source =
186 "var x = 42;" 189 "var x = 42;"
187 "function foo(a) { return function nolazy(b) { return a + b; } }" 190 "function foo(a) { return function nolazy(b) { return a + b; } }"
188 "function bar(a) { if (a) return function lazy(b) { return b; } }" 191 "function bar(a) { if (a) return function lazy(b) { return b; } }"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 int32_t c3 = utf8_stream.Advance(); 537 int32_t c3 = utf8_stream.Advance();
535 CHECK_LT(c1, 0); 538 CHECK_LT(c1, 0);
536 CHECK_LT(c2, 0); 539 CHECK_LT(c2, 0);
537 CHECK_LT(c3, 0); 540 CHECK_LT(c3, 0);
538 } 541 }
539 542
540 543
541 TEST(CharacterStreams) { 544 TEST(CharacterStreams) {
542 v8::HandleScope handles(v8::Isolate::GetCurrent()); 545 v8::HandleScope handles(v8::Isolate::GetCurrent());
543 v8::Persistent<v8::Context> context = v8::Context::New(); 546 v8::Persistent<v8::Context> context = v8::Context::New();
544 v8::Context::Scope context_scope(context); 547 v8::Context::Scope context_scope(v8::Isolate::GetCurrent(), context);
545 548
546 TestCharacterStream("abc\0\n\r\x7f", 7); 549 TestCharacterStream("abc\0\n\r\x7f", 7);
547 static const unsigned kBigStringSize = 4096; 550 static const unsigned kBigStringSize = 4096;
548 char buffer[kBigStringSize + 1]; 551 char buffer[kBigStringSize + 1];
549 for (unsigned i = 0; i < kBigStringSize; i++) { 552 for (unsigned i = 0; i < kBigStringSize; i++) {
550 buffer[i] = static_cast<char>(i & 0x7f); 553 buffer[i] = static_cast<char>(i & 0x7f);
551 } 554 }
552 TestCharacterStream(buffer, kBigStringSize); 555 TestCharacterStream(buffer, kBigStringSize);
553 556
554 TestCharacterStream(buffer, kBigStringSize, 576, 3298); 557 TestCharacterStream(buffer, kBigStringSize, 576, 3298);
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 { " 'foo';\n" 980 { " 'foo';\n"
978 " (function fun", "(a,b) { 'bar\355\240\201\355\260\213'; }", ")();", 981 " (function fun", "(a,b) { 'bar\355\240\201\355\260\213'; }", ")();",
979 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, 982 i::FUNCTION_SCOPE, i::CLASSIC_MODE },
980 { " 'foo';\n" 983 { " 'foo';\n"
981 " (function fun", "(a,b) { 'bar\360\220\220\214'; }", ")();", 984 " (function fun", "(a,b) { 'bar\360\220\220\214'; }", ")();",
982 i::FUNCTION_SCOPE, i::CLASSIC_MODE }, 985 i::FUNCTION_SCOPE, i::CLASSIC_MODE },
983 { NULL, NULL, NULL, i::EVAL_SCOPE, i::CLASSIC_MODE } 986 { NULL, NULL, NULL, i::EVAL_SCOPE, i::CLASSIC_MODE }
984 }; 987 };
985 988
986 v8::HandleScope handles(v8::Isolate::GetCurrent()); 989 v8::HandleScope handles(v8::Isolate::GetCurrent());
987 v8::Persistent<v8::Context> context = v8::Context::New(); 990 v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent());
988 v8::Context::Scope context_scope(context); 991 v8::Context::Scope context_scope(context);
989 992
990 int marker; 993 int marker;
991 i::Isolate::Current()->stack_guard()->SetStackLimit( 994 i::Isolate::Current()->stack_guard()->SetStackLimit(
992 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 995 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
993 996
994 for (int i = 0; source_data[i].outer_prefix; i++) { 997 for (int i = 0; source_data[i].outer_prefix; i++) {
995 int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix); 998 int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix);
996 int kInnerLen = Utf8LengthHelper(source_data[i].inner_source); 999 int kInnerLen = Utf8LengthHelper(source_data[i].inner_source);
997 int kSuffixLen = Utf8LengthHelper(source_data[i].outer_suffix); 1000 int kSuffixLen = Utf8LengthHelper(source_data[i].outer_suffix);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 ";\n", 1239 ";\n",
1237 "\n;", 1240 "\n;",
1238 NULL 1241 NULL
1239 }; 1242 };
1240 1243
1241 // TODO(mstarzinger): Disabled in GC stress mode for now, we should find the 1244 // TODO(mstarzinger): Disabled in GC stress mode for now, we should find the
1242 // correct timeout for this and re-enable this test again. 1245 // correct timeout for this and re-enable this test again.
1243 if (i::FLAG_stress_compaction) return; 1246 if (i::FLAG_stress_compaction) return;
1244 1247
1245 v8::HandleScope handles(v8::Isolate::GetCurrent()); 1248 v8::HandleScope handles(v8::Isolate::GetCurrent());
1246 v8::Persistent<v8::Context> context = v8::Context::New(); 1249 v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent());
1247 v8::Context::Scope context_scope(context); 1250 v8::Context::Scope context_scope(context);
1248 1251
1249 int marker; 1252 int marker;
1250 i::Isolate::Current()->stack_guard()->SetStackLimit( 1253 i::Isolate::Current()->stack_guard()->SetStackLimit(
1251 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 1254 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
1252 1255
1253 for (int i = 0; context_data[i][0] != NULL; ++i) { 1256 for (int i = 0; context_data[i][0] != NULL; ++i) {
1254 for (int j = 0; statement_data[j] != NULL; ++j) { 1257 for (int j = 0; statement_data[j] != NULL; ++j) {
1255 for (int k = 0; termination_data[k] != NULL; ++k) { 1258 for (int k = 0; termination_data[k] != NULL; ++k) {
1256 int kPrefixLen = i::StrLength(context_data[i][0]); 1259 int kPrefixLen = i::StrLength(context_data[i][0]);
(...skipping 20 matching lines...) Expand all
1277 } 1280 }
1278 } 1281 }
1279 1282
1280 1283
1281 TEST(PreparserStrictOctal) { 1284 TEST(PreparserStrictOctal) {
1282 // Test that syntax error caused by octal literal is reported correctly as 1285 // Test that syntax error caused by octal literal is reported correctly as
1283 // such (issue 2220). 1286 // such (issue 2220).
1284 v8::internal::FLAG_min_preparse_length = 1; // Force preparsing. 1287 v8::internal::FLAG_min_preparse_length = 1; // Force preparsing.
1285 v8::V8::Initialize(); 1288 v8::V8::Initialize();
1286 v8::HandleScope scope(v8::Isolate::GetCurrent()); 1289 v8::HandleScope scope(v8::Isolate::GetCurrent());
1287 v8::Context::Scope context_scope(v8::Context::New()); 1290 v8::Context::Scope context_scope(
1291 v8::Context::New(v8::Isolate::GetCurrent()));
1288 v8::TryCatch try_catch; 1292 v8::TryCatch try_catch;
1289 const char* script = 1293 const char* script =
1290 "\"use strict\"; \n" 1294 "\"use strict\"; \n"
1291 "a = function() { \n" 1295 "a = function() { \n"
1292 " b = function() { \n" 1296 " b = function() { \n"
1293 " 01; \n" 1297 " 01; \n"
1294 " }; \n" 1298 " }; \n"
1295 "}; \n"; 1299 "}; \n";
1296 v8::Script::Compile(v8::String::New(script)); 1300 v8::Script::Compile(v8::String::New(script));
1297 CHECK(try_catch.HasCaught()); 1301 CHECK(try_catch.HasCaught());
1298 v8::String::Utf8Value exception(try_catch.Exception()); 1302 v8::String::Utf8Value exception(try_catch.Exception());
1299 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", 1303 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.",
1300 *exception); 1304 *exception);
1301 } 1305 }
OLDNEW
« no previous file with comments | « test/cctest/test-mark-compact.cc ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698