OLD | NEW |
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 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 explicit OneByteVectorResource(i::Vector<const char> vector) | 1189 explicit OneByteVectorResource(i::Vector<const char> vector) |
1190 : data_(vector) {} | 1190 : data_(vector) {} |
1191 virtual ~OneByteVectorResource() {} | 1191 virtual ~OneByteVectorResource() {} |
1192 virtual size_t length() const { return data_.length(); } | 1192 virtual size_t length() const { return data_.length(); } |
1193 virtual const char* data() const { return data_.start(); } | 1193 virtual const char* data() const { return data_.start(); } |
1194 private: | 1194 private: |
1195 i::Vector<const char> data_; | 1195 i::Vector<const char> data_; |
1196 }; | 1196 }; |
1197 | 1197 |
1198 TEST(InternalizeExternal) { | 1198 TEST(InternalizeExternal) { |
| 1199 FLAG_thin_strings = true; |
| 1200 CcTest::InitializeVM(); |
1199 i::Isolate* isolate = CcTest::i_isolate(); | 1201 i::Isolate* isolate = CcTest::i_isolate(); |
1200 Factory* factory = isolate->factory(); | 1202 Factory* factory = isolate->factory(); |
1201 // This won't leak; the external string mechanism will call Dispose() on it. | 1203 // This won't leak; the external string mechanism will call Dispose() on it. |
1202 OneByteVectorResource* resource = | 1204 OneByteVectorResource* resource = |
1203 new OneByteVectorResource(i::Vector<const char>("prop", 4)); | 1205 new OneByteVectorResource(i::Vector<const char>("prop", 4)); |
1204 { | 1206 { |
1205 v8::HandleScope scope(CcTest::isolate()); | 1207 v8::HandleScope scope(CcTest::isolate()); |
1206 v8::Local<v8::String> ext_string = | 1208 v8::Local<v8::String> ext_string = |
1207 v8::String::NewExternalOneByte(CcTest::isolate(), resource) | 1209 v8::String::NewExternalOneByte(CcTest::isolate(), resource) |
1208 .ToLocalChecked(); | 1210 .ToLocalChecked(); |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 CHECK_EQ(1, CompileRun("external.indexOf('', 1)") | 1664 CHECK_EQ(1, CompileRun("external.indexOf('', 1)") |
1663 ->Int32Value(context.local()) | 1665 ->Int32Value(context.local()) |
1664 .FromJust()); | 1666 .FromJust()); |
1665 CHECK_EQ(-1, CompileRun("external.indexOf('a', 1)") | 1667 CHECK_EQ(-1, CompileRun("external.indexOf('a', 1)") |
1666 ->Int32Value(context.local()) | 1668 ->Int32Value(context.local()) |
1667 .FromJust()); | 1669 .FromJust()); |
1668 CHECK_EQ(-1, CompileRun("external.indexOf('$')") | 1670 CHECK_EQ(-1, CompileRun("external.indexOf('$')") |
1669 ->Int32Value(context.local()) | 1671 ->Int32Value(context.local()) |
1670 .FromJust()); | 1672 .FromJust()); |
1671 } | 1673 } |
OLD | NEW |