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

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

Issue 159653005: Not for committing. Proof that NaCl stuff is insane. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: moar Created 6 years, 10 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 | « src/preparser.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 14826 matching lines...) Expand 10 before | Expand all | Expand 10 after
14837 v8::ScriptData* sd = v8::ScriptData::New(data, invalid_size); 14837 v8::ScriptData* sd = v8::ScriptData::New(data, invalid_size);
14838 14838
14839 CHECK_EQ(0, sd->Length()); 14839 CHECK_EQ(0, sd->Length());
14840 14840
14841 delete sd; 14841 delete sd;
14842 } 14842 }
14843 14843
14844 14844
14845 // Attempts to deserialize bad data. 14845 // Attempts to deserialize bad data.
14846 TEST(PreCompileInvalidPreparseDataError) { 14846 TEST(PreCompileInvalidPreparseDataError) {
14847 fprintf(stderr, "Test 1\n");
14847 v8::V8::Initialize(); 14848 v8::V8::Initialize();
14848 v8::Isolate* isolate = CcTest::isolate(); 14849 v8::Isolate* isolate = CcTest::isolate();
14849 LocalContext context; 14850 LocalContext context;
14850 v8::HandleScope scope(context->GetIsolate()); 14851 v8::HandleScope scope(context->GetIsolate());
14851 14852
14852 const char* script = "function foo(){ return 5;}\n" 14853 const char* script = "function foo(){ return 5;}\n"
14853 "function bar(){ return 6 + 7;} foo();"; 14854 "function bar(){ return 6 + 7;} foo();";
14855 fprintf(stderr, "Test 2\n");
14854 v8::ScriptData* sd = v8::ScriptData::PreCompile(v8::String::NewFromUtf8( 14856 v8::ScriptData* sd = v8::ScriptData::PreCompile(v8::String::NewFromUtf8(
14855 isolate, script, v8::String::kNormalString, i::StrLength(script))); 14857 isolate, script, v8::String::kNormalString, i::StrLength(script)));
14856 CHECK(!sd->HasError()); 14858 CHECK(!sd->HasError());
14859 fprintf(stderr, "Test 3\n");
14857 // ScriptDataImpl private implementation details 14860 // ScriptDataImpl private implementation details
14858 const int kHeaderSize = i::PreparseDataConstants::kHeaderSize; 14861 const int kHeaderSize = i::PreparseDataConstants::kHeaderSize;
14859 const int kFunctionEntrySize = i::FunctionEntry::kSize; 14862 const int kFunctionEntrySize = i::FunctionEntry::kSize;
14860 const int kFunctionEntryStartOffset = 0; 14863 const int kFunctionEntryStartOffset = 0;
14861 const int kFunctionEntryEndOffset = 1; 14864 const int kFunctionEntryEndOffset = 1;
14862 unsigned* sd_data = 14865 unsigned* sd_data =
14863 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); 14866 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data()));
14864 14867
14868 fprintf(stderr, "Test 4\n");
14865 // Overwrite function bar's end position with 0. 14869 // Overwrite function bar's end position with 0.
14866 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0; 14870 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0;
14871 fprintf(stderr, "Test 5\n");
14867 v8::TryCatch try_catch; 14872 v8::TryCatch try_catch;
14868 14873
14874 fprintf(stderr, "Test 6\n");
14869 Local<String> source = String::NewFromUtf8(isolate, script); 14875 Local<String> source = String::NewFromUtf8(isolate, script);
14876 fprintf(stderr, "Test 6b\n");
14870 Local<Script> compiled_script = Script::New(source, NULL, sd); 14877 Local<Script> compiled_script = Script::New(source, NULL, sd);
14878 fprintf(stderr, "Test 7\n");
14871 CHECK(try_catch.HasCaught()); 14879 CHECK(try_catch.HasCaught());
14872 String::Utf8Value exception_value(try_catch.Message()->Get()); 14880 String::Utf8Value exception_value(try_catch.Message()->Get());
14873 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar", 14881 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar",
14874 *exception_value); 14882 *exception_value);
14875 14883
14876 try_catch.Reset(); 14884 try_catch.Reset();
14885 fprintf(stderr, "Test 8\n");
14877 delete sd; 14886 delete sd;
14887 fprintf(stderr, "Test 9\n");
14878 14888
14879 // Overwrite function bar's start position with 200. The function entry 14889 // Overwrite function bar's start position with 200. The function entry
14880 // will not be found when searching for it by position and we should fall 14890 // will not be found when searching for it by position and we should fall
14881 // back on eager compilation. 14891 // back on eager compilation.
14882 sd = v8::ScriptData::PreCompile(v8::String::NewFromUtf8( 14892 sd = v8::ScriptData::PreCompile(v8::String::NewFromUtf8(
14883 isolate, script, v8::String::kNormalString, i::StrLength(script))); 14893 isolate, script, v8::String::kNormalString, i::StrLength(script)));
14894 fprintf(stderr, "Test 10\n");
14884 sd_data = reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); 14895 sd_data = reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data()));
14885 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryStartOffset] = 14896 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryStartOffset] =
14886 200; 14897 200;
14898 fprintf(stderr, "Test 11\n");
14887 compiled_script = Script::New(source, NULL, sd); 14899 compiled_script = Script::New(source, NULL, sd);
14888 CHECK(!try_catch.HasCaught()); 14900 CHECK(!try_catch.HasCaught());
14889 14901
14902 fprintf(stderr, "Test 12\n");
14890 delete sd; 14903 delete sd;
14904 fprintf(stderr, "Test 13\n");
14891 } 14905 }
14892 14906
14893 14907
14894 // This tests that we do not allow dictionary load/call inline caches 14908 // This tests that we do not allow dictionary load/call inline caches
14895 // to use functions that have not yet been compiled. The potential 14909 // to use functions that have not yet been compiled. The potential
14896 // problem of loading a function that has not yet been compiled can 14910 // problem of loading a function that has not yet been compiled can
14897 // arise because we share code between contexts via the compilation 14911 // arise because we share code between contexts via the compilation
14898 // cache. 14912 // cache.
14899 THREADED_TEST(DictionaryICLoadedFunction) { 14913 THREADED_TEST(DictionaryICLoadedFunction) {
14900 v8::HandleScope scope(CcTest::isolate()); 14914 v8::HandleScope scope(CcTest::isolate());
(...skipping 7057 matching lines...) Expand 10 before | Expand all | Expand 10 after
21958 21972
21959 21973
21960 TEST(TestFunctionCallOptimization) { 21974 TEST(TestFunctionCallOptimization) {
21961 i::FLAG_allow_natives_syntax = true; 21975 i::FLAG_allow_natives_syntax = true;
21962 ApiCallOptimizationChecker checker; 21976 ApiCallOptimizationChecker checker;
21963 checker.Run(true, true); 21977 checker.Run(true, true);
21964 checker.Run(false, true); 21978 checker.Run(false, true);
21965 checker.Run(true, false); 21979 checker.Run(true, false);
21966 checker.Run(false, false); 21980 checker.Run(false, false);
21967 } 21981 }
21982
21983 void DoStuff(i::Vector<const char*> args) {
21984 fprintf(stderr, "len is %d\n", args.length());
21985 }
21986
21987
21988 TEST(Foo) {
21989 const char* element[1] = { "foo" };
21990 i::Vector<const char*> args(element, 1);
21991 fprintf(stderr, "len is %d\n", args.length());
21992 DoStuff(args);
21993 CHECK(false);
21994 }
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698