source: webkit/trunk/JavaScriptCore/kjs/JSGlobalData.h@ 37088

Last change on this file since 37088 was 36316, checked in by [email protected], 17 years ago

2008-09-10 Maciej Stachowiak <[email protected]>

Reviewed by Oliver.


  • enable polymorphic inline caching of properties of primitives


1.012x speedup on SunSpider.

We create special structure IDs for JSString and
JSNumberCell. Unlike normal structure IDs, these cannot hold the
true prototype. Due to JS autoboxing semantics, the prototype used
when looking up string or number properties depends on the lexical
global object of the call site, not the creation site. Thus we
enable StructureIDs to handle this quirk for primitives.


Everything else should be straightforward.


  • VM/CTI.cpp: (JSC::CTI::privateCompileGetByIdProto): (JSC::CTI::privateCompileGetByIdChain):
  • VM/CTI.h: (JSC::CTI::compileGetByIdProto): (JSC::CTI::compileGetByIdChain):
  • VM/JSPropertyNameIterator.h: (JSC::JSPropertyNameIterator::JSPropertyNameIterator):
  • VM/Machine.cpp: (JSC::Machine::Machine): (JSC::cachePrototypeChain): (JSC::Machine::tryCachePutByID): (JSC::Machine::tryCacheGetByID): (JSC::Machine::privateExecute): (JSC::Machine::tryCTICachePutByID): (JSC::Machine::tryCTICacheGetByID):
  • kjs/GetterSetter.h: (JSC::GetterSetter::GetterSetter):
  • kjs/JSCell.h:
  • kjs/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
  • kjs/JSGlobalData.h:
  • kjs/JSGlobalObject.h: (JSC::StructureID::prototypeForLookup):
  • kjs/JSNumberCell.h: (JSC::JSNumberCell::JSNumberCell): (JSC::jsNumberCell):
  • kjs/JSObject.h: (JSC::JSObject::prototype):
  • kjs/JSString.cpp: (JSC::jsString): (JSC::jsSubstring): (JSC::jsOwnedString):
  • kjs/JSString.h: (JSC::JSString::JSString): (JSC::JSString::): (JSC::jsSingleCharacterString): (JSC::jsSingleCharacterSubstring): (JSC::jsNontrivialString):
  • kjs/SmallStrings.cpp: (JSC::SmallStrings::createEmptyString): (JSC::SmallStrings::createSingleCharacterString):
  • kjs/StructureID.cpp: (JSC::StructureID::StructureID): (JSC::StructureID::addPropertyTransition): (JSC::StructureID::getterSetterTransition): (JSC::StructureIDChain::StructureIDChain):
  • kjs/StructureID.h: (JSC::StructureID::create): (JSC::StructureID::storedPrototype):
  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef JSGlobalData_h
30#define JSGlobalData_h
31
32#include <wtf/Forward.h>
33#include <wtf/HashCountedSet.h>
34#include <wtf/HashMap.h>
35#include <wtf/HashSet.h>
36#include <wtf/RefCounted.h>
37#include "SmallStrings.h"
38
39struct OpaqueJSClass;
40struct OpaqueJSClassContextData;
41
42namespace JSC {
43
44 class ArgList;
45 class CommonIdentifiers;
46 class Heap;
47 class IdentifierTable;
48 class JSGlobalObject;
49 class Lexer;
50 class Machine;
51 class Parser;
52 class ParserRefCounted;
53 class StructureID;
54 class UString;
55 struct HashTable;
56
57 class JSGlobalData : public RefCounted<JSGlobalData> {
58 public:
59 static bool sharedInstanceExists();
60 static JSGlobalData& sharedInstance();
61
62 static PassRefPtr<JSGlobalData> create();
63 ~JSGlobalData();
64
65 Machine* machine;
66 Heap* heap;
67
68 const HashTable* arrayTable;
69 const HashTable* dateTable;
70 const HashTable* mathTable;
71 const HashTable* numberTable;
72 const HashTable* regExpTable;
73 const HashTable* regExpConstructorTable;
74 const HashTable* stringTable;
75
76 RefPtr<StructureID> nullProtoStructureID;
77 RefPtr<StructureID> stringStructureID;
78 RefPtr<StructureID> numberStructureID;
79
80 IdentifierTable* identifierTable;
81 CommonIdentifiers* propertyNames;
82 const ArgList* emptyList; // Lists are supposed to be allocated on the stack to have their elements properly marked, which is not the case here - but this list has nothing to mark.
83
84 SmallStrings smallStrings;
85
86 HashMap<OpaqueJSClass*, OpaqueJSClassContextData*>* opaqueJSClassData;
87
88 HashSet<ParserRefCounted*>* newParserObjects;
89 HashCountedSet<ParserRefCounted*>* parserObjectExtraRefCounts;
90
91 Lexer* lexer;
92 Parser* parser;
93
94 JSGlobalObject* head;
95
96 bool isSharedInstance;
97
98 private:
99 JSGlobalData(bool isShared = false);
100
101 static JSGlobalData*& sharedInstanceInternal();
102 };
103
104}
105
106#endif
Note: See TracBrowser for help on using the repository browser.