[VM / Runtime] Remove more dead code

Remove ValidatePostFinalizePatch and SetRefinalizeAfterPatch which are
not used anymore

Remove RawClass::kRefinalizeAfterPatch bit

Change-Id: I289df7ffe3e3017335510b5c14331254ca73c503
Reviewed-on: https://dart-review.googlesource.com/c/88621
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 5e88dba..55009dc 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -3144,67 +3144,6 @@
 #endif
 }
 
-bool Class::ValidatePostFinalizePatch(const Class& orig_class,
-                                      Error* error) const {
-  ASSERT(error != NULL);
-  // Not allowed to add new fields in a post finalization patch.
-  if (fields() != Object::empty_array().raw()) {
-    *error = LanguageError::NewFormatted(
-        *error,  // No previous error.
-        Script::Handle(script()), token_pos(), Report::AtLocation,
-        Report::kError, Heap::kNew,
-        "new fields are not allowed for this patch");
-    return false;
-  }
-  // There seem to be no functions, the patch is pointless.
-  if (functions() == Object::empty_array().raw()) {
-    *error = LanguageError::NewFormatted(*error,  // No previous error.
-                                         Script::Handle(script()), token_pos(),
-                                         Report::AtLocation, Report::kError,
-                                         Heap::kNew, "no functions to patch");
-    return false;
-  }
-  // Iterate over all functions that will be patched and make sure
-  // the original function was declared 'external' and has not executed
-  // so far i.e no code has been generated for it.
-  Thread* thread = Thread::Current();
-  ASSERT(thread->IsMutatorThread());
-  Zone* zone = thread->zone();
-  const Array& funcs = Array::Handle(zone, functions());
-  Function& func = Function::Handle(zone);
-  Function& orig_func = Function::Handle(zone);
-  String& name = String::Handle(zone);
-  for (intptr_t i = 0; i < funcs.Length(); i++) {
-    func ^= funcs.At(i);
-    name ^= func.name();
-    orig_func ^= orig_class.LookupFunctionAllowPrivate(name);
-    if (!orig_func.IsNull()) {
-      if (!orig_func.is_external() || orig_func.HasCode()) {
-        // We can only patch external functions in a post finalized class.
-        *error = LanguageError::NewFormatted(
-            *error,  // No previous error.
-            Script::Handle(script()), token_pos(), Report::AtLocation,
-            Report::kError, Heap::kNew,
-            !orig_func.is_external()
-                ? "'%s' is not external and therefore cannot be patched"
-                : "'%s' has already executed and therefore cannot be patched",
-            name.ToCString());
-        return false;
-      }
-    } else if (!Library::IsPrivate(name)) {
-      // We can only have new private functions that are added.
-      *error = LanguageError::NewFormatted(
-          *error,  // No previous error.
-          Script::Handle(script()), token_pos(), Report::AtLocation,
-          Report::kError, Heap::kNew,
-          "'%s' is not private and therefore cannot be patched",
-          name.ToCString());
-      return false;
-    }
-  }
-  return true;
-}
-
 void Class::set_dependent_code(const Array& array) const {
   StorePointer(&raw_ptr()->dependent_code_, array.raw());
 }
@@ -3991,13 +3930,6 @@
       ClassFinalizedBits::update(RawClass::kFinalized, raw_ptr()->state_bits_));
 }
 
-void Class::SetRefinalizeAfterPatch() const {
-  ASSERT(!IsTopLevel());
-  set_state_bits(ClassFinalizedBits::update(RawClass::kRefinalizeAfterPatch,
-                                            raw_ptr()->state_bits_));
-  set_state_bits(TypeFinalizedBit::update(false, raw_ptr()->state_bits_));
-}
-
 void Class::ResetFinalization() const {
   ASSERT(IsTopLevel() || IsClosureClass());
   set_state_bits(
@@ -9097,8 +9029,6 @@
       return "library";
     case RawScript::kSourceTag:
       return "source";
-    case RawScript::kPatchTag:
-      return "patch";
     case RawScript::kEvaluateTag:
       return "evaluate";
     case RawScript::kKernelTag:
@@ -11085,11 +11015,6 @@
   return lib.raw();
 }
 
-RawError* Library::Patch(const Script& script) const {
-  ASSERT(script.kind() == RawScript::kPatchTag);
-  return Compiler::Compile(*this, script);
-}
-
 bool Library::IsPrivate(const String& name) {
   if (ShouldBePrivate(name)) return true;
   // Factory names: List._fromLiteral.
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index bc71cdb..22bd10f 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1128,12 +1128,6 @@
 
   void set_is_prefinalized() const;
 
-  bool is_refinalize_after_patch() const {
-    return ClassFinalizedBits::decode(raw_ptr()->state_bits_) ==
-           RawClass::kRefinalizeAfterPatch;
-  }
-
-  void SetRefinalizeAfterPatch() const;
   void ResetFinalization() const;
 
   bool is_marked_for_lazy_loading() const {
@@ -1277,7 +1271,6 @@
   bool TraceAllocation(Isolate* isolate) const;
   void SetTraceAllocation(bool trace_allocation) const;
 
-  bool ValidatePostFinalizePatch(const Class& orig_class, Error* error) const;
   void ReplaceEnum(const Class& old_enum) const;
   void CopyStaticFieldValues(const Class& old_cls) const;
   void PatchFieldsAndFunctions() const;
@@ -3782,8 +3775,6 @@
     StoreNonPointer(&raw_ptr()->is_in_fullsnapshot_, value);
   }
 
-  RawError* Patch(const Script& script) const;
-
   RawString* PrivateName(const String& name) const;
 
   intptr_t index() const { return raw_ptr()->index_; }
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index 544421b..3fcb8cf 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -909,7 +909,6 @@
     kAllocated = 0,         // Initial state.
     kPreFinalized,          // VM classes: size precomputed, but no checks done.
     kFinalized,             // Class parsed, finalized and ready for use.
-    kRefinalizeAfterPatch,  // Class needs to be refinalized (patched).
   };
 
  private:
@@ -1252,7 +1251,6 @@
     kScriptTag = 0,
     kLibraryTag,
     kSourceTag,
-    kPatchTag,
     kEvaluateTag,
     kKernelTag,
   };