Reviewers: dcarney,

Description:
Massage the CodeStub class hierarchy a bit.

Several tiny changes for the upcoming TurboFan-genrated handlers/stubs:

   * Relaxed the type of code_stub().

   * Made GetCodeKind() public, it effectly was like this, anyway.

   * Const-corrected GetStubType().

Please review this at https://codereview.chromium.org/915583002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+16, -18 lines):
  M src/code-stubs.h
  M src/code-stubs-hydrogen.cc
  M src/compiler.h


Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index bccce299bddcd80a161b8771b7cccc7e51871642..f776abc043cb8d7e8f4c26f4ad4365819df2f5c8 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -58,7 +58,7 @@ class CodeStubGraphBuilderBase : public HGraphBuilder {
     return arguments_length_;
   }
   CompilationInfo* info() { return info_; }
-  HydrogenCodeStub* stub() { return info_->code_stub(); }
+  CodeStub* stub() { return info_->code_stub(); }
   HContext* context() { return context_; }
   Isolate* isolate() { return info_->isolate(); }

Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index a60d9d3c2610a894bed8677d40c953d753172e6e..dbdd3c73577709f884ab1b8ef534edd0e905f2bd 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -213,11 +213,12 @@ class CodeStub BASE_EMBEDDED {
   virtual Major MajorKey() const = 0;
   uint32_t MinorKey() const { return minor_key_; }

+  // BinaryOpStub needs to override this.
+  virtual Code::Kind GetCodeKind() const;
+
   virtual InlineCacheState GetICState() const { return UNINITIALIZED; }
   virtual ExtraICState GetExtraICState() const { return kNoExtraICState; }
-  virtual Code::StubType GetStubType() {
-    return Code::NORMAL;
-  }
+  virtual Code::StubType GetStubType() const { return Code::NORMAL; }

   friend std::ostream& operator<<(std::ostream& os, const CodeStub& s) {
     s.PrintName(os);
@@ -261,9 +262,6 @@ class CodeStub BASE_EMBEDDED {
   // registering stub in the stub cache.
   virtual void Activate(Code* code) { }

-  // BinaryOpStub needs to override this.
-  virtual Code::Kind GetCodeKind() const;
-
   // Add the code to a specialized cache, specific to an individual
   // stub type. Please note, this method must add the code object to a
   // roots object, otherwise we will remove the code during GC.
@@ -888,7 +886,7 @@ class LoadIndexedInterceptorStub : public PlatformCodeStub {
       : PlatformCodeStub(isolate) {}

   Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; }
-  Code::StubType GetStubType() OVERRIDE { return Code::FAST; }
+  Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }

   DEFINE_CALL_INTERFACE_DESCRIPTOR(Load);
   DEFINE_PLATFORM_CODE_STUB(LoadIndexedInterceptor, PlatformCodeStub);
@@ -901,7 +899,7 @@ class LoadIndexedStringStub : public PlatformCodeStub {
       : PlatformCodeStub(isolate) {}

   Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; }
-  Code::StubType GetStubType() OVERRIDE { return Code::FAST; }
+  Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }

   DEFINE_CALL_INTERFACE_DESCRIPTOR(Load);
   DEFINE_PLATFORM_CODE_STUB(LoadIndexedString, PlatformCodeStub);
@@ -941,7 +939,7 @@ class LoadFieldStub: public HandlerStub {

  protected:
   Code::Kind kind() const OVERRIDE { return Code::LOAD_IC; }
-  Code::StubType GetStubType() OVERRIDE { return Code::FAST; }
+  Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }

  private:
   class LoadFieldByIndexBits : public BitField<int, 0, 13> {};
@@ -957,7 +955,7 @@ class KeyedLoadSloppyArgumentsStub : public HandlerStub {

  protected:
   Code::Kind kind() const OVERRIDE { return Code::KEYED_LOAD_IC; }
-  Code::StubType GetStubType() OVERRIDE { return Code::FAST; }
+  Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }

  private:
   DEFINE_HANDLER_CODE_STUB(KeyedLoadSloppyArguments, HandlerStub);
@@ -977,7 +975,7 @@ class LoadConstantStub : public HandlerStub {

  protected:
   Code::Kind kind() const OVERRIDE { return Code::LOAD_IC; }
-  Code::StubType GetStubType() OVERRIDE { return Code::FAST; }
+  Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }

  private:
   class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {};
@@ -992,7 +990,7 @@ class StringLengthStub: public HandlerStub {

  protected:
   Code::Kind kind() const OVERRIDE { return Code::LOAD_IC; }
-  Code::StubType GetStubType() OVERRIDE { return Code::FAST; }
+  Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }

   DEFINE_HANDLER_CODE_STUB(StringLength, HandlerStub);
 };
@@ -1021,7 +1019,7 @@ class StoreFieldStub : public HandlerStub {

  protected:
   Code::Kind kind() const OVERRIDE { return Code::STORE_IC; }
-  Code::StubType GetStubType() OVERRIDE { return Code::FAST; }
+  Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }

  private:
   class StoreFieldByIndexBits : public BitField<int, 0, 13> {};
@@ -1074,7 +1072,7 @@ class StoreTransitionStub : public HandlerStub {

  protected:
   Code::Kind kind() const OVERRIDE { return Code::STORE_IC; }
-  Code::StubType GetStubType() OVERRIDE { return Code::FAST; }
+  Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }

  private:
   class StoreFieldByIndexBits : public BitField<int, 0, 13> {};
@@ -2119,7 +2117,7 @@ class ScriptContextFieldStub : public HandlerStub {
   class SlotIndexBits
       : public BitField<int, kContextIndexBits, kSlotIndexBits> {};

-  Code::StubType GetStubType() OVERRIDE { return Code::FAST; }
+  Code::StubType GetStubType() const OVERRIDE { return Code::FAST; }

   DEFINE_CODE_STUB_BASE(ScriptContextFieldStub, HandlerStub);
 };
Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index 2f6beba0297808824bced1e5fd484f833f9b8e31..381eb2a7595c6ce4947417f16bc1fda3bf2e1b92 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -121,7 +121,7 @@ class CompilationInfo {
   Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
   Handle<Script> script() const { return script_; }
   void set_script(Handle<Script> script) { script_ = script; }
-  HydrogenCodeStub* code_stub() const {return code_stub_; }
+  CodeStub* code_stub() const { return code_stub_; }
   v8::Extension* extension() const { return extension_; }
   ScriptData** cached_data() const { return cached_data_; }
   ScriptCompiler::CompileOptions compile_options() const {
@@ -475,7 +475,7 @@ class CompilationInfo {
   // The script scope provided as a convenience.
   Scope* script_scope_;
   // For compiled stubs, the stub object
-  HydrogenCodeStub* code_stub_;
+  CodeStub* code_stub_;
   // The compiled code.
   Handle<Code> code_;



--
--
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/d/optout.

Reply via email to