Changeset 58317 in webkit
- Timestamp:
- Apr 27, 2010 11:17:35 AM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r58309 r58317 1 2010-04-26 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Add specialized thunks for a char code related string functions 6 https://bugs.webkit.org/show_bug.cgi?id=38177 7 8 This is a simple extension to my prior patch. Basically hoist the 9 existing character loading logic from the charCodeAt thunk and into 10 a helper function, then add a helper to load strings from the small 11 string cache. This allows trivial implementations of fromCharCode 12 and charAt. 13 14 * create_hash_table: 15 * jit/SpecializedThunkJIT.h: 16 (JSC::SpecializedThunkJIT::returnJSCell): 17 (JSC::SpecializedThunkJIT::tagReturnAsJSCell): 18 * jit/ThunkGenerators.cpp: 19 (JSC::stringCharLoad): 20 (JSC::charToString): 21 (JSC::charCodeAtThunkGenerator): 22 (JSC::charAtThunkGenerator): 23 (JSC::fromCharCodeThunkGenerator): 24 * jit/ThunkGenerators.h: 25 * runtime/SmallStrings.h: 26 (JSC::SmallStrings::singleCharacterStrings): 27 * runtime/StringConstructor.cpp: 28 (JSC::StringConstructor::StringConstructor): 29 1 30 2010-04-27 Thomas Zander <t.zander@nokia.com> 2 31 -
trunk/JavaScriptCore/create_hash_table
r58286 r58317 276 276 $thunkGenerator = "charCodeAtThunkGenerator"; 277 277 } 278 if ($key eq "charAt") { 279 $thunkGenerator = "charAtThunkGenerator"; 280 } 278 281 print " { \"$key\", $attrs[$i], (intptr_t)" . $castStr . "($firstValue), (intptr_t)$secondValue THUNK_GENERATOR($thunkGenerator) },\n"; 279 282 $i++; -
trunk/JavaScriptCore/jit/SpecializedThunkJIT.h
r58287 r58317 79 79 ret(); 80 80 } 81 82 void returnJSCell(RegisterID src) 83 { 84 if (src != regT0) 85 move(src, regT0); 86 tagReturnAsJSCell(); 87 loadPtr(Address(callFrameRegister, RegisterFile::CallerFrame * (int)sizeof(Register)), callFrameRegister); 88 ret(); 89 } 81 90 82 91 PassRefPtr<NativeExecutable> finalize() … … 107 116 } 108 117 118 void tagReturnAsJSCell() 119 { 120 #if USE(JSVALUE32_64) 121 move(Imm32(JSValue::CellTag), regT1); 122 #endif 123 } 124 109 125 int m_expectedArgCount; 110 126 JSGlobalData* m_globalData; -
trunk/JavaScriptCore/jit/ThunkGenerators.cpp
r58286 r58317 38 38 static unsigned jsStringValueOffset() { return OBJECT_OFFSETOF(JSString, m_value); } 39 39 }; 40 41 PassRefPtr<NativeExecutable> charCodeAtThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)40 41 static void stringCharLoad(SpecializedThunkJIT& jit) 42 42 { 43 SpecializedThunkJIT jit(1, globalData, pool);44 45 43 // load string 46 44 jit.loadJSStringArgument(SpecializedThunkJIT::ThisArgument, SpecializedThunkJIT::regT0); … … 51 49 jit.loadPtr(MacroAssembler::Address(SpecializedThunkJIT::regT0, ThunkHelpers::jsStringValueOffset()), SpecializedThunkJIT::regT0); 52 50 jit.loadPtr(MacroAssembler::Address(SpecializedThunkJIT::regT0, ThunkHelpers::stringImplDataOffset()), SpecializedThunkJIT::regT0); 53 51 54 52 // load index 55 53 jit.loadInt32Argument(0, SpecializedThunkJIT::regT1); // regT1 contains the index 56 54 57 55 // Do an unsigned compare to simultaneously filter negative indices as well as indices that are too large 58 56 jit.appendFailure(jit.branch32(MacroAssembler::AboveOrEqual, SpecializedThunkJIT::regT1, SpecializedThunkJIT::regT2)); 59 57 60 58 // Load the character 61 59 jit.load16(MacroAssembler::BaseIndex(SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT1, MacroAssembler::TimesTwo, 0), SpecializedThunkJIT::regT0); 60 } 61 62 static void charToString(SpecializedThunkJIT& jit, JSGlobalData* globalData, MacroAssembler::RegisterID src, MacroAssembler::RegisterID dst, MacroAssembler::RegisterID scratch) 63 { 64 jit.appendFailure(jit.branch32(MacroAssembler::AboveOrEqual, src, MacroAssembler::Imm32(0x100))); 65 jit.move(MacroAssembler::ImmPtr(globalData->smallStrings.singleCharacterStrings()), scratch); 66 jit.loadPtr(MacroAssembler::BaseIndex(scratch, src, MacroAssembler::ScalePtr, 0), dst); 67 jit.appendFailure(jit.branchTestPtr(MacroAssembler::Zero, dst)); 68 } 69 70 PassRefPtr<NativeExecutable> charCodeAtThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool) 71 { 72 SpecializedThunkJIT jit(1, globalData, pool); 73 stringCharLoad(jit); 62 74 jit.returnInt32(SpecializedThunkJIT::regT0); 75 return jit.finalize(); 76 } 77 78 PassRefPtr<NativeExecutable> charAtThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool) 79 { 80 SpecializedThunkJIT jit(1, globalData, pool); 81 stringCharLoad(jit); 82 charToString(jit, globalData, SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT1); 83 jit.returnJSCell(SpecializedThunkJIT::regT0); 84 return jit.finalize(); 85 } 86 87 PassRefPtr<NativeExecutable> fromCharCodeThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool) 88 { 89 SpecializedThunkJIT jit(1, globalData, pool); 90 // load char code 91 jit.loadInt32Argument(0, SpecializedThunkJIT::regT0); 92 charToString(jit, globalData, SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT1); 93 jit.returnJSCell(SpecializedThunkJIT::regT0); 63 94 return jit.finalize(); 64 95 } -
trunk/JavaScriptCore/jit/ThunkGenerators.h
r58286 r58317 37 37 typedef PassRefPtr<NativeExecutable> (*ThunkGenerator)(JSGlobalData*, ExecutablePool*); 38 38 PassRefPtr<NativeExecutable> charCodeAtThunkGenerator(JSGlobalData*, ExecutablePool*); 39 PassRefPtr<NativeExecutable> charAtThunkGenerator(JSGlobalData*, ExecutablePool*); 40 PassRefPtr<NativeExecutable> fromCharCodeThunkGenerator(JSGlobalData*, ExecutablePool*); 39 41 } 40 42 #endif -
trunk/JavaScriptCore/runtime/SmallStrings.h
r54574 r58317 61 61 62 62 unsigned count() const; 63 63 #if ENABLE(JIT) 64 JSString** singleCharacterStrings() { return m_singleCharacterStrings; } 65 #endif 64 66 private: 65 67 void createEmptyString(JSGlobalData*); -
trunk/JavaScriptCore/runtime/StringConstructor.cpp
r53320 r58317 55 55 56 56 // ECMA 15.5.3.2 fromCharCode() 57 #if ENABLE(JIT) 58 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, exec->globalData().getThunk(fromCharCodeThunkGenerator), stringFromCharCode), DontEnum); 59 #else 57 60 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum); 58 61 #endif 59 62 // no. of arguments for constructor 60 63 putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
Note: See TracChangeset
for help on using the changeset viewer.