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

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

Issue 3185026: Reordered function entries in PreParse data to be ordered by start position. (Closed)
Patch Set: Added parentheses. Created 10 years, 3 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
« no previous file with comments | « src/utils.h ('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 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 8585 matching lines...) Expand 10 before | Expand all | Expand 10 after
8596 LocalContext context; 8596 LocalContext context;
8597 8597
8598 const char* script = "function foo(){ return 5;}\n" 8598 const char* script = "function foo(){ return 5;}\n"
8599 "function bar(){ return 6 + 7;} foo();"; 8599 "function bar(){ return 6 + 7;} foo();";
8600 v8::ScriptData* sd = 8600 v8::ScriptData* sd =
8601 v8::ScriptData::PreCompile(script, i::StrLength(script)); 8601 v8::ScriptData::PreCompile(script, i::StrLength(script));
8602 CHECK(!sd->HasError()); 8602 CHECK(!sd->HasError());
8603 // ScriptDataImpl private implementation details 8603 // ScriptDataImpl private implementation details
8604 const int kUnsignedSize = sizeof(unsigned); 8604 const int kUnsignedSize = sizeof(unsigned);
8605 const int kHeaderSize = 4; 8605 const int kHeaderSize = 4;
8606 const int kFunctionEntrySize = 4; 8606 const int kFunctionEntrySize = 5;
8607 const int kFunctionEntryStartOffset = 0; 8607 const int kFunctionEntryStartOffset = 0;
8608 const int kFunctionEntryEndOffset = 1; 8608 const int kFunctionEntryEndOffset = 1;
8609 unsigned* sd_data = 8609 unsigned* sd_data =
8610 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); 8610 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data()));
8611 CHECK_EQ(sd->Length(), 8611 CHECK_EQ(sd->Length(),
8612 (kHeaderSize + 2 * kFunctionEntrySize) * kUnsignedSize); 8612 (kHeaderSize + 2 * kFunctionEntrySize) * kUnsignedSize);
8613 8613
8614 // Overwrite function bar's end position with 0. 8614 // Overwrite function bar's end position with 0.
8615 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0; 8615 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0;
8616 v8::TryCatch try_catch; 8616 v8::TryCatch try_catch;
8617 8617
8618 Local<String> source = String::New(script); 8618 Local<String> source = String::New(script);
8619 Local<Script> compiled_script = Script::New(source, NULL, sd); 8619 Local<Script> compiled_script = Script::New(source, NULL, sd);
8620 CHECK(try_catch.HasCaught()); 8620 CHECK(try_catch.HasCaught());
8621 String::AsciiValue exception_value(try_catch.Message()->Get()); 8621 String::AsciiValue exception_value(try_catch.Message()->Get());
8622 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar", 8622 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar",
8623 *exception_value); 8623 *exception_value);
8624 8624
8625 try_catch.Reset(); 8625 try_catch.Reset();
8626 // Overwrite function bar's start position with 200. The function entry 8626 // Overwrite function bar's start position with 200. The function entry
8627 // will not be found when searching for it by position. 8627 // will not be found when searching for it by position.
8628 sd = v8::ScriptData::PreCompile(script, i::StrLength(script));
8629 sd_data = reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data()));
8628 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryStartOffset] = 8630 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryStartOffset] =
8629 200; 8631 200;
8630 compiled_script = Script::New(source, NULL, sd); 8632 compiled_script = Script::New(source, NULL, sd);
8631 CHECK(try_catch.HasCaught()); 8633 CHECK(try_catch.HasCaught());
8632 String::AsciiValue second_exception_value(try_catch.Message()->Get()); 8634 String::AsciiValue second_exception_value(try_catch.Message()->Get());
8633 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar", 8635 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar",
8634 *second_exception_value); 8636 *second_exception_value);
8635 8637
8636 delete sd; 8638 delete sd;
8637 } 8639 }
(...skipping 2640 matching lines...) Expand 10 before | Expand all | Expand 10 after
11278 ExpectFalse("Object.prototype.hasOwnProperty.call(other, \'0\')"); 11280 ExpectFalse("Object.prototype.hasOwnProperty.call(other, \'0\')");
11279 11281
11280 CHECK_EQ(false, global0->HasRealIndexedProperty(0)); 11282 CHECK_EQ(false, global0->HasRealIndexedProperty(0));
11281 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x"))); 11283 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x")));
11282 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x"))); 11284 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x")));
11283 11285
11284 // Reset the failed access check callback so it does not influence 11286 // Reset the failed access check callback so it does not influence
11285 // the other tests. 11287 // the other tests.
11286 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); 11288 v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
11287 } 11289 }
OLDNEW
« no previous file with comments | « src/utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698