Revision: 18971
Author: [email protected]
Date: Fri Jan 31 07:29:25 2014 UTC
Log: Fixed a few lifetime/ownership issues in cctest/test-api.
* Fixed CompileExternalTwoByteSource: Registered resources should
better still be alive when they are accessed.
* Fixed ownership in cctest/test-api/VisitExternalStrings.
[email protected]
Review URL: https://codereview.chromium.org/139923003
http://code.google.com/p/v8/source/detail?r=18971
Modified:
/branches/bleeding_edge/test/cctest/cctest.cc
/branches/bleeding_edge/test/cctest/cctest.h
/branches/bleeding_edge/test/cctest/test-api.cc
=======================================
--- /branches/bleeding_edge/test/cctest/cctest.cc Fri Jan 17 10:52:00 2014
UTC
+++ /branches/bleeding_edge/test/cctest/cctest.cc Fri Jan 31 07:29:25 2014
UTC
@@ -199,6 +199,7 @@
}
if (print_run_count && tests_run != 1)
printf("Ran %i tests.\n", tests_run);
+ CcTest::TearDown();
if (!disable_automatic_dispose_) v8::V8::Dispose();
return 0;
}
=======================================
--- /branches/bleeding_edge/test/cctest/cctest.h Fri Jan 17 10:52:00 2014
UTC
+++ /branches/bleeding_edge/test/cctest/cctest.h Fri Jan 31 07:29:25 2014
UTC
@@ -130,6 +130,11 @@
CcTestExtensionFlags extensions,
v8::Isolate* isolate = CcTest::isolate());
+ static void TearDown() {
+ // TODO(svenpanne) Enable this when our cctests are fixed.
+ // if (isolate_ != NULL) isolate_->Dispose();
+ }
+
private:
friend int main(int argc, char** argv);
TestFunction* callback_;
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Thu Jan 30 13:18:41
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-api.cc Fri Jan 31 07:29:25
2014 UTC
@@ -462,13 +462,13 @@
class TestResource: public String::ExternalStringResource {
public:
- explicit TestResource(uint16_t* data, int* counter = NULL)
- : data_(data), length_(0), counter_(counter) {
+ TestResource(uint16_t* data, int* counter = NULL, bool owning_data =
true)
+ : data_(data), length_(0), counter_(counter),
owning_data_(owning_data) {
while (data[length_]) ++length_;
}
~TestResource() {
- i::DeleteArray(data_);
+ if (owning_data_) i::DeleteArray(data_);
if (counter_ != NULL) ++*counter_;
}
@@ -479,10 +479,12 @@
size_t length() const {
return length_;
}
+
private:
uint16_t* data_;
size_t length_;
int* counter_;
+ bool owning_data_;
};
@@ -15218,13 +15220,10 @@
// Compile the sources as external two byte strings.
for (int i = 0; ascii_sources[i] != NULL; i++) {
uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]);
- UC16VectorResource uc16_resource(
- i::Vector<const uint16_t>(two_byte_string,
- i::StrLength(ascii_sources[i])));
+ TestResource* uc16_resource = new TestResource(two_byte_string);
v8::Local<v8::String> source =
- v8::String::NewExternal(context->GetIsolate(), &uc16_resource);
+ v8::String::NewExternal(context->GetIsolate(), uc16_resource);
v8::Script::Compile(source);
- i::DeleteArray(two_byte_string);
}
}
@@ -17871,12 +17870,12 @@
resource[0] = new TestResource(two_byte_string);
v8::Local<v8::String> string0 =
v8::String::NewExternal(env->GetIsolate(), resource[0]);
- resource[1] = new TestResource(two_byte_string);
+ resource[1] = new TestResource(two_byte_string, NULL, false);
v8::Local<v8::String> string1 =
v8::String::NewExternal(env->GetIsolate(), resource[1]);
// Externalized symbol.
- resource[2] = new TestResource(two_byte_string);
+ resource[2] = new TestResource(two_byte_string, NULL, false);
v8::Local<v8::String> string2 = v8::String::NewFromUtf8(
env->GetIsolate(), string, v8::String::kInternalizedString);
CHECK(string2->MakeExternal(resource[2]));
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.