| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 3be068009e275e53bb60903d812af6f841ab6069..4e4c50d965997d1681843c6c01e3aec53f5ac16d 100644
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -14816,11 +14816,12 @@ THREADED_TEST(GetHeapStatistics) {
|
|
|
| class VisitorImpl : public v8::ExternalResourceVisitor {
|
| public:
|
| - VisitorImpl(TestResource* r1, TestResource* r2)
|
| - : resource1_(r1),
|
| - resource2_(r2),
|
| - found_resource1_(false),
|
| - found_resource2_(false) {}
|
| + VisitorImpl(TestResource** resource) {
|
| + for (int i = 0; i < 4; i++) {
|
| + resource_[i] = resource[i];
|
| + found_resource_[i] = false;
|
| + }
|
| + }
|
| virtual ~VisitorImpl() {}
|
| virtual void VisitExternalString(v8::Handle<v8::String> string) {
|
| if (!string->IsExternal()) {
|
| @@ -14830,25 +14831,22 @@ class VisitorImpl : public v8::ExternalResourceVisitor {
|
| v8::String::ExternalStringResource* resource =
|
| string->GetExternalStringResource();
|
| CHECK(resource);
|
| - if (resource1_ == resource) {
|
| - CHECK(!found_resource1_);
|
| - found_resource1_ = true;
|
| - }
|
| - if (resource2_ == resource) {
|
| - CHECK(!found_resource2_);
|
| - found_resource2_ = true;
|
| + for (int i = 0; i < 4; i++) {
|
| + if (resource_[i] == resource) {
|
| + CHECK(!found_resource_[i]);
|
| + found_resource_[i] = true;
|
| + }
|
| }
|
| }
|
| void CheckVisitedResources() {
|
| - CHECK(found_resource1_);
|
| - CHECK(found_resource2_);
|
| + for (int i = 0; i < 4; i++) {
|
| + CHECK(found_resource_[i]);
|
| + }
|
| }
|
|
|
| private:
|
| - v8::String::ExternalStringResource* resource1_;
|
| - v8::String::ExternalStringResource* resource2_;
|
| - bool found_resource1_;
|
| - bool found_resource2_;
|
| + v8::String::ExternalStringResource* resource_[4];
|
| + bool found_resource_[4];
|
| };
|
|
|
| TEST(VisitExternalStrings) {
|
| @@ -14856,16 +14854,33 @@ TEST(VisitExternalStrings) {
|
| LocalContext env;
|
| const char* string = "Some string";
|
| uint16_t* two_byte_string = AsciiToTwoByteString(string);
|
| - TestResource* resource1 = new TestResource(two_byte_string);
|
| - v8::Local<v8::String> string1 = v8::String::NewExternal(resource1);
|
| - TestResource* resource2 = new TestResource(two_byte_string);
|
| - v8::Local<v8::String> string2 = v8::String::NewExternal(resource2);
|
| -
|
| - // We need to add usages for string1 and string2 to avoid warnings in GCC 4.7
|
| + TestResource* resource[4];
|
| + resource[0] = new TestResource(two_byte_string);
|
| + v8::Local<v8::String> string0 = v8::String::NewExternal(resource[0]);
|
| + resource[1] = new TestResource(two_byte_string);
|
| + v8::Local<v8::String> string1 = v8::String::NewExternal(resource[1]);
|
| +
|
| + // Externalized symbol.
|
| + resource[2] = new TestResource(two_byte_string);
|
| + v8::Local<v8::String> string2 = v8::String::NewSymbol(string);
|
| + CHECK(string2->MakeExternal(resource[2]));
|
| +
|
| + // Symbolized External.
|
| + resource[3] = new TestResource(AsciiToTwoByteString("Some other string"));
|
| + v8::Local<v8::String> string3 = v8::String::NewExternal(resource[3]);
|
| + HEAP->CollectAllAvailableGarbage(); // Tenure string.
|
| + // Turn into a symbol.
|
| + i::Handle<i::String> string3_i = v8::Utils::OpenHandle(*string3);
|
| + CHECK(!HEAP->LookupSymbol(*string3_i)->IsFailure());
|
| + CHECK(string3_i->IsSymbol());
|
| +
|
| + // We need to add usages for string* to avoid warnings in GCC 4.7
|
| + CHECK(string0->IsExternal());
|
| CHECK(string1->IsExternal());
|
| CHECK(string2->IsExternal());
|
| + CHECK(string3->IsExternal());
|
|
|
| - VisitorImpl visitor(resource1, resource2);
|
| + VisitorImpl visitor(resource);
|
| v8::V8::VisitExternalResources(&visitor);
|
| visitor.CheckVisitedResources();
|
| }
|
|
|