[json] Remove pretenuring based on json source size

It's not necessarily helpful, and can actually cause pretty bad performance and
memory usage.

I moved up the next_ field to where allocation_ used to be since apparently the
alignment caused by it has huge impact on perf (>10% diff...) at least on my
machine.

Change-Id: I1026a2e954d061b1a178f6a733d8ef81ae6d0cab
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1594432
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61250}
diff --git a/src/json-parser.cc b/src/json-parser.cc
index 3369912..efe9dff 100644
--- a/src/json-parser.cc
+++ b/src/json-parser.cc
@@ -262,10 +262,6 @@
   }
   cursor_ = chars_ + start;
   end_ = cursor_ + length;
-
-  allocation_ = (source->length() >= kPretenureTreshold)
-                    ? AllocationType::kOld
-                    : AllocationType::kYoung;
 }
 
 template <typename Char>
@@ -453,8 +449,7 @@
 template <typename Char>
 Handle<Object> JsonParser<Char>::ParseJsonObject() {
   HandleScope scope(isolate());
-  Handle<JSObject> json_object =
-      factory()->NewJSObject(object_constructor(), allocation_);
+  Handle<JSObject> json_object = factory()->NewJSObject(object_constructor());
   Handle<Map> map(json_object->map(), isolate());
   int descriptor = 0;
   VectorSegment<ZoneVector<Handle<Object>>> properties(&properties_);
@@ -643,19 +638,18 @@
   switch (kind) {
     case PACKED_ELEMENTS:
     case PACKED_SMI_ELEMENTS: {
-      Handle<FixedArray> elems =
-          factory()->NewFixedArray(elements_size, allocation_);
+      Handle<FixedArray> elems = factory()->NewFixedArray(elements_size);
       for (int i = 0; i < elements_size; i++) elems->set(i, *elements[i]);
-      json_array = factory()->NewJSArrayWithElements(elems, kind, allocation_);
+      json_array = factory()->NewJSArrayWithElements(elems, kind);
       break;
     }
     case PACKED_DOUBLE_ELEMENTS: {
       Handle<FixedDoubleArray> elems = Handle<FixedDoubleArray>::cast(
-          factory()->NewFixedDoubleArray(elements_size, allocation_));
+          factory()->NewFixedDoubleArray(elements_size));
       for (int i = 0; i < elements_size; i++) {
         elems->set(i, elements[i]->Number());
       }
-      json_array = factory()->NewJSArrayWithElements(elems, kind, allocation_);
+      json_array = factory()->NewJSArrayWithElements(elems, kind);
       break;
     }
     default:
@@ -757,7 +751,7 @@
     DCHECK(!std::isnan(number));
   }
 
-  return factory()->NewNumber(number, allocation_);
+  return factory()->NewNumber(number);
 }
 
 namespace {
@@ -810,12 +804,11 @@
       chars.length() > kMaxInternalizedStringValueLength) {
     if (sizeof(LiteralChar) == 1) {
       return factory()
-          ->NewStringFromOneByte(Vector<const uint8_t>::cast(chars),
-                                 allocation_)
+          ->NewStringFromOneByte(Vector<const uint8_t>::cast(chars))
           .ToHandleChecked();
     }
     return factory()
-        ->NewStringFromTwoByte(Vector<const uint16_t>::cast(chars), allocation_)
+        ->NewStringFromTwoByte(Vector<const uint16_t>::cast(chars))
         .ToHandleChecked();
   }
 
diff --git a/src/json-parser.h b/src/json-parser.h
index 0c055ab..c0db095 100644
--- a/src/json-parser.h
+++ b/src/json-parser.h
@@ -167,7 +167,6 @@
   Handle<String> ParseJsonString(bool requires_internalization,
                                  Handle<String> expected = Handle<String>());
 
-  Handle<String> ScanJsonString();
 
   // A JSON number (production JSONNumber) is a subset of the valid JavaScript
   // decimal number literals.
@@ -212,7 +211,6 @@
   inline Handle<JSFunction> object_constructor() { return object_constructor_; }
 
   static const int kInitialSpecialStringLength = 32;
-  static const int kPretenureTreshold = 100 * 1024;
 
   static void UpdatePointersCallback(v8::Isolate* v8_isolate, v8::GCType type,
                                      v8::GCCallbackFlags flags, void* parser) {
@@ -252,7 +250,9 @@
   Isolate* isolate_;
   Zone zone_;
   const uint64_t hash_seed_;
-  AllocationType allocation_;
+  JsonToken next_;
+  // Indicates whether the bytes underneath source_ can relocate during GC.
+  bool chars_may_relocate_;
   Handle<JSFunction> object_constructor_;
   const Handle<String> original_source_;
   Handle<String> source_;
@@ -262,14 +262,11 @@
   // end_ should never be locally cached across a possible allocation. The scope
   // in which we cache chars has to be guarded by a DisallowHeapAllocation
   // scope.
-  const Char* chars_;
   const Char* cursor_;
   const Char* end_;
+  const Char* chars_;
 
-  JsonToken next_;
   LiteralBuffer literal_buffer_;
-  // Indicates whether the bytes underneath source_ can relocate during GC.
-  bool chars_may_relocate_;
 
   // Property handles are stored here inside ParseJsonObject.
   ZoneVector<Handle<Object>> properties_;