| OLD | NEW |
| 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 8563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8574 const int kFunctionEntrySize = 4; | 8574 const int kFunctionEntrySize = 4; |
| 8575 const int kFunctionEntryStartOffset = 0; | 8575 const int kFunctionEntryStartOffset = 0; |
| 8576 const int kFunctionEntryEndOffset = 1; | 8576 const int kFunctionEntryEndOffset = 1; |
| 8577 unsigned* sd_data = | 8577 unsigned* sd_data = |
| 8578 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); | 8578 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); |
| 8579 CHECK_EQ(sd->Length(), | 8579 CHECK_EQ(sd->Length(), |
| 8580 (kHeaderSize + 2 * kFunctionEntrySize) * kUnsignedSize); | 8580 (kHeaderSize + 2 * kFunctionEntrySize) * kUnsignedSize); |
| 8581 | 8581 |
| 8582 // Overwrite function bar's end position with 0. | 8582 // Overwrite function bar's end position with 0. |
| 8583 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0; | 8583 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0; |
| 8584 v8::TryCatch try_catch; |
| 8585 |
| 8584 Local<String> source = String::New(script); | 8586 Local<String> source = String::New(script); |
| 8585 Local<Script> compiled_script = Script::New(source, NULL, sd); | 8587 Local<Script> compiled_script = Script::New(source, NULL, sd); |
| 8588 CHECK(try_catch.HasCaught()); |
| 8589 String::AsciiValue exception_value(try_catch.Message()->Get()); |
| 8590 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar", |
| 8591 *exception_value); |
| 8586 | 8592 |
| 8593 try_catch.Reset(); |
| 8587 // Overwrite function bar's start position with 200. The function entry | 8594 // Overwrite function bar's start position with 200. The function entry |
| 8588 // will not be found when searching for it by position. | 8595 // will not be found when searching for it by position. |
| 8589 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryStartOffset] = | 8596 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryStartOffset] = |
| 8590 200; | 8597 200; |
| 8591 compiled_script = Script::New(source, NULL, sd); | 8598 compiled_script = Script::New(source, NULL, sd); |
| 8599 CHECK(try_catch.HasCaught()); |
| 8600 String::AsciiValue second_exception_value(try_catch.Message()->Get()); |
| 8601 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar", |
| 8602 *second_exception_value); |
| 8592 | 8603 |
| 8593 delete sd; | 8604 delete sd; |
| 8594 } | 8605 } |
| 8595 | 8606 |
| 8596 | 8607 |
| 8597 // Verifies that the Handle<String> and const char* versions of the API produce | 8608 // Verifies that the Handle<String> and const char* versions of the API produce |
| 8598 // the same results (at least for one trivial case). | 8609 // the same results (at least for one trivial case). |
| 8599 TEST(PreCompileAPIVariationsAreSame) { | 8610 TEST(PreCompileAPIVariationsAreSame) { |
| 8600 v8::V8::Initialize(); | 8611 v8::V8::Initialize(); |
| 8601 v8::HandleScope scope; | 8612 v8::HandleScope scope; |
| (...skipping 2499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11101 | 11112 |
| 11102 ExpectString("str2.substring(2, 10);", "elspenda"); | 11113 ExpectString("str2.substring(2, 10);", "elspenda"); |
| 11103 | 11114 |
| 11104 ExpectString("str2.substring(2, 20);", "elspendabelabelspe"); | 11115 ExpectString("str2.substring(2, 20);", "elspendabelabelspe"); |
| 11105 | 11116 |
| 11106 ExpectString("str2.charAt(2);", "e"); | 11117 ExpectString("str2.charAt(2);", "e"); |
| 11107 | 11118 |
| 11108 reresult = CompileRun("str2.charCodeAt(2);"); | 11119 reresult = CompileRun("str2.charCodeAt(2);"); |
| 11109 CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value()); | 11120 CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value()); |
| 11110 } | 11121 } |
| OLD | NEW |