| 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 17170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17181 CHECK(string1->IsExternal()); | 17181 CHECK(string1->IsExternal()); |
| 17182 CHECK(string2->IsExternal()); | 17182 CHECK(string2->IsExternal()); |
| 17183 CHECK(string3->IsExternal()); | 17183 CHECK(string3->IsExternal()); |
| 17184 | 17184 |
| 17185 VisitorImpl visitor(resource); | 17185 VisitorImpl visitor(resource); |
| 17186 v8::V8::VisitExternalResources(&visitor); | 17186 v8::V8::VisitExternalResources(&visitor); |
| 17187 visitor.CheckVisitedResources(); | 17187 visitor.CheckVisitedResources(); |
| 17188 } | 17188 } |
| 17189 | 17189 |
| 17190 | 17190 |
| 17191 TEST(ExternalStringCollectedAtTearDown) { |
| 17192 int destroyed = 0; |
| 17193 v8::Isolate* isolate = v8::Isolate::New(); |
| 17194 { v8::Isolate::Scope isolate_scope(isolate); |
| 17195 v8::HandleScope handle_scope(isolate); |
| 17196 const char* s = "One string to test them all, one string to find them."; |
| 17197 TestAsciiResource* inscription = |
| 17198 new TestAsciiResource(i::StrDup(s), &destroyed); |
| 17199 v8::Local<v8::String> ring = v8::String::NewExternal(inscription); |
| 17200 // Ring is still alive. Orcs are roaming freely across our lands. |
| 17201 CHECK_EQ(0, destroyed); |
| 17202 USE(ring); |
| 17203 } |
| 17204 |
| 17205 isolate->Dispose(); |
| 17206 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice. |
| 17207 CHECK_EQ(1, destroyed); |
| 17208 } |
| 17209 |
| 17210 |
| 17191 static double DoubleFromBits(uint64_t value) { | 17211 static double DoubleFromBits(uint64_t value) { |
| 17192 double target; | 17212 double target; |
| 17193 i::OS::MemCopy(&target, &value, sizeof(target)); | 17213 i::OS::MemCopy(&target, &value, sizeof(target)); |
| 17194 return target; | 17214 return target; |
| 17195 } | 17215 } |
| 17196 | 17216 |
| 17197 | 17217 |
| 17198 static uint64_t DoubleToBits(double value) { | 17218 static uint64_t DoubleToBits(double value) { |
| 17199 uint64_t target; | 17219 uint64_t target; |
| 17200 i::OS::MemCopy(&target, &value, sizeof(target)); | 17220 i::OS::MemCopy(&target, &value, sizeof(target)); |
| (...skipping 3510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20711 } | 20731 } |
| 20712 for (int i = 0; i < runs; i++) { | 20732 for (int i = 0; i < runs; i++) { |
| 20713 Local<String> expected; | 20733 Local<String> expected; |
| 20714 if (i != 0) { | 20734 if (i != 0) { |
| 20715 CHECK_EQ(v8_str("escape value"), values[i]); | 20735 CHECK_EQ(v8_str("escape value"), values[i]); |
| 20716 } else { | 20736 } else { |
| 20717 CHECK(values[i].IsEmpty()); | 20737 CHECK(values[i].IsEmpty()); |
| 20718 } | 20738 } |
| 20719 } | 20739 } |
| 20720 } | 20740 } |
| OLD | NEW |