Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: src/d8.cc

Issue 2697723004: Make regress-crbug-514081 less flaky by having max serialization size (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 09cd9631b03b1feb16804001aeac04040ebecc90..8facb20b8fdb9c37d171855dd78c0eb3685fcdc9 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -66,6 +66,7 @@ namespace {
const int MB = 1024 * 1024;
const int kMaxWorkers = 50;
+const int kMaxSerializerMemoryUsage = 1 * MB; // Arbitrary maximum for testing.
#define USE_VM 1
#define VM_THRESHOLD 65536
@@ -2471,7 +2472,6 @@ bool Shell::SetOptions(int argc, char* argv[]) {
argv[i] = NULL;
} else if (strncmp(argv[i], "--lcov=", 7) == 0) {
options.lcov_file = argv[i] + 7;
- argv[i] = NULL;
Yang 2017/02/16 07:59:32 Accidental change?
binji 2017/02/17 00:49:13 Oops, fixed.
}
}
@@ -2571,7 +2571,9 @@ void Shell::EmptyMessageQueues(Isolate* isolate) {
class Serializer : public ValueSerializer::Delegate {
public:
explicit Serializer(Isolate* isolate)
- : isolate_(isolate), serializer_(isolate, this) {}
+ : isolate_(isolate),
+ serializer_(isolate, this),
+ current_memory_usage_(0) {}
Maybe<bool> WriteValue(Local<Context> context, Local<Value> value,
Local<Value> transfer) {
@@ -2622,6 +2624,11 @@ class Serializer : public ValueSerializer::Delegate {
void* ReallocateBufferMemory(void* old_buffer, size_t size,
size_t* actual_size) override {
+ // Not accurate, because we don't take into account reallocated buffers,
+ // but this is fine for testing.
+ current_memory_usage_ += size;
+ if (current_memory_usage_ > kMaxSerializerMemoryUsage) return nullptr;
+
void* result = realloc(old_buffer, size);
*actual_size = result ? size : 0;
return result;
@@ -2699,6 +2706,7 @@ class Serializer : public ValueSerializer::Delegate {
std::unique_ptr<SerializationData> data_;
std::vector<Global<ArrayBuffer>> array_buffers_;
std::vector<Global<SharedArrayBuffer>> shared_array_buffers_;
+ size_t current_memory_usage_;
DISALLOW_COPY_AND_ASSIGN(Serializer);
};
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698