Changed FuncNameInferrer and ScopeInfo to support zone allocation.
authorbak@chromium.org <bak@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 18 May 2009 09:41:16 +0000 (09:41 +0000)
committerbak@chromium.org <bak@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 18 May 2009 09:41:16 +0000 (09:41 +0000)
Yields a 2% speedup when running compiler-benchmark.

Review URL: http://codereview.chromium.org/113519

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1985 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/codegen.cc
src/factory.cc
src/factory.h
src/func-name-inferrer.h
src/globals.h
src/heap.cc
src/heap.h
src/ia32/codegen-ia32.h
src/scopeinfo.cc
src/scopeinfo.h
src/scopes.cc

index 2c56534edd5080c4bc3a760962a38b86a8818f7b..ffc9dce5a7710c1a2b9de3c85f405d5a15f0b917 100644 (file)
@@ -170,7 +170,7 @@ Handle<Code> CodeGenerator::MakeCode(FunctionLiteral* flit,
   HistogramTimerScope timer(&Counters::code_creation);
   CodeDesc desc;
   cgen.masm()->GetCode(&desc);
-  ScopeInfo<> sinfo(flit->scope());
+  ZoneScopeInfo sinfo(flit->scope());
   Code::Flags flags = Code::ComputeFlags(Code::FUNCTION);
   Handle<Code> code = Factory::NewCode(desc,
                                        &sinfo,
index 4b0b7f51f7ea5463650ed17a72fffc4ec6b2d778..0e1db15f86b1159a9bd37086c11436e2fd7d73b0 100644 (file)
@@ -509,8 +509,10 @@ Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
 }
 
 
-Handle<Code> Factory::NewCode(const CodeDesc& desc, ScopeInfo<>* sinfo,
-                              Code::Flags flags, Handle<Object> self_ref) {
+Handle<Code> Factory::NewCode(const CodeDesc& desc,
+                              ZoneScopeInfo* sinfo,
+                              Code::Flags flags,
+                              Handle<Object> self_ref) {
   CALL_HEAP_FUNCTION(Heap::CreateCode(desc, sinfo, flags, self_ref), Code);
 }
 
index 6ac2706ec18a2d3f9a886bd2a2e41ca0f60f89ab..a55b1f1f986677887a8b744502fb7d81785b6e48 100644 (file)
@@ -29,6 +29,7 @@
 #define V8_FACTORY_H_
 
 #include "heap.h"
+#include "zone-inl.h"
 
 namespace v8 { namespace internal {
 
@@ -202,8 +203,10 @@ class Factory : public AllStatic {
       Handle<JSFunction> boilerplate,
       Handle<Context> context);
 
-  static Handle<Code> NewCode(const CodeDesc& desc, ScopeInfo<>* sinfo,
-                              Code::Flags flags, Handle<Object> self_reference);
+  static Handle<Code> NewCode(const CodeDesc& desc,
+                              ZoneScopeInfo* sinfo,
+                              Code::Flags flags,
+                              Handle<Object> self_reference);
 
   static Handle<Code> CopyCode(Handle<Code> code);
 
index d8270c36428a72c0ef15d1c9138e6748d116c319..c5c81eb5b77259df3b4cf3b0164892d16dc8ba6b 100644 (file)
@@ -82,9 +82,9 @@ class FuncNameInferrer BASE_EMBEDDED {
   Handle<String> MakeNameFromStackHelper(int pos, Handle<String> prev);
   void InferFunctionsNames();
 
-  List<int> entries_stack_;
-  List<Handle<String> > names_stack_;
-  List<FunctionLiteral*> funcs_to_infer_;
+  ZoneList<int> entries_stack_;
+  ZoneList<Handle<String> > names_stack_;
+  ZoneList<FunctionLiteral*> funcs_to_infer_;
   Handle<String> dot_;
 
   DISALLOW_COPY_AND_ASSIGN(FuncNameInferrer);
index e0c5278ae246ac74844d9a03a142d56363330e64..8aa15288ae2cf6714d7a9dd74920ccffeecd9273 100644 (file)
@@ -239,6 +239,7 @@ class ObjectGroup;
 class TickSample;
 class VirtualMemory;
 class Mutex;
+class ZoneScopeInfo;
 
 typedef bool (*WeakSlotCallback)(Object** pointer);
 
index a5b7b30658de00b0601d0041875c3014f7fa33dd..00f71ea18a6ebb3d4303a536a1f8d4f5605fb0cd 100644 (file)
@@ -1699,7 +1699,7 @@ void Heap::CreateFillerObjectAt(Address addr, int size) {
 
 
 Object* Heap::CreateCode(const CodeDesc& desc,
-                         ScopeInfo<>* sinfo,
+                         ZoneScopeInfo* sinfo,
                          Code::Flags flags,
                          Handle<Object> self_reference) {
   // Compute size
index ccc552f8d0fd3ce340907987ba182c39885e1da4..cc8b6091f61f4933db6496190aecbb3dc3331827 100644 (file)
@@ -28,6 +28,8 @@
 #ifndef V8_HEAP_H_
 #define V8_HEAP_H_
 
+#include "zone-inl.h"
+
 namespace v8 { namespace internal {
 
 // Defines all the roots in Heap.
@@ -570,7 +572,7 @@ class Heap : public AllStatic {
   // object by containing this pointer.
   // Please note this function does not perform a garbage collection.
   static Object* CreateCode(const CodeDesc& desc,
-                            ScopeInfo<>* sinfo,
+                            ZoneScopeInfo* sinfo,
                             Code::Flags flags,
                             Handle<Object> self_reference);
 
index 0e019570e3f8dac5974fc8efef0f3f8d47425c05..d2508694c84294e7fd88d7bf1a774b53c6258398 100644 (file)
@@ -588,7 +588,7 @@ class CodeGenerator: public AstVisitor {
 
   bool is_eval_;  // Tells whether code is generated for eval.
   Handle<Script> script_;
-  List<DeferredCode*> deferred_;
+  ZoneList<DeferredCode*> deferred_;
 
   // Assembler
   MacroAssembler* masm_;  // to generate code
index 6d2ade81547ec30b58fdf196e874e4f7b0208e5b..91335fc2576b82f1c1b3f4564aa686829ff5fa94 100644 (file)
@@ -566,5 +566,6 @@ void ScopeInfo<Allocator>::Print() {
 // Make sure the classes get instantiated by the template system.
 template class ScopeInfo<FreeStoreAllocationPolicy>;
 template class ScopeInfo<PreallocatedStorage>;
+template class ScopeInfo<ZoneListAllocationPolicy>;
 
 } }  // namespace v8::internal
index dbe235ad0f91849fe7d43723c39321d598865df1..032229d5e755130bb8be2ac1433caf4e829ac3ab 100644 (file)
@@ -150,6 +150,18 @@ class ScopeInfo BASE_EMBEDDED {
   List<Variable::Mode, Allocator > context_modes_;
 };
 
+class ZoneScopeInfo: public ScopeInfo<ZoneListAllocationPolicy> {
+ public:
+  // Create a ZoneScopeInfo instance from a scope.
+  explicit ZoneScopeInfo(Scope* scope)
+      : ScopeInfo<ZoneListAllocationPolicy>(scope) {}
+
+  // Create a ZoneScopeInfo instance from a Code object.
+  explicit ZoneScopeInfo(Code* code)
+      :  ScopeInfo<ZoneListAllocationPolicy>(code) {}
+};
+
+
 } }  // namespace v8::internal
 
 #endif  // V8_SCOPEINFO_H_
index 7717eaaf78991cfbf41d88e002161216f7ab0358..471f62f6bb427b092f1f7149c66478bbd5cb426d 100644 (file)
@@ -301,6 +301,8 @@ template void Scope::CollectUsedVariables(
     List<Variable*, FreeStoreAllocationPolicy>* locals);
 template void Scope::CollectUsedVariables(
     List<Variable*, PreallocatedStorage>* locals);
+template void Scope::CollectUsedVariables(
+    List<Variable*, ZoneListAllocationPolicy>* locals);
 
 
 void Scope::AllocateVariables(Handle<Context> context) {