Import Cobalt 2.13191
diff --git a/src/cobalt/build/build.id b/src/cobalt/build/build.id
index efa2c49..8616f99 100644
--- a/src/cobalt/build/build.id
+++ b/src/cobalt/build/build.id
@@ -1 +1 @@
-13114
\ No newline at end of file
+13191
\ No newline at end of file
diff --git a/src/cobalt/script/mozjs/mozjs_engine.cc b/src/cobalt/script/mozjs/mozjs_engine.cc
index 27561ab..be18f1e 100644
--- a/src/cobalt/script/mozjs/mozjs_engine.cc
+++ b/src/cobalt/script/mozjs/mozjs_engine.cc
@@ -88,7 +88,7 @@
 
 }  // namespace
 
-MozjsEngine::MozjsEngine() {
+MozjsEngine::MozjsEngine() : accumulated_extra_memory_cost_(0) {
   // TODO: Investigate the benefit of helper threads and things like
   // parallel compilation.
   runtime_ =
@@ -136,7 +136,14 @@
   JS_GC(runtime_);
 }
 
-void MozjsEngine::ReportExtraMemoryCost(size_t bytes) { NOTIMPLEMENTED(); }
+void MozjsEngine::ReportExtraMemoryCost(size_t bytes) {
+  DCHECK(thread_checker_.CalledOnValidThread());
+  accumulated_extra_memory_cost_ += bytes;
+  if (accumulated_extra_memory_cost_ > kGarbageCollectionThresholdBytes) {
+    accumulated_extra_memory_cost_ = 0;
+    CollectGarbage();
+  }
+}
 
 size_t MozjsEngine::UpdateMemoryStatsAndReturnReserved() {
   return EngineStats::GetInstance()->UpdateMemoryStatsAndReturnReserved();
@@ -162,6 +169,9 @@
 void MozjsEngine::GCCallback(JSRuntime* runtime, JSGCStatus status) {
   MozjsEngine* engine =
       static_cast<MozjsEngine*>(JS_GetRuntimePrivate(runtime));
+  if (status == JSGC_END) {
+    engine->accumulated_extra_memory_cost_ = 0;
+  }
   for (int i = 0; i < engine->contexts_.size(); ++i) {
     MozjsGlobalEnvironment* global_environment =
         MozjsGlobalEnvironment::GetFromContext(engine->contexts_[i]);
diff --git a/src/cobalt/script/mozjs/mozjs_engine.h b/src/cobalt/script/mozjs/mozjs_engine.h
index 2a86ce5..393f98d 100644
--- a/src/cobalt/script/mozjs/mozjs_engine.h
+++ b/src/cobalt/script/mozjs/mozjs_engine.h
@@ -51,6 +51,9 @@
   // A list of all contexts created for this JSRuntime.
   typedef std::vector<JSContext*> ContextVector;
   ContextVector contexts_;
+
+  // The amount of externally allocated memory since last forced GC.
+  size_t accumulated_extra_memory_cost_;
 };
 }  // namespace mozjs
 }  // namespace script