From 9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73 Mon Sep 17 00:00:00 2001 From: Apple Date: Sat, 6 Jun 2009 12:22:11 +0000 Subject: [PATCH] JavaScriptCore-521.tar.gz --- API/APICast.h | 68 +- API/JSBase.cpp | 74 +- API/JSBase.h | 31 +- bindings/c/c_class.h => API/JSBasePrivate.h | 57 +- API/JSCallbackConstructor.cpp | 49 +- API/JSCallbackConstructor.h | 32 +- API/JSCallbackFunction.cpp | 44 +- API/JSCallbackFunction.h | 34 +- API/JSCallbackObject.cpp | 16 +- API/JSCallbackObject.h | 85 +- API/JSCallbackObjectFunctions.h | 313 +- API/JSClassRef.cpp | 172 +- API/JSClassRef.h | 61 +- API/JSContextRef.cpp | 104 +- API/JSContextRef.h | 61 +- API/JSObjectRef.cpp | 317 +- API/JSObjectRef.h | 57 +- .../JSProfilerPrivate.cpp | 29 +- .../c/c_runtime.h => API/JSProfilerPrivate.h | 72 +- API/JSStringRef.cpp | 81 +- API/JSStringRef.h | 7 +- API/JSStringRefBSTR.cpp | 1 - API/JSStringRefBSTR.h | 5 +- API/JSStringRefCF.cpp | 36 +- API/JSStringRefCF.h | 7 +- API/JSValueRef.cpp | 175 +- API/JSValueRef.h | 13 +- API/JavaScript.h | 3 +- API/JavaScriptCore.h | 3 +- API/OpaqueJSString.cpp | 55 + .../c/c_instance.h => API/OpaqueJSString.h | 87 +- API/WebKitAvailability.h | 763 + API/{ => tests}/JSNode.c | 7 +- API/{ => tests}/JSNode.h | 3 +- API/{ => tests}/JSNodeList.c | 3 +- API/{ => tests}/JSNodeList.h | 3 +- API/{ => tests}/Node.c | 5 +- API/{ => tests}/Node.h | 3 +- API/{ => tests}/NodeList.c | 9 +- API/{ => tests}/NodeList.h | 3 +- API/{ => tests}/minidom.c | 8 +- API/{ => tests}/minidom.html | 0 API/{ => tests}/minidom.js | 1 - API/{ => tests}/testapi.c | 114 +- API/{ => tests}/testapi.js | 2 +- AllInOneFile.cpp | 105 + ChangeLog-2008-08-10 | 31482 ++++++++++++++++ DerivedSources.make | 46 +- ForwardingHeaders/JavaScriptCore/JSLock.h | 1 - .../JavaScriptCore/OpaqueJSString.h | 1 + .../JavaScriptCore/WebKitAvailability.h | 1 + GNUmakefile.am | 590 +- Info.plist | 4 +- JavaScriptCore.exp | 490 +- JavaScriptCore.iPhone.order | 806 + JavaScriptCore.order | 3132 +- JavaScriptCore.pri | 273 +- JavaScriptCore.pro | 72 + JavaScriptCore.scons | 307 + JavaScriptCorePrefix.h | 9 + JavaScriptCoreSources.bkl | 183 +- SConstruct | 1 + assembler/AssemblerBuffer.h | 160 + assembler/MacroAssembler.h | 2019 + assembler/X86Assembler.h | 1704 + bindings/NP_jsobject.cpp | 409 - bindings/c/c_class.cpp | 123 - bindings/c/c_instance.cpp | 212 - bindings/c/c_runtime.cpp | 96 - bindings/c/c_utility.cpp | 185 - bindings/jni/jni_class.cpp | 140 - bindings/jni/jni_instance.cpp | 358 - bindings/jni/jni_instance.h | 103 - bindings/jni/jni_jsobject.cpp | 594 - bindings/jni/jni_jsobject.h | 129 - bindings/jni/jni_objc.mm | 82 - bindings/jni/jni_runtime.cpp | 549 - bindings/jni/jni_runtime.h | 190 - bindings/jni/jni_utility.cpp | 992 - bindings/jni/jni_utility.h | 125 - bindings/make_testbindings | 2 - bindings/npapi.h | 720 - bindings/npruntime.cpp | 226 - bindings/npruntime.h | 358 - bindings/npruntime_impl.h | 65 - bindings/npruntime_internal.h | 39 - bindings/objc/WebScriptObject.h | 46 - bindings/objc/objc_class.mm | 258 - bindings/objc/objc_instance.h | 81 - bindings/objc/objc_instance.mm | 349 - bindings/objc/objc_runtime.h | 128 - bindings/objc/objc_runtime.mm | 295 - bindings/objc/objc_utility.h | 87 - bindings/objc/objc_utility.mm | 372 - bindings/qt/qt_class.cpp | 223 - bindings/qt/qt_class.h | 55 - bindings/qt/qt_instance.cpp | 394 - bindings/qt/qt_instance.h | 85 - bindings/qt/qt_runtime.cpp | 1590 - bindings/qt/qt_runtime.h | 217 - bindings/runtime.cpp | 154 - bindings/runtime.h | 174 - bindings/runtime_array.cpp | 118 - bindings/runtime_array.h | 65 - bindings/runtime_method.cpp | 94 - bindings/runtime_object.cpp | 254 - bindings/runtime_object.h | 74 - bindings/runtime_root.cpp | 309 - bindings/runtime_root.h | 109 - bindings/test.js | 19 - bindings/testC.js | 21 - bindings/testM.js | 29 - bindings/testbindings.cpp | 422 - bindings/testbindings.mm | 289 - bindings/testbindings.pro | 8 - bindings/testqtbindings.cpp | 142 - bytecode/CodeBlock.cpp | 1686 + bytecode/CodeBlock.h | 584 + bytecode/EvalCodeCache.h | 87 + bytecode/Instruction.h | 155 + bytecode/JumpTable.cpp | 45 + bytecode/JumpTable.h | 102 + bytecode/Opcode.cpp | 186 + bytecode/Opcode.h | 231 + bytecode/SamplingTool.cpp | 298 + bytecode/SamplingTool.h | 214 + bytecode/StructureStubInfo.cpp | 80 + bytecode/StructureStubInfo.h | 156 + bytecompiler/BytecodeGenerator.cpp | 1792 + bytecompiler/BytecodeGenerator.h | 481 + bytecompiler/Label.h | 92 + .../LabelScope.h | 69 +- bytecompiler/RegisterID.h | 121 + bytecompiler/SegmentedVector.h | 170 + kjs/config.h => config.h | 41 +- create_hash_table | 278 + debugger/Debugger.cpp | 70 + debugger/Debugger.h | 63 + debugger/DebuggerActivation.cpp | 103 + debugger/DebuggerActivation.h | 63 + debugger/DebuggerCallFrame.cpp | 81 + debugger/DebuggerCallFrame.h | 67 + docs/make-bytecode-docs.pl | 42 + icu/unicode/parseerr.h | 88 + icu/unicode/ucol.h | 1219 + icu/unicode/uloc.h | 917 + icu/unicode/unorm.h | 575 + icu/unicode/uset.h | 745 + icu/unicode/utf_old.h | 1 + interpreter/CallFrame.cpp | 38 + interpreter/CallFrame.h | 147 + interpreter/Interpreter.cpp | 6089 +++ interpreter/Interpreter.h | 377 + interpreter/Register.h | 299 + interpreter/RegisterFile.cpp | 45 + interpreter/RegisterFile.h | 216 + jit/ExecutableAllocator.cpp | 38 + jit/ExecutableAllocator.h | 179 + jit/ExecutableAllocatorPosix.cpp | 56 + jit/ExecutableAllocatorWin.cpp | 56 + jit/JIT.cpp | 1944 + jit/JIT.h | 577 + jit/JITArithmetic.cpp | 974 + jit/JITCall.cpp | 345 + jit/JITInlineMethods.h | 434 + jit/JITPropertyAccess.cpp | 704 + jsc.cpp | 487 + jsc.pro | 39 + jscore.bkl | 52 +- kjs/Activation.h | 99 - kjs/AllInOneFile.cpp | 73 - kjs/CollectorHeapIntrospector.cpp | 94 - kjs/CollectorHeapIntrospector.h | 75 - kjs/DateMath.cpp | 506 - kjs/ExecState.cpp | 215 - kjs/ExecState.h | 241 - kjs/JSGlobalObject.cpp | 568 - kjs/JSGlobalObject.h | 262 - kjs/JSImmediate.cpp | 82 - kjs/JSImmediate.h | 278 - kjs/JSLock.cpp | 182 - kjs/JSLockC.h | 19 - kjs/JSVariableObject.h | 121 - kjs/JSWrapperObject.h | 84 - kjs/LabelStack.h | 84 - kjs/Parser.cpp | 97 - kjs/PropertyNameArray.h | 56 - kjs/SavedBuiltins.h | 94 - kjs/array_instance.cpp | 612 - kjs/array_instance.h | 72 - kjs/array_object.cpp | 760 - kjs/array_object.h | 71 - kjs/bool_object.cpp | 117 - kjs/collector.cpp | 1078 - kjs/collector.h | 193 - kjs/completion.h | 60 - kjs/create_hash_table | 250 - kjs/date_object.cpp | 1542 - kjs/date_object.h | 135 - kjs/debugger.cpp | 133 - kjs/debugger.h | 225 - kjs/dtoa.cpp | 3300 -- kjs/error_object.cpp | 153 - kjs/error_object.h | 77 - kjs/function.cpp | 877 - kjs/function.h | 159 - kjs/function_object.cpp | 235 - kjs/function_object.h | 61 - kjs/grammar.y | 1844 - kjs/identifier.cpp | 205 - kjs/identifier.h | 100 - kjs/internal.cpp | 302 - kjs/internal.h | 122 - kjs/interpreter.cpp | 140 - kjs/interpreter.h | 72 - kjs/lexer.cpp | 919 - kjs/lexer.h | 163 - kjs/list.h | 118 - kjs/lookup.cpp | 81 - kjs/lookup.h | 342 - kjs/math_object.cpp | 243 - kjs/math_object.h | 65 - kjs/nodes.cpp | 4761 --- kjs/nodes.h | 2919 -- kjs/nodes2string.cpp | 980 - kjs/number_object.h | 76 - kjs/object.cpp | 681 - kjs/object.h | 605 - kjs/object_object.cpp | 216 - kjs/operations.cpp | 128 - kjs/property_map.cpp | 850 - kjs/property_map.h | 184 - kjs/property_slot.h | 142 - kjs/protect.h | 143 - kjs/regexp.cpp | 120 - kjs/regexp.h | 75 - kjs/regexp_object.cpp | 475 - kjs/regexp_object.h | 105 - kjs/scope_chain.h | 156 - kjs/scope_chain_mark.h | 49 - kjs/string_object.cpp | 1055 - kjs/string_object.h | 153 - kjs/testkjs.cpp | 346 - kjs/testkjs.pro | 34 - kjs/types.h | 25 - kjs/ustring.cpp | 1281 - kjs/ustring.h | 470 - kjs/value.h | 523 - make-generated-sources.sh | 2 +- os-win32/stdint.h | 12 + parser/Grammar.y | 2084 + kjs/keywords.table => parser/Keywords.table | 0 parser/Lexer.cpp | 900 + parser/Lexer.h | 171 + parser/NodeInfo.h | 63 + parser/Nodes.cpp | 2750 ++ parser/Nodes.h | 2424 ++ parser/Parser.cpp | 106 + {kjs => parser}/Parser.h | 74 +- parser/ResultType.h | 177 + {kjs => parser}/SourceCode.h | 14 +- {kjs => parser}/SourceProvider.h | 8 +- pcre/dftables | 32 +- pcre/pcre.h | 4 +- pcre/pcre.pri | 5 +- pcre/pcre_compile.cpp | 687 +- pcre/pcre_exec.cpp | 294 +- pcre/pcre_internal.h | 98 +- pcre/pcre_tables.cpp | 11 +- pcre/pcre_ucp_searchfuncs.cpp | 5 +- pcre/pcre_xclass.cpp | 9 +- profiler/CallIdentifier.h | 95 + profiler/HeavyProfile.cpp | 115 + .../jni_class.h => profiler/HeavyProfile.h | 69 +- profiler/Profile.cpp | 137 + profiler/Profile.h | 83 + profiler/ProfileGenerator.cpp | 169 + profiler/ProfileGenerator.h | 76 + profiler/ProfileNode.cpp | 352 + profiler/ProfileNode.h | 178 + profiler/Profiler.cpp | 153 + profiler/Profiler.h | 75 + profiler/ProfilerServer.h | 35 + profiler/ProfilerServer.mm | 115 + profiler/TreeProfile.cpp | 51 + profiler/TreeProfile.h | 51 + kjs/list.cpp => runtime/ArgList.cpp | 66 +- runtime/ArgList.h | 161 + runtime/Arguments.cpp | 232 + runtime/Arguments.h | 227 + runtime/ArrayConstructor.cpp | 84 + runtime/ArrayConstructor.h | 40 + runtime/ArrayPrototype.cpp | 805 + kjs/NodeInfo.h => runtime/ArrayPrototype.h | 35 +- runtime/BatchedTransitionOptimizer.h | 55 + runtime/BooleanConstructor.cpp | 78 + runtime/BooleanConstructor.h | 44 + runtime/BooleanObject.cpp | 35 + kjs/bool_object.h => runtime/BooleanObject.h | 45 +- runtime/BooleanPrototype.cpp | 82 + runtime/BooleanPrototype.h | 35 + runtime/CallData.cpp | 42 + runtime/CallData.h | 63 + runtime/ClassInfo.h | 62 + runtime/Collector.cpp | 1126 + runtime/Collector.h | 287 + runtime/CollectorHeapIterator.h | 90 + {kjs => runtime}/CommonIdentifiers.cpp | 25 +- {kjs => runtime}/CommonIdentifiers.h | 45 +- runtime/Completion.cpp | 77 + runtime/Completion.h | 63 + runtime/ConstructData.cpp | 42 + runtime/ConstructData.h | 63 + runtime/DateConstructor.cpp | 175 + runtime/DateConstructor.h | 43 + runtime/DateInstance.cpp | 116 + runtime/DateInstance.h | 65 + runtime/DateMath.cpp | 939 + {kjs => runtime}/DateMath.h | 47 +- runtime/DatePrototype.cpp | 972 + runtime/DatePrototype.h | 47 + runtime/Error.cpp | 127 + runtime/Error.h | 65 + runtime/ErrorConstructor.cpp | 73 + runtime/ErrorConstructor.h | 44 + runtime/ErrorInstance.cpp | 33 + runtime/ErrorInstance.h | 38 + runtime/ErrorPrototype.cpp | 67 + runtime/ErrorPrototype.h | 37 + runtime/ExceptionHelpers.cpp | 211 + runtime/ExceptionHelpers.h | 57 + runtime/FunctionConstructor.cpp | 131 + runtime/FunctionConstructor.h | 48 + runtime/FunctionPrototype.cpp | 136 + runtime/FunctionPrototype.h | 44 + runtime/GetterSetter.cpp | 84 + runtime/GetterSetter.h | 75 + runtime/GlobalEvalFunction.cpp | 49 + .../GlobalEvalFunction.h | 42 +- runtime/Identifier.cpp | 268 + runtime/Identifier.h | 144 + runtime/InitializeThreading.cpp | 72 + runtime/InitializeThreading.h | 40 + runtime/InternalFunction.cpp | 51 + runtime/InternalFunction.h | 64 + runtime/JSActivation.cpp | 184 + runtime/JSActivation.h | 98 + runtime/JSArray.cpp | 1046 + runtime/JSArray.h | 127 + runtime/JSByteArray.cpp | 97 + runtime/JSByteArray.h | 110 + kjs/value.cpp => runtime/JSCell.cpp | 156 +- runtime/JSCell.h | 300 + runtime/JSFunction.cpp | 174 + runtime/JSFunction.h | 103 + runtime/JSGlobalData.cpp | 207 + runtime/JSGlobalData.h | 148 + runtime/JSGlobalObject.cpp | 460 + runtime/JSGlobalObject.h | 407 + runtime/JSGlobalObjectFunctions.cpp | 434 + runtime/JSGlobalObjectFunctions.h | 60 + runtime/JSImmediate.cpp | 107 + runtime/JSImmediate.h | 837 + runtime/JSLock.cpp | 254 + {kjs => runtime}/JSLock.h | 57 +- runtime/JSNotAnObject.cpp | 124 + runtime/JSNotAnObject.h | 97 + runtime/JSNumberCell.cpp | 126 + runtime/JSNumberCell.h | 449 + runtime/JSObject.cpp | 518 + runtime/JSObject.h | 555 + runtime/JSPropertyNameIterator.cpp | 90 + runtime/JSPropertyNameIterator.h | 116 + runtime/JSStaticScopeObject.cpp | 84 + runtime/JSStaticScopeObject.h | 69 + runtime/JSString.cpp | 152 + runtime/JSString.h | 214 + {kjs => runtime}/JSType.h | 39 +- runtime/JSValue.cpp | 87 + runtime/JSValue.h | 222 + {kjs => runtime}/JSVariableObject.cpp | 74 +- runtime/JSVariableObject.h | 164 + {kjs => runtime}/JSWrapperObject.cpp | 12 +- runtime/JSWrapperObject.h | 60 + runtime/Lookup.cpp | 98 + runtime/Lookup.h | 276 + runtime/MathObject.cpp | 242 + runtime/MathObject.h | 45 + runtime/NativeErrorConstructor.cpp | 73 + runtime/NativeErrorConstructor.h | 51 + runtime/NativeErrorPrototype.cpp | 39 + runtime/NativeErrorPrototype.h | 35 + runtime/NumberConstructor.cpp | 123 + runtime/NumberConstructor.h | 55 + runtime/NumberObject.cpp | 51 + runtime/NumberObject.h | 44 + .../NumberPrototype.cpp | 261 +- runtime/NumberPrototype.h | 35 + runtime/ObjectConstructor.cpp | 72 + runtime/ObjectConstructor.h | 41 + runtime/ObjectPrototype.cpp | 134 + .../ObjectPrototype.h | 36 +- .../Operations.cpp | 39 +- runtime/Operations.h | 135 + runtime/PropertyMapHashTable.h | 87 + runtime/PropertyNameArray.cpp | 50 + runtime/PropertyNameArray.h | 112 + runtime/PropertySlot.cpp | 45 + runtime/PropertySlot.h | 213 + runtime/Protect.h | 215 + runtime/PrototypeFunction.cpp | 57 + runtime/PrototypeFunction.h | 45 + runtime/PutPropertySlot.h | 81 + runtime/RegExp.cpp | 182 + runtime/RegExp.h | 78 + runtime/RegExpConstructor.cpp | 385 + runtime/RegExpConstructor.h | 82 + runtime/RegExpMatchesArray.h | 87 + runtime/RegExpObject.cpp | 167 + runtime/RegExpObject.h | 83 + runtime/RegExpPrototype.cpp | 118 + runtime/RegExpPrototype.h | 38 + kjs/scope_chain.cpp => runtime/ScopeChain.cpp | 45 +- runtime/ScopeChain.h | 225 + kjs/dtoa.h => runtime/ScopeChainMark.h | 28 +- runtime/SmallStrings.cpp | 136 + runtime/SmallStrings.h | 74 + runtime/StringConstructor.cpp | 90 + runtime/StringConstructor.h | 40 + runtime/StringObject.cpp | 101 + runtime/StringObject.h | 72 + .../StringObjectThatMasqueradesAsUndefined.h | 55 + runtime/StringPrototype.cpp | 846 + runtime/StringPrototype.h | 42 + runtime/Structure.cpp | 1029 + runtime/Structure.h | 228 + .../StructureChain.cpp | 40 +- .../NP_jsobject.h => runtime/StructureChain.h | 42 +- runtime/StructureTransitionTable.h | 72 + runtime/SymbolTable.h | 126 + runtime/Tracing.d | 40 + runtime/Tracing.h | 50 + runtime/TypeInfo.h | 63 + runtime/UString.cpp | 1670 + runtime/UString.h | 440 + tests/mozilla/ecma/Array/15.4.4.5-3.js | 2 +- tests/mozilla/expected.html | 228 +- tests/mozilla/js1_2/Array/tostring_1.js | 2 +- tests/mozilla/js1_2/Array/tostring_2.js | 2 +- tests/mozilla/js1_5/Array/regress-157652.js | 2 +- tests/mozilla/jsDriver.pl | 38 +- wrec/CharacterClass.cpp | 140 + .../c/c_utility.h => wrec/CharacterClass.h | 72 +- wrec/CharacterClassConstructor.cpp | 257 + wrec/CharacterClassConstructor.h | 99 + wrec/Escapes.h | 150 + wrec/Quantifier.h | 66 + wrec/WREC.cpp | 86 + wrec/WREC.h | 54 + wrec/WRECFunctors.cpp | 80 + wrec/WRECFunctors.h | 109 + wrec/WRECGenerator.cpp | 665 + wrec/WRECGenerator.h | 112 + wrec/WRECParser.cpp | 643 + wrec/WRECParser.h | 214 + wtf/ASCIICType.h | 67 +- wtf/AVLTree.h | 959 + wtf/AlwaysInline.h | 34 +- wtf/Assertions.cpp | 5 +- wtf/Assertions.cpp.rej | 35 + wtf/Assertions.h | 27 +- wtf/ByteArray.cpp | 38 + wtf/ByteArray.h | 81 + wtf/CONTRIBUTORS.pthreads-win32 | 137 + wtf/CurrentTime.cpp | 226 + wtf/CurrentTime.h | 47 + wtf/Deque.h | 9 + wtf/FastMalloc.cpp | 305 +- wtf/FastMalloc.h | 28 +- wtf/GOwnPtr.cpp | 59 + wtf/GOwnPtr.h | 97 + wtf/HashCountedSet.h | 32 +- wtf/HashFunctions.h | 73 +- wtf/HashIterators.h | 1 - wtf/HashMap.h | 133 +- wtf/HashSet.h | 181 +- wtf/HashTable.cpp | 15 +- wtf/HashTable.h | 295 +- wtf/HashTraits.h | 180 +- wtf/ListHashSet.h | 56 +- wtf/ListRefPtr.h | 8 +- wtf/Locker.h | 47 + wtf/MainThread.cpp | 142 + wtf/MainThread.h | 57 + wtf/MathExtras.h | 93 +- wtf/MessageQueue.h | 169 + wtf/Noncopyable.h | 1 - wtf/NotFound.h | 35 + wtf/OwnArrayPtr.h | 1 - wtf/OwnPtr.h | 7 +- wtf/OwnPtrWin.cpp | 0 wtf/PassRefPtr.h | 6 +- wtf/Platform.h | 355 +- wtf/PtrAndFlags.h | 53 + wtf/RandomNumber.cpp | 94 + .../objc/objc_header.h => wtf/RandomNumber.h | 35 +- .../objc_class.h => wtf/RandomNumberSeed.h | 72 +- wtf/RefCounted.h | 69 +- wtf/RefCountedLeakCounter.cpp | 100 + .../RefCountedLeakCounter.h | 43 +- wtf/RefPtr.h | 19 +- wtf/RefPtrHashMap.h | 130 +- wtf/RetainPtr.h | 4 +- wtf/StdLibExtras.h | 63 + wtf/StringExtras.h | 47 +- wtf/TCSpinLock.h | 15 +- wtf/TCSystemAlloc.cpp | 35 +- wtf/TCSystemAlloc.h | 6 + wtf/ThreadSpecific.h | 229 + wtf/ThreadSpecificWin.cpp | 45 + wtf/Threading.cpp | 83 + wtf/Threading.h | 295 + wtf/ThreadingGtk.cpp | 245 + wtf/ThreadingNone.cpp | 58 + wtf/ThreadingPthreads.cpp | 264 + wtf/ThreadingQt.cpp | 263 + wtf/ThreadingWin.cpp | 477 + wtf/UnusedParam.h | 3 +- wtf/Vector.h | 1093 +- wtf/VectorTraits.h | 8 +- wtf/dtoa.cpp | 2439 ++ kjs/operations.h => wtf/dtoa.h | 27 +- wtf/gtk/MainThreadGtk.cpp | 49 + wtf/iphone/MainThreadIPhone.mm | 58 + wtf/iphone/ThreadingNSThread.mm | 48 + wtf/mac/MainThreadMac.mm | 57 + wtf/qt/MainThreadQt.cpp | 69 + wtf/unicode/Collator.h | 67 + wtf/unicode/CollatorDefault.cpp | 75 + wtf/unicode/Unicode.h | 14 +- wtf/unicode/icu/CollatorICU.cpp | 144 + wtf/unicode/icu/UnicodeIcu.h | 415 +- wtf/unicode/qt4/UnicodeQt4.h | 751 +- wtf/win/MainThreadWin.cpp | 78 + wtf/wx/MainThreadWx.cpp | 38 + 545 files changed, 115512 insertions(+), 53229 deletions(-) rename bindings/c/c_class.h => API/JSBasePrivate.h (61%) rename bindings/npruntime_priv.h => API/JSProfilerPrivate.cpp (71%) rename bindings/c/c_runtime.h => API/JSProfilerPrivate.h (58%) create mode 100644 API/OpaqueJSString.cpp rename bindings/c/c_instance.h => API/OpaqueJSString.h (51%) create mode 100644 API/WebKitAvailability.h rename API/{ => tests}/JSNode.c (98%) rename API/{ => tests}/JSNode.h (96%) rename API/{ => tests}/JSNodeList.c (98%) rename API/{ => tests}/JSNodeList.h (95%) rename API/{ => tests}/Node.c (93%) rename API/{ => tests}/Node.h (97%) rename API/{ => tests}/NodeList.c (92%) rename API/{ => tests}/NodeList.h (96%) rename API/{ => tests}/minidom.c (95%) rename API/{ => tests}/minidom.html (100%) rename API/{ => tests}/minidom.js (98%) rename API/{ => tests}/testapi.c (89%) rename API/{ => tests}/testapi.js (98%) create mode 100644 AllInOneFile.cpp create mode 100644 ChangeLog-2008-08-10 delete mode 100644 ForwardingHeaders/JavaScriptCore/JSLock.h create mode 100644 ForwardingHeaders/JavaScriptCore/OpaqueJSString.h create mode 100644 ForwardingHeaders/JavaScriptCore/WebKitAvailability.h create mode 100644 JavaScriptCore.iPhone.order create mode 100644 JavaScriptCore.pro create mode 100644 JavaScriptCore.scons create mode 100644 SConstruct create mode 100644 assembler/AssemblerBuffer.h create mode 100644 assembler/MacroAssembler.h create mode 100644 assembler/X86Assembler.h delete mode 100644 bindings/NP_jsobject.cpp delete mode 100644 bindings/c/c_class.cpp delete mode 100644 bindings/c/c_instance.cpp delete mode 100644 bindings/c/c_runtime.cpp delete mode 100644 bindings/c/c_utility.cpp delete mode 100644 bindings/jni/jni_class.cpp delete mode 100644 bindings/jni/jni_instance.cpp delete mode 100644 bindings/jni/jni_instance.h delete mode 100644 bindings/jni/jni_jsobject.cpp delete mode 100644 bindings/jni/jni_jsobject.h delete mode 100644 bindings/jni/jni_objc.mm delete mode 100644 bindings/jni/jni_runtime.cpp delete mode 100644 bindings/jni/jni_runtime.h delete mode 100644 bindings/jni/jni_utility.cpp delete mode 100644 bindings/jni/jni_utility.h delete mode 100755 bindings/make_testbindings delete mode 100644 bindings/npapi.h delete mode 100644 bindings/npruntime.cpp delete mode 100644 bindings/npruntime.h delete mode 100644 bindings/npruntime_impl.h delete mode 100644 bindings/npruntime_internal.h delete mode 100644 bindings/objc/WebScriptObject.h delete mode 100644 bindings/objc/objc_class.mm delete mode 100644 bindings/objc/objc_instance.h delete mode 100644 bindings/objc/objc_instance.mm delete mode 100644 bindings/objc/objc_runtime.h delete mode 100644 bindings/objc/objc_runtime.mm delete mode 100644 bindings/objc/objc_utility.h delete mode 100644 bindings/objc/objc_utility.mm delete mode 100644 bindings/qt/qt_class.cpp delete mode 100644 bindings/qt/qt_class.h delete mode 100644 bindings/qt/qt_instance.cpp delete mode 100644 bindings/qt/qt_instance.h delete mode 100644 bindings/qt/qt_runtime.cpp delete mode 100644 bindings/qt/qt_runtime.h delete mode 100644 bindings/runtime.cpp delete mode 100644 bindings/runtime.h delete mode 100644 bindings/runtime_array.cpp delete mode 100644 bindings/runtime_array.h delete mode 100644 bindings/runtime_method.cpp delete mode 100644 bindings/runtime_object.cpp delete mode 100644 bindings/runtime_object.h delete mode 100644 bindings/runtime_root.cpp delete mode 100644 bindings/runtime_root.h delete mode 100644 bindings/test.js delete mode 100644 bindings/testC.js delete mode 100644 bindings/testM.js delete mode 100644 bindings/testbindings.cpp delete mode 100644 bindings/testbindings.mm delete mode 100644 bindings/testbindings.pro delete mode 100644 bindings/testqtbindings.cpp create mode 100644 bytecode/CodeBlock.cpp create mode 100644 bytecode/CodeBlock.h create mode 100644 bytecode/EvalCodeCache.h create mode 100644 bytecode/Instruction.h create mode 100644 bytecode/JumpTable.cpp create mode 100644 bytecode/JumpTable.h create mode 100644 bytecode/Opcode.cpp create mode 100644 bytecode/Opcode.h create mode 100644 bytecode/SamplingTool.cpp create mode 100644 bytecode/SamplingTool.h create mode 100644 bytecode/StructureStubInfo.cpp create mode 100644 bytecode/StructureStubInfo.h create mode 100644 bytecompiler/BytecodeGenerator.cpp create mode 100644 bytecompiler/BytecodeGenerator.h create mode 100644 bytecompiler/Label.h rename kjs/SymbolTable.h => bytecompiler/LabelScope.h (53%) create mode 100644 bytecompiler/RegisterID.h create mode 100644 bytecompiler/SegmentedVector.h rename kjs/config.h => config.h (70%) create mode 100755 create_hash_table create mode 100644 debugger/Debugger.cpp create mode 100644 debugger/Debugger.h create mode 100644 debugger/DebuggerActivation.cpp create mode 100644 debugger/DebuggerActivation.h create mode 100644 debugger/DebuggerCallFrame.cpp create mode 100644 debugger/DebuggerCallFrame.h create mode 100755 docs/make-bytecode-docs.pl create mode 100644 icu/unicode/parseerr.h create mode 100644 icu/unicode/ucol.h create mode 100644 icu/unicode/uloc.h create mode 100644 icu/unicode/unorm.h create mode 100644 icu/unicode/uset.h create mode 100644 interpreter/CallFrame.cpp create mode 100644 interpreter/CallFrame.h create mode 100644 interpreter/Interpreter.cpp create mode 100644 interpreter/Interpreter.h create mode 100644 interpreter/Register.h create mode 100644 interpreter/RegisterFile.cpp create mode 100644 interpreter/RegisterFile.h create mode 100644 jit/ExecutableAllocator.cpp create mode 100644 jit/ExecutableAllocator.h create mode 100644 jit/ExecutableAllocatorPosix.cpp create mode 100644 jit/ExecutableAllocatorWin.cpp create mode 100644 jit/JIT.cpp create mode 100644 jit/JIT.h create mode 100644 jit/JITArithmetic.cpp create mode 100644 jit/JITCall.cpp create mode 100644 jit/JITInlineMethods.h create mode 100644 jit/JITPropertyAccess.cpp create mode 100644 jsc.cpp create mode 100644 jsc.pro delete mode 100644 kjs/Activation.h delete mode 100644 kjs/AllInOneFile.cpp delete mode 100644 kjs/CollectorHeapIntrospector.cpp delete mode 100644 kjs/CollectorHeapIntrospector.h delete mode 100644 kjs/DateMath.cpp delete mode 100644 kjs/ExecState.cpp delete mode 100644 kjs/ExecState.h delete mode 100644 kjs/JSGlobalObject.cpp delete mode 100644 kjs/JSGlobalObject.h delete mode 100644 kjs/JSImmediate.cpp delete mode 100644 kjs/JSImmediate.h delete mode 100644 kjs/JSLock.cpp delete mode 100644 kjs/JSLockC.h delete mode 100644 kjs/JSVariableObject.h delete mode 100644 kjs/JSWrapperObject.h delete mode 100644 kjs/LabelStack.h delete mode 100644 kjs/Parser.cpp delete mode 100644 kjs/PropertyNameArray.h delete mode 100644 kjs/SavedBuiltins.h delete mode 100644 kjs/array_instance.cpp delete mode 100644 kjs/array_instance.h delete mode 100644 kjs/array_object.cpp delete mode 100644 kjs/array_object.h delete mode 100644 kjs/bool_object.cpp delete mode 100644 kjs/collector.cpp delete mode 100644 kjs/collector.h delete mode 100644 kjs/completion.h delete mode 100755 kjs/create_hash_table delete mode 100644 kjs/date_object.cpp delete mode 100644 kjs/date_object.h delete mode 100644 kjs/debugger.cpp delete mode 100644 kjs/debugger.h delete mode 100644 kjs/dtoa.cpp delete mode 100644 kjs/error_object.cpp delete mode 100644 kjs/error_object.h delete mode 100644 kjs/function.cpp delete mode 100644 kjs/function.h delete mode 100644 kjs/function_object.cpp delete mode 100644 kjs/function_object.h delete mode 100644 kjs/grammar.y delete mode 100644 kjs/identifier.cpp delete mode 100644 kjs/identifier.h delete mode 100644 kjs/internal.cpp delete mode 100644 kjs/internal.h delete mode 100644 kjs/interpreter.cpp delete mode 100644 kjs/interpreter.h delete mode 100644 kjs/lexer.cpp delete mode 100644 kjs/lexer.h delete mode 100644 kjs/list.h delete mode 100644 kjs/lookup.cpp delete mode 100644 kjs/lookup.h delete mode 100644 kjs/math_object.cpp delete mode 100644 kjs/math_object.h delete mode 100644 kjs/nodes.cpp delete mode 100644 kjs/nodes.h delete mode 100644 kjs/nodes2string.cpp delete mode 100644 kjs/number_object.h delete mode 100644 kjs/object.cpp delete mode 100644 kjs/object.h delete mode 100644 kjs/object_object.cpp delete mode 100644 kjs/operations.cpp delete mode 100644 kjs/property_map.cpp delete mode 100644 kjs/property_map.h delete mode 100644 kjs/property_slot.h delete mode 100644 kjs/protect.h delete mode 100644 kjs/regexp.cpp delete mode 100644 kjs/regexp.h delete mode 100644 kjs/regexp_object.cpp delete mode 100644 kjs/regexp_object.h delete mode 100644 kjs/scope_chain.h delete mode 100644 kjs/scope_chain_mark.h delete mode 100644 kjs/string_object.cpp delete mode 100644 kjs/string_object.h delete mode 100644 kjs/testkjs.cpp delete mode 100644 kjs/testkjs.pro delete mode 100644 kjs/types.h delete mode 100644 kjs/ustring.cpp delete mode 100644 kjs/ustring.h delete mode 100644 kjs/value.h create mode 100644 parser/Grammar.y rename kjs/keywords.table => parser/Keywords.table (100%) create mode 100644 parser/Lexer.cpp create mode 100644 parser/Lexer.h create mode 100644 parser/NodeInfo.h create mode 100644 parser/Nodes.cpp create mode 100644 parser/Nodes.h create mode 100644 parser/Parser.cpp rename {kjs => parser}/Parser.h (51%) create mode 100644 parser/ResultType.h rename {kjs => parser}/SourceCode.h (91%) rename {kjs => parser}/SourceProvider.h (95%) create mode 100644 profiler/CallIdentifier.h create mode 100644 profiler/HeavyProfile.cpp rename bindings/jni/jni_class.h => profiler/HeavyProfile.h (51%) create mode 100644 profiler/Profile.cpp create mode 100644 profiler/Profile.h create mode 100644 profiler/ProfileGenerator.cpp create mode 100644 profiler/ProfileGenerator.h create mode 100644 profiler/ProfileNode.cpp create mode 100644 profiler/ProfileNode.h create mode 100644 profiler/Profiler.cpp create mode 100644 profiler/Profiler.h create mode 100644 profiler/ProfilerServer.h create mode 100644 profiler/ProfilerServer.mm create mode 100644 profiler/TreeProfile.cpp create mode 100644 profiler/TreeProfile.h rename kjs/list.cpp => runtime/ArgList.cpp (59%) create mode 100644 runtime/ArgList.h create mode 100644 runtime/Arguments.cpp create mode 100644 runtime/Arguments.h create mode 100644 runtime/ArrayConstructor.cpp create mode 100644 runtime/ArrayConstructor.h create mode 100644 runtime/ArrayPrototype.cpp rename kjs/NodeInfo.h => runtime/ArrayPrototype.h (53%) create mode 100644 runtime/BatchedTransitionOptimizer.h create mode 100644 runtime/BooleanConstructor.cpp create mode 100644 runtime/BooleanConstructor.h create mode 100644 runtime/BooleanObject.cpp rename kjs/bool_object.h => runtime/BooleanObject.h (51%) create mode 100644 runtime/BooleanPrototype.cpp create mode 100644 runtime/BooleanPrototype.h create mode 100644 runtime/CallData.cpp create mode 100644 runtime/CallData.h create mode 100644 runtime/ClassInfo.h create mode 100644 runtime/Collector.cpp create mode 100644 runtime/Collector.h create mode 100644 runtime/CollectorHeapIterator.h rename {kjs => runtime}/CommonIdentifiers.cpp (66%) rename {kjs => runtime}/CommonIdentifiers.h (62%) create mode 100644 runtime/Completion.cpp create mode 100644 runtime/Completion.h create mode 100644 runtime/ConstructData.cpp create mode 100644 runtime/ConstructData.h create mode 100644 runtime/DateConstructor.cpp create mode 100644 runtime/DateConstructor.h create mode 100644 runtime/DateInstance.cpp create mode 100644 runtime/DateInstance.h create mode 100644 runtime/DateMath.cpp rename {kjs => runtime}/DateMath.h (78%) create mode 100644 runtime/DatePrototype.cpp create mode 100644 runtime/DatePrototype.h create mode 100644 runtime/Error.cpp create mode 100644 runtime/Error.h create mode 100644 runtime/ErrorConstructor.cpp create mode 100644 runtime/ErrorConstructor.h create mode 100644 runtime/ErrorInstance.cpp create mode 100644 runtime/ErrorInstance.h create mode 100644 runtime/ErrorPrototype.cpp create mode 100644 runtime/ErrorPrototype.h create mode 100644 runtime/ExceptionHelpers.cpp create mode 100644 runtime/ExceptionHelpers.h create mode 100644 runtime/FunctionConstructor.cpp create mode 100644 runtime/FunctionConstructor.h create mode 100644 runtime/FunctionPrototype.cpp create mode 100644 runtime/FunctionPrototype.h create mode 100644 runtime/GetterSetter.cpp create mode 100644 runtime/GetterSetter.h create mode 100644 runtime/GlobalEvalFunction.cpp rename kjs/LocalStorage.h => runtime/GlobalEvalFunction.h (61%) create mode 100644 runtime/Identifier.cpp create mode 100644 runtime/Identifier.h create mode 100644 runtime/InitializeThreading.cpp create mode 100644 runtime/InitializeThreading.h create mode 100644 runtime/InternalFunction.cpp create mode 100644 runtime/InternalFunction.h create mode 100644 runtime/JSActivation.cpp create mode 100644 runtime/JSActivation.h create mode 100644 runtime/JSArray.cpp create mode 100644 runtime/JSArray.h create mode 100644 runtime/JSByteArray.cpp create mode 100644 runtime/JSByteArray.h rename kjs/value.cpp => runtime/JSCell.cpp (50%) create mode 100644 runtime/JSCell.h create mode 100644 runtime/JSFunction.cpp create mode 100644 runtime/JSFunction.h create mode 100644 runtime/JSGlobalData.cpp create mode 100644 runtime/JSGlobalData.h create mode 100644 runtime/JSGlobalObject.cpp create mode 100644 runtime/JSGlobalObject.h create mode 100644 runtime/JSGlobalObjectFunctions.cpp create mode 100644 runtime/JSGlobalObjectFunctions.h create mode 100644 runtime/JSImmediate.cpp create mode 100644 runtime/JSImmediate.h create mode 100644 runtime/JSLock.cpp rename {kjs => runtime}/JSLock.h (63%) create mode 100644 runtime/JSNotAnObject.cpp create mode 100644 runtime/JSNotAnObject.h create mode 100644 runtime/JSNumberCell.cpp create mode 100644 runtime/JSNumberCell.h create mode 100644 runtime/JSObject.cpp create mode 100644 runtime/JSObject.h create mode 100644 runtime/JSPropertyNameIterator.cpp create mode 100644 runtime/JSPropertyNameIterator.h create mode 100644 runtime/JSStaticScopeObject.cpp create mode 100644 runtime/JSStaticScopeObject.h create mode 100644 runtime/JSString.cpp create mode 100644 runtime/JSString.h rename {kjs => runtime}/JSType.h (64%) create mode 100644 runtime/JSValue.cpp create mode 100644 runtime/JSValue.h rename {kjs => runtime}/JSVariableObject.cpp (52%) create mode 100644 runtime/JSVariableObject.h rename {kjs => runtime}/JSWrapperObject.cpp (83%) create mode 100644 runtime/JSWrapperObject.h create mode 100644 runtime/Lookup.cpp create mode 100644 runtime/Lookup.h create mode 100644 runtime/MathObject.cpp create mode 100644 runtime/MathObject.h create mode 100644 runtime/NativeErrorConstructor.cpp create mode 100644 runtime/NativeErrorConstructor.h create mode 100644 runtime/NativeErrorPrototype.cpp create mode 100644 runtime/NativeErrorPrototype.h create mode 100644 runtime/NumberConstructor.cpp create mode 100644 runtime/NumberConstructor.h create mode 100644 runtime/NumberObject.cpp create mode 100644 runtime/NumberObject.h rename kjs/number_object.cpp => runtime/NumberPrototype.cpp (53%) create mode 100644 runtime/NumberPrototype.h create mode 100644 runtime/ObjectConstructor.cpp create mode 100644 runtime/ObjectConstructor.h create mode 100644 runtime/ObjectPrototype.cpp rename kjs/object_object.h => runtime/ObjectPrototype.h (52%) rename kjs/property_slot.cpp => runtime/Operations.cpp (52%) create mode 100644 runtime/Operations.h create mode 100644 runtime/PropertyMapHashTable.h create mode 100644 runtime/PropertyNameArray.cpp create mode 100644 runtime/PropertyNameArray.h create mode 100644 runtime/PropertySlot.cpp create mode 100644 runtime/PropertySlot.h create mode 100644 runtime/Protect.h create mode 100644 runtime/PrototypeFunction.cpp create mode 100644 runtime/PrototypeFunction.h create mode 100644 runtime/PutPropertySlot.h create mode 100644 runtime/RegExp.cpp create mode 100644 runtime/RegExp.h create mode 100644 runtime/RegExpConstructor.cpp create mode 100644 runtime/RegExpConstructor.h create mode 100644 runtime/RegExpMatchesArray.h create mode 100644 runtime/RegExpObject.cpp create mode 100644 runtime/RegExpObject.h create mode 100644 runtime/RegExpPrototype.cpp create mode 100644 runtime/RegExpPrototype.h rename kjs/scope_chain.cpp => runtime/ScopeChain.cpp (68%) create mode 100644 runtime/ScopeChain.h rename kjs/dtoa.h => runtime/ScopeChainMark.h (65%) create mode 100644 runtime/SmallStrings.cpp create mode 100644 runtime/SmallStrings.h create mode 100644 runtime/StringConstructor.cpp create mode 100644 runtime/StringConstructor.h create mode 100644 runtime/StringObject.cpp create mode 100644 runtime/StringObject.h create mode 100644 runtime/StringObjectThatMasqueradesAsUndefined.h create mode 100644 runtime/StringPrototype.cpp create mode 100644 runtime/StringPrototype.h create mode 100644 runtime/Structure.cpp create mode 100644 runtime/Structure.h rename bindings/runtime_method.h => runtime/StructureChain.cpp (64%) rename bindings/NP_jsobject.h => runtime/StructureChain.h (66%) create mode 100644 runtime/StructureTransitionTable.h create mode 100644 runtime/SymbolTable.h create mode 100644 runtime/Tracing.d create mode 100644 runtime/Tracing.h create mode 100644 runtime/TypeInfo.h create mode 100644 runtime/UString.cpp create mode 100644 runtime/UString.h create mode 100644 wrec/CharacterClass.cpp rename bindings/c/c_utility.h => wrec/CharacterClass.h (50%) create mode 100644 wrec/CharacterClassConstructor.cpp create mode 100644 wrec/CharacterClassConstructor.h create mode 100644 wrec/Escapes.h create mode 100644 wrec/Quantifier.h create mode 100644 wrec/WREC.cpp create mode 100644 wrec/WREC.h create mode 100644 wrec/WRECFunctors.cpp create mode 100644 wrec/WRECFunctors.h create mode 100644 wrec/WRECGenerator.cpp create mode 100644 wrec/WRECGenerator.h create mode 100644 wrec/WRECParser.cpp create mode 100644 wrec/WRECParser.h create mode 100644 wtf/AVLTree.h create mode 100644 wtf/Assertions.cpp.rej create mode 100644 wtf/ByteArray.cpp create mode 100644 wtf/ByteArray.h create mode 100644 wtf/CONTRIBUTORS.pthreads-win32 create mode 100644 wtf/CurrentTime.cpp create mode 100644 wtf/CurrentTime.h create mode 100644 wtf/GOwnPtr.cpp create mode 100644 wtf/GOwnPtr.h create mode 100644 wtf/Locker.h create mode 100644 wtf/MainThread.cpp create mode 100644 wtf/MainThread.h create mode 100644 wtf/MessageQueue.h create mode 100644 wtf/NotFound.h mode change 100755 => 100644 wtf/OwnPtrWin.cpp create mode 100644 wtf/PtrAndFlags.h create mode 100644 wtf/RandomNumber.cpp rename bindings/objc/objc_header.h => wtf/RandomNumber.h (68%) rename bindings/objc/objc_class.h => wtf/RandomNumberSeed.h (54%) create mode 100644 wtf/RefCountedLeakCounter.cpp rename kjs/PropertyNameArray.cpp => wtf/RefCountedLeakCounter.h (56%) create mode 100644 wtf/StdLibExtras.h create mode 100644 wtf/ThreadSpecific.h create mode 100644 wtf/ThreadSpecificWin.cpp create mode 100644 wtf/Threading.cpp create mode 100644 wtf/Threading.h create mode 100644 wtf/ThreadingGtk.cpp create mode 100644 wtf/ThreadingNone.cpp create mode 100644 wtf/ThreadingPthreads.cpp create mode 100644 wtf/ThreadingQt.cpp create mode 100644 wtf/ThreadingWin.cpp create mode 100644 wtf/dtoa.cpp rename kjs/operations.h => wtf/dtoa.h (68%) create mode 100644 wtf/gtk/MainThreadGtk.cpp create mode 100644 wtf/iphone/MainThreadIPhone.mm create mode 100644 wtf/iphone/ThreadingNSThread.mm create mode 100644 wtf/mac/MainThreadMac.mm create mode 100644 wtf/qt/MainThreadQt.cpp create mode 100644 wtf/unicode/Collator.h create mode 100644 wtf/unicode/CollatorDefault.cpp create mode 100644 wtf/unicode/icu/CollatorICU.cpp create mode 100644 wtf/win/MainThreadWin.cpp create mode 100644 wtf/wx/MainThreadWx.cpp diff --git a/API/APICast.h b/API/APICast.h index d8c7c18..1344a16 100644 --- a/API/APICast.h +++ b/API/APICast.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -27,94 +26,93 @@ #ifndef APICast_h #define APICast_h -#include "ustring.h" -#include "ExecState.h" +#include "JSValue.h" -namespace KJS { +namespace JSC { class ExecState; - class JSValue; - class JSObject; class PropertyNameArray; + class JSGlobalData; + class JSObject; + class JSValuePtr; } +typedef const struct OpaqueJSContextGroup* JSContextGroupRef; typedef const struct OpaqueJSContext* JSContextRef; typedef struct OpaqueJSContext* JSGlobalContextRef; -typedef struct OpaqueJSString* JSStringRef; typedef struct OpaqueJSPropertyNameAccumulator* JSPropertyNameAccumulatorRef; typedef const struct OpaqueJSValue* JSValueRef; typedef struct OpaqueJSValue* JSObjectRef; /* Opaque typing convenience methods */ -inline KJS::ExecState* toJS(JSContextRef c) -{ - return reinterpret_cast(const_cast(c)); -} - -inline KJS::ExecState* toJS(JSGlobalContextRef c) +inline JSC::ExecState* toJS(JSContextRef c) { - return reinterpret_cast(c); + return reinterpret_cast(const_cast(c)); } -inline KJS::JSValue* toJS(JSValueRef v) +inline JSC::ExecState* toJS(JSGlobalContextRef c) { - return reinterpret_cast(const_cast(v)); + return reinterpret_cast(c); } -inline KJS::UString::Rep* toJS(JSStringRef b) +inline JSC::JSValuePtr toJS(JSValueRef v) { - return reinterpret_cast(b); + return JSC::JSValuePtr::decode(reinterpret_cast(const_cast(v))); } -inline KJS::JSObject* toJS(JSObjectRef o) +inline JSC::JSObject* toJS(JSObjectRef o) { - return reinterpret_cast(o); + return reinterpret_cast(o); } -inline KJS::PropertyNameArray* toJS(JSPropertyNameAccumulatorRef a) +inline JSC::PropertyNameArray* toJS(JSPropertyNameAccumulatorRef a) { - return reinterpret_cast(a); + return reinterpret_cast(a); } -inline JSValueRef toRef(KJS::JSValue* v) +inline JSC::JSGlobalData* toJS(JSContextGroupRef g) { - return reinterpret_cast(v); + return reinterpret_cast(const_cast(g)); } -inline JSValueRef* toRef(KJS::JSValue** v) +inline JSValueRef toRef(JSC::JSValuePtr v) { - return reinterpret_cast(const_cast(v)); + return reinterpret_cast(JSC::JSValuePtr::encode(v)); } -inline JSStringRef toRef(KJS::UString::Rep* s) +inline JSValueRef* toRef(JSC::JSValuePtr* v) { - return reinterpret_cast(s); + return reinterpret_cast(v); } -inline JSObjectRef toRef(KJS::JSObject* o) +inline JSObjectRef toRef(JSC::JSObject* o) { return reinterpret_cast(o); } -inline JSObjectRef toRef(const KJS::JSObject* o) +inline JSObjectRef toRef(const JSC::JSObject* o) { - return reinterpret_cast(const_cast(o)); + return reinterpret_cast(const_cast(o)); } -inline JSContextRef toRef(KJS::ExecState* e) +inline JSContextRef toRef(JSC::ExecState* e) { return reinterpret_cast(e); } -inline JSGlobalContextRef toGlobalRef(KJS::ExecState* e) +inline JSGlobalContextRef toGlobalRef(JSC::ExecState* e) { - ASSERT(!e->callingExecState()); return reinterpret_cast(e); } -inline JSPropertyNameAccumulatorRef toRef(KJS::PropertyNameArray* l) +inline JSPropertyNameAccumulatorRef toRef(JSC::PropertyNameArray* l) { return reinterpret_cast(l); } +inline JSContextGroupRef toRef(JSC::JSGlobalData* g) +{ + return reinterpret_cast(g); +} + #endif // APICast_h diff --git a/API/JSBase.cpp b/API/JSBase.cpp index 65f2128..2ffe345 100644 --- a/API/JSBase.cpp +++ b/API/JSBase.cpp @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * @@ -21,32 +20,38 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "JSBase.h" +#include "JSBasePrivate.h" #include "APICast.h" +#include "Completion.h" +#include "OpaqueJSString.h" #include "SourceCode.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -using namespace KJS; +using namespace JSC; JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsThisObject = toJS(thisObject); - UString::Rep* scriptRep = toJS(script); - UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; - SourceCode source = makeSource(UString(scriptRep), UString(sourceURLRep), startingLineNumber); - // Interpreter::evaluate sets "this" to the global object if it is NULL - Completion completion = Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), source, jsThisObject); + + // evaluate sets "this" to the global object if it is NULL + JSGlobalObject* globalObject = exec->dynamicGlobalObject(); + SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber); + Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject); if (completion.complType() == Throw) { if (exception) @@ -63,13 +68,12 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) { - JSLock lock; - ExecState* exec = toJS(ctx); - UString::Rep* scriptRep = toJS(script); - UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; - SourceCode source = makeSource(UString(scriptRep), UString(sourceURLRep), startingLineNumber); - Completion completion = Interpreter::checkSyntax(exec->dynamicGlobalObject()->globalExec(), source); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber); + Completion completion = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source); if (completion.complType() == Throw) { if (exception) *exception = toRef(completion.value()); @@ -79,12 +83,34 @@ bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourc return true; } -void JSGarbageCollect(JSContextRef) +void JSGarbageCollect(JSContextRef ctx) { - JSLock lock; - if (!Collector::isBusy()) - Collector::collect(); + // We used to recommend passing NULL as an argument here, which caused the only heap to be collected. + // As there is no longer a shared heap, the previously recommended usage became a no-op (but the GC + // will happen when the context group is destroyed). + // Because the function argument was originally ignored, some clients may pass their released context here, + // in which case there is a risk of crashing if another thread performs GC on the same heap in between. + if (!ctx) + return; + + ExecState* exec = toJS(ctx); + JSGlobalData& globalData = exec->globalData(); + + JSLock lock(globalData.isSharedInstance); + + if (!globalData.heap.isBusy()) + globalData.heap.collect(); + // FIXME: Perhaps we should trigger a second mark and sweep // once the garbage collector is done if this is called when // the collector is busy. } + +void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) +{ + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + exec->globalData().heap.reportExtraMemoryCost(size); +} diff --git a/API/JSBase.h b/API/JSBase.h index 7cf7c7d..f44d4ad 100644 --- a/API/JSBase.h +++ b/API/JSBase.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -27,10 +26,15 @@ #ifndef JSBase_h #define JSBase_h +#ifndef __cplusplus #include +#endif /* JavaScript engine interface */ +/*! @typedef JSContextGroupRef A group that associates JavaScript contexts with one another. Contexts in the same group may share and exchange JavaScript objects. */ +typedef const struct OpaqueJSContextGroup* JSContextGroupRef; + /*! @typedef JSContextRef A JavaScript execution context. Holds the global object and other execution state. */ typedef const struct OpaqueJSContext* JSContextRef; @@ -64,8 +68,10 @@ typedef struct OpaqueJSValue* JSObjectRef; #if defined(__GNUC__) #define JS_EXPORT __attribute__((visibility("default"))) #elif defined(WIN32) || defined(_WIN32) - // TODO: Export symbols with JS_EXPORT when using MSVC. - // See http://bugs.webkit.org/show_bug.cgi?id=16227 + /* + * TODO: Export symbols with JS_EXPORT when using MSVC. + * See http://bugs.webkit.org/show_bug.cgi?id=16227 + */ #define JS_EXPORT #else #define JS_EXPORT @@ -78,7 +84,7 @@ extern "C" { /* Script Evaluation */ /*! -@function +@function JSEvaluateScript @abstract Evaluates a string of JavaScript. @param ctx The execution context to use. @param script A JSString containing the script to evaluate. @@ -103,18 +109,17 @@ JS_EXPORT JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSOb JS_EXPORT bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); /*! -@function +@function JSGarbageCollect @abstract Performs a JavaScript garbage collection. -@param ctx This parameter is currently unused. Pass NULL. +@param ctx The execution context to use. @discussion JavaScript values that are on the machine stack, in a register, protected by JSValueProtect, set as the global object of an execution context, - or reachable from any such value will not be collected. - + or reachable from any such value will not be collected. + During JavaScript execution, you are not required to call this function; the - JavaScript engine will garbage collect as needed. One place you may want to call - this function, however, is after releasing the last reference to a JSGlobalContextRef. - At that point, a garbage collection can free the objects still referenced by the - JSGlobalContextRef's global object, along with the global object itself. + JavaScript engine will garbage collect as needed. JavaScript values created + within a context group are automatically destroyed when the last reference + to the context group is released. */ JS_EXPORT void JSGarbageCollect(JSContextRef ctx); @@ -122,4 +127,4 @@ JS_EXPORT void JSGarbageCollect(JSContextRef ctx); } #endif -#endif // JSBase_h +#endif /* JSBase_h */ diff --git a/bindings/c/c_class.h b/API/JSBasePrivate.h similarity index 61% rename from bindings/c/c_class.h rename to API/JSBasePrivate.h index 68a81fb..6beacda 100644 --- a/bindings/c/c_class.h +++ b/API/JSBasePrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2008 Apple Computer, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,39 +23,30 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BINDINGS_C_CLASS_H_ -#define BINDINGS_C_CLASS_H_ +#ifndef JSBasePrivate_h +#define JSBasePrivate_h -#if ENABLE(NETSCAPE_API) +#include +#include -#include "npruntime_internal.h" -#include "runtime.h" -#include - -namespace KJS { -namespace Bindings { - -class CClass : public Class { -protected: - CClass(NPClass*); // Use classForIsA to create a CClass. - -public: - static CClass* classForIsA(NPClass*); - virtual ~CClass(); - - virtual const char* name() const; - virtual MethodList methodsNamed(const Identifier&, Instance*) const; - virtual Field* fieldNamed(const Identifier&, Instance*) const; - -private: - NPClass* _isa; - mutable MethodMap _methods; - mutable FieldMap _fields; -}; - -} // namespace Bindings -} // namespace KJS - -#endif // ENABLE(NETSCAPE_API) +#ifdef __cplusplus +extern "C" { +#endif +/*! +@function +@abstract Reports an object's non-GC memory payload to the garbage collector. +@param ctx The execution context to use. +@param size The payload's size, in bytes. +@discussion Use this function to notify the garbage collector that a GC object +owns a large non-GC memory region. Calling this function will encourage the +garbage collector to collect soon, hoping to reclaim that large non-GC memory +region. +*/ +JS_EXPORT void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) AVAILABLE_AFTER_WEBKIT_VERSION_3_1; + +#ifdef __cplusplus +} #endif + +#endif /* JSBasePrivate_h */ diff --git a/API/JSCallbackConstructor.cpp b/API/JSCallbackConstructor.cpp index 46c1823..e10733e 100644 --- a/API/JSCallbackConstructor.cpp +++ b/API/JSCallbackConstructor.cpp @@ -1,6 +1,5 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,16 +27,17 @@ #include "JSCallbackConstructor.h" #include "APICast.h" -#include -#include +#include +#include +#include #include -namespace KJS { +namespace JSC { -const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0}; +const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0, 0 }; -JSCallbackConstructor::JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback) - : JSObject(exec->lexicalGlobalObject()->objectPrototype()) +JSCallbackConstructor::JSCallbackConstructor(PassRefPtr structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback) + : JSObject(structure) , m_class(jsClass) , m_callback(callback) { @@ -51,32 +51,29 @@ JSCallbackConstructor::~JSCallbackConstructor() JSClassRelease(m_class); } -bool JSCallbackConstructor::implementsHasInstance() const -{ - return true; -} - -bool JSCallbackConstructor::implementsConstruct() const -{ - return true; -} - -JSObject* JSCallbackConstructor::construct(ExecState* exec, const List &args) +static JSObject* constructJSCallback(ExecState* exec, JSObject* constructor, const ArgList& args) { JSContextRef ctx = toRef(exec); - JSObjectRef thisRef = toRef(this); + JSObjectRef constructorRef = toRef(constructor); - if (m_callback) { + JSObjectCallAsConstructorCallback callback = static_cast(constructor)->callback(); + if (callback) { int argumentCount = static_cast(args.size()); Vector arguments(argumentCount); for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(args[i]); + arguments[i] = toRef(args.at(exec, i)); - JSLock::DropAllLocks dropAllLocks; - return toJS(m_callback(ctx, thisRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); + JSLock::DropAllLocks dropAllLocks(exec); + return toJS(callback(ctx, constructorRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); } - return toJS(JSObjectMake(ctx, m_class, 0)); + return toJS(JSObjectMake(ctx, static_cast(constructor)->classRef(), 0)); +} + +ConstructType JSCallbackConstructor::getConstructData(ConstructData& constructData) +{ + constructData.native.function = constructJSCallback; + return ConstructTypeHost; } -} // namespace KJS +} // namespace JSC diff --git a/API/JSCallbackConstructor.h b/API/JSCallbackConstructor.h index fc45cb5..cb8307f 100644 --- a/API/JSCallbackConstructor.h +++ b/API/JSCallbackConstructor.h @@ -1,6 +1,5 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,32 +27,31 @@ #define JSCallbackConstructor_h #include "JSObjectRef.h" -#include +#include -namespace KJS { +namespace JSC { -class JSCallbackConstructor : public JSObject -{ +class JSCallbackConstructor : public JSObject { public: - JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback); + JSCallbackConstructor(PassRefPtr, JSClassRef, JSObjectCallAsConstructorCallback); virtual ~JSCallbackConstructor(); - - virtual bool implementsHasInstance() const; - - virtual bool implementsConstruct() const; - virtual JSObject* construct(ExecState*, const List &args); - - virtual const ClassInfo *classInfo() const { return &info; } + JSClassRef classRef() const { return m_class; } + JSObjectCallAsConstructorCallback callback() const { return m_callback; } static const ClassInfo info; + static PassRefPtr createStructure(JSValuePtr proto) + { + return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot)); + } + private: - JSCallbackConstructor(); // prevent default construction - JSCallbackConstructor(const JSCallbackConstructor&); + virtual ConstructType getConstructData(ConstructData&); + virtual const ClassInfo* classInfo() const { return &info; } JSClassRef m_class; JSObjectCallAsConstructorCallback m_callback; }; -} // namespace KJS +} // namespace JSC #endif // JSCallbackConstructor_h diff --git a/API/JSCallbackFunction.cpp b/API/JSCallbackFunction.cpp index fb3937d..86a2ebc 100644 --- a/API/JSCallbackFunction.cpp +++ b/API/JSCallbackFunction.cpp @@ -1,6 +1,5 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,40 +28,43 @@ #include "JSCallbackFunction.h" #include "APICast.h" -#include "function.h" -#include "function_object.h" -#include +#include "JSFunction.h" +#include "FunctionPrototype.h" +#include +#include #include -namespace KJS { +namespace JSC { -const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunctionImp::info, 0}; +ASSERT_CLASS_FITS_IN_CELL(JSCallbackFunction); + +const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 }; JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name) - : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name) + : InternalFunction(&exec->globalData(), exec->lexicalGlobalObject()->callbackFunctionStructure(), name) , m_callback(callback) { } -// InternalFunctionImp mish-mashes constructor and function behavior -- we should -// refactor the code so this override isn't necessary -bool JSCallbackFunction::implementsHasInstance() const { - return false; -} - -JSValue* JSCallbackFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args) +JSValuePtr JSCallbackFunction::call(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args) { JSContextRef execRef = toRef(exec); - JSObjectRef thisRef = toRef(this); - JSObjectRef thisObjRef = toRef(thisObj); + JSObjectRef functionRef = toRef(functionObject); + JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec)); int argumentCount = static_cast(args.size()); Vector arguments(argumentCount); for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(args[i]); + arguments[i] = toRef(args.at(exec, i)); - JSLock::DropAllLocks dropAllLocks; - return toJS(m_callback(execRef, thisRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); + JSLock::DropAllLocks dropAllLocks(exec); + return toJS(static_cast(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); +} + +CallType JSCallbackFunction::getCallData(CallData& callData) +{ + callData.native.function = call; + return CallTypeHost; } -} // namespace KJS +} // namespace JSC diff --git a/API/JSCallbackFunction.h b/API/JSCallbackFunction.h index 48be3d2..46f6fcc 100644 --- a/API/JSCallbackFunction.h +++ b/API/JSCallbackFunction.h @@ -1,6 +1,5 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,30 +26,33 @@ #ifndef JSCallbackFunction_h #define JSCallbackFunction_h +#include "InternalFunction.h" #include "JSObjectRef.h" -#include "function.h" -#include "object.h" -namespace KJS { +namespace JSC { -class JSCallbackFunction : public InternalFunctionImp -{ +class JSCallbackFunction : public InternalFunction { public: - JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name); + JSCallbackFunction(ExecState*, JSObjectCallAsFunctionCallback, const Identifier& name); - virtual bool implementsHasInstance() const; - virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List &args); - - virtual const ClassInfo *classInfo() const { return &info; } static const ClassInfo info; + // InternalFunction mish-mashes constructor and function behavior -- we should + // refactor the code so this override isn't necessary + static PassRefPtr createStructure(JSValuePtr proto) + { + return Structure::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot)); + } + private: - JSCallbackFunction(); // prevent default construction - JSCallbackFunction(const JSCallbackFunction&); - + virtual CallType getCallData(CallData&); + virtual const ClassInfo* classInfo() const { return &info; } + + static JSValuePtr call(ExecState*, JSObject*, JSValuePtr, const ArgList&); + JSObjectCallAsFunctionCallback m_callback; }; -} // namespace KJS +} // namespace JSC #endif // JSCallbackFunction_h diff --git a/API/JSCallbackObject.cpp b/API/JSCallbackObject.cpp index 129b304..2fde0f8 100644 --- a/API/JSCallbackObject.cpp +++ b/API/JSCallbackObject.cpp @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * Copyright (C) 2007 Eric Seidel @@ -28,14 +27,15 @@ #include "config.h" #include "JSCallbackObject.h" -#include "collector.h" +#include "Collector.h" -namespace KJS { +namespace JSC { -// Define the two types of JSCallbackObjects we support. -template <> const ClassInfo JSCallbackObject::info = { "CallbackObject", 0, 0 }; -template <> const ClassInfo JSCallbackObject::info = { "CallbackGlobalObject", 0, 0 }; +ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject); +ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject); -COMPILE_ASSERT(sizeof(JSCallbackObject) <= CELL_SIZE, global_callback_object_fits_in_cell); +// Define the two types of JSCallbackObjects we support. +template <> const ClassInfo JSCallbackObject::info = { "CallbackObject", 0, 0, 0 }; +template <> const ClassInfo JSCallbackObject::info = { "CallbackGlobalObject", 0, 0, 0 }; -} // namespace KJS +} // namespace JSC diff --git a/API/JSCallbackObject.h b/API/JSCallbackObject.h index 7eb32a6..9001c43 100644 --- a/API/JSCallbackObject.h +++ b/API/JSCallbackObject.h @@ -1,6 +1,5 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2007 Eric Seidel * * Redistribution and use in source and binary forms, with or without @@ -30,64 +29,84 @@ #include "JSObjectRef.h" #include "JSValueRef.h" -#include "object.h" +#include "JSObject.h" -namespace KJS { +namespace JSC { template -class JSCallbackObject : public Base -{ +class JSCallbackObject : public Base { public: - JSCallbackObject(ExecState*, JSClassRef, JSValue* prototype, void* data); + JSCallbackObject(ExecState*, PassRefPtr, JSClassRef, void* data); JSCallbackObject(JSClassRef); virtual ~JSCallbackObject(); + void setPrivate(void* data); + void* getPrivate(); + + static const ClassInfo info; + + JSClassRef classRef() const { return m_callbackObjectData->jsClass; } + bool inherits(JSClassRef) const; + + static PassRefPtr createStructure(JSValuePtr proto) + { + return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | OverridesHasInstance)); + } + +private: virtual UString className() const; virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); virtual bool getOwnPropertySlot(ExecState*, unsigned, PropertySlot&); - virtual void put(ExecState*, const Identifier&, JSValue*, int attr); - virtual void put(ExecState*, unsigned, JSValue*, int attr); + virtual void put(ExecState*, const Identifier&, JSValuePtr, PutPropertySlot&); virtual bool deleteProperty(ExecState*, const Identifier&); virtual bool deleteProperty(ExecState*, unsigned); - virtual bool implementsConstruct() const; - virtual JSObject* construct(ExecState*, const List& args); - - virtual bool implementsHasInstance() const; - virtual bool hasInstance(ExecState *exec, JSValue *value); - - virtual bool implementsCall() const; - virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List &args); + virtual bool hasInstance(ExecState* exec, JSValuePtr value, JSValuePtr proto); virtual void getPropertyNames(ExecState*, PropertyNameArray&); virtual double toNumber(ExecState*) const; virtual UString toString(ExecState*) const; - void setPrivate(void* data); - void* getPrivate(); - - virtual const ClassInfo *classInfo() const { return &info; } - static const ClassInfo info; + virtual ConstructType getConstructData(ConstructData&); + virtual CallType getCallData(CallData&); + virtual const ClassInfo* classInfo() const { return &info; } - bool inherits(JSClassRef) const; - -private: void init(ExecState*); + + static JSCallbackObject* asCallbackObject(JSValuePtr); + + static JSValuePtr call(ExecState*, JSObject* functionObject, JSValuePtr thisValue, const ArgList&); + static JSObject* construct(ExecState*, JSObject* constructor, const ArgList&); + + static JSValuePtr staticValueGetter(ExecState*, const Identifier&, const PropertySlot&); + static JSValuePtr staticFunctionGetter(ExecState*, const Identifier&, const PropertySlot&); + static JSValuePtr callbackGetter(ExecState*, const Identifier&, const PropertySlot&); + + struct JSCallbackObjectData { + JSCallbackObjectData(void* privateData, JSClassRef jsClass) + : privateData(privateData) + , jsClass(jsClass) + { + JSClassRetain(jsClass); + } + + ~JSCallbackObjectData() + { + JSClassRelease(jsClass); + } + + void* privateData; + JSClassRef jsClass; + }; - static JSValue* cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); - static JSValue* staticValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot); - static JSValue* staticFunctionGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot); - static JSValue* callbackGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); - - void* m_privateData; - JSClassRef m_class; + OwnPtr m_callbackObjectData; }; -} // namespace KJS +} // namespace JSC // include the actual template class implementation #include "JSCallbackObjectFunctions.h" diff --git a/API/JSCallbackObjectFunctions.h b/API/JSCallbackObjectFunctions.h index f987dd8..23f941d 100644 --- a/API/JSCallbackObjectFunctions.h +++ b/API/JSCallbackObjectFunctions.h @@ -1,6 +1,5 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * Copyright (C) 2007 Eric Seidel * * Redistribution and use in source and binary forms, with or without @@ -25,33 +24,42 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include "APICast.h" +#include "Error.h" #include "JSCallbackFunction.h" #include "JSClassRef.h" -#include "JSObjectRef.h" #include "JSGlobalObject.h" +#include "JSLock.h" +#include "JSObjectRef.h" +#include "JSString.h" #include "JSStringRef.h" +#include "OpaqueJSString.h" #include "PropertyNameArray.h" -#include "internal.h" #include -namespace KJS { +namespace JSC { + +template +inline JSCallbackObject* JSCallbackObject::asCallbackObject(JSValuePtr value) +{ + ASSERT(asObject(value)->inherits(&info)); + return static_cast(asObject(value)); +} template -JSCallbackObject::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JSValue* prototype, void* data) - : Base(prototype) - , m_privateData(data) - , m_class(JSClassRetain(jsClass)) +JSCallbackObject::JSCallbackObject(ExecState* exec, PassRefPtr structure, JSClassRef jsClass, void* data) + : Base(structure) + , m_callbackObjectData(new JSCallbackObjectData(data, jsClass)) { init(exec); } -// Global object constructor. FIXME: Move this into a JSGlobalCallbackObject subclass. +// Global object constructor. +// FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one. template JSCallbackObject::JSCallbackObject(JSClassRef jsClass) - : m_privateData(0) - , m_class(JSClassRetain(jsClass)) + : Base() + , m_callbackObjectData(new JSCallbackObjectData(0, jsClass)) { ASSERT(Base::isGlobalObject()); init(static_cast(this)->globalExec()); @@ -63,7 +71,7 @@ void JSCallbackObject::init(ExecState* exec) ASSERT(exec); Vector initRoutines; - JSClassRef jsClass = m_class; + JSClassRef jsClass = classRef(); do { if (JSObjectInitializeCallback initialize = jsClass->initialize) initRoutines.append(initialize); @@ -71,7 +79,7 @@ void JSCallbackObject::init(ExecState* exec) // initialize from base to derived for (int i = static_cast(initRoutines.size()) - 1; i >= 0; i--) { - JSLock::DropAllLocks dropAllLocks; + JSLock::DropAllLocks dropAllLocks(exec); JSObjectInitializeCallback initialize = initRoutines[i]; initialize(toRef(exec), toRef(this)); } @@ -82,19 +90,17 @@ JSCallbackObject::~JSCallbackObject() { JSObjectRef thisRef = toRef(this); - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) - if (JSObjectFinalizeCallback finalize = jsClass->finalize) { + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) + if (JSObjectFinalizeCallback finalize = jsClass->finalize) finalize(thisRef); - } - - JSClassRelease(m_class); } template UString JSCallbackObject::className() const { - if (!m_class->className.isNull()) - return m_class->className; + UString thisClassName = classRef()->className(); + if (!thisClassName.isNull()) + return thisClassName; return Base::className(); } @@ -104,35 +110,36 @@ bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, const Identifie { JSContextRef ctx = toRef(exec); JSObjectRef thisRef = toRef(this); - JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); + RefPtr propertyNameRef; - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { // optional optimization to bypass getProperty in cases when we only need to know if the property exists if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) { - JSLock::DropAllLocks dropAllLocks; - if (hasProperty(ctx, thisRef, propertyNameRef)) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSLock::DropAllLocks dropAllLocks(exec); + if (hasProperty(ctx, thisRef, propertyNameRef.get())) { slot.setCustom(this, callbackGetter); return true; } } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { - JSLock::DropAllLocks dropAllLocks; - if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) { - // cache the value so we don't have to compute it again - // FIXME: This violates the PropertySlot design a little bit. - // We should either use this optimization everywhere, or nowhere. - slot.setCustom(reinterpret_cast(toJS(value)), cachedValueGetter); + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSLock::DropAllLocks dropAllLocks(exec); + if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) { + slot.setValue(toJS(value)); return true; } } - if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) { + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { if (staticValues->contains(propertyName.ustring().rep())) { slot.setCustom(this, staticValueGetter); return true; } } - if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { if (staticFunctions->contains(propertyName.ustring().rep())) { slot.setCustom(this, staticFunctionGetter); return true; @@ -146,54 +153,52 @@ bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, const Identifie template bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) { - return getOwnPropertySlot(exec, Identifier::from(propertyName), slot); + return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot); } template -void JSCallbackObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) +void JSCallbackObject::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) { JSContextRef ctx = toRef(exec); JSObjectRef thisRef = toRef(this); - JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); + RefPtr propertyNameRef; JSValueRef valueRef = toRef(value); - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { - JSLock::DropAllLocks dropAllLocks; - if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()))) + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSLock::DropAllLocks dropAllLocks(exec); + if (setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, toRef(exec->exceptionSlot()))) return; } - if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) { + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) { if (entry->attributes & kJSPropertyAttributeReadOnly) return; if (JSObjectSetPropertyCallback setProperty = entry->setProperty) { - JSLock::DropAllLocks dropAllLocks; - if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()))) + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSLock::DropAllLocks dropAllLocks(exec); + if (setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, toRef(exec->exceptionSlot()))) return; } else throwError(exec, ReferenceError, "Attempt to set a property that is not settable."); } } - if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { if (entry->attributes & kJSPropertyAttributeReadOnly) return; - JSCallbackObject::putDirect(propertyName, value, attr); // put as override property + JSCallbackObject::putDirect(propertyName, value); // put as override property return; } } } - return Base::put(exec, propertyName, value, attr); -} - -template -void JSCallbackObject::put(ExecState* exec, unsigned propertyName, JSValue* value, int attr) -{ - return put(exec, Identifier::from(propertyName), value, attr); + return Base::put(exec, propertyName, value, slot); } template @@ -201,16 +206,18 @@ bool JSCallbackObject::deleteProperty(ExecState* exec, const Identifier& p { JSContextRef ctx = toRef(exec); JSObjectRef thisRef = toRef(this); - JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); + RefPtr propertyNameRef; - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) { - JSLock::DropAllLocks dropAllLocks; - if (deleteProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSLock::DropAllLocks dropAllLocks(exec); + if (deleteProperty(ctx, thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) return true; } - if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) { + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) { if (entry->attributes & kJSPropertyAttributeDontDelete) return false; @@ -218,7 +225,7 @@ bool JSCallbackObject::deleteProperty(ExecState* exec, const Identifier& p } } - if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { if (entry->attributes & kJSPropertyAttributeDontDelete) return false; @@ -233,97 +240,89 @@ bool JSCallbackObject::deleteProperty(ExecState* exec, const Identifier& p template bool JSCallbackObject::deleteProperty(ExecState* exec, unsigned propertyName) { - return deleteProperty(exec, Identifier::from(propertyName)); + return deleteProperty(exec, Identifier::from(exec, propertyName)); } template -bool JSCallbackObject::implementsConstruct() const +ConstructType JSCallbackObject::getConstructData(ConstructData& constructData) { - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) - if (jsClass->callAsConstructor) - return true; - - return false; + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { + if (jsClass->callAsConstructor) { + constructData.native.function = construct; + return ConstructTypeHost; + } + } + return ConstructTypeNone; } template -JSObject* JSCallbackObject::construct(ExecState* exec, const List& args) +JSObject* JSCallbackObject::construct(ExecState* exec, JSObject* constructor, const ArgList& args) { JSContextRef execRef = toRef(exec); - JSObjectRef thisRef = toRef(this); + JSObjectRef constructorRef = toRef(constructor); - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + for (JSClassRef jsClass = static_cast*>(constructor)->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callAsConstructor) { int argumentCount = static_cast(args.size()); Vector arguments(argumentCount); for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(args[i]); - JSLock::DropAllLocks dropAllLocks; - return toJS(callAsConstructor(execRef, thisRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); + arguments[i] = toRef(args.at(exec, i)); + JSLock::DropAllLocks dropAllLocks(exec); + return toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); } } - ASSERT(0); // implementsConstruct should prevent us from reaching here + ASSERT_NOT_REACHED(); // getConstructData should prevent us from reaching here return 0; } template -bool JSCallbackObject::implementsHasInstance() const -{ - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) - if (jsClass->hasInstance) - return true; - - return false; -} - -template -bool JSCallbackObject::hasInstance(ExecState *exec, JSValue *value) +bool JSCallbackObject::hasInstance(ExecState* exec, JSValuePtr value, JSValuePtr) { JSContextRef execRef = toRef(exec); JSObjectRef thisRef = toRef(this); - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) { - JSLock::DropAllLocks dropAllLocks; + JSLock::DropAllLocks dropAllLocks(exec); return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot())); } - - ASSERT_NOT_REACHED(); // implementsHasInstance should prevent us from reaching here - return 0; + } + return false; } - template -bool JSCallbackObject::implementsCall() const +CallType JSCallbackObject::getCallData(CallData& callData) { - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) - if (jsClass->callAsFunction) - return true; - - return false; + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { + if (jsClass->callAsFunction) { + callData.native.function = call; + return CallTypeHost; + } + } + return CallTypeNone; } template -JSValue* JSCallbackObject::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args) +JSValuePtr JSCallbackObject::call(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args) { JSContextRef execRef = toRef(exec); - JSObjectRef thisRef = toRef(this); - JSObjectRef thisObjRef = toRef(thisObj); + JSObjectRef functionRef = toRef(functionObject); + JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec)); - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + for (JSClassRef jsClass = static_cast*>(functionObject)->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) { int argumentCount = static_cast(args.size()); Vector arguments(argumentCount); for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(args[i]); - JSLock::DropAllLocks dropAllLocks; - return toJS(callAsFunction(execRef, thisRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); + arguments[i] = toRef(args.at(exec, i)); + JSLock::DropAllLocks dropAllLocks(exec); + return toJS(callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); } } - ASSERT_NOT_REACHED(); // implementsCall should prevent us from reaching here - return 0; + ASSERT_NOT_REACHED(); // getCallData should prevent us from reaching here + return noValue(); } template @@ -332,31 +331,31 @@ void JSCallbackObject::getPropertyNames(ExecState* exec, PropertyNameArray JSContextRef execRef = toRef(exec); JSObjectRef thisRef = toRef(this); - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) { + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) { - JSLock::DropAllLocks dropAllLocks; + JSLock::DropAllLocks dropAllLocks(exec); getPropertyNames(execRef, thisRef, toRef(&propertyNames)); } - if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) { - typedef OpaqueJSClass::StaticValuesTable::const_iterator iterator; + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { + typedef OpaqueJSClassStaticValuesTable::const_iterator iterator; iterator end = staticValues->end(); for (iterator it = staticValues->begin(); it != end; ++it) { UString::Rep* name = it->first.get(); StaticValueEntry* entry = it->second; if (entry->getProperty && !(entry->attributes & kJSPropertyAttributeDontEnum)) - propertyNames.add(Identifier(name)); + propertyNames.add(Identifier(exec, name)); } } - if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { - typedef OpaqueJSClass::StaticFunctionsTable::const_iterator iterator; + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { + typedef OpaqueJSClassStaticFunctionsTable::const_iterator iterator; iterator end = staticFunctions->end(); for (iterator it = staticFunctions->begin(); it != end; ++it) { UString::Rep* name = it->first.get(); StaticFunctionEntry* entry = it->second; if (!(entry->attributes & kJSPropertyAttributeDontEnum)) - propertyNames.add(Identifier(name)); + propertyNames.add(Identifier(exec, name)); } } } @@ -367,14 +366,21 @@ void JSCallbackObject::getPropertyNames(ExecState* exec, PropertyNameArray template double JSCallbackObject::toNumber(ExecState* exec) const { + // We need this check to guard against the case where this object is rhs of + // a binary expression where lhs threw an exception in its conversion to + // primitive + if (exec->hadException()) + return NaN; JSContextRef ctx = toRef(exec); JSObjectRef thisRef = toRef(this); - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { - JSLock::DropAllLocks dropAllLocks; - if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot()))) - return toJS(value)->getNumber(); + JSLock::DropAllLocks dropAllLocks(exec); + if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot()))) { + double dValue; + return toJS(value).getNumber(dValue) ? dValue : NaN; + } } return Base::toNumber(exec); @@ -386,11 +392,15 @@ UString JSCallbackObject::toString(ExecState* exec) const JSContextRef ctx = toRef(exec); JSObjectRef thisRef = toRef(this); - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { - JSLock::DropAllLocks dropAllLocks; - if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot()))) - return toJS(value)->getString(); + JSValueRef value; + { + JSLock::DropAllLocks dropAllLocks(exec); + value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot())); + } + if (value) + return toJS(value).getString(); } return Base::toString(exec); @@ -399,19 +409,19 @@ UString JSCallbackObject::toString(ExecState* exec) const template void JSCallbackObject::setPrivate(void* data) { - m_privateData = data; + m_callbackObjectData->privateData = data; } template void* JSCallbackObject::getPrivate() { - return m_privateData; + return m_callbackObjectData->privateData; } template bool JSCallbackObject::inherits(JSClassRef c) const { - for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) if (jsClass == c) return true; @@ -419,28 +429,21 @@ bool JSCallbackObject::inherits(JSClassRef c) const } template -JSValue* JSCallbackObject::cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) -{ - JSValue* v = slot.slotBase(); - ASSERT(v); - return v; -} - -template -JSValue* JSCallbackObject::staticValueGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSCallbackObject::staticValueGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { - ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info)); - JSCallbackObject* thisObj = static_cast(slot.slotBase()); + JSCallbackObject* thisObj = asCallbackObject(slot.slotBase()); JSObjectRef thisRef = toRef(thisObj); - JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); + RefPtr propertyNameRef; - for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) - if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) + for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) if (JSObjectGetPropertyCallback getProperty = entry->getProperty) { - JSLock::DropAllLocks dropAllLocks; - if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSLock::DropAllLocks dropAllLocks(exec); + if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) return toJS(value); } @@ -448,21 +451,20 @@ JSValue* JSCallbackObject::staticValueGetter(ExecState* exec, JSObject*, c } template -JSValue* JSCallbackObject::staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSCallbackObject::staticFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { - ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info)); - JSCallbackObject* thisObj = static_cast(slot.slotBase()); + JSCallbackObject* thisObj = asCallbackObject(slot.slotBase()); // Check for cached or override property. - PropertySlot slot2; + PropertySlot slot2(thisObj); if (thisObj->Base::getOwnPropertySlot(exec, propertyName, slot2)) - return slot2.getValue(exec, thisObj, propertyName); + return slot2.getValue(exec, propertyName); - for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) { - if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) { + for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) { + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) { - JSObject* o = new JSCallbackFunction(exec, callAsFunction, propertyName); + JSObject* o = new (exec) JSCallbackFunction(exec, callAsFunction, propertyName); thisObj->putDirect(propertyName, o, entry->attributes); return o; } @@ -474,22 +476,23 @@ JSValue* JSCallbackObject::staticFunctionGetter(ExecState* exec, JSObject* } template -JSValue* JSCallbackObject::callbackGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSCallbackObject::callbackGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { - ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info)); - JSCallbackObject* thisObj = static_cast(slot.slotBase()); + JSCallbackObject* thisObj = asCallbackObject(slot.slotBase()); JSObjectRef thisRef = toRef(thisObj); - JSStringRef propertyNameRef = toRef(propertyName.ustring().rep()); + RefPtr propertyNameRef; - for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) + for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { - JSLock::DropAllLocks dropAllLocks; - if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSLock::DropAllLocks dropAllLocks(exec); + if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) return toJS(value); } return throwError(exec, ReferenceError, "hasProperty callback returned true for a property that doesn't exist."); } -} // namespace KJS +} // namespace JSC diff --git a/API/JSClassRef.cpp b/API/JSClassRef.cpp index 98aaaf5..afde7ce 100644 --- a/API/JSClassRef.cpp +++ b/API/JSClassRef.cpp @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * @@ -30,21 +29,18 @@ #include "APICast.h" #include "JSCallbackObject.h" #include "JSObjectRef.h" -#include -#include -#include +#include +#include +#include +#include -using namespace KJS; +using namespace JSC; const JSClassDefinition kJSClassDefinitionEmpty = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* protoClass) - // FIXME: - : className(definition->className) - , parentClass(definition->parentClass) + : parentClass(definition->parentClass) , prototypeClass(0) - , staticValues(0) - , staticFunctions(0) , initialize(definition->initialize) , finalize(definition->finalize) , hasProperty(definition->hasProperty) @@ -56,23 +52,25 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* , callAsConstructor(definition->callAsConstructor) , hasInstance(definition->hasInstance) , convertToType(definition->convertToType) - , cachedPrototype(0) + , m_className(UString::Rep::createFromUTF8(definition->className)) + , m_staticValues(0) + , m_staticFunctions(0) { + initializeThreading(); + if (const JSStaticValue* staticValue = definition->staticValues) { - staticValues = new StaticValuesTable(); + m_staticValues = new OpaqueJSClassStaticValuesTable(); while (staticValue->name) { - // FIXME: - staticValues->add(Identifier(staticValue->name).ustring().rep(), + m_staticValues->add(UString::Rep::createFromUTF8(staticValue->name), new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes)); ++staticValue; } } - + if (const JSStaticFunction* staticFunction = definition->staticFunctions) { - staticFunctions = new StaticFunctionsTable(); + m_staticFunctions = new OpaqueJSClassStaticFunctionsTable(); while (staticFunction->name) { - // FIXME: - staticFunctions->add(Identifier(staticFunction->name).ustring().rep(), + m_staticFunctions->add(UString::Rep::createFromUTF8(staticFunction->name), new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes)); ++staticFunction; } @@ -84,48 +82,131 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* OpaqueJSClass::~OpaqueJSClass() { - if (staticValues) { - deleteAllValues(*staticValues); - delete staticValues; + ASSERT(!m_className.rep()->identifierTable()); + + if (m_staticValues) { + OpaqueJSClassStaticValuesTable::const_iterator end = m_staticValues->end(); + for (OpaqueJSClassStaticValuesTable::const_iterator it = m_staticValues->begin(); it != end; ++it) { + ASSERT(!it->first->identifierTable()); + delete it->second; + } + delete m_staticValues; } - if (staticFunctions) { - deleteAllValues(*staticFunctions); - delete staticFunctions; + if (m_staticFunctions) { + OpaqueJSClassStaticFunctionsTable::const_iterator end = m_staticFunctions->end(); + for (OpaqueJSClassStaticFunctionsTable::const_iterator it = m_staticFunctions->begin(); it != end; ++it) { + ASSERT(!it->first->identifierTable()); + delete it->second; + } + delete m_staticFunctions; } if (prototypeClass) JSClassRelease(prototypeClass); } -JSClassRef OpaqueJSClass::createNoAutomaticPrototype(const JSClassDefinition* definition) +PassRefPtr OpaqueJSClass::createNoAutomaticPrototype(const JSClassDefinition* definition) { - return new OpaqueJSClass(definition, 0); + return adoptRef(new OpaqueJSClass(definition, 0)); } -void clearReferenceToPrototype(JSObjectRef prototype) +static void clearReferenceToPrototype(JSObjectRef prototype) { - OpaqueJSClass* jsClass = static_cast(JSObjectGetPrivate(prototype)); - ASSERT(jsClass); - jsClass->cachedPrototype = 0; + OpaqueJSClassContextData* jsClassData = static_cast(JSObjectGetPrivate(prototype)); + ASSERT(jsClassData); + jsClassData->cachedPrototype = 0; } -JSClassRef OpaqueJSClass::create(const JSClassDefinition* definition) +PassRefPtr OpaqueJSClass::create(const JSClassDefinition* definition) { if (const JSStaticFunction* staticFunctions = definition->staticFunctions) { // copy functions into a prototype class JSClassDefinition protoDefinition = kJSClassDefinitionEmpty; protoDefinition.staticFunctions = staticFunctions; protoDefinition.finalize = clearReferenceToPrototype; - OpaqueJSClass* protoClass = new OpaqueJSClass(&protoDefinition, 0); + + // We are supposed to use JSClassRetain/Release but since we know that we currently have + // the only reference to this class object we cheat and use a RefPtr instead. + RefPtr protoClass = adoptRef(new OpaqueJSClass(&protoDefinition, 0)); // remove functions from the original class JSClassDefinition objectDefinition = *definition; objectDefinition.staticFunctions = 0; - return new OpaqueJSClass(&objectDefinition, protoClass); + + return adoptRef(new OpaqueJSClass(&objectDefinition, protoClass.get())); + } + + return adoptRef(new OpaqueJSClass(definition, 0)); +} + +OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass* jsClass) + : m_class(jsClass) + , cachedPrototype(0) +{ + if (jsClass->m_staticValues) { + staticValues = new OpaqueJSClassStaticValuesTable; + OpaqueJSClassStaticValuesTable::const_iterator end = jsClass->m_staticValues->end(); + for (OpaqueJSClassStaticValuesTable::const_iterator it = jsClass->m_staticValues->begin(); it != end; ++it) { + ASSERT(!it->first->identifierTable()); + staticValues->add(UString::Rep::createCopying(it->first->data(), it->first->size()), + new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes)); + } + + } else + staticValues = 0; + + + if (jsClass->m_staticFunctions) { + staticFunctions = new OpaqueJSClassStaticFunctionsTable; + OpaqueJSClassStaticFunctionsTable::const_iterator end = jsClass->m_staticFunctions->end(); + for (OpaqueJSClassStaticFunctionsTable::const_iterator it = jsClass->m_staticFunctions->begin(); it != end; ++it) { + ASSERT(!it->first->identifierTable()); + staticFunctions->add(UString::Rep::createCopying(it->first->data(), it->first->size()), + new StaticFunctionEntry(it->second->callAsFunction, it->second->attributes)); + } + + } else + staticFunctions = 0; +} + +OpaqueJSClassContextData::~OpaqueJSClassContextData() +{ + if (staticValues) { + deleteAllValues(*staticValues); + delete staticValues; } - return new OpaqueJSClass(definition, 0); + if (staticFunctions) { + deleteAllValues(*staticFunctions); + delete staticFunctions; + } +} + +OpaqueJSClassContextData& OpaqueJSClass::contextData(ExecState* exec) +{ + OpaqueJSClassContextData*& contextData = exec->globalData().opaqueJSClassData.add(this, 0).first->second; + if (!contextData) + contextData = new OpaqueJSClassContextData(this); + return *contextData; +} + +UString OpaqueJSClass::className() +{ + // Make a deep copy, so that the caller has no chance to put the original into IdentifierTable. + return UString(m_className.data(), m_className.size()); +} + +OpaqueJSClassStaticValuesTable* OpaqueJSClass::staticValues(JSC::ExecState* exec) +{ + OpaqueJSClassContextData& jsClassData = contextData(exec); + return jsClassData.staticValues; +} + +OpaqueJSClassStaticFunctionsTable* OpaqueJSClass::staticFunctions(JSC::ExecState* exec) +{ + OpaqueJSClassContextData& jsClassData = contextData(exec); + return jsClassData.staticFunctions; } /*! @@ -136,7 +217,7 @@ JSClassRef OpaqueJSClass::create(const JSClassDefinition* definition) @param jsClass A JSClass whose prototype you want to get. @result The JSObject prototype that was automatically generated for jsClass, or NULL if no prototype was automatically generated. This is the prototype that will be used when constructing an object using jsClass. */ -JSObject* OpaqueJSClass::prototype(JSContextRef ctx) +JSObject* OpaqueJSClass::prototype(ExecState* exec) { /* Class (C++) and prototype (JS) inheritance are parallel, so: * (C++) | (JS) @@ -148,17 +229,16 @@ JSObject* OpaqueJSClass::prototype(JSContextRef ctx) if (!prototypeClass) return 0; - - ExecState* exec = toJS(ctx); - - if (!cachedPrototype) { + + OpaqueJSClassContextData& jsClassData = contextData(exec); + + if (!jsClassData.cachedPrototype) { // Recursive, but should be good enough for our purposes - JSObject* parentPrototype = 0; - if (parentClass) - parentPrototype = parentClass->prototype(ctx); // can be null - if (!parentPrototype) - parentPrototype = exec->dynamicGlobalObject()->objectPrototype(); - cachedPrototype = new JSCallbackObject(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction + jsClassData.cachedPrototype = new (exec) JSCallbackObject(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction + if (parentClass) { + if (JSObject* prototype = parentClass->prototype(exec)) + jsClassData.cachedPrototype->setPrototype(prototype); + } } - return cachedPrototype; + return jsClassData.cachedPrototype; } diff --git a/API/JSClassRef.h b/API/JSClassRef.h index eb2b35b..4f67618 100644 --- a/API/JSClassRef.h +++ b/API/JSClassRef.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -29,9 +28,9 @@ #include "JSObjectRef.h" -#include -#include -#include +#include +#include +#include #include #include @@ -56,22 +55,42 @@ struct StaticFunctionEntry { JSPropertyAttributes attributes; }; -struct OpaqueJSClass : public RefCounted { - static OpaqueJSClass* create(const JSClassDefinition*); - static OpaqueJSClass* createNoAutomaticPrototype(const JSClassDefinition*); +typedef HashMap, StaticValueEntry*> OpaqueJSClassStaticValuesTable; +typedef HashMap, StaticFunctionEntry*> OpaqueJSClassStaticFunctionsTable; + +class OpaqueJSClass; + +// An OpaqueJSClass (JSClass) is created without a context, so it can be used with any context, even across context groups. +// This structure holds data members that vary across context groups. +struct OpaqueJSClassContextData : Noncopyable { + OpaqueJSClassContextData(OpaqueJSClass*); + ~OpaqueJSClassContextData(); + + // It is necessary to keep OpaqueJSClass alive because of the following rare scenario: + // 1. A class is created and used, so its context data is stored in JSGlobalData hash map. + // 2. The class is released, and when all JS objects that use it are collected, OpaqueJSClass + // is deleted (that's the part prevented by this RefPtr). + // 3. Another class is created at the same address. + // 4. When it is used, the old context data is found in JSGlobalData and used. + RefPtr m_class; + + OpaqueJSClassStaticValuesTable* staticValues; + OpaqueJSClassStaticFunctionsTable* staticFunctions; + JSC::JSObject* cachedPrototype; +}; + +struct OpaqueJSClass : public ThreadSafeShared { + static PassRefPtr create(const JSClassDefinition*); + static PassRefPtr createNoAutomaticPrototype(const JSClassDefinition*); ~OpaqueJSClass(); - KJS::JSObject* prototype(JSContextRef ctx); - - typedef HashMap, StaticValueEntry*> StaticValuesTable; - typedef HashMap, StaticFunctionEntry*> StaticFunctionsTable; + JSC::UString className(); + OpaqueJSClassStaticValuesTable* staticValues(JSC::ExecState*); + OpaqueJSClassStaticFunctionsTable* staticFunctions(JSC::ExecState*); + JSC::JSObject* prototype(JSC::ExecState*); - KJS::UString className; OpaqueJSClass* parentClass; OpaqueJSClass* prototypeClass; - - StaticValuesTable* staticValues; - StaticFunctionsTable* staticFunctions; JSObjectInitializeCallback initialize; JSObjectFinalizeCallback finalize; @@ -86,12 +105,18 @@ struct OpaqueJSClass : public RefCounted { JSObjectConvertToTypeCallback convertToType; private: + friend struct OpaqueJSClassContextData; + OpaqueJSClass(); OpaqueJSClass(const OpaqueJSClass&); OpaqueJSClass(const JSClassDefinition*, OpaqueJSClass* protoClass); - - friend void clearReferenceToPrototype(JSObjectRef prototype); - KJS::JSObject* cachedPrototype; + + OpaqueJSClassContextData& contextData(JSC::ExecState*); + + // UStrings in these data members should not be put into any IdentifierTable. + JSC::UString m_className; + OpaqueJSClassStaticValuesTable* m_staticValues; + OpaqueJSClassStaticFunctionsTable* m_staticFunctions; }; #endif // JSClassRef_h diff --git a/API/JSContextRef.cpp b/API/JSContextRef.cpp index 203326e..c331179 100644 --- a/API/JSContextRef.cpp +++ b/API/JSContextRef.cpp @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * @@ -28,49 +27,128 @@ #include "JSContextRef.h" #include "APICast.h" +#include "InitializeThreading.h" #include "JSCallbackObject.h" #include "JSClassRef.h" #include "JSGlobalObject.h" -#include "object.h" +#include "JSObject.h" #include -using namespace KJS; +#if PLATFORM(DARWIN) +#include + +static const int32_t webkitFirstVersionWithConcurrentGlobalContexts = 0x2100500; // 528.5.0 +#endif + +using namespace JSC; + +JSContextGroupRef JSContextGroupCreate() +{ + initializeThreading(); + return toRef(JSGlobalData::create().releaseRef()); +} + +JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) +{ + toJS(group)->ref(); + return group; +} + +void JSContextGroupRelease(JSContextGroupRef group) +{ + toJS(group)->deref(); +} JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) { - JSLock lock; + initializeThreading(); +#if PLATFORM(DARWIN) + // When running on Tiger or Leopard, or if the application was linked before JSGlobalContextCreate was changed + // to use a unique JSGlobalData, we use a shared one for compatibility. +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + if (NSVersionOfLinkTimeLibrary("JavaScriptCore") <= webkitFirstVersionWithConcurrentGlobalContexts) { +#else + { +#endif + JSLock lock(true); + return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass); + } +#endif // PLATFORM(DARWIN) + + return JSGlobalContextCreateInGroup(0, globalObjectClass); +} + +JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) +{ + initializeThreading(); + + JSLock lock(true); + + RefPtr globalData = group ? PassRefPtr(toJS(group)) : JSGlobalData::create(); + +#if ENABLE(JSC_MULTIPLE_THREADS) + globalData->makeUsableFromMultipleThreads(); +#endif if (!globalObjectClass) { - JSGlobalObject* globalObject = new JSGlobalObject; + JSGlobalObject* globalObject = new (globalData.get()) JSGlobalObject; return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec())); } - JSGlobalObject* globalObject = new JSCallbackObject(globalObjectClass); - JSGlobalContextRef ctx = toGlobalRef(globalObject->globalExec()); - JSValue* prototype = globalObjectClass->prototype(ctx); + JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject(globalObjectClass); + ExecState* exec = globalObject->globalExec(); + JSValuePtr prototype = globalObjectClass->prototype(exec); if (!prototype) prototype = jsNull(); - globalObject->reset(prototype); - return JSGlobalContextRetain(ctx); + globalObject->resetPrototype(prototype); + return JSGlobalContextRetain(toGlobalRef(exec)); } JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx) { - JSLock lock; ExecState* exec = toJS(ctx); + JSLock lock(exec); + + JSGlobalData& globalData = exec->globalData(); + + globalData.heap.registerThread(); + gcProtect(exec->dynamicGlobalObject()); + globalData.ref(); return ctx; } void JSGlobalContextRelease(JSGlobalContextRef ctx) { - JSLock lock; ExecState* exec = toJS(ctx); + JSLock lock(exec); + gcUnprotect(exec->dynamicGlobalObject()); + + JSGlobalData& globalData = exec->globalData(); + if (globalData.refCount() == 2) { // One reference is held by JSGlobalObject, another added by JSGlobalContextRetain(). + // The last reference was released, this is our last chance to collect. + ASSERT(!globalData.heap.protectedObjectCount()); + ASSERT(!globalData.heap.isBusy()); + globalData.heap.destroy(); + } else + globalData.heap.collect(); + + globalData.deref(); } JSObjectRef JSContextGetGlobalObject(JSContextRef ctx) { ExecState* exec = toJS(ctx); - return toRef(exec->dynamicGlobalObject()); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + // It is necessary to call toThisObject to get the wrapper object when used with WebCore. + return toRef(exec->lexicalGlobalObject()->toThisObject(exec)); +} + +JSContextGroupRef JSContextGetGroup(JSContextRef ctx) +{ + ExecState* exec = toJS(ctx); + return toRef(&exec->globalData()); } diff --git a/API/JSContextRef.h b/API/JSContextRef.h index df0a397..bc89511 100644 --- a/API/JSContextRef.h +++ b/API/JSContextRef.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -29,23 +28,71 @@ #include #include +#include +#ifndef __cplusplus #include +#endif #ifdef __cplusplus extern "C" { #endif +/*! +@function +@abstract Creates a JavaScript context group. +@discussion A JSContextGroup associates JavaScript contexts with one another. + Contexts in the same group may share and exchange JavaScript objects. Sharing and/or exchanging + JavaScript objects between contexts in different groups will produce undefined behavior. + When objects from the same context group are used in multiple threads, explicit + synchronization is required. +@result The created JSContextGroup. +*/ +JS_EXPORT JSContextGroupRef JSContextGroupCreate() AVAILABLE_AFTER_WEBKIT_VERSION_3_1; + +/*! +@function +@abstract Retains a JavaScript context group. +@param group The JSContextGroup to retain. +@result A JSContextGroup that is the same as group. +*/ +JS_EXPORT JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) AVAILABLE_AFTER_WEBKIT_VERSION_3_1; + +/*! +@function +@abstract Releases a JavaScript context group. +@param group The JSContextGroup to release. +*/ +JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) AVAILABLE_AFTER_WEBKIT_VERSION_3_1; + /*! @function @abstract Creates a global JavaScript execution context. @discussion JSGlobalContextCreate allocates a global object and populates it with all the built-in JavaScript objects, such as Object, Function, String, and Array. + + In WebKit version 4.0 and later, the context is created in a unique context group. + Therefore, scripts may execute in it concurrently with scripts executing in other contexts. + However, you may not use values created in the context in other contexts. @param globalObjectClass The class to use when creating the global object. Pass NULL to use the default object class. @result A JSGlobalContext with a global object of class globalObjectClass. */ -JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass); +JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; + +/*! +@function +@abstract Creates a global JavaScript execution context in the context group provided. +@discussion JSGlobalContextCreateInGroup allocates a global object and populates it with + all the built-in JavaScript objects, such as Object, Function, String, and Array. +@param globalObjectClass The class to use when creating the global object. Pass + NULL to use the default object class. +@param group The context group to use. The created global context retains the group. + Pass NULL to create a unique group for the context. +@result A JSGlobalContext with a global object of class globalObjectClass and a context + group equal to group. +*/ +JS_EXPORT JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) AVAILABLE_AFTER_WEBKIT_VERSION_3_1; /*! @function @@ -70,8 +117,16 @@ JS_EXPORT void JSGlobalContextRelease(JSGlobalContextRef ctx); */ JS_EXPORT JSObjectRef JSContextGetGlobalObject(JSContextRef ctx); +/*! +@function +@abstract Gets the context group to which a JavaScript execution context belongs. +@param ctx The JSContext whose group you want to get. +@result ctx's group. +*/ +JS_EXPORT JSContextGroupRef JSContextGetGroup(JSContextRef ctx) AVAILABLE_AFTER_WEBKIT_VERSION_3_1; + #ifdef __cplusplus } #endif -#endif // JSContextRef_h +#endif /* JSContextRef_h */ diff --git a/API/JSObjectRef.cpp b/API/JSObjectRef.cpp index c6cda25..e81e512 100644 --- a/API/JSObjectRef.cpp +++ b/API/JSObjectRef.cpp @@ -1,6 +1,6 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008 Kelvin W Sherlock (ksherlock@gmail.com) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,108 +27,202 @@ #include "config.h" #include "JSObjectRef.h" -#include #include "APICast.h" -#include "JSValueRef.h" +#include "DateConstructor.h" +#include "ErrorConstructor.h" +#include "FunctionConstructor.h" +#include "Identifier.h" +#include "InitializeThreading.h" +#include "JSArray.h" #include "JSCallbackConstructor.h" #include "JSCallbackFunction.h" #include "JSCallbackObject.h" #include "JSClassRef.h" +#include "JSFunction.h" #include "JSGlobalObject.h" - +#include "JSObject.h" +#include "JSRetainPtr.h" +#include "JSString.h" +#include "JSValueRef.h" +#include "ObjectPrototype.h" #include "PropertyNameArray.h" -#include "function.h" -#include "function_object.h" -#include "identifier.h" -#include "internal.h" -#include "object.h" -#include "object_object.h" +#include "RegExpConstructor.h" +#include -using namespace KJS; +using namespace JSC; JSClassRef JSClassCreate(const JSClassDefinition* definition) { - JSLock lock; - JSClassRef jsClass = (definition->attributes & kJSClassAttributeNoAutomaticPrototype) + initializeThreading(); + RefPtr jsClass = (definition->attributes & kJSClassAttributeNoAutomaticPrototype) ? OpaqueJSClass::createNoAutomaticPrototype(definition) : OpaqueJSClass::create(definition); - return JSClassRetain(jsClass); + return jsClass.release().releaseRef(); } JSClassRef JSClassRetain(JSClassRef jsClass) { - JSLock lock; jsClass->ref(); return jsClass; } void JSClassRelease(JSClassRef jsClass) { - JSLock lock; jsClass->deref(); } JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); if (!jsClass) - return toRef(new JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient + return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure())); // slightly more efficient - JSValue* jsPrototype = jsClass->prototype(ctx); - if (!jsPrototype) - jsPrototype = exec->lexicalGlobalObject()->objectPrototype(); + JSCallbackObject* object = new (exec) JSCallbackObject(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data); + if (JSObject* prototype = jsClass->prototype(exec)) + object->setPrototype(prototype); - return toRef(new JSCallbackObject(exec, jsClass, jsPrototype, data)); + return toRef(object); } JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction) { - JSLock lock; ExecState* exec = toJS(ctx); - Identifier nameID = name ? Identifier(toJS(name)) : Identifier("anonymous"); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous"); - return toRef(new JSCallbackFunction(exec, callAsFunction, nameID)); + return toRef(new (exec) JSCallbackFunction(exec, callAsFunction, nameID)); } JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + JSValuePtr jsPrototype = jsClass + ? jsClass->prototype(exec) + : exec->lexicalGlobalObject()->objectPrototype(); - JSValue* jsPrototype = jsClass - ? jsClass->prototype(ctx) - : exec->dynamicGlobalObject()->objectPrototype(); - - JSCallbackConstructor* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor); + JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor); constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly); return toRef(constructor); } JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) { - JSLock lock; - ExecState* exec = toJS(ctx); - UString::Rep* bodyRep = toJS(body); - UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; - - Identifier nameID = name ? Identifier(toJS(name)) : Identifier("anonymous"); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous"); - List args; + ArgList args; for (unsigned i = 0; i < parameterCount; i++) - args.append(jsString(UString(toJS(parameterNames[i])))); - args.append(jsString(UString(bodyRep))); + args.append(jsString(exec, parameterNames[i]->ustring())); + args.append(jsString(exec, body->ustring())); + + JSObject* result = constructFunction(exec, args, nameID, sourceURL->ustring(), startingLineNumber); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + result = 0; + } + return toRef(result); +} + +JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + JSObject* result; + if (argumentCount) { + ArgList argList; + for (size_t i = 0; i < argumentCount; ++i) + argList.append(toJS(arguments[i])); + + result = constructArray(exec, argList); + } else + result = constructEmptyArray(exec); - JSObject* result = exec->dynamicGlobalObject()->functionConstructor()->construct(exec, args, nameID, UString(sourceURLRep), startingLineNumber); if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); exec->clearException(); result = 0; } + + return toRef(result); +} + +JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + ArgList argList; + for (size_t i = 0; i < argumentCount; ++i) + argList.append(toJS(arguments[i])); + + JSObject* result = constructDate(exec, argList); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + result = 0; + } + + return toRef(result); +} + +JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + ArgList argList; + for (size_t i = 0; i < argumentCount; ++i) + argList.append(toJS(arguments[i])); + + JSObject* result = constructError(exec, argList); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + result = 0; + } + + return toRef(result); +} + +JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + ArgList argList; + for (size_t i = 0; i < argumentCount; ++i) + argList.append(toJS(arguments[i])); + + JSObject* result = constructRegExp(exec, argList); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec->exception()); + exec->clearException(); + result = 0; + } + return toRef(result); } @@ -141,29 +235,31 @@ JSValueRef JSObjectGetPrototype(JSContextRef, JSObjectRef object) void JSObjectSetPrototype(JSContextRef, JSObjectRef object, JSValueRef value) { JSObject* jsObject = toJS(object); - JSValue* jsValue = toJS(value); + JSValuePtr jsValue = toJS(value); - jsObject->setPrototype(jsValue); + jsObject->setPrototype(jsValue.isObject() ? jsValue : jsNull()); } bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsObject = toJS(object); - UString::Rep* nameRep = toJS(propertyName); - return jsObject->hasProperty(exec, Identifier(nameRep)); + return jsObject->hasProperty(exec, propertyName->identifier(&exec->globalData())); } JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsObject = toJS(object); - UString::Rep* nameRep = toJS(propertyName); - JSValue* jsValue = jsObject->get(exec, Identifier(nameRep)); + JSValuePtr jsValue = jsObject->get(exec, propertyName->identifier(&exec->globalData())); if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); @@ -174,13 +270,21 @@ JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsObject = toJS(object); - UString::Rep* nameRep = toJS(propertyName); - JSValue* jsValue = toJS(value); - - jsObject->put(exec, Identifier(nameRep), jsValue, attributes); + Identifier name(propertyName->identifier(&exec->globalData())); + JSValuePtr jsValue = toJS(value); + + if (attributes && !jsObject->hasProperty(exec, name)) + jsObject->putWithAttributes(exec, name, jsValue, attributes); + else { + PutPropertySlot slot; + jsObject->put(exec, name, jsValue, slot); + } + if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); @@ -190,11 +294,13 @@ void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef prope JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsObject = toJS(object); - JSValue* jsValue = jsObject->get(exec, propertyIndex); + JSValuePtr jsValue = jsObject->get(exec, propertyIndex); if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); @@ -206,10 +312,12 @@ JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsi void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsObject = toJS(object); - JSValue* jsValue = toJS(value); + JSValuePtr jsValue = toJS(value); jsObject->put(exec, propertyIndex, jsValue); if (exec->hadException()) { @@ -221,12 +329,13 @@ void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned p bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsObject = toJS(object); - UString::Rep* nameRep = toJS(propertyName); - bool result = jsObject->deleteProperty(exec, Identifier(nameRep)); + bool result = jsObject->deleteProperty(exec, propertyName->identifier(&exec->globalData())); if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); @@ -264,25 +373,32 @@ bool JSObjectSetPrivate(JSObjectRef object, void* data) bool JSObjectIsFunction(JSContextRef, JSObjectRef object) { - JSObject* jsObject = toJS(object); - return jsObject->implementsCall(); + CallData callData; + return toJS(object)->getCallData(callData) != CallTypeNone; } JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsObject = toJS(object); JSObject* jsThisObject = toJS(thisObject); if (!jsThisObject) - jsThisObject = exec->dynamicGlobalObject(); - - List argList; + jsThisObject = exec->globalThisValue(); + + ArgList argList; for (size_t i = 0; i < argumentCount; i++) argList.append(toJS(arguments[i])); - JSValueRef result = toRef(jsObject->call(exec, jsThisObject, argList)); // returns NULL if object->implementsCall() is false + CallData callData; + CallType callType = jsObject->getCallData(callData); + if (callType == CallTypeNone) + return 0; + + JSValueRef result = toRef(call(exec, jsObject, callType, callData, jsThisObject, argList)); if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); @@ -295,20 +411,27 @@ JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObject bool JSObjectIsConstructor(JSContextRef, JSObjectRef object) { JSObject* jsObject = toJS(object); - return jsObject->implementsConstruct(); + ConstructData constructData; + return jsObject->getConstructData(constructData) != ConstructTypeNone; } JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + JSObject* jsObject = toJS(object); - - List argList; + + ConstructData constructData; + ConstructType constructType = jsObject->getConstructData(constructData); + if (constructType == ConstructTypeNone) + return 0; + + ArgList argList; for (size_t i = 0; i < argumentCount; i++) argList.append(toJS(arguments[i])); - - JSObjectRef result = toRef(jsObject->construct(exec, argList)); // returns NULL if object->implementsCall() is false + JSObjectRef result = toRef(construct(exec, jsObject, constructType, constructData, argList)); if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); @@ -318,40 +441,51 @@ JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size return result; } -struct OpaqueJSPropertyNameArray -{ - OpaqueJSPropertyNameArray() : refCount(0) +struct OpaqueJSPropertyNameArray { + OpaqueJSPropertyNameArray(JSGlobalData* globalData) + : refCount(0) + , globalData(globalData) { } unsigned refCount; - PropertyNameArray array; + JSGlobalData* globalData; + Vector > array; }; JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object) { - JSLock lock; JSObject* jsObject = toJS(object); ExecState* exec = toJS(ctx); - - JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(); - jsObject->getPropertyNames(exec, propertyNames->array); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + JSGlobalData* globalData = &exec->globalData(); + + JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(globalData); + PropertyNameArray array(globalData); + jsObject->getPropertyNames(exec, array); + + size_t size = array.size(); + propertyNames->array.reserveInitialCapacity(size); + for (size_t i = 0; i < size; ++i) + propertyNames->array.append(JSRetainPtr(Adopt, OpaqueJSString::create(array[i].ustring()).releaseRef())); return JSPropertyNameArrayRetain(propertyNames); } JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array) { - JSLock lock; ++array->refCount; return array; } void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array) { - JSLock lock; - if (--array->refCount == 0) + if (--array->refCount == 0) { + JSLock lock(array->globalData->isSharedInstance); delete array; + } } size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array) @@ -361,14 +495,15 @@ size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array) JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index) { - return toRef(array->array[static_cast(index)].ustring().rep()); + return array->array[static_cast(index)].get(); } void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef array, JSStringRef propertyName) { - JSLock lock; PropertyNameArray* propertyNames = toJS(array); - UString::Rep* rep = toJS(propertyName); - - propertyNames->add(Identifier(rep)); + + propertyNames->globalData()->heap.registerThread(); + JSLock lock(propertyNames->globalData()->isSharedInstance); + + propertyNames->add(propertyName->identifier(propertyNames->globalData())); } diff --git a/API/JSObjectRef.h b/API/JSObjectRef.h index bf4041f..461764c 100644 --- a/API/JSObjectRef.h +++ b/API/JSObjectRef.h @@ -1,6 +1,6 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2008 Kelvin W Sherlock (ksherlock@gmail.com) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,9 +29,12 @@ #include #include +#include +#ifndef __cplusplus #include -#include // for size_t +#endif +#include /* for size_t */ #ifdef __cplusplus extern "C" { @@ -338,7 +341,7 @@ Standard JavaScript practice calls for storing function objects in prototypes, s A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute. */ typedef struct { - int version; // current (and only) version is 0 + int version; /* current (and only) version is 0 */ JSClassAttributes attributes; const char* className; @@ -427,6 +430,52 @@ JS_EXPORT JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStrin */ JS_EXPORT JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor); +/*! + @function + @abstract Creates a JavaScript Array object. + @param ctx The execution context to use. + @param argumentCount An integer count of the number of arguments in arguments. + @param arguments A JSValue array of data to populate the Array with. Pass NULL if argumentCount is 0. + @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. + @result A JSObject that is an Array. + @discussion The behavior of this function does not exactly match the behavior of the built-in Array constructor. Specifically, if one argument + is supplied, this function returns an array with one element. + */ +JS_EXPORT JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_AFTER_WEBKIT_VERSION_3_1; + +/*! + @function + @abstract Creates a JavaScript Date object, as if by invoking the built-in Date constructor. + @param ctx The execution context to use. + @param argumentCount An integer count of the number of arguments in arguments. + @param arguments A JSValue array of arguments to pass to the Date Constructor. Pass NULL if argumentCount is 0. + @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. + @result A JSObject that is a Date. + */ +JS_EXPORT JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_AFTER_WEBKIT_VERSION_3_1; + +/*! + @function + @abstract Creates a JavaScript Error object, as if by invoking the built-in Error constructor. + @param ctx The execution context to use. + @param argumentCount An integer count of the number of arguments in arguments. + @param arguments A JSValue array of arguments to pass to the Error Constructor. Pass NULL if argumentCount is 0. + @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. + @result A JSObject that is a Error. + */ +JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_AFTER_WEBKIT_VERSION_3_1; + +/*! + @function + @abstract Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor. + @param ctx The execution context to use. + @param argumentCount An integer count of the number of arguments in arguments. + @param arguments A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0. + @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. + @result A JSObject that is a RegExp. + */ +JS_EXPORT JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_AFTER_WEBKIT_VERSION_3_1; + /*! @function @abstract Creates a function with a given script as its body. @@ -642,4 +691,4 @@ JS_EXPORT void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef acc } #endif -#endif // JSObjectRef_h +#endif /* JSObjectRef_h */ diff --git a/bindings/npruntime_priv.h b/API/JSProfilerPrivate.cpp similarity index 71% rename from bindings/npruntime_priv.h rename to API/JSProfilerPrivate.cpp index 8df3871..ea277f0 100644 --- a/bindings/npruntime_priv.h +++ b/API/JSProfilerPrivate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,19 +23,24 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef NP_RUNTIME_PRIV_H_ -#define NP_RUNTIME_PRIV_H_ +#include "config.h" +#include "JSProfilerPrivate.h" -#if ENABLE(NETSCAPE_API) +#include "APICast.h" +#include "OpaqueJSString.h" +#include "Profiler.h" -#include "npruntime_internal.h" +using namespace JSC; -/* - NPN_InitializeVariantWithStringCopy() will copy string data. The string data - will be deallocated by calls to NPReleaseVariantValue(). -*/ -void NPN_InitializeVariantWithStringCopy(NPVariant*, const NPString*); +void JSStartProfiling(JSContextRef ctx, JSStringRef title) +{ + Profiler::profiler()->startProfiling(toJS(ctx), title->ustring()); +} -#endif // ENABLE(NETSCAPE_API) -#endif +void JSEndProfiling(JSContextRef ctx, JSStringRef title) +{ + ExecState* exec = toJS(ctx); + Profiler* profiler = Profiler::profiler(); + profiler->stopProfiling(exec, title->ustring()); +} diff --git a/bindings/c/c_runtime.h b/API/JSProfilerPrivate.h similarity index 58% rename from bindings/c/c_runtime.h rename to API/JSProfilerPrivate.h index 7502166..b3fe533 100644 --- a/bindings/c/c_runtime.h +++ b/API/JSProfilerPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,45 +23,41 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BINDINGS_C_RUNTIME_H_ -#define BINDINGS_C_RUNTIME_H_ +#ifndef JSProfiler_h +#define JSProfiler_h -#if ENABLE(NETSCAPE_API) +#include -#include "npruntime_internal.h" -#include "runtime.h" - -namespace KJS { -namespace Bindings { - -class CField : public Field { -public: - CField(NPIdentifier ident) : _fieldIdentifier(ident) { } - - virtual JSValue* valueFromInstance(ExecState*, const Instance*) const; - virtual void setValueToInstance(ExecState*, const Instance*, JSValue*) const; - virtual const char* name() const; - -private: - NPIdentifier _fieldIdentifier; -}; - - -class CMethod : public Method -{ -public: - CMethod(NPIdentifier ident) : _methodIdentifier(ident) { } - - virtual const char* name() const; - virtual int numParameters() const { return 0; } - -private: - NPIdentifier _methodIdentifier; -}; - -} // namespace Bindings -} // namespace KJS +#ifndef __cplusplus +#include +#endif -#endif // ENABLE(NETSCAPE_API) +#ifdef __cplusplus +extern "C" { +#endif +/*! +@function JSStartProfiling +@abstract Enables the profler. +@param ctx The execution context to use. +@param title The title of the profile. +@result The profiler is turned on. +*/ +JS_EXPORT void JSStartProfiling(JSContextRef ctx, JSStringRef title); + +/*! +@function JSEndProfiling +@abstract Disables the profler. +@param ctx The execution context to use. +@param title The title of the profile. +@result The profiler is turned off. If there is no name, the most recently started + profile is stopped. If the name does not match any profile then no profile + is stopped. +*/ +JS_EXPORT void JSEndProfiling(JSContextRef ctx, JSStringRef title); + +#ifdef __cplusplus +} #endif + +#endif /* JSProfiler_h */ diff --git a/API/JSStringRef.cpp b/API/JSStringRef.cpp index 9a307d0..8e236e4 100644 --- a/API/JSStringRef.cpp +++ b/API/JSStringRef.cpp @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * @@ -27,92 +26,80 @@ #include "config.h" #include "JSStringRef.h" -#include - -#include "APICast.h" -#include -#include -#include -#include -#include -#include +#include "InitializeThreading.h" +#include "OpaqueJSString.h" #include -using namespace KJS; +using namespace JSC; using namespace WTF::Unicode; JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars) { - JSLock lock; - return toRef(UString(reinterpret_cast(chars), static_cast(numChars)).rep()->ref()); + initializeThreading(); + return OpaqueJSString::create(chars, numChars).releaseRef(); } JSStringRef JSStringCreateWithUTF8CString(const char* string) { - JSLock lock; - - size_t length = strlen(string); - Vector< ::UChar, 1024> buffer(length); - ::UChar* p = buffer.data(); - if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length)) - return 0; - - return toRef(UString(reinterpret_cast(buffer.data()), p - buffer.data()).rep()->ref()); + initializeThreading(); + if (string) { + size_t length = strlen(string); + Vector buffer(length); + UChar* p = buffer.data(); + if (conversionOK == convertUTF8ToUTF16(&string, string + length, &p, p + length)) + return OpaqueJSString::create(buffer.data(), p - buffer.data()).releaseRef(); + } + + // Null string. + return OpaqueJSString::create().releaseRef(); } JSStringRef JSStringRetain(JSStringRef string) { - JSLock lock; - UString::Rep* rep = toJS(string); - return toRef(rep->ref()); + string->ref(); + return string; } void JSStringRelease(JSStringRef string) { - JSLock lock; - UString::Rep* rep = toJS(string); - rep->deref(); + string->deref(); } size_t JSStringGetLength(JSStringRef string) { - UString::Rep* rep = toJS(string); - return rep->size(); + return string->length(); } const JSChar* JSStringGetCharactersPtr(JSStringRef string) { - UString::Rep* rep = toJS(string); - return reinterpret_cast(rep->data()); + return string->characters(); } size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string) { - UString::Rep* rep = toJS(string); - // Any UTF8 character > 3 bytes encodes as a UTF16 surrogate pair. - return rep->size() * 3 + 1; // + 1 for terminating '\0' + return string->length() * 3 + 1; // + 1 for terminating '\0' } size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize) { - JSLock lock; - UString::Rep* rep = toJS(string); - CString cString = UString(rep).UTF8String(); + if (!bufferSize) + return 0; + + char* p = buffer; + const UChar* d = string->characters(); + ConversionResult result = convertUTF16ToUTF8(&d, d + string->length(), &p, p + bufferSize - 1, true); + *p++ = '\0'; + if (result != conversionOK && result != targetExhausted) + return 0; - size_t length = std::min(bufferSize, cString.size() + 1); // + 1 for terminating '\0' - memcpy(buffer, cString.c_str(), length); - return length; + return p - buffer; } bool JSStringIsEqual(JSStringRef a, JSStringRef b) { - JSLock lock; - - UString::Rep* aRep = toJS(a); - UString::Rep* bRep = toJS(b); - - return UString(aRep) == UString(bRep); + unsigned len = a->length(); + return len == b->length() && 0 == memcmp(a->characters(), b->characters(), len * sizeof(UChar)); } bool JSStringIsEqualToUTF8CString(JSStringRef a, const char* b) diff --git a/API/JSStringRef.h b/API/JSStringRef.h index fb5649f..8b17ee2 100644 --- a/API/JSStringRef.h +++ b/API/JSStringRef.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -29,8 +28,10 @@ #include +#ifndef __cplusplus #include -#include // for size_t +#endif +#include /* for size_t */ #ifdef __cplusplus extern "C" { @@ -140,4 +141,4 @@ JS_EXPORT bool JSStringIsEqualToUTF8CString(JSStringRef a, const char* b); } #endif -#endif // JSStringRef_h +#endif /* JSStringRef_h */ diff --git a/API/JSStringRefBSTR.cpp b/API/JSStringRefBSTR.cpp index 1a538ab..a7d3e99 100644 --- a/API/JSStringRefBSTR.cpp +++ b/API/JSStringRefBSTR.cpp @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2007 Apple Inc. All rights reserved. * diff --git a/API/JSStringRefBSTR.h b/API/JSStringRefBSTR.h index 4987f83..59f19b7 100644 --- a/API/JSStringRefBSTR.h +++ b/API/JSStringRefBSTR.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2007 Apple Inc. All rights reserved. * @@ -38,7 +37,7 @@ extern "C" { #endif -// COM convenience methods +/* COM convenience methods */ /*! @function @@ -60,4 +59,4 @@ JS_EXPORT BSTR JSStringCopyBSTR(const JSStringRef string); } #endif -#endif // JSStringRefBSTR_h +#endif /* JSStringRefBSTR_h */ diff --git a/API/JSStringRefCF.cpp b/API/JSStringRefCF.cpp index 70a5aa7..d1f6fe3 100644 --- a/API/JSStringRefCF.cpp +++ b/API/JSStringRefCF.cpp @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006, 2007 Apple Computer, Inc. All rights reserved. * @@ -28,30 +27,31 @@ #include "JSStringRefCF.h" #include "APICast.h" +#include "InitializeThreading.h" #include "JSStringRef.h" -#include -#include -#include - -using namespace KJS; +#include "OpaqueJSString.h" +#include +#include +#include JSStringRef JSStringCreateWithCFString(CFStringRef string) { - JSLock lock; - CFIndex length = CFStringGetLength(string); - UString::Rep* rep; - if (!length) - rep = UString("").rep()->ref(); - else { - UniChar* buffer = static_cast(fastMalloc(sizeof(UniChar) * length)); - CFStringGetCharacters(string, CFRangeMake(0, length), buffer); - rep = UString(reinterpret_cast(buffer), length, false).rep()->ref(); + JSC::initializeThreading(); + + // We cannot use CFIndex here since CFStringGetLength can return values larger than + // it can hold. () + size_t length = CFStringGetLength(string); + if (length) { + OwnArrayPtr buffer(new UniChar[length]); + CFStringGetCharacters(string, CFRangeMake(0, length), buffer.get()); + COMPILE_ASSERT(sizeof(UniChar) == sizeof(UChar), unichar_and_uchar_must_be_same_size); + return OpaqueJSString::create(reinterpret_cast(buffer.get()), length).releaseRef(); + } else { + return OpaqueJSString::create(0, 0).releaseRef(); } - return toRef(rep); } CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string) { - UString::Rep* rep = toJS(string); - return CFStringCreateWithCharacters(alloc, reinterpret_cast(rep->data()), rep->size()); + return CFStringCreateWithCharacters(alloc, reinterpret_cast(string->characters()), string->length()); } diff --git a/API/JSStringRefCF.h b/API/JSStringRefCF.h index ef84a9c..a424765 100644 --- a/API/JSStringRefCF.h +++ b/API/JSStringRefCF.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006, 2007 Apple Computer, Inc. All rights reserved. * @@ -34,7 +33,7 @@ extern "C" { #endif -// CFString convenience methods +/* CFString convenience methods */ /*! @function @@ -53,9 +52,9 @@ JS_EXPORT JSStringRef JSStringCreateWithCFString(CFStringRef string); @result A CFString containing string. Ownership follows the Create Rule. */ JS_EXPORT CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string); - + #ifdef __cplusplus } #endif -#endif // JSStringRefCF_h +#endif /* JSStringRefCF_h */ diff --git a/API/JSValueRef.cpp b/API/JSValueRef.cpp index 468a2d1..7080952 100644 --- a/API/JSValueRef.cpp +++ b/API/JSValueRef.cpp @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * @@ -31,13 +30,12 @@ #include "APICast.h" #include "JSCallbackObject.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include @@ -45,69 +43,64 @@ JSType JSValueGetType(JSContextRef, JSValueRef value) { - KJS::JSValue* jsValue = toJS(value); - switch (jsValue->type()) { - case KJS::UndefinedType: - return kJSTypeUndefined; - case KJS::NullType: - return kJSTypeNull; - case KJS::BooleanType: - return kJSTypeBoolean; - case KJS::NumberType: - return kJSTypeNumber; - case KJS::StringType: - return kJSTypeString; - case KJS::ObjectType: - return kJSTypeObject; - default: - ASSERT(!"JSValueGetType: unknown type code.\n"); - return kJSTypeUndefined; - } + JSC::JSValuePtr jsValue = toJS(value); + if (jsValue.isUndefined()) + return kJSTypeUndefined; + if (jsValue.isNull()) + return kJSTypeNull; + if (jsValue.isBoolean()) + return kJSTypeBoolean; + if (jsValue.isNumber()) + return kJSTypeNumber; + if (jsValue.isString()) + return kJSTypeString; + ASSERT(jsValue.isObject()); + return kJSTypeObject; } -using namespace KJS; // placed here to avoid conflict between KJS::JSType and JSType, above. +using namespace JSC; // placed here to avoid conflict between JSC::JSType and JSType, above. bool JSValueIsUndefined(JSContextRef, JSValueRef value) { - JSValue* jsValue = toJS(value); - return jsValue->isUndefined(); + JSValuePtr jsValue = toJS(value); + return jsValue.isUndefined(); } bool JSValueIsNull(JSContextRef, JSValueRef value) { - JSValue* jsValue = toJS(value); - return jsValue->isNull(); + JSValuePtr jsValue = toJS(value); + return jsValue.isNull(); } bool JSValueIsBoolean(JSContextRef, JSValueRef value) { - JSValue* jsValue = toJS(value); - return jsValue->isBoolean(); + JSValuePtr jsValue = toJS(value); + return jsValue.isBoolean(); } bool JSValueIsNumber(JSContextRef, JSValueRef value) { - JSValue* jsValue = toJS(value); - return jsValue->isNumber(); + JSValuePtr jsValue = toJS(value); + return jsValue.isNumber(); } bool JSValueIsString(JSContextRef, JSValueRef value) { - JSValue* jsValue = toJS(value); - return jsValue->isString(); + JSValuePtr jsValue = toJS(value); + return jsValue.isString(); } bool JSValueIsObject(JSContextRef, JSValueRef value) { - JSValue* jsValue = toJS(value); - return jsValue->isObject(); + JSValuePtr jsValue = toJS(value); + return jsValue.isObject(); } bool JSValueIsObjectOfClass(JSContextRef, JSValueRef value, JSClassRef jsClass) { - JSValue* jsValue = toJS(value); + JSValuePtr jsValue = toJS(value); - if (JSObject* o = jsValue->getObject()) { + if (JSObject* o = jsValue.getObject()) { if (o->inherits(&JSCallbackObject::info)) return static_cast*>(o)->inherits(jsClass); else if (o->inherits(&JSCallbackObject::info)) @@ -118,12 +111,14 @@ bool JSValueIsObjectOfClass(JSContextRef, JSValueRef value, JSClassRef jsClass) bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); - JSValue* jsA = toJS(a); - JSValue* jsB = toJS(b); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + JSValuePtr jsA = toJS(a); + JSValuePtr jsB = toJS(b); - bool result = equal(exec, jsA, jsB); // false if an exception is thrown + bool result = JSValuePtr::equal(exec, jsA, jsB); // false if an exception is thrown if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); @@ -132,27 +127,26 @@ bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* ex return result; } -bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b) +bool JSValueIsStrictEqual(JSContextRef, JSValueRef a, JSValueRef b) { - JSLock lock; - ExecState* exec = toJS(ctx); - JSValue* jsA = toJS(a); - JSValue* jsB = toJS(b); + JSValuePtr jsA = toJS(a); + JSValuePtr jsB = toJS(b); - bool result = strictEqual(exec, jsA, jsB); // can't throw because it doesn't perform value conversion - ASSERT(!exec->hadException()); + bool result = JSValuePtr::strictEqual(jsA, jsB); return result; } bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); - JSValue* jsValue = toJS(value); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + JSValuePtr jsValue = toJS(value); JSObject* jsConstructor = toJS(constructor); - if (!jsConstructor->implementsHasInstance()) + if (!jsConstructor->structure()->typeInfo().implementsHasInstance()) return false; - bool result = jsConstructor->hasInstance(exec, jsValue); // false if an exception is thrown + bool result = jsConstructor->hasInstance(exec, jsValue, jsConstructor->get(exec, exec->propertyNames().prototype)); // false if an exception is thrown if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); @@ -176,33 +170,40 @@ JSValueRef JSValueMakeBoolean(JSContextRef, bool value) return toRef(jsBoolean(value)); } -JSValueRef JSValueMakeNumber(JSContextRef, double value) +JSValueRef JSValueMakeNumber(JSContextRef ctx, double value) { - JSLock lock; - return toRef(jsNumber(value)); + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + return toRef(jsNumber(exec, value)); } -JSValueRef JSValueMakeString(JSContextRef, JSStringRef string) +JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string) { - JSLock lock; - UString::Rep* rep = toJS(string); - return toRef(jsString(UString(rep))); + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + return toRef(jsString(exec, string->ustring())); } bool JSValueToBoolean(JSContextRef ctx, JSValueRef value) { ExecState* exec = toJS(ctx); - JSValue* jsValue = toJS(value); - return jsValue->toBoolean(exec); + JSValuePtr jsValue = toJS(value); + return jsValue.toBoolean(exec); } double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception) { - JSLock lock; - JSValue* jsValue = toJS(value); ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); - double number = jsValue->toNumber(exec); + JSValuePtr jsValue = toJS(value); + + double number = jsValue.toNumber(exec); if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); @@ -214,27 +215,31 @@ double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception) { - JSLock lock; - JSValue* jsValue = toJS(value); ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + JSValuePtr jsValue = toJS(value); - JSStringRef stringRef = toRef(jsValue->toString(exec).rep()->ref()); + RefPtr stringRef(OpaqueJSString::create(jsValue.toString(exec))); if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); exec->clearException(); - stringRef = 0; + stringRef.clear(); } - return stringRef; + return stringRef.release().releaseRef(); } JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception) { - JSLock lock; ExecState* exec = toJS(ctx); - JSValue* jsValue = toJS(value); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + JSValuePtr jsValue = toJS(value); - JSObjectRef objectRef = toRef(jsValue->toObject(exec)); + JSObjectRef objectRef = toRef(jsValue.toObject(exec)); if (exec->hadException()) { if (exception) *exception = toRef(exec->exception()); @@ -244,16 +249,22 @@ JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exce return objectRef; } -void JSValueProtect(JSContextRef, JSValueRef value) +void JSValueProtect(JSContextRef ctx, JSValueRef value) { - JSLock lock; - JSValue* jsValue = toJS(value); + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + JSValuePtr jsValue = toJS(value); gcProtect(jsValue); } -void JSValueUnprotect(JSContextRef, JSValueRef value) +void JSValueUnprotect(JSContextRef ctx, JSValueRef value) { - JSLock lock; - JSValue* jsValue = toJS(value); + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + JSValuePtr jsValue = toJS(value); gcUnprotect(jsValue); } diff --git a/API/JSValueRef.h b/API/JSValueRef.h index 6f1ce08..7a7bf93 100644 --- a/API/JSValueRef.h +++ b/API/JSValueRef.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -29,7 +28,9 @@ #include +#ifndef __cplusplus #include +#endif /*! @enum JSType @@ -127,7 +128,7 @@ JS_EXPORT bool JSValueIsObject(JSContextRef ctx, JSValueRef value); */ JS_EXPORT bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass); -// Comparing values +/* Comparing values */ /*! @function @@ -161,7 +162,7 @@ JS_EXPORT bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b */ JS_EXPORT bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception); -// Creating values +/* Creating values */ /*! @function @@ -207,7 +208,7 @@ JS_EXPORT JSValueRef JSValueMakeNumber(JSContextRef ctx, double number); */ JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string); -// Converting to primitive values +/* Converting to primitive values */ /*! @function @@ -248,7 +249,7 @@ JS_EXPORT JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JS */ JS_EXPORT JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception); -// Garbage collection +/* Garbage collection */ /*! @function @abstract Protects a JavaScript value from garbage collection. @@ -274,4 +275,4 @@ JS_EXPORT void JSValueUnprotect(JSContextRef ctx, JSValueRef value); } #endif -#endif // JSValueRef_h +#endif /* JSValueRef_h */ diff --git a/API/JavaScript.h b/API/JavaScript.h index 3a6cc38..f8d92d8 100644 --- a/API/JavaScript.h +++ b/API/JavaScript.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Inc. All rights reserved. * Copyright (C) 2008 Alp Toker @@ -34,4 +33,4 @@ #include #include -#endif // JavaScript_h +#endif /* JavaScript_h */ diff --git a/API/JavaScriptCore.h b/API/JavaScriptCore.h index be6b8b2..87d6018 100644 --- a/API/JavaScriptCore.h +++ b/API/JavaScriptCore.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * @@ -30,4 +29,4 @@ #include #include -#endif // JavaScriptCore_h +#endif /* JavaScriptCore_h */ diff --git a/API/OpaqueJSString.cpp b/API/OpaqueJSString.cpp new file mode 100644 index 0000000..7c7b1af --- /dev/null +++ b/API/OpaqueJSString.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "OpaqueJSString.h" + +#include +#include +#include + +using namespace JSC; + +PassRefPtr OpaqueJSString::create(const UString& ustring) +{ + if (!ustring.isNull()) + return adoptRef(new OpaqueJSString(ustring.data(), ustring.size())); + return 0; +} + +UString OpaqueJSString::ustring() const +{ + if (this && m_characters) + return UString(m_characters, m_length, true); + return UString::null(); +} + +Identifier OpaqueJSString::identifier(JSGlobalData* globalData) const +{ + if (!this || !m_characters) + return Identifier(globalData, static_cast(0)); + + return Identifier(globalData, m_characters, m_length); +} diff --git a/bindings/c/c_instance.h b/API/OpaqueJSString.h similarity index 51% rename from bindings/c/c_instance.h rename to API/OpaqueJSString.h index 7d779ba..473c815 100644 --- a/bindings/c/c_instance.h +++ b/API/OpaqueJSString.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,58 +23,59 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BINDINGS_C_INSTANCE_H_ -#define BINDINGS_C_INSTANCE_H_ +#ifndef OpaqueJSString_h +#define OpaqueJSString_h -#if ENABLE(NETSCAPE_API) +#include -#include "runtime.h" -#include +namespace JSC { + class Identifier; + class JSGlobalData; +} -typedef struct NPObject NPObject; +struct OpaqueJSString : public ThreadSafeShared { -namespace KJS { + static PassRefPtr create() // null + { + return adoptRef(new OpaqueJSString); + } -namespace Bindings { + static PassRefPtr create(const UChar* characters, unsigned length) + { + return adoptRef(new OpaqueJSString(characters, length)); + } -class CClass; + static PassRefPtr create(const JSC::UString&); -class CInstance : public Instance { -public: - CInstance (NPObject*, PassRefPtr); - ~CInstance (); - - virtual Class *getClass() const; - - virtual void begin(); - virtual void end(); - - virtual JSValue *valueOf() const; - virtual JSValue *defaultValue (JSType hint) const; + UChar* characters() { return this ? m_characters : 0; } + unsigned length() { return this ? m_length : 0; } - virtual bool implementsCall() const; - - virtual JSValue *invokeMethod (ExecState *exec, const MethodList &method, const List &args); - virtual JSValue *invokeDefaultMethod (ExecState *exec, const List &args); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); - - JSValue *stringValue() const; - JSValue *numberValue() const; - JSValue *booleanValue() const; - - NPObject *getObject() const { return _object; } - - virtual BindingLanguage getBindingLanguage() const { return CLanguage; } + JSC::UString ustring() const; + JSC::Identifier identifier(JSC::JSGlobalData*) const; private: - mutable CClass *_class; - NPObject *_object; + friend class WTF::ThreadSafeShared; + + OpaqueJSString() + : m_characters(0) + , m_length(0) + { + } + + OpaqueJSString(const UChar* characters, unsigned length) + : m_length(length) + { + m_characters = new UChar[length]; + memcpy(m_characters, characters, length * sizeof(UChar)); + } + + ~OpaqueJSString() + { + delete[] m_characters; + } + + UChar* m_characters; + unsigned m_length; }; -} // namespace Bindings - -} // namespace KJS - -#endif // ENABLE(NETSCAPE_API) - #endif diff --git a/API/WebKitAvailability.h b/API/WebKitAvailability.h new file mode 100644 index 0000000..1273360 --- /dev/null +++ b/API/WebKitAvailability.h @@ -0,0 +1,763 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __WebKitAvailability__ +#define __WebKitAvailability__ + +/* The structure of this header is based on AvailabilityMacros.h. The major difference is that the availability + macros are defined in terms of WebKit version numbers rather than Mac OS X system version numbers, as WebKit + releases span multiple versions of Mac OS X. +*/ + +#define WEBKIT_VERSION_1_0 0x0100 +#define WEBKIT_VERSION_1_1 0x0110 +#define WEBKIT_VERSION_1_2 0x0120 +#define WEBKIT_VERSION_1_3 0x0130 +#define WEBKIT_VERSION_2_0 0x0200 +#define WEBKIT_VERSION_3_0 0x0300 +#define WEBKIT_VERSION_3_1 0x0310 +#define WEBKIT_VERSION_LATEST 0x9999 + +#ifdef __APPLE__ +#import +#else +/* + * For non-Mac platforms, require the newest version. + */ +#define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_LATEST +/* + * only certain compilers support __attribute__((deprecated)) + */ +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) + #define DEPRECATED_ATTRIBUTE __attribute__((deprecated)) +#else + #define DEPRECATED_ATTRIBUTE +#endif +#endif + +/* The versions of GCC that shipped with Xcode prior to 3.0 (GCC build number < 5400) did not support attributes on methods. + If we are building with one of these versions, we need to omit the attribute. We achieve this by wrapping the annotation + in WEBKIT_OBJC_METHOD_ANNOTATION, which will remove the annotation when an old version of GCC is in use and will otherwise + expand to the annotation. The same is needed for protocol methods. +*/ +#if defined(__APPLE_CC__) && __APPLE_CC__ < 5400 + #define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) +#else + #define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION +#endif + + +/* If minimum WebKit version is not specified, assume the version that shipped with the target Mac OS X version */ +#ifndef WEBKIT_VERSION_MIN_REQUIRED + #if !defined(MAC_OS_X_VERSION_10_2) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2 + #error WebKit was not available prior to Mac OS X 10.2 + #elif !defined(MAC_OS_X_VERSION_10_3) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 + /* WebKit 1.0 is the only version available on Mac OS X 10.2. */ + #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_1_0 + #elif !defined(MAC_OS_X_VERSION_10_4) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4 + /* WebKit 1.1 is the version that shipped on Mac OS X 10.3. */ + #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_1_1 + #elif !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 + /* WebKit 2.0 is the version that shipped on Mac OS X 10.4. */ + #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_2_0 + #elif !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 + /* WebKit 3.0 is the version that shipped on Mac OS X 10.5. */ + #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_3_0 + #else + #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_LATEST + #endif +#endif + + +/* If maximum WebKit version is not specified, assume largerof(latest, minimum) */ +#ifndef WEBKIT_VERSION_MAX_ALLOWED + #if WEBKIT_VERSION_MIN_REQUIRED > WEBKIT_VERSION_LATEST + #define WEBKIT_VERSION_MAX_ALLOWED WEBKIT_VERSION_MIN_REQUIRED + #else + #define WEBKIT_VERSION_MAX_ALLOWED WEBKIT_VERSION_LATEST + #endif +#endif + + +/* Sanity check the configured values */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_MIN_REQUIRED + #error WEBKIT_VERSION_MAX_ALLOWED must be >= WEBKIT_VERSION_MIN_REQUIRED +#endif +#if WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_0 + #error WEBKIT_VERSION_MIN_REQUIRED must be >= WEBKIT_VERSION_1_0 +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER + * + * Used on functions introduced in WebKit 1.0 + */ +#define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED + * + * Used on functions introduced in WebKit 1.0, + * and deprecated in WebKit 1.0 + */ +#define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE + +/* + * DEPRECATED_IN_WEBKIT_VERSION_1_0_AND_LATER + * + * Used on types deprecated in WebKit 1.0 + */ +#define DEPRECATED_IN_WEBKIT_VERSION_1_0_AND_LATER DEPRECATED_ATTRIBUTE + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER + * + * Used on declarations introduced in WebKit 1.1 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_1_1 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_1 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 1.1, + * and deprecated in WebKit 1.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_1 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_1 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 1.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_1 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_1 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_1_1_AND_LATER + * + * Used on types deprecated in WebKit 1.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_1 + #define DEPRECATED_IN_WEBKIT_VERSION_1_1_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_1_1_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER + * + * Used on declarations introduced in WebKit 1.2 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_1_2 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_2 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 1.2, + * and deprecated in WebKit 1.2 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 1.2 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 1.2 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_1_2_AND_LATER + * + * Used on types deprecated in WebKit 1.2 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 + #define DEPRECATED_IN_WEBKIT_VERSION_1_2_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_1_2_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER + * + * Used on declarations introduced in WebKit 1.3 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 1.3, + * and deprecated in WebKit 1.3 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 1.3 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 1.3 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 + * + * Used on declarations introduced in WebKit 1.2, + * but later deprecated in WebKit 1.3 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_1_3_AND_LATER + * + * Used on types deprecated in WebKit 1.3 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 + #define DEPRECATED_IN_WEBKIT_VERSION_1_3_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_1_3_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER + * + * Used on declarations introduced in WebKit 2.0 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 2.0, + * and deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 + * + * Used on declarations introduced in WebKit 1.2, + * but later deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 + * + * Used on declarations introduced in WebKit 1.3, + * but later deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_2_0_AND_LATER + * + * Used on types deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define DEPRECATED_IN_WEBKIT_VERSION_2_0_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_2_0_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER + * + * Used on declarations introduced in WebKit 3.0 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 3.0, + * and deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 + * + * Used on declarations introduced in WebKit 1.2, + * but later deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 + * + * Used on declarations introduced in WebKit 1.3, + * but later deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 + * + * Used on declarations introduced in WebKit 2.0, + * but later deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_3_0_AND_LATER + * + * Used on types deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define DEPRECATED_IN_WEBKIT_VERSION_3_0_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_3_0_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER + * + * Used on declarations introduced in WebKit 3.1 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 3.1, + * and deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.2, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.3, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 2.0, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 3.0, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_3_1_AND_LATER + * + * Used on types deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define DEPRECATED_IN_WEBKIT_VERSION_3_1_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_3_1_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_AFTER_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced after WebKit 3.1 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_LATEST + #define AVAILABLE_AFTER_WEBKIT_VERSION_3_1 UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_LATEST + #define AVAILABLE_AFTER_WEBKIT_VERSION_3_1 WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_AFTER_WEBKIT_VERSION_3_1 +#endif + +/* + * AVAILABLE_AFTER_WEBKIT_VERSION_3_1_BUT_DEPRECATED + * + * Used on declarations introduced after WebKit 3.1, + * and deprecated after WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_AFTER_WEBKIT_VERSION_3_1_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_AFTER_WEBKIT_VERSION_3_1_BUT_DEPRECATED AVAILABLE_AFTER_WEBKIT_VERSION_3_1 +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated after WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated after WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.2, + * but later deprecated after WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.3, + * but later deprecated after WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 2.0, + * but later deprecated after WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 3.0, + * but later deprecated after WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 3.1, + * but later deprecated after WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER +#endif + +/* + * DEPRECATED_AFTER_WEBKIT_VERSION_3_1 + * + * Used on types deprecated after WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define DEPRECATED_AFTER_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_AFTER_WEBKIT_VERSION_3_1 +#endif + + +#endif /* __WebKitAvailability__ */ diff --git a/API/JSNode.c b/API/tests/JSNode.c similarity index 98% rename from API/JSNode.c rename to API/tests/JSNode.c index c1f6294..d9ac0a9 100644 --- a/API/JSNode.c +++ b/API/tests/JSNode.c @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -38,7 +37,7 @@ static JSValueRef JSNode_appendChild(JSContextRef context, JSObjectRef function, { UNUSED_PARAM(function); - // Example of throwing a type error for invalid values + /* Example of throwing a type error for invalid values */ if (!JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) { JSStringRef message = JSStringCreateWithUTF8CString("TypeError: appendChild can only be called on nodes"); *exception = JSValueMakeString(context, message); @@ -60,8 +59,8 @@ static JSValueRef JSNode_appendChild(JSContextRef context, JSObjectRef function, static JSValueRef JSNode_removeChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { UNUSED_PARAM(function); - - // Example of ignoring invalid values + + /* Example of ignoring invalid values */ if (argumentCount > 0) { if (JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) { if (JSValueIsObjectOfClass(context, arguments[0], JSNode_class(context))) { diff --git a/API/JSNode.h b/API/tests/JSNode.h similarity index 96% rename from API/JSNode.h rename to API/tests/JSNode.h index cd3a441..7725733 100644 --- a/API/JSNode.h +++ b/API/tests/JSNode.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -35,4 +34,4 @@ extern JSObjectRef JSNode_new(JSContextRef context, Node* node); extern JSClassRef JSNode_class(JSContextRef context); extern JSObjectRef JSNode_construct(JSContextRef context, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); -#endif // JSNode_h +#endif /* JSNode_h */ diff --git a/API/JSNodeList.c b/API/tests/JSNodeList.c similarity index 98% rename from API/JSNodeList.c rename to API/tests/JSNodeList.c index 0da7c8d..bc4a8ad 100644 --- a/API/JSNodeList.c +++ b/API/tests/JSNodeList.c @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -72,7 +71,7 @@ static JSValueRef JSNodeList_getProperty(JSContextRef context, JSObjectRef thisO ASSERT(nodeList); double index = JSValueToNumber(context, JSValueMakeString(context, propertyName), exception); unsigned uindex = (unsigned)index; - if (uindex == index) { // false for NaN + if (uindex == index) { /* false for NaN */ Node* node = NodeList_item(nodeList, uindex); if (node) return JSNode_new(context, node); diff --git a/API/JSNodeList.h b/API/tests/JSNodeList.h similarity index 95% rename from API/JSNodeList.h rename to API/tests/JSNodeList.h index 0bc5f74..f930914 100644 --- a/API/JSNodeList.h +++ b/API/tests/JSNodeList.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -32,4 +31,4 @@ extern JSObjectRef JSNodeList_new(JSContextRef, NodeList*); -#endif // JSNodeList_h +#endif /* JSNodeList_h */ diff --git a/API/Node.c b/API/tests/Node.c similarity index 93% rename from API/Node.c rename to API/tests/Node.c index 3ff82e2..913da0a 100644 --- a/API/Node.c +++ b/API/tests/Node.c @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -49,7 +48,7 @@ void Node_appendChild(Node* node, Node* child) void Node_removeChild(Node* node, Node* child) { - // Linear search from tail -- good enough for our purposes here + /* Linear search from tail -- good enough for our purposes here */ NodeLink* current; NodeLink** currentHandle; for (currentHandle = &node->childNodesTail, current = *currentHandle; current; currentHandle = ¤t->prev, current = *currentHandle) { @@ -64,7 +63,7 @@ void Node_removeChild(Node* node, Node* child) void Node_replaceChild(Node* node, Node* newChild, Node* oldChild) { - // Linear search from tail -- good enough for our purposes here + /* Linear search from tail -- good enough for our purposes here */ NodeLink* current; for (current = node->childNodesTail; current; current = current->prev) { if (current->node == oldChild) { diff --git a/API/Node.h b/API/tests/Node.h similarity index 97% rename from API/Node.h rename to API/tests/Node.h index 04b2c70..e9250b3 100644 --- a/API/Node.h +++ b/API/tests/Node.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -48,4 +47,4 @@ extern void Node_appendChild(Node* node, Node* child); extern void Node_removeChild(Node* node, Node* child); extern void Node_replaceChild(Node* node, Node* newChild, Node* oldChild); -#endif // Node_h +#endif /* Node_h */ diff --git a/API/NodeList.c b/API/tests/NodeList.c similarity index 92% rename from API/NodeList.c rename to API/tests/NodeList.c index 21b2c62..ae4c170 100644 --- a/API/NodeList.c +++ b/API/tests/NodeList.c @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -31,7 +30,7 @@ extern NodeList* NodeList_new(Node* parentNode) { Node_ref(parentNode); - + NodeList* nodeList = (NodeList*)malloc(sizeof(NodeList)); nodeList->parentNode = parentNode; nodeList->refCount = 0; @@ -40,7 +39,7 @@ extern NodeList* NodeList_new(Node* parentNode) extern unsigned NodeList_length(NodeList* nodeList) { - // Linear count from tail -- good enough for our purposes here + /* Linear count from tail -- good enough for our purposes here */ unsigned i = 0; NodeLink* n = nodeList->parentNode->childNodesTail; while (n) { @@ -56,8 +55,8 @@ extern Node* NodeList_item(NodeList* nodeList, unsigned index) unsigned length = NodeList_length(nodeList); if (index >= length) return NULL; - - // Linear search from tail -- good enough for our purposes here + + /* Linear search from tail -- good enough for our purposes here */ NodeLink* n = nodeList->parentNode->childNodesTail; unsigned i = 0; unsigned count = length - 1 - index; diff --git a/API/NodeList.h b/API/tests/NodeList.h similarity index 96% rename from API/NodeList.h rename to API/tests/NodeList.h index 289d206..25b95bf 100644 --- a/API/NodeList.h +++ b/API/tests/NodeList.h @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -40,4 +39,4 @@ extern Node* NodeList_item(NodeList*, unsigned); extern void NodeList_ref(NodeList*); extern void NodeList_deref(NodeList*); -#endif // NodeList_h +#endif /* NodeList_h */ diff --git a/API/minidom.c b/API/tests/minidom.c similarity index 95% rename from API/minidom.c rename to API/tests/minidom.c index 1537925..43ae2c1 100644 --- a/API/minidom.c +++ b/API/tests/minidom.c @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * Copyright (C) 2007 Alp Toker @@ -44,7 +43,7 @@ int main(int argc, char* argv[]) scriptPath = argv[1]; } - JSGlobalContextRef context = JSGlobalContextCreate(NULL); + JSGlobalContextRef context = JSGlobalContextCreateInGroup(NULL, NULL); JSObjectRef globalObject = JSContextGetGlobalObject(context); JSStringRef printIString = JSStringCreateWithUTF8CString("print"); @@ -58,7 +57,7 @@ int main(int argc, char* argv[]) char* scriptUTF8 = createStringWithContentsOfFile(scriptPath); JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8); JSValueRef exception; - JSValueRef result = JSEvaluateScript(context, script, NULL, NULL, 0, &exception); + JSValueRef result = JSEvaluateScript(context, script, NULL, NULL, 1, &exception); if (result) printf("PASS: Test script executed successfully.\n"); else { @@ -76,7 +75,6 @@ int main(int argc, char* argv[]) globalObject = 0; JSGlobalContextRelease(context); - JSGarbageCollect(context); printf("PASS: Program exited normally.\n"); return 0; } @@ -113,7 +111,7 @@ static char* createStringWithContentsOfFile(const char* fileName) while (!feof(f) && !ferror(f)) { buffer_size += fread(buffer + buffer_size, 1, buffer_capacity - buffer_size, f); - if (buffer_size == buffer_capacity) { // guarantees space for trailing '\0' + if (buffer_size == buffer_capacity) { /* guarantees space for trailing '\0' */ buffer_capacity *= 2; buffer = (char*)realloc(buffer, buffer_capacity); ASSERT(buffer); diff --git a/API/minidom.html b/API/tests/minidom.html similarity index 100% rename from API/minidom.html rename to API/tests/minidom.html diff --git a/API/minidom.js b/API/tests/minidom.js similarity index 98% rename from API/minidom.js rename to API/tests/minidom.js index 7624d39..4808960 100644 --- a/API/minidom.js +++ b/API/tests/minidom.js @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * diff --git a/API/testapi.c b/API/tests/testapi.c similarity index 89% rename from API/testapi.c rename to API/tests/testapi.c index 5319b89..48c8583 100644 --- a/API/testapi.c +++ b/API/tests/testapi.c @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -25,10 +24,22 @@ */ #include "JavaScriptCore.h" +#include "JSBasePrivate.h" #include #include #include +#if COMPILER(MSVC) + +#include + +static double nan(const char*) +{ + return std::numeric_limits::quiet_NaN(); +} + +#endif + static JSGlobalContextRef context = 0; static void assertEqualsAsBoolean(JSValueRef value, bool expectedValue) @@ -53,7 +64,7 @@ static void assertEqualsAsUTF8String(JSValueRef value, const char* expectedValue JSStringRef valueAsString = JSValueToStringCopy(context, value, NULL); size_t jsSize = JSStringGetMaximumUTF8CStringSize(valueAsString); - char jsBuffer[jsSize]; + char* jsBuffer = (char*)malloc(jsSize); JSStringGetUTF8CString(valueAsString, jsBuffer, jsSize); unsigned i; @@ -64,6 +75,7 @@ static void assertEqualsAsUTF8String(JSValueRef value, const char* expectedValue if (jsSize < strlen(jsBuffer) + 1) fprintf(stderr, "assertEqualsAsUTF8String failed: jsSize was too small\n"); + free(jsBuffer); JSStringRelease(valueAsString); } @@ -78,7 +90,7 @@ static void assertEqualsAsCharactersPtr(JSValueRef value, const char* expectedVa expectedValue, kCFStringEncodingUTF8); CFIndex cfLength = CFStringGetLength(expectedValueAsCFString); - UniChar cfBuffer[cfLength]; + UniChar* cfBuffer = (UniChar*)malloc(cfLength * sizeof(UniChar)); CFStringGetCharacters(expectedValueAsCFString, CFRangeMake(0, cfLength), cfBuffer); CFRelease(expectedValueAsCFString); @@ -88,6 +100,7 @@ static void assertEqualsAsCharactersPtr(JSValueRef value, const char* expectedVa if (jsLength != (size_t)cfLength) fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsLength(%ld) != cfLength(%ld)\n", jsLength, cfLength); + free(cfBuffer); JSStringRelease(valueAsString); } @@ -225,6 +238,13 @@ static JSValueRef MyObject_convertToType(JSContextRef context, JSObjectRef objec switch (type) { case kJSTypeNumber: return JSValueMakeNumber(context, 1); + case kJSTypeString: + { + JSStringRef string = JSStringCreateWithUTF8CString("MyObjectAsString"); + JSValueRef result = JSValueMakeString(context, string); + JSStringRelease(string); + return result; + } default: break; } @@ -443,9 +463,10 @@ static JSValueRef print_callAsFunction(JSContextRef context, JSObjectRef functio if (argumentCount > 0) { JSStringRef string = JSValueToStringCopy(context, arguments[0], NULL); size_t sizeUTF8 = JSStringGetMaximumUTF8CStringSize(string); - char stringUTF8[sizeUTF8]; + char* stringUTF8 = (char*)malloc(sizeUTF8); JSStringGetUTF8CString(string, stringUTF8, sizeUTF8); printf("%s\n", stringUTF8); + free(stringUTF8); JSStringRelease(string); } @@ -545,11 +566,10 @@ int main(int argc, char* argv[]) } // Test garbage collection with a fresh context - context = JSGlobalContextCreate(NULL); + context = JSGlobalContextCreateInGroup(NULL, NULL); TestInitializeFinalize = true; testInitializeFinalize(); JSGlobalContextRelease(context); - JSGarbageCollect(context); TestInitializeFinalize = false; ASSERT(Base_didFinalize); @@ -560,8 +580,15 @@ int main(int argc, char* argv[]) globalObjectClassDefinition.staticFunctions = globalObject_staticFunctions; globalObjectClassDefinition.attributes = kJSClassAttributeNoAutomaticPrototype; JSClassRef globalObjectClass = JSClassCreate(&globalObjectClassDefinition); - context = JSGlobalContextCreate(globalObjectClass); + context = JSGlobalContextCreateInGroup(NULL, globalObjectClass); + + JSGlobalContextRetain(context); + JSGlobalContextRelease(context); + JSReportExtraMemoryCost(context, 0); + JSReportExtraMemoryCost(context, 1); + JSReportExtraMemoryCost(context, 1024); + JSObjectRef globalObject = JSContextGetGlobalObject(context); ASSERT(JSValueIsObject(context, globalObject)); @@ -599,14 +626,15 @@ int main(int argc, char* argv[]) JSValueRef jsCFEmptyString = JSValueMakeString(context, jsCFEmptyIString); CFIndex cfStringLength = CFStringGetLength(cfString); - UniChar buffer[cfStringLength]; + UniChar* buffer = (UniChar*)malloc(cfStringLength * sizeof(UniChar)); CFStringGetCharacters(cfString, CFRangeMake(0, cfStringLength), buffer); - JSStringRef jsCFIStringWithCharacters = JSStringCreateWithCharacters(buffer, cfStringLength); + JSStringRef jsCFIStringWithCharacters = JSStringCreateWithCharacters((JSChar*)buffer, cfStringLength); JSValueRef jsCFStringWithCharacters = JSValueMakeString(context, jsCFIStringWithCharacters); - JSStringRef jsCFEmptyIStringWithCharacters = JSStringCreateWithCharacters(buffer, CFStringGetLength(cfEmptyString)); + JSStringRef jsCFEmptyIStringWithCharacters = JSStringCreateWithCharacters((JSChar*)buffer, CFStringGetLength(cfEmptyString)); + free(buffer); JSValueRef jsCFEmptyStringWithCharacters = JSValueMakeString(context, jsCFEmptyIStringWithCharacters); ASSERT(JSValueGetType(context, jsUndefined) == kJSTypeUndefined); @@ -784,7 +812,7 @@ int main(int argc, char* argv[]) ASSERT(!JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception)); ASSERT(JSValueIsObject(context, exception)); v = JSObjectGetProperty(context, JSValueToObject(context, exception, NULL), line, NULL); - assertEqualsAsNumber(v, 2); // FIXME: Lexer::setCode bumps startingLineNumber by 1 -- we need to change internal callers so that it doesn't have to (saying '0' to mean '1' in the API would be really confusing -- it's really confusing internally, in fact) + assertEqualsAsNumber(v, 1); JSStringRelease(functionBody); JSStringRelease(line); @@ -818,7 +846,7 @@ int main(int argc, char* argv[]) JSStringRelease(functionBody); string = JSValueToStringCopy(context, function, NULL); - assertEqualsAsUTF8String(JSValueMakeString(context, string), "function foo(foo) \n{\n return foo;\n}"); + assertEqualsAsUTF8String(JSValueMakeString(context, string), "function foo(foo) {return foo;}"); JSStringRelease(string); JSStringRef print = JSStringCreateWithUTF8CString("print"); @@ -853,6 +881,39 @@ int main(int argc, char* argv[]) JSPropertyNameArrayRelease(nameArray); ASSERT(count == 1); // jsCFString should not be enumerated + JSValueRef argumentsArrayValues[] = { JSValueMakeNumber(context, 10), JSValueMakeNumber(context, 20) }; + o = JSObjectMakeArray(context, sizeof(argumentsArrayValues) / sizeof(JSValueRef), argumentsArrayValues, NULL); + string = JSStringCreateWithUTF8CString("length"); + v = JSObjectGetProperty(context, o, string, NULL); + assertEqualsAsNumber(v, 2); + v = JSObjectGetPropertyAtIndex(context, o, 0, NULL); + assertEqualsAsNumber(v, 10); + v = JSObjectGetPropertyAtIndex(context, o, 1, NULL); + assertEqualsAsNumber(v, 20); + + o = JSObjectMakeArray(context, 0, NULL, NULL); + v = JSObjectGetProperty(context, o, string, NULL); + assertEqualsAsNumber(v, 0); + JSStringRelease(string); + + JSValueRef argumentsDateValues[] = { JSValueMakeNumber(context, 0) }; + o = JSObjectMakeDate(context, 1, argumentsDateValues, NULL); + assertEqualsAsUTF8String(o, "Wed Dec 31 1969 16:00:00 GMT-0800 (PST)"); + + string = JSStringCreateWithUTF8CString("an error message"); + JSValueRef argumentsErrorValues[] = { JSValueMakeString(context, string) }; + o = JSObjectMakeError(context, 1, argumentsErrorValues, NULL); + assertEqualsAsUTF8String(o, "Error: an error message"); + JSStringRelease(string); + + string = JSStringCreateWithUTF8CString("foo"); + JSStringRef string2 = JSStringCreateWithUTF8CString("gi"); + JSValueRef argumentsRegExpValues[] = { JSValueMakeString(context, string), JSValueMakeString(context, string2) }; + o = JSObjectMakeRegExp(context, 2, argumentsRegExpValues, NULL); + assertEqualsAsUTF8String(o, "/foo/gi"); + JSStringRelease(string); + JSStringRelease(string2); + JSClassDefinition nullDefinition = kJSClassDefinitionEmpty; nullDefinition.attributes = kJSClassAttributeNoAutomaticPrototype; JSClassRef nullClass = JSClassCreate(&nullDefinition); @@ -869,12 +930,34 @@ int main(int argc, char* argv[]) ASSERT(JSValueIsEqual(context, v, globalObject, NULL)); v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL); ASSERT(JSValueIsEqual(context, v, o, NULL)); - - char* scriptUTF8 = createStringWithContentsOfFile(scriptPath); + + functionBody = JSStringCreateWithUTF8CString("return eval(\"this\");"); + function = JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, NULL); + JSStringRelease(functionBody); + v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL); + ASSERT(JSValueIsEqual(context, v, globalObject, NULL)); + v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL); + ASSERT(JSValueIsEqual(context, v, o, NULL)); + + JSStringRef script = JSStringCreateWithUTF8CString("this;"); + v = JSEvaluateScript(context, script, NULL, NULL, 1, NULL); + ASSERT(JSValueIsEqual(context, v, globalObject, NULL)); + v = JSEvaluateScript(context, script, o, NULL, 1, NULL); + ASSERT(JSValueIsEqual(context, v, o, NULL)); + JSStringRelease(script); + + script = JSStringCreateWithUTF8CString("eval(this);"); + v = JSEvaluateScript(context, script, NULL, NULL, 1, NULL); + ASSERT(JSValueIsEqual(context, v, globalObject, NULL)); + v = JSEvaluateScript(context, script, o, NULL, 1, NULL); + ASSERT(JSValueIsEqual(context, v, o, NULL)); + JSStringRelease(script); + + char* scriptUTF8 = createStringWithContentsOfFile(scriptPath); if (!scriptUTF8) printf("FAIL: Test script could not be loaded.\n"); else { - JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8); + script = JSStringCreateWithUTF8CString(scriptUTF8); result = JSEvaluateScript(context, script, NULL, NULL, 1, &exception); if (JSValueIsUndefined(context, result)) printf("PASS: Test script executed successfully.\n"); @@ -906,7 +989,6 @@ int main(int argc, char* argv[]) JSStringRelease(badSyntax); JSGlobalContextRelease(context); - JSGarbageCollect(context); JSClassRelease(globalObjectClass); printf("PASS: Program exited normally.\n"); diff --git a/API/testapi.js b/API/tests/testapi.js similarity index 98% rename from API/testapi.js rename to API/tests/testapi.js index 52bcb71..9c8ca9e 100644 --- a/API/testapi.js +++ b/API/tests/testapi.js @@ -1,4 +1,3 @@ -// -*- mode: c++; c-basic-offset: 4 -*- /* * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. * @@ -100,6 +99,7 @@ shouldBe("typeof myObject", "object"); shouldBe("MyObject ? 1 : 0", true); // toBoolean shouldBe("+MyObject", 1); // toNumber shouldBe("(MyObject.toString())", "[object MyObject]"); // toString +shouldBe("String(MyObject)", "MyObjectAsString"); // type conversion to string shouldBe("MyObject - 0", NaN); // toPrimitive shouldBe("typeof MyConstructor", "object"); diff --git a/AllInOneFile.cpp b/AllInOneFile.cpp new file mode 100644 index 0000000..904734f --- /dev/null +++ b/AllInOneFile.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +// This file exists to help compile the essential code of +// JavaScriptCore all as one file, for compilers and build systems +// that see a significant speed gain from this. + +#define KDE_USE_FINAL 1 +#define JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE 1 +#include "config.h" + +// these headers are included here to avoid confusion between ::JSType and JSC::JSType +#include "JSCallbackConstructor.h" +#include "JSCallbackFunction.h" +#include "JSCallbackObject.h" + +#include "runtime/JSStaticScopeObject.cpp" +#include "runtime/JSFunction.cpp" +#include "runtime/Arguments.cpp" +#include "runtime/JSGlobalObjectFunctions.cpp" +#include "runtime/PrototypeFunction.cpp" +#include "runtime/GlobalEvalFunction.cpp" +#include "debugger/Debugger.cpp" +#include "runtime/JSArray.cpp" +#include "runtime/ArrayConstructor.cpp" +#include "runtime/ArrayPrototype.cpp" +#include "runtime/BooleanConstructor.cpp" +#include "runtime/BooleanObject.cpp" +#include "runtime/BooleanPrototype.cpp" +#include "runtime/Collector.cpp" +#include "runtime/CommonIdentifiers.cpp" +#include "runtime/DateConstructor.cpp" +#include "runtime/DateMath.cpp" +#include "runtime/DatePrototype.cpp" +#include "runtime/DateInstance.cpp" +#include "wtf/dtoa.cpp" +#include "runtime/ErrorInstance.cpp" +#include "runtime/ErrorPrototype.cpp" +#include "runtime/ErrorConstructor.cpp" +#include "runtime/FunctionConstructor.cpp" +#include "runtime/FunctionPrototype.cpp" +#include "Grammar.cpp" +#include "runtime/Identifier.cpp" +#include "runtime/JSString.cpp" +#include "runtime/JSNumberCell.cpp" +#include "runtime/GetterSetter.cpp" +#include "runtime/InternalFunction.cpp" +#include "runtime/Completion.cpp" +#include "runtime/JSImmediate.cpp" +#include "runtime/JSLock.cpp" +#include "runtime/JSWrapperObject.cpp" +#include "parser/Lexer.cpp" +#include "runtime/ArgList.cpp" +#include "runtime/Lookup.cpp" +#include "runtime/MathObject.cpp" +#include "runtime/NativeErrorConstructor.cpp" +#include "runtime/NativeErrorPrototype.cpp" +#include "runtime/NumberConstructor.cpp" +#include "runtime/NumberObject.cpp" +#include "runtime/NumberPrototype.cpp" +#include "parser/Nodes.cpp" +#include "runtime/JSObject.cpp" +#include "runtime/Error.cpp" +#include "runtime/JSGlobalObject.cpp" +#include "runtime/ObjectConstructor.cpp" +#include "runtime/ObjectPrototype.cpp" +#include "runtime/Operations.cpp" +#include "parser/Parser.cpp" +#include "runtime/PropertySlot.cpp" +#include "runtime/PropertyNameArray.cpp" +#include "runtime/RegExp.cpp" +#include "runtime/RegExpConstructor.cpp" +#include "runtime/RegExpObject.cpp" +#include "runtime/RegExpPrototype.cpp" +#include "runtime/ScopeChain.cpp" +#include "runtime/StringConstructor.cpp" +#include "runtime/StringObject.cpp" +#include "runtime/StringPrototype.cpp" +#include "runtime/UString.cpp" +#include "runtime/JSValue.cpp" +#include "runtime/CallData.cpp" +#include "runtime/ConstructData.cpp" +#include "runtime/JSCell.cpp" +#include "runtime/JSVariableObject.cpp" +#include "wtf/FastMalloc.cpp" +#include "wtf/TCSystemAlloc.cpp" +#include "bytecompiler/BytecodeGenerator.cpp" +#include "interpreter/RegisterFile.cpp" diff --git a/ChangeLog-2008-08-10 b/ChangeLog-2008-08-10 new file mode 100644 index 0000000..0912aec --- /dev/null +++ b/ChangeLog-2008-08-10 @@ -0,0 +1,31482 @@ +2008-08-10 Jan Michael Alonzo + + Reviewed (and updated) by Alp Toker. + + https://bugs.webkit.org/show_bug.cgi?id=16620 + [GTK] Autotools make dist and make check support + + Get make dist working. + + Note that not all possible configurations have been tested yet. + + * GNUmakefile.am: + +2008-08-09 Alexey Proskuryakov + + Reviewed by Sam Weinig. + + Added same heap debug checks to more code paths. + + * kjs/JSActivation.cpp: + (KJS::JSActivation::put): + (KJS::JSActivation::putWithAttributes): + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::putWithAttributes): + * kjs/JSObject.h: + (KJS::JSObject::putDirect): + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTablePut): + (KJS::JSVariableObject::symbolTablePutWithAttributes): + +2008-08-09 Cameron Zwarich + + Reviewed by Maciej. + + Fix some style issues in the sampling tool. + + * VM/SamplingTool.cpp: + (KJS::sleepForMicroseconds): + (KJS::SamplingTool::dump): + +2008-08-09 Cameron Zwarich + + Reviewed by Oliver. + + Revision 35651, despite being a rather trivial change, introduced a + large regression on the regexp-dna SunSpider test. This regression + stemmed from an increase in the size of CodeBlock::dump(). There is + no reason for this method (and several related methods) to be compiled + in non-debug builds with the sampling tool disabled. This patch + conditionally compiles them, reversing the regression on SunSpider. + + * JavaScriptCore.exp: + * VM/CodeBlock.cpp: + * VM/CodeBlock.h: + * VM/Machine.cpp: + +2008-08-08 Cameron Zwarich + + Reviewed by Oliver. + + Bug 20330: JSCore crash loading any filehurricane media page + + + Fix a typo in the constant loading patch. Also, add a case for + op_unexpected_load to CodeBlock::dump(). + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addUnexpectedConstant): + +2008-08-08 Matt Lilek + + Not reviewed, build fix. + + * JavaScriptCore.exp: + +2008-08-08 Oliver Hunt + + Reviewed by Cameron Zwarich. + + Improve performance of arithmetic operators + + Added a fast (non-virtual) mechanism to determine if a non-immediate JSValue* + is a JSNumberCell. We then use this to allow improved specialisation in many + arithmetic operators. SunSpider reports a 2.5% progression overall, with greater + than 10% progressions on a number of arithmetic heavy tests. + + * VM/Machine.cpp: + (KJS::fastIsNumber): + (KJS::fastToInt32): + (KJS::fastToUInt32): + (KJS::jsLess): + (KJS::jsLessEq): + (KJS::jsAdd): + (KJS::Machine::privateExecute): + * kjs/JSNumberCell.h: + (KJS::JSNumberCell::fastToInt32): + (KJS::JSNumberCell::fastToUInt32): + * kjs/collector.cpp: + (KJS::allocateBlock): + (KJS::Heap::heapAllocate): + * kjs/collector.h: + (KJS::Heap::fastIsNumber): + +2008-08-06 Adam Roben + + Try to fix the Windows build bots + + * API/JSBase.cpp: Touch this to force JSC to rebuild and re-copy the + WTF headers. + +2008-08-06 Tor Arne Vestbø + + Revert change 35595. + + * wtf/RetainPtr.h: + +2008-08-06 Ariya Hidayat + + Fix non-Mac build. + + * wtf/RetainPtr.h: CoreFoundation only for PLATFORM(MAC) + +2008-08-06 Ariya Hidayat + + Fix non-Mac build. + + * wtf/RetainPtr.h: CoreFoundation only for PLATFORM(MAC) + +2008-08-06 Csaba Osztrogonac + + Reviewed by Darin. Landed by Cameron. + + Bug 20272: typo in JavaScriptCore + + + Correct the documentation for op_not. (typo) + Fix #undef. (typo) + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-08-06 Cameron Zwarich + + Reviewed by Maciej. + + Bug 20286: Load constants all at once instead of using op_load + + + Load constants all at once into temporary registers instead of using + individual instances of op_load. + + This is a 2.6% speedup on SunSpider. + + * JavaScriptCore.exp: + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + (KJS::CodeBlock::mark): + * VM/CodeBlock.h: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::newTemporary): + (KJS::CodeGenerator::addConstant): + (KJS::CodeGenerator::addUnexpectedConstant): + (KJS::CodeGenerator::emitLoad): + (KJS::CodeGenerator::emitUnexpectedLoad): + (KJS::CodeGenerator::emitNewError): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::slideRegisterWindowForCall): + (KJS::Machine::unwindCallFrame): + (KJS::Machine::throwException): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * VM/Machine.h: + * VM/Opcode.h: + * VM/RegisterID.h: + (KJS::RegisterID::RegisterID): + (KJS::RegisterID::makeConstant): + (KJS::RegisterID::isTemporary): + * kjs/NodeInfo.h: + * kjs/Parser.cpp: + (KJS::Parser::didFinishParsing): + * kjs/Parser.h: + (KJS::Parser::parse): + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::NullNode::emitCode): + (KJS::BooleanNode::emitCode): + (KJS::NumberNode::emitCode): + (KJS::StringNode::emitCode): + (KJS::ArrayNode::emitCode): + (KJS::DeleteResolveNode::emitCode): + (KJS::DeleteValueNode::emitCode): + (KJS::VoidNode::emitCode): + (KJS::ConstDeclNode::emitCodeSingle): + (KJS::ReturnNode::emitCode): + (KJS::ScopeNode::ScopeNode): + (KJS::ProgramNode::ProgramNode): + (KJS::ProgramNode::create): + (KJS::EvalNode::EvalNode): + (KJS::EvalNode::create): + (KJS::FunctionBodyNode::FunctionBodyNode): + (KJS::FunctionBodyNode::create): + (KJS::FunctionBodyNode::emitCode): + * kjs/nodes.h: + (KJS::ScopeNode::neededConstants): + +2008-08-05 Maciej Stachowiak + + Reviewed by Cameron. + + - add fast path for immediates to % operator, as we have for many other math ops + + This fixes handling for a 0 divisor relative to the last patch. Only an 0.2% speedup on SunSpider but + still a 1.4x win on Oliver's prime test. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-08-05 Cameron Zwarich + + Reviewed by Darin. + + Bug 20293: Crash in JavaScript codegen for eval("const a;") + + + Correctly handle constant declarations in eval code with no initializer. + + * kjs/nodes.cpp: + (KJS::ConstDeclNode::emitCodeSingle): + +2008-08-05 Cameron Zwarich + + Reviewed by Oliver. + + Roll out r35555 because of correctness issues. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-08-05 Maciej Stachowiak + + Reviewed by Geoff. + + - add fast path for immediates to % operator, as we have for many other math ops + + 0.6% speedup on SunSpider. 1.4x speedup on a prime testing torture test that Oliver whipped up. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-07-31 Oliver Hunt + + Reviewed by Cameron Zwarich. + + Bug 19359: JavaScriptCore behaves differently from FF2/3 and IE when handling context in catch statement + + + Make our catch behave like Firefox and IE, we do this by using a StaticScopeObject + instead of a generic JSObject for the scope node. We still don't make use of the + fact that we have a static scope inside the catch block, so the internal performance + of the catch block is not improved, even though technically it would be possible to + do so. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitPushNewScope): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::createExceptionScope): + (KJS::Machine::privateExecute): + * VM/Machine.h: + * VM/Opcode.h: + * kjs/JSStaticScopeObject.cpp: + (KJS::JSStaticScopeObject::toThisObject): + (KJS::JSStaticScopeObject::put): + * kjs/JSStaticScopeObject.h: + * kjs/nodes.cpp: + (KJS::TryNode::emitCode): + +2008-08-02 Rob Gowin + + Reviewed by Eric Seidel. + + Added JavaScriptCore/API/WebKitAvailability to list of files in + javascriptcore_h_api. + + * GNUmakefile.am: + +2008-08-01 Alexey Proskuryakov + + Rubber-stamped by Maciej. + + Remove JSGlobalData::DataInstance. It was only needed when we had per-thread JSGlobalData + instances. + + * kjs/JSGlobalData.h: + +2008-07-31 Kevin Ollivier + + Second attempt at Windows/wx build fix. Instead of avoiding inclusion of windows.h, + use defines, etc. to avoid conflicts in each affected file. Also, change PLATFORM(WIN) + to PLATFORM(WIN_OS) so that other ports using Windows headers get the right impls. + + * VM/SamplingTool.cpp: + * wtf/Threading.h: + +2008-07-31 Anders Carlsson + + Reviewed by Adam. + + Fix Windows build. + + * kjs/collector.h: + * wtf/FastMalloc.cpp: + +2008-07-31 Csaba Osztrogonac + + Reviewed by Simon. + + Bug 20170: [Qt] missing namespace defines in JavaScriptCore.pro + + + * JavaScriptCore.pro: Added missing define. + +2008-07-31 Alexey Proskuryakov + + Rubber-stamped by Maciej. + + Eliminate JSLock (it was already disabled, removing the stub implementaion and all + call sites now). + + * API/JSBase.cpp: + (JSEvaluateScript): + (JSCheckScriptSyntax): + (JSGarbageCollect): + * API/JSCallbackConstructor.cpp: + (KJS::constructJSCallback): + * API/JSCallbackFunction.cpp: + (KJS::JSCallbackFunction::call): + * API/JSCallbackObjectFunctions.h: + (KJS::::init): + (KJS::::getOwnPropertySlot): + (KJS::::put): + (KJS::::deleteProperty): + (KJS::::construct): + (KJS::::hasInstance): + (KJS::::call): + (KJS::::getPropertyNames): + (KJS::::toNumber): + (KJS::::toString): + (KJS::::staticValueGetter): + (KJS::::callbackGetter): + * API/JSContextRef.cpp: + (JSGlobalContextCreateInGroup): + (JSGlobalContextRetain): + (JSGlobalContextRelease): + * API/JSObjectRef.cpp: + (JSObjectMake): + (JSObjectMakeFunctionWithCallback): + (JSObjectMakeConstructor): + (JSObjectMakeFunction): + (JSObjectHasProperty): + (JSObjectGetProperty): + (JSObjectSetProperty): + (JSObjectGetPropertyAtIndex): + (JSObjectSetPropertyAtIndex): + (JSObjectDeleteProperty): + (JSObjectCallAsFunction): + (JSObjectCallAsConstructor): + (JSObjectCopyPropertyNames): + (JSPropertyNameArrayRelease): + (JSPropertyNameAccumulatorAddName): + * API/JSStringRef.cpp: + (JSStringRelease): + * API/JSValueRef.cpp: + (JSValueIsEqual): + (JSValueIsInstanceOfConstructor): + (JSValueMakeNumber): + (JSValueMakeString): + (JSValueToNumber): + (JSValueToStringCopy): + (JSValueToObject): + (JSValueProtect): + (JSValueUnprotect): + * ForwardingHeaders/JavaScriptCore/JSLock.h: Removed. + * GNUmakefile.am: + * JavaScriptCore.exp: + * JavaScriptCore.order: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * kjs/AllInOneFile.cpp: + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): + * kjs/JSGlobalData.h: + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::~JSGlobalObject): + (KJS::JSGlobalObject::init): + * kjs/JSLock.cpp: Removed. + * kjs/JSLock.h: Removed. + * kjs/Shell.cpp: + (functionGC): + (jscmain): + * kjs/collector.cpp: + (KJS::Heap::~Heap): + (KJS::Heap::heapAllocate): + (KJS::Heap::setGCProtectNeedsLocking): + (KJS::Heap::protect): + (KJS::Heap::unprotect): + (KJS::Heap::collect): + * kjs/identifier.cpp: + * kjs/interpreter.cpp: + (KJS::Interpreter::checkSyntax): + (KJS::Interpreter::evaluate): + +2008-07-31 Alexey Proskuryakov + + Rubber-stamped by Oliver Hunt. + + Fix the Mac project to not display "test/" as part of file name for tests. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-07-31 Eric Seidel + + Reviewed by Alexey Proskuryakov. + + Rename USE(MULTIPLE_THREADS) to ENABLE(JSC_MULTIPLE_THREADS) + to better match the use/enable pattern (and better describe + the usage of the feature in question.) + + I also fixed a couple other ENABLE_ macros to be pre-processor + definition override-able to match the rest of the ENABLE_ macros + since it seems to be our convention that build systems can set + ENABLE_ macros in Makefiles. + + * kjs/InitializeThreading.cpp: + (KJS::initializeThreadingOnce): + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): + (KJS::JSGlobalData::~JSGlobalData): + * kjs/MathObject.cpp: + * kjs/collector.cpp: + (KJS::Heap::Heap): + (KJS::Heap::~Heap): + (KJS::allocateBlock): + (KJS::Heap::markStackObjectsConservatively): + * kjs/collector.h: + * kjs/dtoa.cpp: + (KJS::pow5mult): + (KJS::rv_alloc): + (KJS::freedtoa): + (KJS::dtoa): + * wtf/FastMalloc.cpp: + * wtf/Platform.h: + * wtf/RefCountedLeakCounter.cpp: + +2008-07-30 Eric Seidel + + Reviewed by Mark Rowe. + + Try to clean up our usage of USE(MULTIPLE_THREADS) vs. USE(PTHREADS) a little. + It looks like JSC assumes that if MULTIPLE_THREADS is defined, then pthreads will always be available + I'm not sure that's always the case for gtk, certainly not for Windows. We should eventually go back + and fix wtf/Threading.h to cover all these cases some day. + + * kjs/JSLock.cpp: + * kjs/collector.h: + * wtf/Platform.h: + +2008-07-30 Eric Seidel + + Reviewed by Oliver. + + MSVC warns when structs are called classes or vice versa. + Make all the source refer to JSGlobalData as a class. + + * kjs/CommonIdentifiers.h: + * kjs/JSGlobalData.h: + * kjs/Parser.h: + * kjs/lexer.h: + +2008-07-30 Alexey Proskuryakov + + Reviewed by Geoff Garen. + + Add consistency checks to UString to document and enforce its design. + + * kjs/ustring.cpp: + (KJS::UString::Rep::create): + (KJS::UString::Rep::destroy): + (KJS::UString::Rep::checkConsistency): + (KJS::UString::expandCapacity): + (KJS::UString::expandPreCapacity): + (KJS::UString::UString): + (KJS::UString::spliceSubstringsWithSeparators): + (KJS::UString::append): + * kjs/ustring.h: + (KJS::UString::Rep::checkConsistency): + +2008-07-30 Gavin Barraclough + + Reviewed by Geoff Garen. + + Fixes for Windows and non-AllInOne file build with SamplingTool, plus review fixes. + + * GNUmakefile.am: Adding SamplingTool.cpp to build. + * JavaScriptCore.exp: Export hooks to init & control SamplingTool. + * JavaScriptCore.pri: Adding SamplingTool.cpp to build. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Adding SamplingTool.cpp to build. + * JavaScriptCore.xcodeproj/project.pbxproj: Adding SamplingTool.cpp to build. + * JavaScriptCoreSources.bkl: Adding SamplingTool.cpp to build. + * VM/Machine.cpp: MACHINE_SAMPLING_callingNativeFunction renamed MACHINE_SAMPLING_callingHostFunction + * VM/Machine.h: + * VM/Opcode.cpp: SamplingTool moved to SamplingTool.cpp/.h, opcodeNames generated from FOR_EACH_OPCODE_ID. + * VM/Opcode.h: + * VM/SamplingTool.cpp: Added .cpp/.h for SamplingTool. + * VM/SamplingTool.h: + * kjs/Shell.cpp: Switched SAMPLING_TOOL_ENABLED to ENABLE_SAMPLING_TOOL. + * wtf/Platform.h: Added ENABLE_SAMPLING_TOOL config option. + * kjs/nodes.cpp: Header include to fix non-AllInOne builds. + +2008-07-30 Ariya Hidayat + + Reviewed by Alexey Proskuryakov. + + Fix compilation without multi-threading support. + + * kjs/collector.cpp: + (KJS::Heap::Heap): + +2008-07-30 Anders Carlsson + + Add WebKitAvailability.h forwarding header. + + * ForwardingHeaders/JavaScriptCore/WebKitAvailability.h: Added. + +2008-07-30 Anders Carlsson + + Fix the else. + + * API/WebKitAvailability.h: + +2008-07-30 Anders Carlsson + + * API/WebKitAvailability.h: + Fix Windows (and other non-Mac builds). + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + Add WebKitAvailability.h to the project. + +2008-07-30 Anders Carlsson + + One step closer towards fixing the Windows build. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make: + Make sure to copy WebKitAvailability.h + +2008-07-29 Gavin Barraclough + + Reviewed by Geoff Garen. + + Bug 20209: Atomize constant strings + + + Prevents significant performance degradation seen when a script contains multiple + identical strings that are used as keys to identify properties on objects. + + No performance change on SunSpider. + + * kjs/nodes.cpp: Atomize constant strings. + +2008-07-30 Oliver Hunt + + Reviewed by Alexey Proskuryakov. + + JavaScript exceptions fail if the scope chain includes the global object + + In an attempt to remove the branch I just added to KJS::depth I + used the existence of a Variable Object at a point in the scope + chain as an indicator of function or global scope activation. + However this assumption results in incorrect behaviour if the + global object is injected into the scope chain with 'with'. + + * VM/Machine.cpp: + (KJS::depth): + +2008-07-30 Alexey Proskuryakov + + Reviewed by Geoff Garen. + + Don't call JSGarbageCollect() on a released context. + + * API/testapi.c: (main): + +2008-07-29 Alexey Proskuryakov + + Reviewed by Geoff Garen. + + Implement JSContextGroup APIs to make concurrent execution possible for + JavaScriptCore clients. + + This changes the behavior of JSGlobalContextCreate(), so that it now uses a private context + group for each context, making JSlock implicit locking unnecessary. + + * API/JSContextRef.h: + * API/JSContextRef.cpp: + (JSContextGroupCreate): + (JSContextGroupRetain): + (JSContextGroupRelease): + (JSGlobalContextCreate): + (JSGlobalContextCreateInGroup): + (JSGlobalContextRelease): + (JSContextGetGroup): + Added new methods. JSGlobalContextCreate() calls JSGlobalContextCreateInGroup() now. + + * API/APICast.h: (toJS): (toRef): Added converters for JSContextGroupRef. + * API/JSBase.cpp: (JSGarbageCollect): JSGarbageCollect(0) is now a no-op, and the passed in + context is actually used. + + * API/JSBase.h: Aded a typedef for JSContextGroupRef. Updated documentation for + JSGarbageCollect(). + + * JavaScriptCore.exp: Removed JSGlobalData::sharedInstance(). + + * kjs/JSGlobalData.cpp: + * kjs/JSGlobalData.h: + Removed support for JSGlobalData shared instance. JSGlobalData::isSharedInstance member + variable still remains, to be deleted in a followup patch. + + * kjs/JSLock.cpp: (KJS::JSLock::JSLock): Disabled JSLock, to be deleted in a follow-up patch. + + * kjs/collector.cpp: + (KJS::Heap::markOtherThreadConservatively): Removed an assertion that referenced + JSGlobalData::sharedInstance. + + * kjs/collector.h: Made Heap destructor public, so that JSContextRelease can use it. + +2008-07-29 Alexey Proskuryakov + + Reviewed by Geoff Garen. + + Fix a leak of ThreadRegistrar objects. + + As the heap is usually deleted when registered threads still exist, ThreadSpecific doesn't + have a chance to clean up per-thread object. Switched to native pthread calls, storing a + plain pointer that doesn't require cleanup. + + * kjs/collector.cpp: + (KJS::PlatformThread::PlatformThread): + (KJS::Heap::Thread::Thread): + (KJS::Heap::Heap): + (KJS::Heap::~Heap): + (KJS::Heap::registerThread): + (KJS::Heap::unregisterThread): + * kjs/collector.h: + +2008-07-29 Alexey Proskuryakov + + Reviewed by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=20169 + Memory allocated with fastMalloc is freed with delete + + * VM/JSPropertyNameIterator.cpp: + (KJS::JSPropertyNameIterator::invalidate): Free the array properly. + (KJS::JSPropertyNameIterator::~JSPropertyNameIterator): Delete the array by calling + invalidate(). + +2008-07-29 Mark Rowe + + Attempt to fix the Qt build. + + * wtf/ThreadingQt.cpp: Add the extra argument to createThread. + +2008-07-29 Adam Roben + + Change Vector::find to return an index instead of an iterator + + Indices are more natural than iterators when working with Vector. + + Reviewed by John Sullivan. + + * wtf/Vector.h: + (WTF::Vector::find): Changed to iterate the Vector manually and return + the index of the found item, rather than an iterator. When the item + could not be found, we return WTF::notFound. + +2008-07-29 Adam Roben + + Windows build fix + + * wtf/ThreadingWin.cpp: + (WTF::setThreadName): Move a misplaced assertion to here... + (WTF::createThread): ...from here. + +2008-07-29 Adam Roben + + Add support for setting thread names on Windows + + These thread names make it much easier to identify particular threads + in Visual Studio's Threads panel. + + WTF::createThread now takes a const char* representing the thread's + name. On Windows, we throw a special exception to set this string as + the thread's name. Other platforms do nothing with this name for now. + + Reviewed by Anders Carlsson. + + * JavaScriptCore.exp: Export the new version of createThread that + takes 3 arguments (the old one continues to be exported for backward + compatibility). + * wtf/Threading.h: Add a threadName argument to createThread. + + * wtf/ThreadingGtk.cpp: + (WTF::createThread): + * wtf/ThreadingNone.cpp: + (WTF::createThread): + Updated for function signature change. + + * wtf/ThreadingPthreads.cpp: + (WTF::createThread): Updated for function signature change. We keep + around the old 2-argument version of createThread for backward + compatibility. + + * wtf/ThreadingWin.cpp: + (WTF::setThreadName): Added. This function's implementation came from + MSDN. + (WTF::initializeThreading): Set the name of the main thread. + (WTF::createThread): Call setThreadName. We keep around the old + 2-argument version of createThread for backward compatibility. + +2008-07-29 Alexey Proskuryakov + + Reviewed by Oliver Hunt. + + Store UString::Rep::isStatic bit in identifierTable pointer instead of reportedCost for + slightly nicer code and a 0.5% SunSpider improvement. + + * API/JSClassRef.cpp: + (OpaqueJSClass::~OpaqueJSClass): + (OpaqueJSClassContextData::OpaqueJSClassContextData): + * API/JSStringRef.cpp: + (JSStringRelease): + * kjs/PropertyNameArray.cpp: + (KJS::PropertyNameArray::add): + * kjs/identifier.cpp: + (KJS::IdentifierTable::~IdentifierTable): + (KJS::IdentifierTable::add): + (KJS::Identifier::addSlowCase): + (KJS::Identifier::remove): + * kjs/identifier.h: + (KJS::Identifier::add): + * kjs/ustring.cpp: + (KJS::): + (KJS::UString::Rep::create): + (KJS::UString::Rep::destroy): + * kjs/ustring.h: + (KJS::UString::Rep::identifierTable): + (KJS::UString::Rep::setIdentifierTable): + (KJS::UString::Rep::isStatic): + (KJS::UString::Rep::setStatic): + (KJS::UString::cost): + +2008-07-28 Geoffrey Garen + + Reviewed by Sam Weinig. + + Renamed "ConstructTypeNative" => "ConstructTypeHost". + +2008-07-26 Mark Rowe + + Speculative fix for the wx build. + + * JavaScriptCoreSources.bkl: Add JSStaticScopeObject.cpp to the list of source files. + +2008-07-25 Oliver Hunt + + RS=Cameron Zwarich. + + Whoops, forgot to save style correction. + + * kjs/JSStaticScopeObject.h: + +2008-07-25 Oliver Hunt + + Reviewed by Cameron Zwarich. + + Bug 19718: Named anonymous functions are slow accessing global variables + + + To fix this we switch over to an activation-like scope object for + on which we attach the function name property, and add logic to + prevent cross scope assignment to read only properties. + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::findScopedProperty): + (KJS::CodeGenerator::emitResolve): + * VM/CodeGenerator.h: + * kjs/AllInOneFile.cpp: + * kjs/JSStaticScopeObject.cpp: Added. + (KJS::JSStaticScopeObject::putWithAttributes): + (KJS::JSStaticScopeObject::isDynamicScope): + (KJS::JSStaticScopeObject::~JSStaticScopeObject): + (KJS::JSStaticScopeObject::getOwnPropertySlot): + * kjs/JSStaticScopeObject.h: Added. + (KJS::JSStaticScopeObject::JSStaticScopeObjectData::JSStaticScopeObjectData): + (KJS::JSStaticScopeObject::JSStaticScopeObject): + * kjs/nodes.cpp: + (KJS::FunctionCallResolveNode::emitCode): + (KJS::PostfixResolveNode::emitCode): + (KJS::PrefixResolveNode::emitCode): + (KJS::ReadModifyResolveNode::emitCode): + (KJS::AssignResolveNode::emitCode): + (KJS::FuncExprNode::makeFunction): + +2008-07-25 kevino + + wx build fix for Win. + + On wx/Win, including windows.h in Threading.h causes multiply-defined symbol errors + for libjpeg and wx, and also wx needs to include windows.h itself first for wx + includes to work right. So until we can find a better solution to this problem, + on wx, we work around the need to include windows.h here. + + * wtf/Threading.h: + +2008-07-25 Adam Roben + + Windows build fix + + * JavaScriptCore.vcproj/testapi/testapi.vcproj: Add API/ to the + include path. + +2008-07-25 Simon Hausmann + + Fix the build of jsc on Qt/Windows, make sure os-win32 is in the + include search path (added by WebKit.pri). + + * kjs/jsc.pro: + +2008-07-25 Alexey Proskuryakov + + Reviewed by Simon Hausmann. + + Move JavaScriptCore API tests into a subdirectory of their own to avoid header name + conflicts and developer confusion. + + * API/JSNode.c: Removed. + * API/JSNode.h: Removed. + * API/JSNodeList.c: Removed. + * API/JSNodeList.h: Removed. + * API/Node.c: Removed. + * API/Node.h: Removed. + * API/NodeList.c: Removed. + * API/NodeList.h: Removed. + * API/minidom.c: Removed. + * API/minidom.html: Removed. + * API/minidom.js: Removed. + * API/testapi.c: Removed. + * API/testapi.js: Removed. + * API/tests: Added. + * API/tests/JSNode.c: Copied from JavaScriptCore/API/JSNode.c. + * API/tests/JSNode.h: Copied from JavaScriptCore/API/JSNode.h. + * API/tests/JSNodeList.c: Copied from JavaScriptCore/API/JSNodeList.c. + * API/tests/JSNodeList.h: Copied from JavaScriptCore/API/JSNodeList.h. + * API/tests/Node.c: Copied from JavaScriptCore/API/Node.c. + * API/tests/Node.h: Copied from JavaScriptCore/API/Node.h. + * API/tests/NodeList.c: Copied from JavaScriptCore/API/NodeList.c. + * API/tests/NodeList.h: Copied from JavaScriptCore/API/NodeList.h. + * API/tests/minidom.c: Copied from JavaScriptCore/API/minidom.c. + * API/tests/minidom.html: Copied from JavaScriptCore/API/minidom.html. + * API/tests/minidom.js: Copied from JavaScriptCore/API/minidom.js. + * API/tests/testapi.c: Copied from JavaScriptCore/API/testapi.c. + * API/tests/testapi.js: Copied from JavaScriptCore/API/testapi.js. + * GNUmakefile.am: + * JavaScriptCore.vcproj/testapi/testapi.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-07-25 Simon Hausmann + + Prospective WX build fix, add JavaScriptCore/API to the include search + path. + + * jscore.bkl: + +2008-07-25 Simon Hausmann + + Rubber-stamped by Lars. + + Fix the build on Windows. operator new for ArgList is implemented using fastMalloc() + but operator delete was not implemented. Unfortunately MSVC decides to call/reference + the function, so a simple implementation using fastFree() fixes the build. + + * kjs/ArgList.h: + (KJS::ArgList::operator delete): + +2008-07-25 Simon Hausmann + + Discussed with and rubber-stamped by Lars. + + Fix the build system for the Qt port. + + Recent JavaScriptCore changes require the addition of JavaScriptCore/API to the + include search path. With a build process that combines JavaScriptCore and + WebCore in one build process/Makefile the existance of + JavaScriptCore/API/Node.h and WebCore/dom/Node.h causes include conflicts. + + This commit solves this by introducing a separate build of JavaScriptCore into + a static library. + + As a result of the split-up a race-condition due to broken dependencies of + regular source files to header files of generated sources showed up very + frequently when doing parallel builds (which the buildbot does). This commit at + the same time tries to address the dependency problem by making the + addExtraCompiler() function also generate a pseudo extra compiler that + represents the header file output, so that qmake is aware of the creation of + the header file for dependency calculation. + + At the same time I removed a lot of cruft from the pro files to ease maintenance. + + * JavaScriptCore.pri: + * JavaScriptCore.pro: Added. + * kjs/jsc.pro: + +2008-07-24 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed a strict aliasing violation, which caused hash tables with floating + point keys not to find items that were indeed in the tables + (intermittently, and only in release builds, of course). + + SunSpider reports no change. + + This bug doesn't seem to affect any existing code, but it causes obvious + crashes in some new code I'm working on. + + * wtf/HashFunctions.h: + (WTF::FloatHash::hash): Use a union when punning between a float / double + and an unsigned (bucket of bits). With strict aliasing enabled, unions + are the only safe way to do this kind of type punning. + + * wtf/HashTable.h: When rehashing, ASSERT that the item we just added to + the table is indeed in the table. In the buggy case described above, this + ASSERT fires. + +2008-07-24 Oliver Hunt + + Reviewed by Alexey Proskuryakov. + + Bug 20142: REGRESSION(r35245): /=/ weirdness + + + When adding all the meta data needed for exception error messages + I accidentally clobbered the handling of regex beginning with /=. + + * kjs/grammar.y: + +2008-07-23 Alp Toker + + Build fix after r35293: Add API/ to the include path. + + * GNUmakefile.am: + +2008-07-23 Adam Roben + + Windows build fixes + + Build fix after r35293: + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Add API/ + to the include path. + + Build fix after r35305: + + * VM/Machine.cpp: + * VM/Machine.h: + * VM/Opcode.cpp: + * VM/Opcode.h: + Completely compile out all sampler-related code when + SAMPLING_TOOL_ENABLED is 0. The sampler code can't be compiled 1) on + non-AllInOne configurations due to circular header dependencies, and + 2) on platforms that don't have a usleep() function, such as Windows. + +2008-07-23 Oliver Hunt + + Reviewed by Geoff Garen and Sam Weinig. + + Improve switch performance. + + Improve switch performance by converting to a hashmap based jump + table to avoid the sequence of dispatches that would otherwise be + needed. This results in a 9-19x performance win for string switches + based on ad hoc testing, and a 6x improvement for integer switch + statements. SunSpider reports a 1.2% progression. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + (KJS::SimpleJumpTable::offsetForValue): + * VM/CodeBlock.h: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::beginSwitch): + (KJS::prepareJumpTableForImmediateSwitch): + (KJS::prepareJumpTableForCharacterSwitch): + (KJS::prepareJumpTableForStringSwitch): + (KJS::CodeGenerator::endSwitch): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::offsetForStringSwitch): + (KJS::Machine::privateExecute): + * VM/Opcode.cpp: + (KJS::): + * VM/Opcode.h: + * kjs/JSImmediate.h: + * kjs/nodes.cpp: + (KJS::): + (KJS::processClauseList): + (KJS::CaseBlockNode::tryOptimisedSwitch): + (KJS::CaseBlockNode::emitCodeForBlock): + * kjs/nodes.h: + (KJS::SwitchInfo::): + +2008-07-23 Gavin Barraclough + + Reviewed by Geoff Garen. + + Sampling tool to analyze cost of instruction execution and identify hot regions of JS code. + Enable Switches by setting SAMPLING_TOOL_ENABLED in Opcode.h. + + * JavaScriptCore.exp: Export symbols for Shell.cpp. + * VM/Machine.cpp: Added sampling hooks. + * VM/Machine.h: Machine contains a pointer to a sampler, when sampling. + * VM/Opcode.cpp: Tool implementation. + * VM/Opcode.h: Tool declaration. + * kjs/Shell.cpp: Initialize the sampler, if enabled. + * kjs/nodes.cpp: Added sampling hooks. + +2008-07-23 Gabor Loki + + Bug 20097: [Qt] 20% Sunspider slow-down + + + + Reviewed by Simon Hausmann. + + * kjs/jsc.pro: Added missing NDEBUG define for release builds. + +2008-07-23 Alexey Proskuryakov + + Reviewed by Geoff Garen. + + JSClassRef is created context-free, but gets infatuated with the first context it sees. + + The implicit API contract is that JSClassRef can be used with any context on any thread. + This no longer worked, because UStrings in the class were turned into per-context + identifiers, and the cached JSObject prototype was tied to JSGlobalData, too. + + * API/JSClassRef.h: Made a separate struct for context-dependent parts of OpaqueJSClass. + * API/JSClassRef.cpp: + (OpaqueJSClass::OpaqueJSClass): Updated for renames and changed member variable order. + (OpaqueJSClass::~OpaqueJSClass): Assert that string members are not identifiers. + (clearReferenceToPrototype): Update for the new reference location. + (OpaqueJSClassContextData::OpaqueJSClassContextData): Make a deep copy of all strings. + (OpaqueJSClass::contextData): Added a function that finds the per-context part of + OpaqueJSClass in JSGlobalData, or creates it if not found. + (OpaqueJSClass::className): Always make a deep copy. Callers of this function do not have + a way to access JSGlobalData, so a per-context copy could not be made. + (OpaqueJSClass::staticValues): Updated for new data location. + (OpaqueJSClass::staticFunctions): Ditto. + (OpaqueJSClass::prototype): Changed to take an internal type for consistency. + + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): + (KJS::JSGlobalData::~JSGlobalData): + * kjs/JSGlobalData.h: + Keep a HashMap to access per-context JSClass data given a pointr to the shared part. + + * API/JSCallbackObjectFunctions.h: + (KJS::::className): + (KJS::::getOwnPropertySlot): + (KJS::::put): + (KJS::::deleteProperty): + (KJS::::getPropertyNames): + (KJS::::staticValueGetter): + (KJS::::staticFunctionGetter):j + Use function accessors instead of accessing OpaqueJSClass members directly. + + * API/JSContextRef.cpp: (JSGlobalContextCreate): Updated for the change in + OpaqueJSClass::prototype() argument type. + + * API/JSObjectRef.cpp: + (JSObjectMake): Updated for the change in OpaqueJSClass::prototype() argument type. + (JSObjectMakeConstructor): Ditto. + +2008-07-23 Alexey Proskuryakov + + Build fix. + + * kjs/ArgList.h: (KJS::ArgList::operator new): removed an extraneous "ArgList::" inside the + class definition. + +2008-07-22 Geoffrey Garen + + Reviewed by Oliver Hunt and Sam Weinig. + + Next step toward putting doubles in registers: Prepare the Register class + and its clients for registers that don't contain JSValue*s. + + This means a few things: + + 1. Register::jsValue() clients, including ArgList clients, must now supply + an ExecState* when accessing an entry in an ArgList, in case the entry + will need to create a JSValue* on the fly. + + 2. Register clients that definitely don't want to create a JSValue* on + the fly now use different APIs: getJSValue() for clients that know + the register contains a JSValue*, and v() for clients who just want a + void*. + + 3. I had to change some headers around in order to resolve dependency + problems created by using a Register in the ArgList header. + + SunSpider reports no change. + +2008-07-22 Gavin Barraclough + + Reviewed by Alexey Proskuryakov. + + Prevent integer overflow when reallocating storage vector for arrays. + + Sunspider reports 1.005x as fast (no change expected). + + * kjs/JSArray.cpp: + +2008-07-21 Mark Rowe + + Reviewed by Sam Weinig. + + Revamp the handling of CFBundleShortVersionString to be fixed at the major component of the version number. + + * Configurations/Version.xcconfig: + * Info.plist: + +2008-07-21 Adam Roben + + Add Vector::find + + This is a convenience wrapper around std::find. + + Reviewed by Anders Carlsson. + + * wtf/Vector.h: + +2008-07-19 Oliver Hunt + + Reviewed by Cameron Zwarich. + + Bug 20104: Exception in tables/mozilla_expected_failures/bugs/bug92868_1.html includes the equals operator in the quoted expression + + + To make this correct we make the dot and bracket assign nodes emit the information to indicate + the failure range is the dot/bracket accessor. + + * kjs/grammar.y: + +2008-07-18 Steve Falkenburg + + Windows build fix. + + * kjs/JSGlobalObjectFunctions.cpp: + (KJS::isStrWhiteSpace): + +2008-07-18 Steve Falkenburg + + Windows build fix. + + * kjs/nodes.h: + (KJS::ThrowableExpressionData::ThrowableExpressionData): + +2008-07-18 Oliver Hunt + + Reviewed by Cameron Zwarich. + + Bug 18774: SQUIRRELFISH: print meaningful error messages + SQUIRRELFISH: JavaScript error messages are missing informative text + + Add support for decent error messages in JavaScript. This patch achieves this by providing + ensuring the common errors and exceptions have messages that provide the text of expression + that trigger the exception. In addition it attaches a number of properties to the exception + object detailing where in the source the expression came from. + + * JavaScriptCore.exp: + * VM/CodeBlock.cpp: + (KJS::CodeBlock::lineNumberForVPC): + (KJS::CodeBlock::expressionRangeForVPC): + Function to recover the expression range for an instruction + that triggered an exception. + * VM/CodeBlock.h: + (KJS::ExpressionRangeInfo::): + (KJS::CodeBlock::CodeBlock): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitCall): + (KJS::CodeGenerator::emitCallEval): + Emit call needed to be modified so to place the expression range info internally, + as the CodeGenerator emits the arguments nodes itself, rather than the various call + nodes. + * VM/CodeGenerator.h: + (KJS::CodeGenerator::emitExpressionInfo): + Record the expression range info. + * VM/ExceptionHelpers.cpp: + (KJS::createErrorMessage): + (KJS::createInvalidParamError): + (KJS::createUndefinedVariableError): + (KJS::createNotAConstructorError): + (KJS::createNotAFunctionError): + (KJS::createNotAnObjectErrorStub): + (KJS::createNotAnObjectError): + Rewrite all the code for the error messages so that they make use of the newly available + information. + * VM/ExceptionHelpers.h: + * VM/Machine.cpp: + (KJS::isNotObject): Now needs vPC and codeBlock + (KJS::Machine::throwException): + New logic to handle the NotAnObjectErrorStub and to handle the absurd "no default value" edge case + (KJS::Machine::privateExecute): + * VM/Machine.h: + * kjs/DebuggerCallFrame.cpp: + (KJS::DebuggerCallFrame::evaluate): + * kjs/Error.cpp: + (KJS::Error::create): + * kjs/Error.h: + * kjs/JSGlobalObjectFunctions.cpp: + * kjs/JSImmediate.cpp: + (KJS::JSImmediate::toObject): + (KJS::JSImmediate::prototype): + My changes to the JSNotAnObject constructor needed to be handled here. + * kjs/JSNotAnObject.h: + (KJS::JSNotAnObjectErrorStub::JSNotAnObjectErrorStub): + (KJS::JSNotAnObjectErrorStub::isNull): + (KJS::JSNotAnObjectErrorStub::isNotAnObjectErrorStub): + Added a JSNotAnObjectErrorStub class to ease the handling of toObject failure exceptions, + and potentially allow even more detailed error messages in future. + * kjs/JSObject.h: + * kjs/Parser.h: + (KJS::Parser::parse): + * kjs/SourceRange.h: + * kjs/grammar.y: + Large amounts of position propagation. + * kjs/lexer.cpp: + (KJS::Lexer::Lexer): + (KJS::Lexer::shift): + (KJS::Lexer::lex): + The lexer needed a few changes to be able to correctly track token character positions. + * kjs/lexer.h: + * kjs/nodes.cpp: + (KJS::ThrowableExpressionData::emitThrowError): + (KJS::StatementNode::StatementNode): + (KJS::ResolveNode::emitCode): + (KJS::BracketAccessorNode::emitCode): + (KJS::DotAccessorNode::emitCode): + (KJS::NewExprNode::emitCode): + (KJS::EvalFunctionCallNode::emitCode): + (KJS::FunctionCallValueNode::emitCode): + (KJS::FunctionCallResolveNode::emitCode): + (KJS::FunctionCallBracketNode::emitCode): + (KJS::FunctionCallDotNode::emitCode): + (KJS::PostfixResolveNode::emitCode): + (KJS::PostfixBracketNode::emitCode): + (KJS::PostfixDotNode::emitCode): + (KJS::DeleteResolveNode::emitCode): + (KJS::DeleteBracketNode::emitCode): + (KJS::DeleteDotNode::emitCode): + (KJS::PrefixResolveNode::emitCode): + (KJS::PrefixBracketNode::emitCode): + (KJS::PrefixDotNode::emitCode): + (KJS::ThrowableBinaryOpNode::emitCode): + (KJS::ReadModifyResolveNode::emitCode): + (KJS::AssignResolveNode::emitCode): + (KJS::AssignDotNode::emitCode): + (KJS::ReadModifyDotNode::emitCode): + (KJS::AssignBracketNode::emitCode): + (KJS::ReadModifyBracketNode::emitCode): + (KJS::ForInNode::ForInNode): + (KJS::ForInNode::emitCode): + (KJS::WithNode::emitCode): + (KJS::LabelNode::emitCode): + (KJS::ThrowNode::emitCode): + (KJS::ProgramNode::ProgramNode): + (KJS::ProgramNode::create): + (KJS::EvalNode::generateCode): + (KJS::FunctionBodyNode::create): + (KJS::FunctionBodyNode::generateCode): + (KJS::ProgramNode::generateCode): + All of these methods were handling the position information. + Constructors and create methods were modified to store the information. + All the emitCall implementations listed needed to be updated to actually + record the position information we have so carefully collected. + * kjs/nodes.h: + (KJS::ThrowableExpressionData::ThrowableExpressionData): + (KJS::ThrowableExpressionData::setExceptionSourceRange): + (KJS::ThrowableExpressionData::divot): + (KJS::ThrowableExpressionData::startOffset): + (KJS::ThrowableExpressionData::endOffset): + (KJS::ThrowableSubExpressionData::ThrowableSubExpressionData): + (KJS::ThrowableSubExpressionData::setSubexpressionInfo): + (KJS::ThrowablePrefixedSubExpressionData::ThrowablePrefixedSubExpressionData): + (KJS::ThrowablePrefixedSubExpressionData::setSubexpressionInfo): + ThrowableExpressionData is just a uniform mechanism for storing the position + information. + (KJS::ResolveNode::): + (KJS::PrePostResolveNode::): + (KJS::ThrowableBinaryOpNode::): + (KJS::WithNode::): + +2008-07-18 Geoffrey Garen + + Reviewed by Cameron Zwarich. + + Three renames: + + "CallTypeNative" => "CallTypeHost" + "code" => "byteCode" + "generatedCode" => "generatedByteCode" + +2008-07-18 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Optimized <= for immediate number cases. + + SunSpider reports no overall change, but a 10% speedup on access-nsieve. + +2008-07-18 Mark Rowe + + Rubber-stamped by Sam Weinig. + + Fix some casts added in a previous build fix to match the style used + throughout WebKit. + + * VM/Machine.cpp: + (KJS::Machine::initializeCallFrame): + * VM/Register.h: + (KJS::Register::Register): + +2008-07-18 Landry Breuil + + Bug 19975: [OpenBSD] Patches to enable build of WebKit + + + + Reviewed by David Kilzer. + + Support for OpenBSD, mostly threading and libm tweaks. + + * kjs/collector.cpp: #include + (KJS::currentThreadStackBase): use pthread_stackseg_np() to get stack base + * kjs/config.h: OpenBSD also provides + * wtf/MathExtras.h: #include and + (isfinite), (signbit): as long as we don't have those functions provide fallback implementations + * wtf/Platform.h: Add support for PLATFORM(OPENBSD) and PLATFORM(SPARC64) macro + +2008-07-17 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Next step toward putting doubles in registers: Store constant pool + entries as registers, not JSValue*s. + + SunSpider reports no change. + +2008-07-17 Geoffrey Garen + + Reviewed by John Sullivan and Oliver Hunt. + + A tiny bit of tidying in function call register allocation. + + This patch saves one register when invoking a function expression and/or + a new expression that is stored in a temporary. + + Since it's just one register, I can't make a testcase for it. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitCall): No need to ref the function we're calling + or its base. We'd like the call frame to overlap with them, if possible. + op_call will read the function and its base before writing the call frame, + so this is safe. + + * kjs/nodes.cpp: + (KJS::NewExprNode::emitCode): No need to ref the function we're new-ing, + for the same reasons stated above. + + (KJS::FunctionCallValueNode::emitCode): ditto + +2008-07-17 Steve Falkenburg + + Build fix. + + * kjs/InternalFunction.cpp: + +2008-07-17 Sam Weinig + + Roll out r35199 as it is causing failures on the PPC build. + +2008-07-17 Geoffrey Garen + + Reviewed by David Kilzer. + + Fixed https://bugs.webkit.org/show_bug.cgi?id=20067 + Support function.name (Firefox extension) + + Pretty straight-forward. + +2008-07-17 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed Functions calls use more temporary + registers than necessary + + Holding a reference to the last statement result register caused each + successive statement to output its result to an even higher register. + + Happily, statements don't actually need to return a result register + at all. I hope to make this clearer in a future cleanup patch, + but this change will fix the major bug for now. + + * kjs/nodes.cpp: + (KJS::statementListEmitCode): + +2008-07-17 Gavin Barraclough + + Reviewed by Sam Weinig. + + Merge pre&post dot nodes to simplify the parse tree. + Sunspider results show 0.6% progression (no performance change expected). + + * kjs/grammar.y: + * kjs/nodes.cpp: + * kjs/nodes.h: + * kjs/nodes2string.cpp: + +2008-07-17 Gavin Barraclough + + Reviewed by Cameron Zwarich. + + Merge pre&post resolve nodes to simplify the parse tree. + Sunspider results show no performance change. + + * kjs/grammar.y: + * kjs/nodes.cpp: + * kjs/nodes.h: + * kjs/nodes2string.cpp: + +2008-07-17 Gavin Barraclough + + Reviewed by Cameron Zwarich. + + Merge logical nodes to simplify the parse tree. + Sunspider results show 0.6% progression (no performance change expected). + + * kjs/grammar.y: + * kjs/nodes.cpp: + * kjs/nodes.h: + * kjs/nodes2string.cpp: + +2008-07-17 Ariya Hidayat + + Reviewed by Simon. + + Fix MinGW build (broken in r35198) and simplify getLocalTime(). + + * kjs/DateMath.cpp: + (KJS::getLocalTime): + +2008-07-17 Gavin Barraclough + + Reviewed by Sam Weinig. + + Merge pre&post bracket nodes to simplify the parse tree. + Sunspider results show no performance change. + + * kjs/grammar.y: + * kjs/nodes.cpp: + * kjs/nodes.h: + * kjs/nodes2string.cpp: + +2008-07-17 Ariya Hidayat + + Reviewed by Simon. + + Fix the 32-bit gcc builds, conversion from "long int" to Register is + ambiguous. Explicitly choose the intptr_t constructor. + + * VM/Machine.cpp: + (KJS::Machine::initializeCallFrame): + * VM/Register.h: + (KJS::Register::Register): + +2008-07-16 Mark Rowe + + Rubber-stamped by Geoff Garen. + + Fix JavaScript in 64-bit by using a pointer-sized integer + type in the Register union. Also includes a rename of + the intType constant to IntType. + + * VM/Machine.cpp: + (KJS::Machine::initializeCallFrame): + * VM/Register.h: + (KJS::Register::): + (KJS::Register::Register): + +2008-07-17 Geoffrey Garen + + Reviewed by Oliver Hunt. + + First step toward putting doubles in registers: Turned Register into a + proper abstraction layer. It is no longer possible to cast a Register + to a JSValue*, or a Register& to a JSValue*&, or to access the union + inside a Register directly. + + SunSpider reports no change. + + In support of this change, I had to make the following mechanical changes + in a lot of places: + + 1. Clients now use explicit accessors to read data out of Registers, and + implicit copy constructors to write data into registers. + + So, assignment that used to look like + + x.u.jsValue = y; + + now looks like + + x = y; + + And access that used to look like + + x = y.u.jsValue; + + now looks like + + x = y.jsValue(); + + 2. I made generic flow control specific in opcodes that made their flow + control generic by treating a Register& as a JSValue*&. This had the + added benefit of removing some exception checking branches from immediate + number code. + + 3. I beefed up PropertySlot to support storing a Register* in a property + slot. For now, only JSVariableObject's symbolTableGet and symbolTablePut + use this functionality, but I expect more clients to use it in the future. + + 4. I changed ArgList to be a buffer of Registers, not JSValue*'s, and I + changed ArgList iterator clients to iterate Registers, not JSValue*'s. + +2008-07-16 Ada Chan + + Fixed build. + + * kjs/JSGlobalObject.cpp: + +2008-07-16 Kevin McCullough + + Reviewed by Sam and Geoff. + + Navigating to another page while profiler is + attached results in slow JavaScript for all time. + + - The UNLIKELY keeps this from being a sunspider performance regression. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::~JSGlobalObject): Stop the profiler associated + with this exec state. + +2008-07-16 Sam Weinig + + Reviewed by Steve Falkenburg. + + Replace adopting UString constructor in favor of explicit + static adopt method. + + * API/JSStringRefCF.cpp: + (JSStringCreateWithCFString): + * kjs/StringConstructor.cpp: + (KJS::stringFromCharCode): + * kjs/StringPrototype.cpp: + (KJS::stringProtoFuncToLowerCase): + (KJS::stringProtoFuncToUpperCase): + (KJS::stringProtoFuncToLocaleLowerCase): + (KJS::stringProtoFuncToLocaleUpperCase): + * kjs/ustring.cpp: + (KJS::UString::adopt): + * kjs/ustring.h: + (KJS::UString::UString): + (KJS::UString::~UString): + +2008-07-16 Ariya Hidayat + + Reviewed by Simon. + + http://trolltech.com/developer/task-tracker/index_html?method=entry&id=216179 + Fix potential crash (on Qt for Windows port) when performing JavaScript date + conversion. + + * kjs/DateMath.cpp: + (KJS::getLocalTime): For the Qt port, prefer to use Windows code, i.e. + localtime_s() instead of localtime() since the latter might crash (on Windows) + given a non-sensible, e.g. NaN, argument. + +2008-07-16 Alexey Proskuryakov + + Reviewed by Anders and Geoff. + + https://bugs.webkit.org/show_bug.cgi?id=20023 + Failed assertion in PropertyNameArray.cpp + + This is already tested by testapi. + + * API/JSObjectRef.cpp: (JSPropertyNameAccumulatorAddName): Add the string to identifier + table to appease PropertyNameArray. + +2008-07-16 Alexey Proskuryakov + + Reviewed by Geoff. + + Dereference identifiers when deleting a hash table (fixes leaks with private JSGlobalData + objects). + + * kjs/JSGlobalData.cpp: (KJS::JSGlobalData::~JSGlobalData): + * kjs/lookup.cpp: (KJS::HashTable::deleteTable): + * kjs/lookup.h: + * kjs/lexer.cpp: (KJS::Lexer::~Lexer) + HashTable cannot have a destructor, because check-for-global-initializers complains about + having a global constructor then. + +2008-07-16 Alexey Proskuryakov + + Reviewed by Geoff. + + Check pthread_key_create return value. + + This check was helpful when debugging a crash in run-webkit-tests --threaded that happened + because JSGlobalData objects were not deleted, and we were running out of pthread keys soon. + It also looks useful for production builds. + + * wtf/ThreadSpecific.h: (WTF::::ThreadSpecific): + +2008-07-15 Kevin McCullough + + Reviewed by Geoff. + + Rename pageGroupIdentifier to profileGroup to keep mention of a + pageGroup out of JavaScriptCore. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::init): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::setProfileGroup): + (KJS::JSGlobalObject::profileGroup): + * profiler/ProfileGenerator.cpp: + (KJS::ProfileGenerator::create): + (KJS::ProfileGenerator::ProfileGenerator): + * profiler/ProfileGenerator.h: + (KJS::ProfileGenerator::profileGroup): + * profiler/Profiler.cpp: + (KJS::Profiler::startProfiling): + (KJS::dispatchFunctionToProfiles): + (KJS::Profiler::willExecute): + (KJS::Profiler::didExecute): + +2008-07-14 Mark Rowe + + Reviewed by Sam Weinig. + + Fix https://bugs.webkit.org/show_bug.cgi?id=20037 + Bug 20037: GCC 4.2 build broken due to strict aliasing violation. + + * kjs/ustring.cpp: + (KJS::UString::Rep::computeHash): Add a version of computeHash that takes a char* and explicit length. + * kjs/ustring.h: + * profiler/CallIdentifier.h: + (WTF::): Use new version of computeHash that takes a char* and explicit length to avoid unsafe aliasing. + +2008-07-14 David Hyatt + + Fix a crashing bug in ListHashSet's -- operator. Make sure that end() can be -- by special-casing the null + position. + + Reviewed by Maciej + + * wtf/ListHashSet.h: + (WTF::ListHashSetConstIterator::operator--): + +2008-07-14 David Hyatt + + Buidl fix. Make sure the second insertBefore method returns a value. + + * wtf/ListHashSet.h: + (WTF::::insertBefore): + +2008-07-14 Adam Roben + + Windows build fix + + * JavaScriptCore.vcproj/jsc/jsc.vcproj: Added include/pthreads to the + include path. + +2008-07-14 Alexey Proskuryakov + + Reviewed by Kevin McCullough. + + Make JSGlobalData refcounted in preparation to adding a way to create contexts that share + global data. + + * JavaScriptCore.exp: + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::create): + * kjs/JSGlobalData.h: + Made contructor private, and added a static create() method. Made the class inherit from + RefCounted. + + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::globalData): + JSGlobalData is now owned by JSGlobalObject (except for the shared one, and the common + WebCore one, which are never deleted). + + * kjs/Shell.cpp: (main): Create JSGlobalData with create() method. + +2008-07-14 Simon Hausmann + + Fix the single-threaded build. + + * kjs/JSLock.cpp: Removed undeclared registerThread() function. + * kjs/collector.cpp: + (KJS::Heap::registerThread): Added dummy implementation. + +2008-07-14 Alexey Proskuryakov + + Reviewed by Geoff Garen. + + Eliminate per-thread JavaScript global data instance support and make arbitrary + global data/global object combinations possible. + + * kjs/collector.cpp: + (KJS::Heap::Heap): Store a JSGlobalData pointer instead of multiple pointers to its members. + This allows for going from any JS object to its associated global data, currently used in + JSGlobalObject constructor to initialize its JSGlobalData pointer. + (KJS::Heap::registerThread): Changed thread registration data to be per-heap. Previously, + only the shared heap could be used from multiple threads, so it was the only one that needed + thread registration, but now this can happen to any heap. + (KJS::Heap::unregisterThread): Ditto. + (KJS::Heap::markStackObjectsConservatively): Adapt for the above changes. + (KJS::Heap::setGCProtectNeedsLocking): Ditto. + (KJS::Heap::protect): Ditto. + (KJS::Heap::unprotect): Ditto. + (KJS::Heap::collect): Ditto. + (KJS::Heap::globalObjectCount): Use global object list associated with the current heap, + not the late per-thread one. + (KJS::Heap::protectedGlobalObjectCount): Ditto. + + * kjs/collector.h: + (KJS::Heap::ThreadRegistrar): Added a helper object that unregisters a thread when it is + destroyed. + + * kjs/JSLock.cpp: + (KJS::JSLock::JSLock): + * kjs/JSLock.h: + (KJS::JSLock::JSLock): + Don't use JSLock to implicitly register threads. I've added registerThread() calls to most + places that use JSLock - we cannot guarantee absolute safety unless we always mark all + threads in the process, but these implicit registration calls should cover reasonable usage + scenarios, I hope. + + * API/JSBase.cpp: + (JSEvaluateScript): Explicitly register the current thread. + (JSCheckScriptSyntax): Explicitly register the current thread. + (JSGarbageCollect): Changed to use the passed in context. Unfortunately, this creates a race + condition for clients that pass an already released context to JSGarbageCollect - but it is + unlikely to create real life problems. + To maintain compatibility, the shared heap is collected if NULL is passed. + + * API/JSContextRef.cpp: + (JSGlobalContextCreate): Use a new syntax for JSGlobalObject allocation. + (JSGlobalContextRetain): Register the thread. + (JSContextGetGlobalObject): Register the thread. + + * API/JSObjectRef.cpp: + (JSObjectMake): + (JSObjectMakeFunctionWithCallback): + (JSObjectMakeConstructor): + (JSObjectMakeFunction): + (JSObjectHasProperty): + (JSObjectGetProperty): + (JSObjectSetProperty): + (JSObjectGetPropertyAtIndex): + (JSObjectSetPropertyAtIndex): + (JSObjectDeleteProperty): + (JSObjectCallAsFunction): + (JSObjectCallAsConstructor): + (JSObjectCopyPropertyNames): + (JSPropertyNameAccumulatorAddName): + * API/JSValueRef.cpp: + (JSValueIsEqual): + (JSValueIsInstanceOfConstructor): + (JSValueMakeNumber): + (JSValueMakeString): + (JSValueToNumber): + (JSValueToStringCopy): + (JSValueToObject): + (JSValueProtect): + (JSValueUnprotect): + Register the thread. + + * API/JSStringRef.cpp: (JSStringRelease): Changed a comment to not mention per-thread contexts. + + * API/JSStringRefCF.cpp: Removed an unnecessary include of JSLock.h. + + * JavaScriptCore.exp: Export JSGlobalData constructor/destructor, now that anyone can have + their own instances. Adapt to other changes, too. + + * JavaScriptCore.xcodeproj/project.pbxproj: Made ThreadSpecific.h private, as it is now + included by collector.h and is thus needed in other projects. + + * kjs/InitializeThreading.cpp: (KJS::initializeThreadingOnce): Don't initialize per-thread + global data, as it no longer exists. + + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): + (KJS::JSGlobalData::~JSGlobalData): + * kjs/JSGlobalData.h: + Removed support for per-thread instance. Made constructor and destructor public. + + * kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::init): Get to now arbitrary JSGlobalData + via the heap. + (KJS::JSGlobalObject::operator new): Changed ot take JSGlobalDatra pointer. + * kjs/JSGlobalObject.h: + + * kjs/Shell.cpp: + (main): + (jscmain): + Changed to maintain a custom JSGlobalData pointer instead of a per-thread one. + +2008-07-13 Ada Chan + + Windows build fix: Add wtf/RefCountedLeakCounter to the project. + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + +2008-07-12 Jan Michael Alonzo + + Gtk, Qt and Wx build fix: Add wtf/RefCountedLeakCounter in the + build scripts + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCoreSources.bkl: + +2008-07-11 Stephanie Lewis + + Reviewed by Darin Adler and Oliver Hunt. + + Refactor RefCounting Leak counting code into a common class. + + In order to export the symbols I needed to put the debug defines inside the function names + + Before we had a separate channel for each Logging each Leak type. Since the leak channels were only used in one location, and only at quit for simplicity I combined them all into one leak channel. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: add new class + * kjs/nodes.cpp: remove old leak counting code + * wtf/RefCountedLeakCounter.cpp: Added. create a common leak counting class + * wtf/RefCountedLeakCounter.h: Added. + +2008-07-11 David Hyatt + + Add an insertBefore method to ListHashSet to allow for insertions in the middle of the list (rather than just + at the end). + + Reviewed by Anders + + * wtf/ListHashSet.h: + (WTF::::insertBefore): + (WTF::::insertNodeBefore): + +2008-07-11 Sam Weinig + + Rubber-stamped by Darin Adler. + + Move call function to CallData.cpp and construct to ConstructData.cpp. + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * kjs/AllInOneFile.cpp: + * kjs/CallData.cpp: Copied from kjs/JSValue.cpp. + * kjs/ConstructData.cpp: Copied from kjs/JSValue.cpp. + * kjs/JSValue.cpp: + +2008-07-10 Mark Rowe + + Reviewed by Sam Weinig. + + Define WEBKIT_VERSION_MIN_REQUIRED=WEBKIT_VERSION_LATEST when building WebKit to ensure that no symbols end up with the weak_import attribute. + + * Configurations/Base.xcconfig: + +2008-07-10 Mark Rowe + + Reviewed by Sam Weinig. + + Fix the Tiger build by omitting annotations from methods declared in categories when using old versions of GCC. + + * API/WebKitAvailability.h: + +2008-07-10 Kevin McCullough + + Reviewed by Darin. + + -Minor cleanup. Renamed callTree() to head() and no longer use m_head + directly but instead keep it private and access via a method(). + + * profiler/HeavyProfile.cpp: + (KJS::HeavyProfile::HeavyProfile): + (KJS::HeavyProfile::generateHeavyStructure): + (KJS::HeavyProfile::addNode): + * profiler/Profile.h: + (KJS::Profile::head): + * profiler/ProfileGenerator.cpp: + (KJS::ProfileGenerator::ProfileGenerator): + +2008-07-10 Alexey Proskuryakov + + Reviewed by Mark Rowe. + + Eliminate CollectorHeapIntrospector. + + CollectorHeapIntrospector was added primarily in the hopes to improve leaks tool output, + a result that it didn't deliver. Also, it helped by labeling JSC heap regions as reported by + vmmap tool, but at the same time, it made them mislabeled as malloc'd ones - the correct + way to label mapped regions is to use a VM tag. + + So, it makes more sense to remove it completely than to make it work with multiple heaps. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/AllInOneFile.cpp: + * kjs/InitializeThreading.cpp: + (KJS::initializeThreading): + * kjs/collector.cpp: + * kjs/collector.h: + * kjs/CollectorHeapIntrospector.cpp: Removed. + * kjs/CollectorHeapIntrospector.h: Removed. + +2008-07-09 Kevin McCullough + + Reviewed by Darin. + + JSProfiler: Implement heavy (or bottom-up) + view (19228) + - Implemented the time and call count portionof heavy. Now all that we + need is some UI. + + * profiler/CallIdentifier.h: Removed an unused constructor. + * profiler/HeavyProfile.cpp: + (KJS::HeavyProfile::HeavyProfile): Set the initial time of the head + node so that percentages work correctly. + (KJS::HeavyProfile::mergeProfiles): Sum the times and call count of + nodes being merged. + * profiler/ProfileNode.cpp: Set the intital values of time and call + count when copying ProfileNodes. + (KJS::ProfileNode::ProfileNode): + +2008-07-10 Jan Michael Alonzo + + Gtk build fix. + + * GNUmakefile.am: Add HeavyProfile.cpp + +2008-07-09 Mark Rowe + + Reviewed by Geoff Garen. + + Don't warn about deprecated functions in production builds. + + * Configurations/Base.xcconfig: + * Configurations/DebugRelease.xcconfig: + +2008-07-09 Darin Adler + + * JavaScriptCore.pri: Fix Qt build by adding HeavyProfile.cpp. + +2008-07-09 Kevin Ollivier + + wx biuld fix. Add HeavyProfile.cpp to build files. + + * JavaScriptCoreSources.bkl: + +2008-07-09 Kevin McCullough + + - Windows build fix. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2008-07-09 Kevin McCullough + + - Build fix. + + * profiler/HeavyProfile.cpp: + (KJS::HeavyProfile::mergeProfiles): + +2008-07-09 Kevin McCullough + + Reviewed by Geoff and Adam. + + JSProfiler: Implement Bottom-Up view (19228) + - This is the plumbing for bottom-up, but does not include calculating + time, mostly because I'm still undclear about what the end result should + look like. + - This, obviously, does not include the UI to expose this in the + inspector yet. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * profiler/CallIdentifier.h: + (KJS::CallIdentifier::CallIdentifier): + (WTF::): Added HashTraits for CallIdentifiers to be used by a HashMap. + * profiler/HeavyProfile.cpp: Added. + (KJS::HeavyProfile::HeavyProfile): + (KJS::HeavyProfile::generateHeavyStructure): + (KJS::HeavyProfile::addNode): + (KJS::HeavyProfile::mergeProfiles): + (KJS::HeavyProfile::addAncestorsAsChildren): + * profiler/HeavyProfile.h: Added. + (KJS::HeavyProfile::create): + (KJS::HeavyProfile::heavyProfile): + (KJS::HeavyProfile::treeProfile): + * profiler/Profile.cpp: Removed old commented out includes. + * profiler/Profile.h: The m_head is needed by the HeavyProfile so it + is now protected as opposed to private. + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::ProfileNode): Created a constructor to copy + ProfileNodes. + (KJS::ProfileNode::findChild): Added a null check to make HeavyProfile + children finding easier and avoid a potential crasher. + * profiler/ProfileNode.h: Mostly moved things around but also added some + functionality needed by HeavyProfile. + (KJS::ProfileNode::create): + (KJS::ProfileNode::functionName): + (KJS::ProfileNode::url): + (KJS::ProfileNode::lineNumber): + (KJS::ProfileNode::head): + (KJS::ProfileNode::setHead): + (KJS::ProfileNode::setNextSibling): + (KJS::ProfileNode::actualTotalTime): + (KJS::ProfileNode::actualSelfTime): + * profiler/TreeProfile.cpp: Implemented the ability to get a + HeavyProfile. + (KJS::TreeProfile::heavyProfile): + * profiler/TreeProfile.h: + +2008-07-08 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Added support for checking if an object has custom properties in its + property map. WebCore uses this to optimize marking DOM wrappers. + +2008-07-08 Simon Hausmann + + Prospective Gtk/Wx build fixes, add ProfileGenerator.cpp to the build. + + * GNUmakefile.am: + * JavaScriptCoreSources.bkl: + +2008-07-08 Simon Hausmann + + Fix the Qt build, add ProfileGenerator.cpp to the build. + + * JavaScriptCore.pri: + +2008-07-07 David Kilzer + + releaseFastMallocFreeMemory() should always be defined + + Reviewed by Darin. + + * JavaScriptCore.exp: Changed to export C++ binding for + WTF::releaseFastMallocFreeMemory() instead of C binding for + releaseFastMallocFreeMemory(). + * wtf/FastMalloc.cpp: Moved definitions of + releaseFastMallocFreeMemory() to be in the WTF namespace + regardless whether FORCE_SYSTEM_MALLOC is defined. + * wtf/FastMalloc.h: Moved releaseFastMallocFreeMemory() from + extern "C" binding to WTF::releaseFastMallocFreeMemory(). + +2008-07-07 Cameron Zwarich + + Reviewed by Geoff. + + Bug 19926: URL causes crash within a minute + + + Add a check that lastGlobalObject is non-null in Machine::execute() + before copying its globals to the current register file. + + In theory, it is possible to make a test case for this, but it will + take a while to get it right. + + * VM/Machine.cpp: + (KJS::Machine::execute): + +2008-07-07 Darin Adler + + Rubber stamped by Adele. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Fix a typo in a comment. + +2008-07-07 Steve Falkenburg + + Build fixes. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.vcproj/testapi/testapi.vcproj: + +2008-07-07 Kevin McCullough + + Reviewed by Darin. + + When the profiler is running it gathers information and creates a + Profile. After it finishes the Profile can be sorted and have other + data refinements run over it. Both of these were done in the same class + before. Now I split the gathering operations into a new class called + ProfileGenerator. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * profiler/Profile.cpp: Removed code related to the gather stage of a + Profile's creation. + (KJS::Profile::create): + (KJS::Profile::Profile): + * profiler/Profile.h: Ditto. + (KJS::Profile::title): + (KJS::Profile::callTree): + (KJS::Profile::setHead): + * profiler/ProfileGenerator.cpp: Added. This is the class that will + handle the stage of creating a Profile. Once the Profile is finished + being created, this class goes away. + (KJS::ProfileGenerator::create): + (KJS::ProfileGenerator::ProfileGenerator): + (KJS::ProfileGenerator::title): + (KJS::ProfileGenerator::willExecute): + (KJS::ProfileGenerator::didExecute): + (KJS::ProfileGenerator::stopProfiling): + (KJS::ProfileGenerator::didFinishAllExecution): + (KJS::ProfileGenerator::removeProfileStart): + (KJS::ProfileGenerator::removeProfileEnd): + * profiler/ProfileGenerator.h: Added. + (KJS::ProfileGenerator::profile): + (KJS::ProfileGenerator::originatingGlobalExec): + (KJS::ProfileGenerator::pageGroupIdentifier): + (KJS::ProfileGenerator::client): + (KJS::ProfileGenerator::stoppedProfiling): + * profiler/Profiler.cpp: Now operates with the ProfileGenerator instead + of the Profile. + (KJS::Profiler::startProfiling): + (KJS::Profiler::stopProfiling): + (KJS::Profiler::didFinishAllExecution): It is here that the Profile is + handed off to its client and the Profile Generator is no longer needed. + (KJS::dispatchFunctionToProfiles): + (KJS::Profiler::willExecute): + (KJS::Profiler::didExecute): + * profiler/Profiler.h: Cleaned up the includes and subsequently the + forward declarations. Also use the new ProfileGenerator. + (KJS::ProfilerClient::~ProfilerClient): + (KJS::Profiler::currentProfiles): + * profiler/TreeProfile.cpp: Use Profile's new interface. + (KJS::TreeProfile::create): + (KJS::TreeProfile::TreeProfile): + * profiler/TreeProfile.h: + +2008-07-07 Sam Weinig + + Reviewed by Cameron Zwarich. + + Third step in broad cleanup effort. + + [ File list elided ] + +2008-07-06 Sam Weinig + + Reviewed by Cameron Zwarich. + + Second step in broad cleanup effort. + + [ File list elided ] + +2008-07-05 Sam Weinig + + Reviewed by Cameron Zwarich. + + First step in broad cleanup effort. + + [ File list elided ] + +2008-07-05 Sam Weinig + + Rubber-stamped by Cameron Zwarich. + + Rename list.h/cpp to ArgList.h/cpp. + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * VM/Machine.h: + * kjs/AllInOneFile.cpp: + * kjs/ArgList.cpp: Copied from JavaScriptCore/kjs/list.cpp. + * kjs/ArgList.h: Copied from JavaScriptCore/kjs/list.h. + * kjs/IndexToNameMap.cpp: + * kjs/JSGlobalData.cpp: + * kjs/JSGlobalData.h: + * kjs/JSObject.h: + * kjs/collector.cpp: + * kjs/list.cpp: Removed. + * kjs/list.h: Removed. + +2008-07-05 Sam Weinig + + Fix non-AllInOne builds again. + + * kjs/BooleanPrototype.cpp: + * kjs/ErrorPrototype.cpp: + * kjs/FunctionPrototype.cpp: + * kjs/NumberPrototype.cpp: + * kjs/ObjectPrototype.cpp: + +2008-07-05 Sam Weinig + + Fix build on case-sensitive build systems. + + * kjs/IndexToNameMap.cpp: + +2008-07-05 Sam Weinig + + Fix build. + + * kjs/Arguments.cpp: + * kjs/BooleanPrototype.cpp: + * kjs/DateConstructor.cpp: + * kjs/ErrorPrototype.cpp: + * kjs/FunctionPrototype.cpp: + * kjs/NumberPrototype.cpp: + * kjs/ObjectPrototype.cpp: + * kjs/RegExpPrototype.cpp: + * kjs/StringConstructor.cpp: + * kjs/lookup.cpp: + +2008-07-05 Sam Weinig + + Fix non-AllInOne build. + + * kjs/JSGlobalObject.cpp: + +2008-07-05 Sam Weinig + + Rubber-stamped by Cameron Zwarich. + + Split Arguments, IndexToNameMap, PrototypeFunction, GlobalEvalFunction and + the functions on the global object out of JSFunction.h/cpp. + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * VM/Machine.cpp: + * kjs/AllInOneFile.cpp: + * kjs/Arguments.cpp: Copied from JavaScriptCore/kjs/JSFunction.cpp. + * kjs/Arguments.h: Copied from JavaScriptCore/kjs/JSFunction.h. + * kjs/GlobalEvalFunction.cpp: Copied from JavaScriptCore/kjs/JSFunction.cpp. + * kjs/GlobalEvalFunction.h: Copied from JavaScriptCore/kjs/JSFunction.h. + * kjs/IndexToNameMap.cpp: Copied from JavaScriptCore/kjs/JSFunction.cpp. + * kjs/IndexToNameMap.h: Copied from JavaScriptCore/kjs/JSFunction.h. + * kjs/JSActivation.cpp: + * kjs/JSFunction.cpp: + * kjs/JSFunction.h: + * kjs/JSGlobalObject.cpp: + * kjs/JSGlobalObjectFunctions.cpp: Copied from JavaScriptCore/kjs/JSFunction.cpp. + * kjs/JSGlobalObjectFunctions.h: Copied from JavaScriptCore/kjs/JSFunction.h. + The functions on the global object should be in JSGlobalObject.cpp, but putting them there + was a 0.5% regression. + + * kjs/PrototypeFunction.cpp: Copied from JavaScriptCore/kjs/JSFunction.cpp. + * kjs/PrototypeFunction.h: Copied from JavaScriptCore/kjs/JSFunction.h. + * kjs/Shell.cpp: + * kjs/lexer.cpp: + * kjs/ustring.cpp: + +2008-07-04 Sam Weinig + + Really fix the mac build. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-07-04 Sam Weinig + + Fix mac build. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-07-04 Sam Weinig + + Fix non-AllInOne builds. + + * kjs/Error.cpp: + * kjs/GetterSetter.cpp: + * kjs/JSImmediate.cpp: + * kjs/operations.cpp: + +2008-07-04 Sam Weinig + + Rubber-stamped by Dan Bernstein. + + Split Error and GetterSetter out of JSObject.h. + + * API/JSCallbackObjectFunctions.h: + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * kjs/AllInOneFile.cpp: + * kjs/ClassInfo.h: Copied from JavaScriptCore/kjs/JSObject.h. + * kjs/Error.cpp: Copied from JavaScriptCore/kjs/JSObject.cpp. + * kjs/Error.h: Copied from JavaScriptCore/kjs/JSObject.h. + * kjs/GetterSetter.cpp: + * kjs/GetterSetter.h: Copied from JavaScriptCore/kjs/JSObject.h. + * kjs/JSObject.cpp: + * kjs/JSObject.h: + * kjs/nodes.h: + +2008-07-04 Simon Hausmann + + Fix the Wx build, added TreeProfile.cpp to the build. + + * JavaScriptCoreSources.bkl: + +2008-07-03 Mark Rowe + + Reviewed by Oliver Hunt. + + Fix output path of recently-added script phase to reference the correct file. + This prevents Xcode from running the script phase unnecessarily, which caused + the generated header to be recreated and lead to AllInOneFile.cpp rebuilding. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-07-03 Mark Rowe + + Follow-up to the 64-bit build fix. Use intptr_t rather than ssize_t as + the latter is non-standard and does not exist on Windows. + + * kjs/JSLock.cpp: + (KJS::JSLock::lockCount): + (KJS::JSLock::lock): + (KJS::JSLock::unlock): + (KJS::JSLock::DropAllLocks::DropAllLocks): + * kjs/JSLock.h: + +2008-07-02 Mark Rowe + + Fix the 64-bit build. pthread_getspecific works with pointer-sized values, + so use ssize_t rather than int to track the lock count to avoid warnings about + truncating the result of pthread_getspecific. + + * kjs/JSLock.cpp: + (KJS::JSLock::lockCount): + (KJS::JSLock::lock): + (KJS::JSLock::unlock): + (KJS::JSLock::DropAllLocks::DropAllLocks): + * kjs/JSLock.h: + +2008-07-03 Geoffrey Garen + + Reviewed by Sam Weinig. + + Removed checking for the array get/put fast case from the array code. + Callers who want the fast case should call getIndex and/or setIndex + instead. (get_by_val and put_by_val already do this.) + + SunSpider reports no change overall, but a 1.4% speedup on fannkuch and + a 3.6% speedup on nsieve. + +2008-07-03 Dan Bernstein + + - Windows build fix + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Added TreeProfile.{h,cpp}. + +2008-07-03 Dan Bernstein + + Reviewed by Anders Carlsson. + + - Windows build fix + + * VM/Machine.cpp: + (KJS::Machine::Machine): + +2008-07-03 Simon Hausmann + + Reviewed by Alexey Proskuryakov. + + Fix the non-threaded build. + + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::threadInstanceInternal): + +2008-07-03 Simon Hausmann + + Fix the Qt build, added TreeProfile to the build. + + * JavaScriptCore.pri: + +2008-07-02 Alexey Proskuryakov + + Reviewed by Geoff. + + Don't create unnecessary JSGlobalData instances. + + * kjs/JSGlobalData.h: + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::threadInstanceExists): + (KJS::JSGlobalData::sharedInstanceExists): + (KJS::JSGlobalData::threadInstance): + (KJS::JSGlobalData::sharedInstance): + (KJS::JSGlobalData::threadInstanceInternal): + (KJS::JSGlobalData::sharedInstanceInternal): + Added methods to query instance existence. + + * kjs/InitializeThreading.cpp: + (KJS::initializeThreadingOnce): + Initialize thread instance static in a new way. + + * API/JSBase.cpp: + (JSGarbageCollect): + * kjs/collector.cpp: + (KJS::Heap::collect): + Check for instance existence before accessing it. + +2008-07-02 Geoffrey Garen + + Reviewed by Cameron Zwarich. + + Fixed https://bugs.webkit.org/show_bug.cgi?id=19862 + REGRESSION (r34907): Gmail crashes in JavaScriptCore code while editing drafts + + I was never able to reproduce this issue, but Cameron could, and he says + that this patch fixes it. + + The crash seems tied to a timer or event handler callback. In such a case, + the sole reference to the global object may be in the current call frame, + so we can't depend on the global object to mark the call frame area in + the register file. + + The new GC marking rule is: the global object is not responsible for + marking the whole register file -- it's just responsible for the globals + section it's tied to. The heap is responsible for marking the call frame area. + +2008-07-02 Mark Rowe + + Reviewed by Sam Weinig. + + Add the ability to trace JavaScriptCore garabge collections using dtrace. + + * JavaScriptCore.xcodeproj/project.pbxproj: Generate the dtrace probe header + file when building on a new enough version of Mac OS X. + * JavaScriptCorePrefix.h: Add our standard Mac OS X version detection macros. + * kjs/Tracing.d: Declare three dtrace probes. + * kjs/Tracing.h: Include the generated dtrace macros if dtrace is available, + otherwise provide versions that do nothing. + * kjs/collector.cpp: + (KJS::Heap::collect): Fire dtrace probes when starting a collection, after the + mark phase has completed, and when the collection is complete. + * wtf/Platform.h: Define HAVE_DTRACE when building on a new enough version of Mac OS X. + +2008-07-02 Geoffrey Garen + + Rubber stamped by Oliver Hunt. + + Reduced the max register file size from 8MB to 2MB. + + We still allow about 20,000 levels of recursion. + +2008-07-02 Alp Toker + + Build fix for r34960. Add TreeProfile.cpp to build. + + * GNUmakefile.am: + +2008-07-02 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Optimized a[n] get for cases when a is an array or a string. When a is + an array, we optimize both get and put. When a is a string, we only + optimize get, since you can't put to a string. + + SunSpider says 3.4% faster. + +2008-07-02 Kevin McCullough + + Reviewed by Darin. + + -Small cleanup in preparation for implementing Bottom-up. + + * profiler/CallIdentifier.h: Rename debug function to make it clear of + its output and intention to be debug only. + (KJS::CallIdentifier::operator const char* ): Implement in terms of + c_str. + (KJS::CallIdentifier::c_str): + * profiler/ProfileNode.cpp: Impelment findChild() which will be needed + by the bottom-up implementation. + (KJS::ProfileNode::findChild): + * profiler/ProfileNode.h: Added comments to make the collections of + functions more clear. + (KJS::ProfileNode::operator==): + (KJS::ProfileNode::c_str): + +2008-07-02 Cameron Zwarich + + Reviewed by Darin. + + Bug 19776: Number.toExponential() is incorrect for numbers between 0.1 and 1 + + + Perform the sign check for the exponent on the actual exponent value, + which is 1 less than the value of decimalPoint, instead of on the value + of decimalPoint itself. + + * kjs/NumberPrototype.cpp: + (KJS::exponentialPartToString): + +2008-07-02 Kevin McCullough + + Reviewed by Darin. + + JSProfiler: Implement Bottom-Up view (19228) + - Subclass TreeProfile as I prepare for a HeavyProfile to be comming + later. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * profiler/Profile.cpp: By default we create a TreeProfile. + (KJS::Profile::create): + * profiler/Profile.h: Changes to the Profile class to make it amenable + to be inherited from. + (KJS::Profile::~Profile): + * profiler/TreeProfile.cpp: Added. + (KJS::TreeProfile::create): + (KJS::TreeProfile::TreeProfile): + (KJS::TreeProfile::heavyProfile): + * profiler/TreeProfile.h: Added. + (KJS::TreeProfile::treeProfile): + +2008-07-02 Kevin McCullough + + Reviewed by Dan. + + Broke CallIdentifier out into its own file. I did this because it's + going to grow a lot soon and I wanted this to be a separate patch. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * profiler/CallIdentifier.h: Added. + (KJS::CallIdentifier::CallIdentifier): + (KJS::CallIdentifier::operator==): + (KJS::CallIdentifier::operator!=): + (KJS::CallIdentifier::operator const char* ): + (KJS::CallIdentifier::toString): + * profiler/ProfileNode.h: + +2008-07-02 Simon Hausmann + + Build fix. Implemented missing functions for single-threaded build. + + * kjs/JSLock.cpp: + (KJS::JSLock::JSLock): + (KJS::JSLock::lock): + (KJS::JSLock::unlock): + (KJS::JSLock::DropAllLocks::DropAllLocks): + +2008-07-02 Alexey Proskuryakov + + Another non-AllInOne build fix. + + * kjs/JSGlobalObject.cpp: Include JSLock.h here, too. + +2008-07-02 Alexey Proskuryakov + + Non-AllInOne build fix. + + * kjs/interpreter.cpp: Include JSLock.h. + +2008-06-30 Alexey Proskuryakov + + Reviewed by Darin. + + Disable JSLock for per-thread contexts. + + No change on SunSpider. + + * kjs/JSGlobalData.h: + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): + (KJS::JSGlobalData::sharedInstance): + Added isSharedInstance as a better way to tell whether the instance is shared (legacy). + + * kjs/JSLock.cpp: + (KJS::createJSLockCount): + (KJS::JSLock::lockCount): + (KJS::setLockCount): + (KJS::JSLock::JSLock): + (KJS::JSLock::lock): + (KJS::JSLock::unlock): + (KJS::JSLock::currentThreadIsHoldingLock): + (KJS::JSLock::DropAllLocks::DropAllLocks): + (KJS::JSLock::DropAllLocks::~DropAllLocks): + * kjs/JSLock.h: + (KJS::JSLock::JSLock): + (KJS::JSLock::~JSLock): + Made JSLock and JSLock::DropAllLocks constructors take a parameter to decide whether to + actually lock a mutex, or only to increment recursion count. We cannot turn it into no-op + if we want to keep existing assertions working. + Made recursion count per-thread, now that locks may not lock. + + * API/JSBase.cpp: + (JSEvaluateScript): Take JSLock after casting JSContextRef to ExecState* (which doesn't need + locking in any case), so that a decision whether to actually lock can be made. + (JSCheckScriptSyntax): Ditto. + (JSGarbageCollect): Only lock while collecting the shared heap, not the per-thread one. + + * API/JSObjectRef.cpp: + (JSClassCreate): Don't lock, as there is no reason to. + (JSClassRetain): Ditto. + (JSClassRelease): Ditto. + (JSPropertyNameArrayRetain): Ditto. + (JSPropertyNameArrayRelease): Only lock while deleting the array, as that may touch + identifier table. + (JSPropertyNameAccumulatorAddName): Adding a string also involves an identifier table + lookup, and possibly modification. + + * API/JSStringRef.cpp: + (JSStringCreateWithCharacters): + (JSStringCreateWithUTF8CString): + (JSStringRetain): + (JSStringRelease): + (JSStringGetUTF8CString): + (JSStringIsEqual): + * API/JSStringRefCF.cpp: + (JSStringCreateWithCFString): + JSStringRef operations other than releasing do not need locking. + + * VM/Machine.cpp: Don't include unused JSLock.h. + + * kjs/CollectorHeapIntrospector.cpp: (KJS::CollectorHeapIntrospector::statistics): + Don't take the lock for real, as heap introspection pauses the process anyway. It seems that + the existing code could cause deadlocks. + + * kjs/Shell.cpp: + (functionGC): + (main): + (jscmain): + The test tool uses a per-thread context, so no real locking is required. + + * kjs/collector.h: + (KJS::Heap::setGCProtectNeedsLocking): Optionally protect m_protectedValues access with a + per-heap mutex. This is only needed for WebCore Database code, which violates the "no data + migration between threads" by using ProtectedPtr on a background thread. + (KJS::Heap::isShared): Keep a shared flag here, as well. + + * kjs/protect.h: + (KJS::::ProtectedPtr): + (KJS::::~ProtectedPtr): + (KJS::::operator): + (KJS::operator==): + (KJS::operator!=): + ProtectedPtr is ony used from WebCore, so it doesn't need to take JSLock. An assertion in + Heap::protect/unprotect guards agains possible future unlocked uses of ProtectedPtr in JSC. + + * kjs/collector.cpp: + (KJS::Heap::Heap): Initialize m_isShared. + (KJS::Heap::~Heap): No need to lock for real during destruction, but must keep assertions + in sweep() working. + (KJS::destroyRegisteredThread): Registered thread list is only accessed for shared heap, + so locking is always needed here. + (KJS::Heap::registerThread): Ditto. + (KJS::Heap::markStackObjectsConservatively): Use m_isShared instead of comparing to a shared + instance for a small speedup. + (KJS::Heap::setGCProtectNeedsLocking): Create m_protectedValuesMutex. There is currently no + way to undo this - and ideally, Database code will be fixed to lo longer require this quirk. + (KJS::Heap::protect): Take m_protectedValuesMutex (if it exists) while accessing + m_protectedValues. + (KJS::Heap::unprotect): Ditto. + (KJS::Heap::markProtectedObjects): Ditto. + (KJS::Heap::protectedGlobalObjectCount): Ditto. + (KJS::Heap::protectedObjectCount): Ditto. + (KJS::Heap::protectedObjectTypeCounts): Ditto. + + * kjs/ustring.cpp: + * kjs/ustring.h: + Don't include JSLock.h, which is no longer used here. As a result, an explicit include had + to be added to many files in JavaScriptGlue, WebCore and WebKit. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::init): + * API/JSCallbackConstructor.cpp: + (KJS::constructJSCallback): + * API/JSCallbackFunction.cpp: + (KJS::JSCallbackFunction::call): + * API/JSCallbackObjectFunctions.h: + (KJS::::init): + (KJS::::getOwnPropertySlot): + (KJS::::put): + (KJS::::deleteProperty): + (KJS::::construct): + (KJS::::hasInstance): + (KJS::::call): + (KJS::::getPropertyNames): + (KJS::::toNumber): + (KJS::::toString): + (KJS::::staticValueGetter): + (KJS::::callbackGetter): + * API/JSContextRef.cpp: + (JSGlobalContextCreate): + (JSGlobalContextRetain): + (JSGlobalContextRelease): + * API/JSValueRef.cpp: + (JSValueIsEqual): + (JSValueIsStrictEqual): + (JSValueIsInstanceOfConstructor): + (JSValueMakeNumber): + (JSValueMakeString): + (JSValueToNumber): + (JSValueToStringCopy): + (JSValueToObject): + (JSValueProtect): + (JSValueUnprotect): + * JavaScriptCore.exp: + * kjs/PropertyNameArray.h: + (KJS::PropertyNameArray::globalData): + * kjs/interpreter.cpp: + (KJS::Interpreter::checkSyntax): + (KJS::Interpreter::evaluate): + Pass a parameter to JSLock/JSLock::DropAllLocks to decide whether the lock needs to be taken. + +2008-07-01 Alexey Proskuryakov + + Reviewed by Darin. + + https://bugs.webkit.org/show_bug.cgi?id=19834 + Failed assertion in JavaScriptCore/VM/SegmentedVector.h:82 + + Creating a global object with a custom prototype resets it twice (wasteful!). + So, addStaticGlobals() was called twice, but JSGlobalObject::reset() didn't reset + the register array. + + * kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::reset): Call setRegisterArray(0, 0). + + * kjs/JSVariableObject.h: Changed registerArray to OwnArrayPtr. Also, added private copy + constructor and operator= to ensure that no one attempts to copy this object (for whatever + reason, I couldn't make Noncopyable work). + + * kjs/JSGlobalObject.h: (KJS::JSGlobalObject::addStaticGlobals): Allocate registerArray + with new[]. + + * kjs/JSVariableObject.cpp: + (KJS::JSVariableObject::copyRegisterArray): Allocate registerArray with new[]. + (KJS::JSVariableObject::setRegisterArray): Avoid hitting an assertion in OwnArrayPtr when + "changing" the value from 0 to 0. + +2008-07-01 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Removed and/or reordered exception checks in array-style a[n] access. + + SunSpider says 1.4% faster. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): No need to check for exceptions before + calling toString, toNumber and/or get. If the call ends up being observable + through toString, valueOf, or a getter, we short-circuit it there, instead. + In the op_del_by_val case, I removed the incorrect comment without actually + removing the code, since I didn't want to tempt the GCC fates! + + * kjs/JSObject.cpp: + (KJS::callDefaultValueFunction): Added exception check to prevent + toString and valueOf functions from observing execution after an exception + has been thrown. This removes some of the burden of exception checking + from the machine. + + (KJS::JSObject::defaultValue): Removed redundant exception check here. + + * kjs/PropertySlot.cpp: + (KJS::PropertySlot::functionGetter): Added exception check to prevent + getter functions from observing execution after an exception has been + thrown. This removes some of the burden of exception checking from the + machine. + +2008-07-01 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Optimized a[n] get and put for cases where n is an immediate unsigned + value. + + SunSpider says 3.5% faster. + +2008-07-01 Cameron Zwarich + + Reviewed by Darin. + + Bug 19844: JavaScript Switch statement modifies "this" + + + Use a temporary when generating code for switch clauses to avoid + overwriting 'this' or a local variable. + + * kjs/nodes.cpp: + (KJS::CaseBlockNode::emitCodeForBlock): + +2008-07-01 Christian Dywan + + Gtk+ build fix. + + * kjs/list.cpp: Include "JSCell.h" + +2008-07-01 Kevin McCullough + + Build fix. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-07-01 Dan Bernstein + + Reviewed by Anders Carlsson. + + - Mac release build fix + + * JavaScriptCore.exp: + +2008-07-01 Sam Weinig + + Try and fix mac builds. + + * JavaScriptCore.exp: + +2008-07-01 Sam Weinig + + Fix non-AllInOne builds. + + * kjs/DateMath.cpp: + +2008-07-01 Sam Weinig + + Reviewed by Darin Adler. + + Split JSCell and JSNumberCell class declarations out of JSValue.h + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * VM/JSPropertyNameIterator.h: + * kjs/AllInOneFile.cpp: + * kjs/JSCell.cpp: Copied from JavaScriptCore/kjs/JSValue.cpp. + * kjs/JSCell.h: Copied from JavaScriptCore/kjs/JSValue.h. + (KJS::JSValue::getJSNumber): + * kjs/JSNumberCell.cpp: + * kjs/JSNumberCell.h: Copied from JavaScriptCore/kjs/JSValue.h. + * kjs/JSObject.h: + * kjs/JSString.cpp: + (KJS::jsString): + (KJS::jsOwnedString): + * kjs/JSString.h: + (KJS::JSValue::toThisJSString): + * kjs/JSValue.cpp: + * kjs/JSValue.h: + +2008-07-01 Anders Carlsson + + Build fixes. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::addStaticGlobals): + +2008-07-01 Simon Hausmann + + Build fix, include OwnPtr.h. + + * kjs/RegExpConstructor.h: + +2008-06-30 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed a global object leak caused by the switch to one register file. + + Don't unconditionally mark the register file, since that logically + makes all global variables GC roots, even when their global object is + no longer reachable. + + Instead, make the global object associated with the register file + responsible for marking the register file. + +2008-06-30 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Removed the "registerBase" abstraction. Since the register file never + reallocates, we can keep direct pointers into it, instead of + tuples. + + SunSpider says 0.8% faster. + +2008-06-30 Oliver Hunt + + Reviewed by NOBODY (build fix). + + Fix build by adding all (hopefully) the missing includes. + + * kjs/BooleanPrototype.cpp: + * kjs/DateConstructor.cpp: + * kjs/ErrorPrototype.cpp: + * kjs/FunctionPrototype.cpp: + * kjs/NativeErrorConstructor.cpp: + * kjs/NumberPrototype.cpp: + * kjs/ObjectPrototype.cpp: + * kjs/RegExpConstructor.cpp: + * kjs/StringConstructor.cpp: + * kjs/StringPrototype.cpp: + +2008-06-30 Cameron Zwarich + + Reviewed by Oliver. + + Bug 19830: REGRESSION (r34883): Google Reader doesn't show up feed list on sidebar + + + Ensure that we do not eliminate a write to a local register when doing + peephole optimizations. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitJumpIfTrue): + (KJS::CodeGenerator::emitJumpIfFalse): + +2008-06-30 Sam Weinig + + Rubber-stamped by Darin Alder. + + Split InternalFunction into its own header file. + + * API/JSCallbackFunction.h: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/ArrayConstructor.h: + * kjs/BooleanConstructor.h: + * kjs/DateConstructor.h: + * kjs/ErrorConstructor.h: + * kjs/FunctionConstructor.h: + * kjs/FunctionPrototype.h: + * kjs/InternalFunction.h: Copied from kjs/JSFunction.h. + * kjs/JSFunction.h: + * kjs/NativeErrorConstructor.h: + * kjs/NumberConstructor.h: + * kjs/ObjectConstructor.h: + * kjs/RegExpConstructor.h: + * kjs/StringConstructor.h: + * profiler/Profiler.cpp: + +2008-06-30 Sam Weinig + + Reviewed by Kevin McCullough. + + Remove empty files Instruction.cpp, LabelID.cpp, Register.cpp and RegisterID.cpp. + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * VM/Instruction.cpp: Removed. + * VM/LabelID.cpp: Removed. + * VM/Register.cpp: Removed. + * VM/RegisterID.cpp: Removed. + +2008-06-30 Sam Weinig + + Rubber-stamped (reluctantly) by Kevin McCullough. + + Rename date_object.h/cpp to DateInstance.h/cpp + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * kjs/AllInOneFile.cpp: + * kjs/DateConstructor.cpp: + * kjs/DateInstance.cpp: Copied from kjs/date_object.cpp. + * kjs/DateInstance.h: Copied from kjs/date_object.h. + * kjs/DatePrototype.cpp: + * kjs/DatePrototype.h: + * kjs/date_object.cpp: Removed. + * kjs/date_object.h: Removed. + +2008-06-30 Sam Weinig + + Rubber-stamped by Darin Adler. + + Remove internal.cpp and move its contents to there own .cpp files. + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * kjs/AllInOneFile.cpp: + * kjs/GetterSetter.cpp: Copied from kjs/internal.cpp. + * kjs/InternalFunction.cpp: Copied from kjs/internal.cpp. + * kjs/JSNumberCell.cpp: Copied from kjs/internal.cpp. + * kjs/JSString.cpp: Copied from kjs/internal.cpp. + * kjs/JSString.h: + * kjs/LabelStack.cpp: Copied from kjs/internal.cpp. + * kjs/NumberConstructor.cpp: + * kjs/NumberObject.cpp: + (KJS::constructNumber): + (KJS::constructNumberFromImmediateNumber): + * kjs/internal.cpp: Removed. + +2008-06-30 Adam Roben + + Fix Assertion failure due to HashTable's use of + operator& + + HashTable was passing &value to constructDeletedValue, which in + classes like WebCore::COMPtr would cause an assertion. We now pass + value by reference instead of by address so that the HashTraits + implementations have more flexibility in constructing the deleted + value. + + Reviewed by Ada Chan. + + * VM/CodeGenerator.h: Updated for changes to HashTraits. + * wtf/HashTable.h: + (WTF::::deleteBucket): Changed to pass bucket by reference instead of + by address. + (WTF::::checkKey): Ditto. + * wtf/HashTraits.h: + (WTF::): Updated HashTraits for HashTable change. + +2008-07-01 Alexey Proskuryakov + + Reviewed by Cameron Zwarich. + + Make RegisterFile really unmap memory on destruction. + + This fixes run-webkit-tests --threaded, which ran out of address space in a few seconds. + + * VM/RegisterFile.cpp: (KJS::RegisterFile::~RegisterFile): Unmap all the memory, not just + 1/4 of it. + + * kjs/JSGlobalObject.h: Don't include RegisterFile.h, so that changes to it don't make + half of WebCore rebuild. + + * VM/Machine.h: Don't forward declare RegisterFile, as RegisterFile.h is included already. + + * VM/RegisterFile.h: (KJS::RegisterFile::RegisterFile): Assert that the allocation succeeded. + +2008-06-30 Cameron Zwarich + + Rubber-stamped by Oliver. + + Correct the documentation for op_put_by_index. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-06-29 Cameron Zwarich + + Reviewed by Oliver. + + Bug 19821: Merge the instruction pair (less, jfalse) + + + This is a 2.4% win on SunSpider. I needed to add an ALWAYS_INLINE + intrinisc to CodeGenerator::rewindBinaryOp() to avoid a massive + regression in regexp-dna. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::rewindBinaryOp): + (KJS::CodeGenerator::emitJumpIfFalse): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.cpp: + (KJS::): + * VM/Opcode.h: + +2008-06-29 Sam Weinig + + Fix non-AllInOne builds. + + * kjs/JSObject.cpp: + * kjs/JSValue.cpp: + +2008-06-29 Sam Weinig + + Build fix for Qt. + + * kjs/DateMath.cpp: + * kjs/DatePrototype.cpp: + +2008-06-29 Sam Weinig + + Rubber-stamped by Cameron Zwarich. + + Splits ErrorConstructor, ErrorPrototype, NativeErrorConstructor and + NativeErrorPrototype out of error_object.h/cpp and renames it ErrorInstance. + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * kjs/AllInOneFile.cpp: + * kjs/ArrayConstructor.cpp: + * kjs/ArrayPrototype.cpp: + * kjs/BooleanPrototype.cpp: + * kjs/DatePrototype.cpp: + * kjs/ErrorConstructor.cpp: Copied from kjs/error_object.cpp. + * kjs/ErrorConstructor.h: Copied from kjs/error_object.h. + * kjs/ErrorInstance.cpp: Copied from kjs/error_object.cpp. + * kjs/ErrorInstance.h: Copied from kjs/error_object.h. + * kjs/ErrorPrototype.cpp: Copied from kjs/error_object.cpp. + * kjs/ErrorPrototype.h: Copied from kjs/error_object.h. + * kjs/JSGlobalObject.cpp: + * kjs/JSObject.cpp: + * kjs/JSValue.cpp: + * kjs/NativeErrorConstructor.cpp: Copied from kjs/error_object.cpp. + * kjs/NativeErrorConstructor.h: Copied from kjs/error_object.h. + * kjs/NativeErrorPrototype.cpp: Copied from kjs/error_object.cpp. + * kjs/NativeErrorPrototype.h: Copied from kjs/error_object.h. + * kjs/NumberPrototype.cpp: + * kjs/RegExpConstructor.cpp: + * kjs/RegExpObject.cpp: + * kjs/RegExpPrototype.cpp: + * kjs/StringPrototype.cpp: + * kjs/error_object.cpp: Removed. + * kjs/error_object.h: Removed. + * kjs/internal.cpp: + +2008-06-29 Sam Weinig + + Fix non-AllInOne build. + + * kjs/DateConstructor.cpp: + * kjs/DateMath.cpp: + * kjs/JSObject.cpp: + +2008-06-29 Sam Weinig + + Rubber-stamped by Oliver Hunt. + + Splits DateConstructor and DatePrototype out of date_object.h/cpp + Moves shared Date code into DateMath. + + * DerivedSources.make: + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * kjs/AllInOneFile.cpp: + * kjs/DateConstructor.cpp: Copied from kjs/date_object.cpp. + * kjs/DateConstructor.h: Copied from kjs/date_object.h. + * kjs/DateMath.cpp: + (KJS::ymdhmsToSeconds): + (KJS::): + (KJS::skipSpacesAndComments): + (KJS::findMonth): + (KJS::parseDate): + (KJS::timeClip): + (KJS::formatDate): + (KJS::formatDateUTCVariant): + (KJS::formatTime): + * kjs/DateMath.h: + (KJS::gmtoffset): + * kjs/DatePrototype.cpp: Copied from kjs/date_object.cpp. + * kjs/DatePrototype.h: Copied from kjs/date_object.h. + * kjs/JSGlobalObject.cpp: + * kjs/JSObject.cpp: + * kjs/date_object.cpp: + * kjs/date_object.h: + * kjs/internal.cpp: + +2008-06-29 Jan Michael Alonzo + + Rubber-stamped by Cameron Zwarich + + Fix Gtk non-AllInOne build + + * GNUmakefile.am: include JSVariableObject.cpp + * kjs/RegExpConstructor.cpp: include RegExpObject.h + * kjs/RegExpObject.h: forward declare RegExpPrototype + +2008-06-28 Darin Adler + + Reviewed by Sam and Cameron. + + - fix https://bugs.webkit.org/show_bug.cgi?id=19805 + Array.concat turns missing array elements into "undefined" + + Test: fast/js/array-holes.html + + * JavaScriptCore.exp: No longer export JSArray::getItem. + + * kjs/ArrayPrototype.cpp: + (KJS::arrayProtoFuncConcat): Changed to use getProperty instead of + JSArray::getItem -- need to handle properties from the prototype chain + instead of ignoring them. + + * kjs/JSArray.cpp: Removed getItem. + * kjs/JSArray.h: Ditto. + +2008-06-28 Darin Adler + + Reviewed by Cameron. + + - https://bugs.webkit.org/show_bug.cgi?id=19804 + optimize access to arrays without "holes" + + SunSpider says 1.8% faster. + + * kjs/JSArray.cpp: + (KJS::JSArray::JSArray): Initialize m_fastAccessCutoff when creating + arrays. Also updated for new location of m_vectorLength. + (KJS::JSArray::getItem): Updated for new location of m_vectorLength. + (KJS::JSArray::getSlowCase): Added. Broke out the non-hot parts of + getOwnPropertySlot to make the hot part faster. + (KJS::JSArray::getOwnPropertySlot): Added a new faster case for + indices lower than m_fastAccessCutoff. We can do theese with no + additional checks or branches. + (KJS::JSArray::put): Added a new faster case for indices lower than + m_fastAccessCutoff. We can do theese with no additional checks or + branches. Moved the maxArrayIndex handling out of this function. + Added code to set m_fastAccessCutoff when the very last hole in + an array is filled; this is how the cutoff gets set for most arrays. + (KJS::JSArray::putSlowCase): Moved the rest of the put function logic + in here, to make the hot part of the put function faster. + (KJS::JSArray::deleteProperty): Added code to lower m_fastAccessCutoff + when a delete makes a new hole in the array. + (KJS::JSArray::getPropertyNames): Updated for new location of + m_vectorLength. + (KJS::JSArray::increaseVectorLength): Ditto. + (KJS::JSArray::setLength): Added code to lower m_fastAccessCutoff + when setLength makes the array smaller. + (KJS::JSArray::mark): Updated for new location of m_vectorLength. + (KJS::JSArray::sort): Ditto. Set m_fastAccessCutoff after moving + all the holes to the end of the array. + (KJS::JSArray::compactForSorting): Ditto. + (KJS::JSArray::checkConsistency): Added consistency checks fro + m_fastAccessCutoff and updated for the new location of m_vectorLength. + + * kjs/JSArray.h: Added declarations for slow case functions. + Replaced m_vectorLength with m_fastAccessCutoff. + +2008-06-28 Cameron Zwarich + + Reviewed by Sam. + + When executing a native call, check for an exception before writing the + return value. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-06-28 Mark Rowe + + Build fix. Flag headers as private or public as is appropriate. + These settings were accidentally removed during some project file cleanup. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-06-28 Sam Weinig + + Rubber-stamped by Darin Adler. + + Splits RegExpConstructor and RegExpPrototype out of RegExpObject.h/cpp + + * DerivedSources.make: + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * VM/Machine.cpp: + * kjs/AllInOneFile.cpp: + * kjs/JSGlobalObject.cpp: + * kjs/RegExpConstructor.cpp: Copied from kjs/RegExpObject.cpp. + * kjs/RegExpConstructor.h: Copied from kjs/RegExpObject.h. + * kjs/RegExpObject.cpp: + * kjs/RegExpObject.h: + * kjs/RegExpPrototype.cpp: Copied from kjs/RegExpObject.cpp. + * kjs/RegExpPrototype.h: Copied from kjs/RegExpObject.h. + * kjs/StringPrototype.cpp: + * kjs/internal.cpp: + +2008-06-28 Sam Weinig + + Fix non-AllInOne builds. + + * kjs/StringConstructor.cpp: + +2008-06-28 Sam Weinig + + Rubber-stamped by Darin Adler. + + Rename string_object.h/cpp to StringObject.h/cpp and split out StringObjectThatMasqueradesAsUndefined, + StringConstructor and StringPrototype. + + * DerivedSources.make: + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * kjs/AllInOneFile.cpp: + * kjs/JSGlobalObject.cpp: + * kjs/StringConstructor.cpp: Copied from JavaScriptCore/kjs/string_object.cpp. + * kjs/StringConstructor.h: Copied from JavaScriptCore/kjs/string_object.h. + * kjs/StringObject.cpp: Copied from JavaScriptCore/kjs/string_object.cpp. + * kjs/StringObject.h: Copied from JavaScriptCore/kjs/string_object.h. + * kjs/StringObjectThatMasqueradesAsUndefined.h: Copied from JavaScriptCore/kjs/string_object.h. + * kjs/StringPrototype.cpp: Copied from JavaScriptCore/kjs/string_object.cpp. + * kjs/StringPrototype.h: Copied from JavaScriptCore/kjs/string_object.h. + * kjs/internal.cpp: + * kjs/string_object.cpp: Removed. + * kjs/string_object.h: Removed. + +2008-06-28 Jan Michael Alonzo + + Gtk build fix: JSVariableObject is now part of AllInOne + + * GNUmakefile.am: + +2008-06-28 Darin Adler + + Reviewed by Oliver. + + - https://bugs.webkit.org/show_bug.cgi?id=19801 + add a feature so we can tell what regular expressions are taking time + + * pcre/pcre_compile.cpp: + (jsRegExpCompile): Compile in the string if REGEXP_HISTOGRAM is on. + + * pcre/pcre_exec.cpp: + (jsRegExpExecute): Add hook to time execution. + (Histogram::~Histogram): Print a sorted list of what took time. + (Histogram::add): Accumulate records of what took time. + (HistogramTimeLogger::~HistogramTimeLogger): Hook that calls + Histogram::add at the right moment and creates the global histogram + object. + + * pcre/pcre_internal.h: Define REGEXP_HISTOGRAM. + + * pcre/pcre_tables.cpp: Added missing include of "config.h". Not needed + any more, but an omissions an earlier version of this patch detected. + * pcre/pcre_ucp_searchfuncs.cpp: Ditto. + * pcre/pcre_xclass.cpp: Ditto. + +2008-06-28 Sam Weinig + + Try and fix the Windows build again. + + * kjs/RegExpObject.cpp: + * kjs/date_object.cpp: + * kjs/error_object.cpp: + +2008-06-28 Sam Weinig + + Rubber-stamped by Darin Adler. + + Remove unused StringConstructorFunction class. + + * kjs/string_object.h: + +2008-06-28 Sam Weinig + + Fix windows build. + + * kjs/ArrayPrototype.cpp: + * kjs/BooleanPrototype.cpp: + * kjs/BooleanPrototype.h: + * kjs/FunctionPrototype.cpp: + * kjs/JSImmediate.cpp: + * kjs/JSObject.cpp: + * kjs/MathObject.cpp: + * kjs/NumberPrototype.cpp: + * kjs/NumberPrototype.h: + * kjs/ObjectConstructor.cpp: + * kjs/RegExpObject.h: + * kjs/error_object.h: + * kjs/string_object.cpp: + +2008-06-28 Sam Weinig + + Rubber-stamped by Oliver Hunt. + + Splits FunctionConstructor out of FunctionPrototype.h/cpp + Splits NumberConstructor and NumberPrototype out of NumberObject.h/cpp + Rename object_object.h/cpp to ObjectPrototype.h/cpp and split out ObjectConstructor. + + * API/JSCallbackConstructor.cpp: + * API/JSClassRef.cpp: + * API/JSObjectRef.cpp: + * DerivedSources.make: + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * VM/Machine.cpp: + * kjs/AllInOneFile.cpp: + * kjs/ArrayConstructor.cpp: + * kjs/ArrayConstructor.h: + * kjs/FunctionConstructor.cpp: Copied from JavaScriptCore/kjs/FunctionPrototype.cpp. + * kjs/FunctionConstructor.h: Copied from JavaScriptCore/kjs/FunctionPrototype.h. + * kjs/FunctionPrototype.cpp: + * kjs/FunctionPrototype.h: + * kjs/JSFunction.cpp: + * kjs/JSGlobalObject.cpp: + * kjs/JSImmediate.cpp: + * kjs/MathObject.h: + * kjs/NumberConstructor.cpp: Copied from JavaScriptCore/kjs/NumberObject.cpp. + * kjs/NumberConstructor.h: Copied from JavaScriptCore/kjs/NumberObject.h. + * kjs/NumberObject.cpp: + * kjs/NumberObject.h: + * kjs/NumberPrototype.cpp: Copied from JavaScriptCore/kjs/NumberObject.cpp. + * kjs/NumberPrototype.h: Copied from JavaScriptCore/kjs/NumberObject.h. + * kjs/ObjectConstructor.cpp: Copied from JavaScriptCore/kjs/object_object.cpp. + * kjs/ObjectConstructor.h: Copied from JavaScriptCore/kjs/object_object.h. + * kjs/ObjectPrototype.cpp: Copied from JavaScriptCore/kjs/object_object.cpp. + * kjs/ObjectPrototype.h: Copied from JavaScriptCore/kjs/object_object.h. + * kjs/RegExpObject.h: + * kjs/Shell.cpp: + * kjs/error_object.h: + * kjs/internal.cpp: + * kjs/nodes.cpp: + * kjs/object_object.cpp: Removed. + * kjs/object_object.h: Removed. + * kjs/string_object.h: + +2008-06-28 Darin Adler + + Reviewed by Oliver. + + - fix https://bugs.webkit.org/show_bug.cgi?id=19796 + optimize expressions with ignored results (especially post-increment) + + SunSpider says 0.9% faster. + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::tempDestination): Create a new temporary for + ignoredResult() too, just as we would for 0. + (KJS::CodeGenerator::finalDestination): Use the temporary if the + register passed in is ignoredResult() too, just as we would for 0. + (KJS::CodeGenerator::destinationForAssignResult): Return 0 if the + passed in register is ignoredResult(), just as we would for 0. + (KJS::CodeGenerator::moveToDestinationIfNeeded): Return 0 if the + register passed in is ignoredResult(). What matters is that we + don't want to emit a move. The return value won't be looked at. + (KJS::CodeGenerator::emitNode): Allow ignoredResult() and pass it + through to the node's emitCode function. + + * VM/RegisterID.h: + (KJS::ignoredResult): Added. Special value to indicate the result of + a node will be ignored and need not be put in any register. + + * kjs/nodes.cpp: + (KJS::NullNode::emitCode): Do nothing if dst == ignoredResult(). + (KJS::BooleanNode::emitCode): Ditto. + (KJS::NumberNode::emitCode): Ditto. + (KJS::StringNode::emitCode): Ditto. + (KJS::RegExpNode::emitCode): Ditto. + (KJS::ThisNode::emitCode): Ditto. + (KJS::ResolveNode::emitCode): Do nothing if dst == ignoredResult() and + the identifier resolves to a local variable. + (KJS::ObjectLiteralNode::emitCode): Do nothing if dst == ignoredResult() + and the object is empty. + (KJS::PostIncResolveNode::emitCode): If dst == ignoredResult(), then do + nothing for the local constant case, and do a pre-increment in all the + other cases. + (KJS::PostDecResolveNode::emitCode): Ditto. + (KJS::PostIncBracketNode::emitCode): Ditto. + (KJS::PostDecBracketNode::emitCode): Ditto. + (KJS::PostIncDotNode::emitCode): Ditto. + (KJS::PostDecDotNode::emitCode): Ditto. + (KJS::DeleteValueNode::emitCode): Pass ignoredResult() when evaluating + the expression. + (KJS::VoidNode::emitCode): Ditto. + (KJS::TypeOfResolveNode::emitCode): If dst == ignoredResult(), do nothing + if the identifier resolves to a local variable, and don't bother generating + a typeof opcode in the other case. + (KJS::TypeOfValueNode::emitCode): Ditto. + (KJS::PreIncResolveNode::emitCode): Do nothing if dst == ignoredResult() and + the identifier resolves to a local constant. + (KJS::PreDecResolveNode::emitCode): Ditto. + (KJS::AssignResolveNode::emitCode): Turn ignoredResult() into 0 in a couple + places, because we need to put the result into a register so we can assign + it. At other sites this is taken care of by functions like finalDestination. + (KJS::CommaNode::emitCode): Pass ignoredResult() when evaluating the first + expression. + (KJS::ForNode::emitCode): Pass ignoredResult() when evaluating the first and + third expressions. + (KJS::ForInNode::emitCode): Pass ignoredResult() when evaluating the first + expression. + +2008-06-28 Darin Adler + + Reviewed by Oliver. + + - https://bugs.webkit.org/show_bug.cgi?id=19787 + create most arrays from values in registers rather than with multiple put operations + + SunSpider says 0.8% faster. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): Added argv and argc parameters to new_array. + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Ditto. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitNewArray): Added. + * VM/CodeGenerator.h: Added ElementNode* argument to emitNewArray. + + * kjs/nodes.cpp: + (KJS::ArrayNode::emitCode): Pass the ElementNode to emitNewArray so it can be + initialized with as many elements as possible. If the array doesn't have any + holes in it, that's all that's needed. If there are holes, then emit some separate + put operations for the other values in the array and for the length as needed. + + * kjs/nodes.h: Added some accessors to ElementNode so the code generator can + iterate through elements and generate code to evaluate them. Now ArrayNode does + not need to be a friend. Also took out some unused PlacementNewAdoptType + constructors. + +2008-06-28 Darin Adler + + Reviewed by Oliver. + + * kjs/nodes.h: Remove obsolete PlacementNewAdopt constructors. + We no longer mutate the AST in place. + +2008-06-28 Jan Michael Alonzo + + Reviewed by Oliver Hunt. + + Build fix + + * VM/Machine.cpp: include stdio.h for printf + +2008-06-27 Sam Weinig + + Reviewed by Oliver Hunt. + + Fix platforms that don't use AllInOne.cpp + + * kjs/BooleanConstructor.h: + * kjs/BooleanPrototype.h: + * kjs/FunctionPrototype.cpp: + +2008-06-27 Sam Weinig + + Rubber-stamped by Oliver Hunt. + + Splits ArrayConstructor out of ArrayPrototype.h/cpp + Splits BooleanConstructor and BooleanPrototype out of BooleanObject.h/cpp + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * VM/Machine.cpp: + * kjs/AllInOneFile.cpp: + * kjs/ArrayConstructor.cpp: Copied from kjs/ArrayPrototype.cpp. + * kjs/ArrayConstructor.h: Copied from kjs/ArrayPrototype.h. + * kjs/ArrayPrototype.cpp: + * kjs/ArrayPrototype.h: + * kjs/BooleanConstructor.cpp: Copied from kjs/BooleanObject.cpp. + * kjs/BooleanConstructor.h: Copied from kjs/BooleanObject.h. + * kjs/BooleanObject.cpp: + * kjs/BooleanObject.h: + * kjs/BooleanPrototype.cpp: Copied from kjs/BooleanObject.cpp. + * kjs/BooleanPrototype.h: Copied from kjs/BooleanObject.h. + * kjs/CommonIdentifiers.h: + * kjs/FunctionPrototype.cpp: + * kjs/JSArray.cpp: + * kjs/JSGlobalObject.cpp: + * kjs/JSImmediate.cpp: + * kjs/Shell.cpp: + * kjs/internal.cpp: + * kjs/nodes.cpp: + * kjs/string_object.cpp: + +2008-06-27 Oliver Hunt + + Reviewed by Sam. + + Bug 18626: SQUIRRELFISH: support the "slow script" dialog + Slow script dialog needs to be reimplemented for squirrelfish + + Adds support for the slow script dialog in squirrelfish. This requires the addition + of three new op codes, op_loop, op_loop_if_true, and op_loop_if_less which have the + same behaviour as their simple jump equivalents but have an additional time out check. + + Additional assertions were added to other jump instructions to prevent accidentally + creating loops with jump types that do not support time out checks. + + Sunspider does not report a regression, however this appears very sensitive to code + layout and hardware, so i would expect up to a 1% regression on other systems. + + Part of this required moving the old timeout logic from JSGlobalObject and into Machine + which is the cause of a number of the larger diff blocks. + + * JavaScriptCore.exp: + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitJumpIfTrue): + (KJS::CodeGenerator::emitJumpScopes): + * VM/ExceptionHelpers.cpp: + (KJS::InterruptedExecutionError::isWatchdogException): + (KJS::createInterruptedExecutionException): + * VM/ExceptionHelpers.h: + * VM/LabelID.h: + * VM/Machine.cpp: + (KJS::Machine::Machine): + (KJS::Machine::throwException): + (KJS::Machine::resetTimeoutCheck): + (KJS::getCurrentTime): + (KJS::Machine::checkTimeout): + (KJS::Machine::privateExecute): + * VM/Machine.h: + (KJS::Machine::setTimeoutTime): + (KJS::Machine::startTimeoutCheck): + (KJS::Machine::stopTimeoutCheck): + (KJS::Machine::initTimeout): + * VM/Opcode.cpp: + (KJS::): + * VM/Opcode.h: + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::init): + (KJS::JSGlobalObject::setTimeoutTime): + (KJS::JSGlobalObject::startTimeoutCheck): + * kjs/JSGlobalObject.h: + * kjs/JSObject.h: + * kjs/interpreter.cpp: + (KJS::Interpreter::evaluate): + +2008-06-27 Jan Michael Alonzo + + Gtk and Qt build fix: Remove RegisterFileStack from the build + scripts. + + * GNUmakefile.am: + * JavaScriptCore.pri: + +2008-06-27 Adele Peterson + + Reviewed by Geoff. + + Build fixes. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * VM/RegisterFile.h: + (KJS::RegisterFile::RegisterFile): + * kjs/JSGlobalObject.cpp: + * kjs/collector.cpp: + +2008-06-27 Geoffrey Garen + + Reviewed by Oliver Hunt. + + One RegisterFile to rule them all! + + SunSpider reports a 0.2% speedup. + + This patch removes the RegisterFileStack abstraction and replaces it with + a single register file that + + (a) allocates a fixed storage area, including a fixed area for global + vars, so that no operation may cause the register file to reallocate + + and + + (b) swaps between global storage areas when executing code in different + global objects. + + This patch also changes the layout of the register file so that all call + frames, including call frames for global code, get a header. This is + required to support re-entrant global code. It also just makes things simpler. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addGlobalVar): New function. Differs from addVar in + that + + (a) global vars don't contribute to a CodeBlock's numLocals count, since + global storage is fixed and allocated at startup + + and + + (b) references to global vars get shifted to elide intermediate stack + between "r" and the global storage area. + + * VM/Machine.cpp: + (KJS::Machine::dumpRegisters): Updated this function to match the new + register file layout, and added the ability to dump exact identifiers + for the different parts of a call frame. + + (KJS::Machine::unwindCallFrame): Updated this function to match the new + register file layout. + + (KJS::Machine::execute): Updated this function to initialize a call frame + header for global code, and to swap global storage areas when switching + to execution in a new global object. + + (KJS::Machine::privateExecute): Got rid of "safeForReentry" and re-reading + of registerBase because the register file is always safe for reentry now, + and registerBase never changes. + + * VM/Machine.h: Moved the call frame header enum from Machine to RegisterFile, + to resolve a header dependency problem (a good sign that the enum belonged + in RegisterFile all along!) + + * VM/RegisterFile.cpp: + * VM/RegisterFile.h: Changed RegisterFile to mmap a fixed size register + area. This allows us to avoid re-allocting the register file later on. + Instead, we rely on the OS to allocate physical pages to the register + file as necessary. + + * VM/RegisterFileStack.cpp: Removed. Tada! + * VM/RegisterFileStack.h: Removed. Tada! + + * kjs/DebuggerCallFrame.cpp: Updated this class to match the new + register file layout, greatly simplifying it in the process. + + * kjs/JSActivation.h: + * kjs/JSActivation.cpp: Moved some of this logic up to JSVariableObject, + since the global object now needs to be able to tear off its registers + just like the activation object. + + * kjs/JSFunction.cpp: No need to fiddle with the register file anymore. + + * kjs/JSGlobalObject.h: + * kjs/JSGlobalObject.cpp: Updated JSGlobalObject to support moving its + global storage area into and out of the register file. + + * kjs/PropertySlot.cpp: No need to fiddle with the register file anymore. + + * kjs/collector.cpp: Renamed markStackObjectConservatively to + markConservatively, since we don't just mark stack objects this way. + + Also, added code to mark the machine's register file. + + * kjs/config.h: Moved some platforms #defines from here... + * wtf/Platform.h: ...to here, to support mmap/VirtualAlloc detection + in RegisterFile.h. + +2008-06-26 Mark Rowe + + Speculative fix for the Windows build. + + * kjs/JSImmediate.cpp: + +2008-06-26 Mark Rowe + + Reviewed by Darin Adler and Geoff Garen. + + Fix the malloc zone introspection functions so that malloc_zone_statistics does not give + bogus output in an application that uses JavaScriptCore. + + * kjs/CollectorHeapIntrospector.cpp: + (KJS::CollectorHeapIntrospector::statistics): Return statistics about memory allocated by the collector. + * kjs/CollectorHeapIntrospector.h: + * wtf/FastMalloc.cpp: Zero out the statistics. FastMalloc doesn't track this information at present. + Returning zero for all values is preferable to returning bogus data. + +2008-06-26 Darin Adler + + Reviewed by Geoff. + + - https://bugs.webkit.org/show_bug.cgi?id=19721 + speed up JavaScriptCore by not wrapping strings in objects just + to call functions on them + + - optimize UString append and the replace function a bit + + SunSpider says 1.8% faster. + + * JavaScriptCore.exp: Updated. + + * VM/JSPropertyNameIterator.cpp: Added include of JSString.h, now needed + because jsString returns a JSString*. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Removed the toObject call from native + function calls. Also removed code to put the this value into a register. + + * kjs/BooleanObject.cpp: + (KJS::booleanProtoFuncToString): Rewrite to handle false and true + separately. + + * kjs/FunctionPrototype.cpp: + (KJS::constructFunction): Use single-character append rather than building + a string for each character. + * kjs/JSFunction.cpp: + (KJS::globalFuncUnescape): Ditto. + + * kjs/JSImmediate.cpp: + (KJS::JSImmediate::prototype): Added. Gets the appropriate prototype for + use with an immediate value. To be used instead of toObject when doing a + get on an immediate value. + * kjs/JSImmediate.h: Added prototype. + + * kjs/JSObject.cpp: + (KJS::JSObject::toString): Tweaked formatting. + + * kjs/JSObject.h: + (KJS::JSValue::get): Use prototype instead of toObject to avoid creating + an object wrapper just to search for properties. This also saves an + unnecessary hash table lookup since the object wrappers themselves don't + have any properties. + + * kjs/JSString.h: Added toThisString and toThisJSString. + + * kjs/JSValue.cpp: + (KJS::JSCell::toThisString): Added. + (KJS::JSCell::toThisJSString): Added. + (KJS::JSCell::getJSNumber): Added. + (KJS::jsString): Changed return type to JSString*. + (KJS::jsOwnedString): Ditto. + + * kjs/JSValue.h: + (KJS::JSValue::toThisString): Added. + (KJS::JSValue::toThisJSString): Added. + (KJS::JSValue::getJSNumber): Added. + + * kjs/NumberObject.cpp: + (KJS::NumberObject::getJSNumber): Added. + (KJS::integer_part_noexp): Append C string directly rather than first + turning it into a UString. + (KJS::numberProtoFuncToString): Use getJSNumber to check if the value + is a number rather than isObject(&NumberObject::info). This works for + immediate numbers, number cells, and NumberObject instances. + (KJS::numberProtoFuncToLocaleString): Ditto. + (KJS::numberProtoFuncValueOf): Ditto. + (KJS::numberProtoFuncToFixed): Ditto. + (KJS::numberProtoFuncToExponential): Ditto. + (KJS::numberProtoFuncToPrecision): Ditto. + * kjs/NumberObject.h: Added getJSNumber. + + * kjs/PropertySlot.cpp: Tweaked comment. + + * kjs/internal.cpp: + (KJS::JSString::toThisString): Added. + (KJS::JSString::toThisJSString): Added. + (KJS::JSString::getOwnPropertySlot): Changed code that searches the + prototype chain to start with the string prototype and not create a + string object. + (KJS::JSNumberCell::toThisString): Added. + (KJS::JSNumberCell::getJSNumber): Added. + + * kjs/lookup.cpp: + (KJS::staticFunctionGetter): Moved here, because there's no point in + having a function that's only used for a function pointer be inline. + (KJS::setUpStaticFunctionSlot): New function for getStaticFunctionSlot. + + * kjs/lookup.h: + (KJS::staticValueGetter): Don't mark this inline. It doesn't make sense + to have a function that's only used for a function pointer be inline. + (KJS::getStaticFunctionSlot): Changed to get properties from the parent + first before doing any handling of functions. This is the fastest way + to return the function once the initial setup is done. + + * kjs/string_object.cpp: + (KJS::StringObject::getPropertyNames): Call value() instead of getString(), + avoiding an unnecessary virtual function call (the call to the type() + function in the implementation of the isString() function). + (KJS::StringObject::toString): Added. + (KJS::StringObject::toThisString): Added. + (KJS::StringObject::toThisJSString): Added. + (KJS::substituteBackreferences): Rewrote to use a appending algorithm + instead of a the old one that tried to replace in place. + (KJS::stringProtoFuncReplace): Merged this function and the replace function. + Replaced the hand-rolled dynamic arrays for source ranges and replacements + with Vector. + (KJS::stringProtoFuncToString): Handle JSString as well as StringObject. + Removed the separate valueOf implementation, since it can just share this. + (KJS::stringProtoFuncCharAt): Use toThisString, which handles JSString as + well as StringObject, and is slightly more efficient than the old code too. + (KJS::stringProtoFuncCharCodeAt): Ditto. + (KJS::stringProtoFuncConcat): Ditto. + (KJS::stringProtoFuncIndexOf): Ditto. + (KJS::stringProtoFuncLastIndexOf): Ditto. + (KJS::stringProtoFuncMatch): Ditto. + (KJS::stringProtoFuncSearch): Ditto. + (KJS::stringProtoFuncSlice): Ditto. + (KJS::stringProtoFuncSplit): Ditto. + (KJS::stringProtoFuncSubstr): Ditto. + (KJS::stringProtoFuncSubstring): Ditto. + (KJS::stringProtoFuncToLowerCase): Use toThisJSString. + (KJS::stringProtoFuncToUpperCase): Ditto. + (KJS::stringProtoFuncToLocaleLowerCase): Ditto. + (KJS::stringProtoFuncToLocaleUpperCase): Ditto. + (KJS::stringProtoFuncLocaleCompare): Ditto. + (KJS::stringProtoFuncBig): Use toThisString. + (KJS::stringProtoFuncSmall): Ditto. + (KJS::stringProtoFuncBlink): Ditto. + (KJS::stringProtoFuncBold): Ditto. + (KJS::stringProtoFuncFixed): Ditto. + (KJS::stringProtoFuncItalics): Ditto. + (KJS::stringProtoFuncStrike): Ditto. + (KJS::stringProtoFuncSub): Ditto. + (KJS::stringProtoFuncSup): Ditto. + (KJS::stringProtoFuncFontcolor): Ditto. + (KJS::stringProtoFuncFontsize): Ditto. + (KJS::stringProtoFuncAnchor): Ditto. + (KJS::stringProtoFuncLink): Ditto. + + * kjs/string_object.h: Added toString, toThisString, and toThisJSString. + + * kjs/ustring.cpp: + (KJS::UString::append): Added a version that takes a character pointer and + size, so we don't have to create a UString just to append to another UString. + * kjs/ustring.h: + +2008-06-26 Alexey Proskuryakov + + Reviewed by Maciej. + + Make JSGlobalData per-thread. + + No change on SunSpider total. + + * wtf/ThreadSpecific.h: Re-enabled the actual implementation. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::~JSGlobalObject): Re-added a JSLock-related assertion. We'll probably + want to preserve these somehow to keep legacy behavior in working condition. + (KJS::JSGlobalObject::init): Initialize globalData pointer earlier, so that it is ready + when updating JSGlobalObject linked list. + + * kjs/JSGlobalObject.h: (KJS::JSGlobalObject::head): Changed head() to be non-static, and + to use JSGlobalData associated with the current object. + + * kjs/InitializeThreading.cpp: (KJS::initializeThreadingOnce): Removed a no longer needed + Heap::registerAsMainThread() call. + + * kjs/JSGlobalData.h: Removed a lying lie comment - parserObjectExtraRefCounts is not + transient, and while newParserObjects may conceptually be such, there is still some node + manipulation going on outside Parser::parse which touches it. + + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::~JSGlobalData): Delete recently added members. + (KJS::JSGlobalData::sharedInstance): Actually use a separate instance. + + * kjs/collector.cpp: + (KJS::Heap::Heap): + (KJS::Heap::~Heap): Added a destructor, which unconditionally deletes everything. + (KJS::Heap::sweep): Removed code related to "collect on main thread only" logic. + (KJS::Heap::collect): Ditto. + (KJS::Heap::globalObjectCount): Explicitly use per-thread instance of JSGlobalObject linked + list now that JSGlobalObject::head() is not static. Curently, WebCoreStatistics methods only + work with the main thread currently anyway. + (KJS::Heap::protectedGlobalObjectCount): Ditto. + + * kjs/collector.h: Removed code related to "collect on main thread only" logic. + + * JavaScriptCore.exp: Removed Heap::collectOnMainThreadOnly. + +2008-06-26 Alexey Proskuryakov + + Reviewed by Darin. + + https://bugs.webkit.org/show_bug.cgi?id=19767 + REGRESSION: Crash in sort() when visiting http://www.onnyturf.com/subway/ + + * kjs/JSArray.cpp: (KJS::AVLTreeAbstractorForArrayCompare::set_balance_factor): + Made changing balance factor from -1 to +1 work correctly. + + * wtf/AVLTree.h: (KJS::AVLTreeDefaultBSet::operator[]): Added an assertion that catches + this slightly earlier. + +2008-06-25 Timothy Hatcher + + Fixes an ASSERT in the profiler when starting multiple profiles + with the same name inside the same function/program. + + Reviewed by Kevin McCullough. + + * profiler/Profile.cpp: + (KJS::Profile::Profile): Initialize m_stoppedCallDepth to zero. + (KJS::Profile::stopProfiling): Set the current node to the parent, + because we are in a call that will not get a didExecute call. + (KJS::Profile::removeProfile): Increment m_stoppedCallDepth to + account for didExecute not being called for profile. + (KJS::Profile::willExecute): Increment m_stoppedCallDepth if stopped. + (KJS::Profile::didExecute): Decrement m_stoppedCallDepth if stopped and + greater than zero, and return early. + * profiler/Profile.h: Added stoppedProfiling(). + * profiler/Profiler.cpp: + (KJS::Profiler::findProfile): Removed. + (KJS::Profiler::startProfiling): Don't return early for stopped profiles. + (KJS::Profiler::stopProfiling): Skipp stopped profiles. + (KJS::Profiler::didFinishAllExecution): Code clean-up. + * profiler/Profiler.h: Removed findProfile. + +2008-06-25 Cameron Zwarich + + Reviewed by Alexey Proskuryakov. + + Attempt to fix Windows debug build. The compiler gives a warning when + Structured Exception Handling and destructors are used in the same + function. Using manual locking and unlocking instead of constructors + and destructors should fix the warning. + + * kjs/Shell.cpp: + (main): + +2008-06-25 Alexey Proskuryakov + + Forgot to address a review comment about better names for tracked objects, doing it now. + + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): + * kjs/JSGlobalData.h: + * kjs/nodes.cpp: + (KJS::ParserRefCounted::ParserRefCounted): + (KJS::ParserRefCounted::ref): + (KJS::ParserRefCounted::deref): + (KJS::ParserRefCounted::hasOneRef): + (KJS::ParserRefCounted::deleteNewObjects): + +2008-06-25 Alexey Proskuryakov + + Reviewed by Geoff. + + Remove more threadInstance() calls. + + * kjs/JSFunction.cpp: + (KJS::JSFunction::getParameterName): + (KJS::IndexToNameMap::unMap): + (KJS::Arguments::deleteProperty): + * kjs/JSFunction.h: + Access nullIdentifier without going to thread specific storage. + + * JavaScriptCore.exp: + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): + * kjs/JSGlobalData.h: + * kjs/Parser.cpp: + (KJS::Parser::parse): + * kjs/Parser.h: + (KJS::ParserRefCountedData::ParserRefCountedData): + (KJS::Parser::parse): + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::ParserRefCounted::ParserRefCounted): + (KJS::ParserRefCounted::ref): + (KJS::ParserRefCounted::deref): + (KJS::ParserRefCounted::hasOneRef): + (KJS::ParserRefCounted::deleteNewObjects): + (KJS::Node::Node): + (KJS::StatementNode::StatementNode): + (KJS::BreakpointCheckStatement::BreakpointCheckStatement): + (KJS::ConstDeclNode::ConstDeclNode): + (KJS::BlockNode::BlockNode): + (KJS::ForInNode::ForInNode): + (KJS::ScopeNode::ScopeNode): + (KJS::ProgramNode::ProgramNode): + (KJS::ProgramNode::create): + (KJS::EvalNode::EvalNode): + (KJS::EvalNode::create): + (KJS::FunctionBodyNode::FunctionBodyNode): + (KJS::FunctionBodyNode::create): + * kjs/nodes.h: + (KJS::ExpressionNode::): + (KJS::NullNode::): + (KJS::BooleanNode::): + (KJS::NumberNode::): + (KJS::ImmediateNumberNode::): + (KJS::StringNode::): + (KJS::RegExpNode::): + (KJS::ThisNode::): + (KJS::ResolveNode::): + (KJS::ElementNode::): + (KJS::ArrayNode::): + (KJS::PropertyNode::): + (KJS::PropertyListNode::): + (KJS::ObjectLiteralNode::): + (KJS::BracketAccessorNode::): + (KJS::DotAccessorNode::): + (KJS::ArgumentListNode::): + (KJS::ArgumentsNode::): + (KJS::NewExprNode::): + (KJS::EvalFunctionCallNode::): + (KJS::FunctionCallValueNode::): + (KJS::FunctionCallResolveNode::): + (KJS::FunctionCallBracketNode::): + (KJS::FunctionCallDotNode::): + (KJS::PrePostResolveNode::): + (KJS::PostIncResolveNode::): + (KJS::PostDecResolveNode::): + (KJS::PostfixBracketNode::): + (KJS::PostIncBracketNode::): + (KJS::PostDecBracketNode::): + (KJS::PostfixDotNode::): + (KJS::PostIncDotNode::): + (KJS::PostDecDotNode::): + (KJS::PostfixErrorNode::): + (KJS::DeleteResolveNode::): + (KJS::DeleteBracketNode::): + (KJS::DeleteDotNode::): + (KJS::DeleteValueNode::): + (KJS::VoidNode::): + (KJS::TypeOfResolveNode::): + (KJS::TypeOfValueNode::): + (KJS::PreIncResolveNode::): + (KJS::PreDecResolveNode::): + (KJS::PrefixBracketNode::): + (KJS::PreIncBracketNode::): + (KJS::PreDecBracketNode::): + (KJS::PrefixDotNode::): + (KJS::PreIncDotNode::): + (KJS::PreDecDotNode::): + (KJS::PrefixErrorNode::): + (KJS::UnaryOpNode::UnaryOpNode): + (KJS::UnaryPlusNode::): + (KJS::NegateNode::): + (KJS::BitwiseNotNode::): + (KJS::LogicalNotNode::): + (KJS::BinaryOpNode::BinaryOpNode): + (KJS::ReverseBinaryOpNode::ReverseBinaryOpNode): + (KJS::MultNode::): + (KJS::DivNode::): + (KJS::ModNode::): + (KJS::AddNode::): + (KJS::SubNode::): + (KJS::LeftShiftNode::): + (KJS::RightShiftNode::): + (KJS::UnsignedRightShiftNode::): + (KJS::LessNode::): + (KJS::GreaterNode::): + (KJS::LessEqNode::): + (KJS::GreaterEqNode::): + (KJS::InstanceOfNode::): + (KJS::InNode::): + (KJS::EqualNode::): + (KJS::NotEqualNode::): + (KJS::StrictEqualNode::): + (KJS::NotStrictEqualNode::): + (KJS::BitAndNode::): + (KJS::BitOrNode::): + (KJS::BitXOrNode::): + (KJS::LogicalAndNode::): + (KJS::LogicalOrNode::): + (KJS::ConditionalNode::): + (KJS::ReadModifyResolveNode::): + (KJS::AssignResolveNode::): + (KJS::ReadModifyBracketNode::): + (KJS::AssignBracketNode::): + (KJS::AssignDotNode::): + (KJS::ReadModifyDotNode::): + (KJS::AssignErrorNode::): + (KJS::CommaNode::): + (KJS::VarDeclCommaNode::): + (KJS::ConstStatementNode::): + (KJS::SourceElements::SourceElements): + (KJS::EmptyStatementNode::): + (KJS::DebuggerStatementNode::): + (KJS::ExprStatementNode::): + (KJS::VarStatementNode::): + (KJS::IfNode::): + (KJS::IfElseNode::): + (KJS::DoWhileNode::): + (KJS::WhileNode::): + (KJS::ForNode::): + (KJS::ContinueNode::): + (KJS::BreakNode::): + (KJS::ReturnNode::): + (KJS::WithNode::): + (KJS::LabelNode::): + (KJS::ThrowNode::): + (KJS::TryNode::): + (KJS::ParameterNode::): + (KJS::FuncExprNode::): + (KJS::FuncDeclNode::): + (KJS::CaseClauseNode::): + (KJS::ClauseListNode::): + (KJS::CaseBlockNode::): + (KJS::SwitchNode::): + Changed ParserRefCounted to hold a JSGlobalData pointer, and used it to replace + threadInstance calls. + +2008-06-24 Cameron Zwarich + + Reviewed by Alexey Proskuryakov. + + Make the JavaScript shell collect the heap from main() instead of + jscmain() to suppress leak messages in debug builds. + + * kjs/Shell.cpp: + (main): + (jscmain): + +2008-06-24 Cameron Zwarich + + Reviewed by Maciej. + + Make the conversion of the pair (less, jtrue) to jless use register + reference counting information for safety instead of requiring callers + to decide whether it is safe. + + No changes on SunSpider codegen. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitJumpIfTrue): + * VM/CodeGenerator.h: + * kjs/nodes.cpp: + (KJS::DoWhileNode::emitCode): + (KJS::WhileNode::emitCode): + (KJS::ForNode::emitCode): + (KJS::CaseBlockNode::emitCodeForBlock): + +2008-06-24 Kevin McCullough + + Reviewed by Tim. + + JSProfiler: Profiler goes into an infinite + loop sometimes. + JSProfiler: Profiler asserts in debug and + give the wrong times in release + + Fixed two issues found by Tim in the same test. + + * profiler/Profile.cpp: + (KJS::Profile::removeProfileStart): No longer take profile's time from + all ancestors, but instead attribute it to its parent. Also add an + Assert to ensure we only delete the child we mean to. + (KJS::Profile::removeProfileEnd): Ditto for profileEnd. + (KJS::Profile::didExecute): Cleaned up the execution order and correctly + attribute all of the parent's time to the new node. + * profiler/ProfileNode.cpp: If this node does not have a startTime it + should not get a giant total time, but instead be 0. + (KJS::ProfileNode::endAndRecordCall): + * profiler/ProfileNode.h: + (KJS::ProfileNode::removeChild): Should reset the sibling pointers since + one of them has been removed. + +2008-06-24 Darin Adler + + Reviewed by Cameron. + + - fix https://bugs.webkit.org/show_bug.cgi?id=19739 + REGRESSION: fast/js/property-getters-and-setters.html fails + + * kjs/JSObject.cpp: + (KJS::JSObject::put): Remove an untested optimization I checked in by accident. + The two loops up the prototype chain both need to start from this; instead the + second loop was starting where the first loop left off. + +2008-06-24 Steve Falkenburg + + Build fix. + + * kjs/nodes.cpp: + +2008-06-24 Joerg Bornemann + + Reviewed by Simon. + + For the Qt build on Windows don't depend on the presence of GNU CPP + but use MSVC's preprocessor instead. + dftables accepts a --preprocessor option which is set in pcre.pri for MSVC platforms. + + * pcre/dftables: Added support for specifying the preprocessor command + to use via --preprocessor, similar to + WebCore/bindings/scripts/generate-bindings.pl. + * pcre/pcre.pri: Pass --preprocessor='cl /e' to dftables, or more + generally speaking QMAKE_CC /E for the win32-msvc buildspecs. + +2008-06-24 Simon Hausmann + + Fix the Qt build, added missing include. + + * kjs/PropertySlot.cpp: + +2008-06-24 Alexey Proskuryakov + + Reviewed by Cameron Zwarich. + + Make ParserRefCountedCounter actually perform a leak check. + + * kjs/nodes.cpp: + (KJS::ParserRefCountedCounter::~ParserRefCountedCounter): Check for leaks in destructor, + not in constructor. + (KJS::ParserRefCountedCounter::increment): + (KJS::ParserRefCountedCounter::decrement): + (KJS::ParserRefCounted::ParserRefCounted): + (KJS::ParserRefCounted::~ParserRefCounted): + While at it, also made counting thread-safe. + +2008-06-24 Cameron Zwarich + + Reviewed by Oliver. + + Bug 19730: REGRESSION (r34497): Text in alerts in "Leisure suit Larry" is not wrapped + + + Do not convert the pair (less, jtrue) to jless when jtrue is a jump + target. An example of this is when the condition of a while loop is a + LogicalOrNode. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitLabel): + +2008-06-20 Ariya Hidayat + + Reviewed by Adam Roben. + + Fix compile with MinGW. + + * kjs/Shell.cpp: + * wtf/Threading.h: + (WTF::atomicIncrement): + (WTF::atomicDecrement): + +2008-06-23 Mark Rowe + + Reviewed by Oliver Hunt. + + Prepration for returning memory to the OS on Windows. Track whether a portion of a span of memory was returned to the OS. + If it was, ask that it be recommitted before returning it to the application as an allocated region. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::New): If the span was decommitted, ask that it be recommitted before returning it. + (WTF::TCMalloc_PageHeap::AllocLarge): Ditto. + (WTF::TCMalloc_PageHeap::Carve): When splitting a span, ensure that the decommitted state propogates to the two new spans. + (WTF::TCMalloc_PageHeap::Delete): When merging a span, ensure that the resulting span is marked as decommitted if any of the + spans being merged were marked as decommitted. + (WTF::TCMalloc_PageHeap::IncrementalScavenge): Mark as decommitted after releasing the span. + (WTF::TCMalloc_Central_FreeList::FetchFromSpans): Add an assertion to catch a decommitted span being returned to the application + without first being recommitted. + (WTF::TCMalloc_Central_FreeList::Populate): Ditto. + * wtf/TCSystemAlloc.cpp: Stub out TCMalloc_SystemCommit. + * wtf/TCSystemAlloc.h: + +2008-06-23 Mark Rowe + + Reviewed by Sam Weinig. + + Remove the sample member of Span when NO_TCMALLOC_SAMPLES is defined. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::Delete): Only update Span::sample if NO_TCMALLOC_SAMPLES is not defined. + (WTF::TCMallocStats::do_free): Ditto. + +2008-06-23 Darin Adler + + Reviewed by Geoff. + + - work toward https://bugs.webkit.org/show_bug.cgi?id=19721 + + More preparation toward making functions work on primitive types without + creating wrapper objects. No speedup this time, but prepares for a future + speedup without slowing things down. + + SunSpider reports no change. + + - Eliminated the implementsCall, callAsFunction and construct virtual + functions from JSObject. Instead, the CallData and ConstructData for + a native function includes a function pointer that the caller can use + directly. Changed all call sites to use CallData and ConstructData. + + - Changed the "this" argument to native functions to be a JSValue rather + than a JSObject. This prepares us for passing primitives into these + functions. The conversion to an object now must be done inside the + function. Critically, if it's a function that can be called on a DOM + window object, then we have to be sure to call toThisObject on the + argument before we use it for anything even if it's already an object. + + - Eliminated the practice of using constructor objects in the global + object to make objects of the various basic types. Since these + constructors can't be replaced by script, there's no reason to involve + a constructor object at all. Added functions to do the construction + directly. + + - Made some more class members private and protected, including virtual + function overrides. This can catch code using unnecessarily slow virtual + function code paths when the type of an object is known statically. If we + later find a new reason use the members outside the class it's easy to + make them public again. + + - Moved the declarations of the native implementations for functions out + of header files. These can have internal linkage and be declared inside + the source file. + + - Changed PrototypeFunction to take function pointers with the right + arguments to be put directly into CallData. This eliminates the + need to have a separate PrototypeReflexiveFunction, and reveals that the + real purpose of that class included something else specific to eval -- + storage of a cached global object. So renamed PrototypeReflexiveFunction + to GlobalEvalFunction. + + * API/JSCallbackConstructor.cpp: + (KJS::constructJSCallback): + (KJS::JSCallbackConstructor::getConstructData): + * API/JSCallbackConstructor.h: + * API/JSCallbackFunction.cpp: + (KJS::JSCallbackFunction::implementsHasInstance): + (KJS::JSCallbackFunction::call): + (KJS::JSCallbackFunction::getCallData): + * API/JSCallbackFunction.h: + (KJS::JSCallbackFunction::classInfo): + * API/JSCallbackObject.h: + (KJS::JSCallbackObject::classRef): + (KJS::JSCallbackObject::classInfo): + * API/JSCallbackObjectFunctions.h: + (KJS::::getConstructData): + (KJS::::construct): + (KJS::::getCallData): + (KJS::::call): + * API/JSObjectRef.cpp: + (JSObjectMakeFunction): + (JSObjectIsFunction): + (JSObjectCallAsFunction): + (JSObjectCallAsConstructor): + * JavaScriptCore.exp: + * VM/Machine.cpp: + (KJS::jsTypeStringForValue): + (KJS::Machine::privateExecute): + * kjs/ArrayPrototype.cpp: + (KJS::arrayProtoFuncToString): + (KJS::arrayProtoFuncToLocaleString): + (KJS::arrayProtoFuncJoin): + (KJS::arrayProtoFuncConcat): + (KJS::arrayProtoFuncPop): + (KJS::arrayProtoFuncPush): + (KJS::arrayProtoFuncReverse): + (KJS::arrayProtoFuncShift): + (KJS::arrayProtoFuncSlice): + (KJS::arrayProtoFuncSort): + (KJS::arrayProtoFuncSplice): + (KJS::arrayProtoFuncUnShift): + (KJS::arrayProtoFuncFilter): + (KJS::arrayProtoFuncMap): + (KJS::arrayProtoFuncEvery): + (KJS::arrayProtoFuncForEach): + (KJS::arrayProtoFuncSome): + (KJS::arrayProtoFuncIndexOf): + (KJS::arrayProtoFuncLastIndexOf): + (KJS::ArrayConstructor::ArrayConstructor): + (KJS::constructArrayWithSizeQuirk): + (KJS::constructWithArrayConstructor): + (KJS::ArrayConstructor::getConstructData): + (KJS::callArrayConstructor): + (KJS::ArrayConstructor::getCallData): + * kjs/ArrayPrototype.h: + * kjs/BooleanObject.cpp: + (KJS::booleanProtoFuncToString): + (KJS::booleanProtoFuncValueOf): + (KJS::constructBoolean): + (KJS::constructWithBooleanConstructor): + (KJS::BooleanConstructor::getConstructData): + (KJS::callBooleanConstructor): + (KJS::BooleanConstructor::getCallData): + (KJS::constructBooleanFromImmediateBoolean): + * kjs/BooleanObject.h: + * kjs/CallData.h: + (KJS::): + * kjs/ConstructData.h: + (KJS::): + * kjs/FunctionPrototype.cpp: + (KJS::callFunctionPrototype): + (KJS::FunctionPrototype::getCallData): + (KJS::functionProtoFuncToString): + (KJS::functionProtoFuncApply): + (KJS::functionProtoFuncCall): + (KJS::constructWithFunctionConstructor): + (KJS::FunctionConstructor::getConstructData): + (KJS::callFunctionConstructor): + (KJS::FunctionConstructor::getCallData): + (KJS::constructFunction): + * kjs/FunctionPrototype.h: + * kjs/JSArray.cpp: + (KJS::AVLTreeAbstractorForArrayCompare::compare_key_key): + (KJS::JSArray::sort): + (KJS::constructEmptyArray): + (KJS::constructArray): + * kjs/JSArray.h: + (KJS::JSArray::classInfo): + * kjs/JSFunction.cpp: + (KJS::JSFunction::call): + (KJS::globalFuncEval): + (KJS::globalFuncParseInt): + (KJS::globalFuncParseFloat): + (KJS::globalFuncIsNaN): + (KJS::globalFuncIsFinite): + (KJS::globalFuncDecodeURI): + (KJS::globalFuncDecodeURIComponent): + (KJS::globalFuncEncodeURI): + (KJS::globalFuncEncodeURIComponent): + (KJS::globalFuncEscape): + (KJS::globalFuncUnescape): + (KJS::globalFuncKJSPrint): + (KJS::PrototypeFunction::PrototypeFunction): + (KJS::PrototypeFunction::getCallData): + (KJS::GlobalEvalFunction::GlobalEvalFunction): + (KJS::GlobalEvalFunction::mark): + * kjs/JSFunction.h: + (KJS::InternalFunction::classInfo): + (KJS::InternalFunction::functionName): + (KJS::JSFunction::classInfo): + (KJS::GlobalEvalFunction::cachedGlobalObject): + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): + (KJS::JSGlobalObject::mark): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::JSGlobalObject): + (KJS::JSGlobalObject::evalFunction): + * kjs/JSImmediate.cpp: + (KJS::JSImmediate::toObject): + * kjs/JSNotAnObject.cpp: + * kjs/JSNotAnObject.h: + * kjs/JSObject.cpp: + (KJS::JSObject::put): + (KJS::callDefaultValueFunction): + (KJS::JSObject::defaultValue): + (KJS::JSObject::lookupGetter): + (KJS::JSObject::lookupSetter): + (KJS::JSObject::hasInstance): + (KJS::JSObject::fillGetterPropertySlot): + (KJS::Error::create): + (KJS::constructEmptyObject): + * kjs/JSObject.h: + (KJS::GetterSetter::GetterSetter): + (KJS::GetterSetter::getter): + (KJS::GetterSetter::setGetter): + (KJS::GetterSetter::setter): + (KJS::GetterSetter::setSetter): + * kjs/JSValue.cpp: + (KJS::JSCell::deleteProperty): + (KJS::call): + (KJS::construct): + * kjs/JSValue.h: + * kjs/MathObject.cpp: + (KJS::mathProtoFuncAbs): + (KJS::mathProtoFuncACos): + (KJS::mathProtoFuncASin): + (KJS::mathProtoFuncATan): + (KJS::mathProtoFuncATan2): + (KJS::mathProtoFuncCeil): + (KJS::mathProtoFuncCos): + (KJS::mathProtoFuncExp): + (KJS::mathProtoFuncFloor): + (KJS::mathProtoFuncLog): + (KJS::mathProtoFuncMax): + (KJS::mathProtoFuncMin): + (KJS::mathProtoFuncPow): + (KJS::mathProtoFuncRandom): + (KJS::mathProtoFuncRound): + (KJS::mathProtoFuncSin): + (KJS::mathProtoFuncSqrt): + (KJS::mathProtoFuncTan): + * kjs/MathObject.h: + * kjs/NumberObject.cpp: + (KJS::numberProtoFuncToString): + (KJS::numberProtoFuncToLocaleString): + (KJS::numberProtoFuncValueOf): + (KJS::numberProtoFuncToFixed): + (KJS::numberProtoFuncToExponential): + (KJS::numberProtoFuncToPrecision): + (KJS::NumberConstructor::NumberConstructor): + (KJS::constructWithNumberConstructor): + (KJS::NumberConstructor::getConstructData): + (KJS::callNumberConstructor): + (KJS::NumberConstructor::getCallData): + (KJS::constructNumber): + (KJS::constructNumberFromImmediateNumber): + * kjs/NumberObject.h: + (KJS::NumberObject::classInfo): + (KJS::NumberConstructor::classInfo): + * kjs/PropertySlot.cpp: + (KJS::PropertySlot::functionGetter): + * kjs/RegExpObject.cpp: + (KJS::regExpProtoFuncTest): + (KJS::regExpProtoFuncExec): + (KJS::regExpProtoFuncCompile): + (KJS::regExpProtoFuncToString): + (KJS::callRegExpObject): + (KJS::RegExpObject::getCallData): + (KJS::constructRegExp): + (KJS::constructWithRegExpConstructor): + (KJS::RegExpConstructor::getConstructData): + (KJS::callRegExpConstructor): + (KJS::RegExpConstructor::getCallData): + * kjs/RegExpObject.h: + (KJS::RegExpConstructor::classInfo): + * kjs/Shell.cpp: + (GlobalObject::GlobalObject): + (functionPrint): + (functionDebug): + (functionGC): + (functionVersion): + (functionRun): + (functionLoad): + (functionReadline): + (functionQuit): + * kjs/date_object.cpp: + (KJS::gmtoffset): + (KJS::formatLocaleDate): + (KJS::fillStructuresUsingDateArgs): + (KJS::DateInstance::getTime): + (KJS::DateInstance::getUTCTime): + (KJS::DateConstructor::DateConstructor): + (KJS::constructDate): + (KJS::DateConstructor::getConstructData): + (KJS::callDate): + (KJS::DateConstructor::getCallData): + (KJS::dateParse): + (KJS::dateNow): + (KJS::dateUTC): + (KJS::dateProtoFuncToString): + (KJS::dateProtoFuncToUTCString): + (KJS::dateProtoFuncToDateString): + (KJS::dateProtoFuncToTimeString): + (KJS::dateProtoFuncToLocaleString): + (KJS::dateProtoFuncToLocaleDateString): + (KJS::dateProtoFuncToLocaleTimeString): + (KJS::dateProtoFuncValueOf): + (KJS::dateProtoFuncGetTime): + (KJS::dateProtoFuncGetFullYear): + (KJS::dateProtoFuncGetUTCFullYear): + (KJS::dateProtoFuncToGMTString): + (KJS::dateProtoFuncGetMonth): + (KJS::dateProtoFuncGetUTCMonth): + (KJS::dateProtoFuncGetDate): + (KJS::dateProtoFuncGetUTCDate): + (KJS::dateProtoFuncGetDay): + (KJS::dateProtoFuncGetUTCDay): + (KJS::dateProtoFuncGetHours): + (KJS::dateProtoFuncGetUTCHours): + (KJS::dateProtoFuncGetMinutes): + (KJS::dateProtoFuncGetUTCMinutes): + (KJS::dateProtoFuncGetSeconds): + (KJS::dateProtoFuncGetUTCSeconds): + (KJS::dateProtoFuncGetMilliSeconds): + (KJS::dateProtoFuncGetUTCMilliseconds): + (KJS::dateProtoFuncGetTimezoneOffset): + (KJS::dateProtoFuncSetTime): + (KJS::setNewValueFromTimeArgs): + (KJS::setNewValueFromDateArgs): + (KJS::dateProtoFuncSetMilliSeconds): + (KJS::dateProtoFuncSetUTCMilliseconds): + (KJS::dateProtoFuncSetSeconds): + (KJS::dateProtoFuncSetUTCSeconds): + (KJS::dateProtoFuncSetMinutes): + (KJS::dateProtoFuncSetUTCMinutes): + (KJS::dateProtoFuncSetHours): + (KJS::dateProtoFuncSetUTCHours): + (KJS::dateProtoFuncSetDate): + (KJS::dateProtoFuncSetUTCDate): + (KJS::dateProtoFuncSetMonth): + (KJS::dateProtoFuncSetUTCMonth): + (KJS::dateProtoFuncSetFullYear): + (KJS::dateProtoFuncSetUTCFullYear): + (KJS::dateProtoFuncSetYear): + (KJS::dateProtoFuncGetYear): + * kjs/date_object.h: + (KJS::DateInstance::internalNumber): + (KJS::DateInstance::classInfo): + * kjs/error_object.cpp: + (KJS::errorProtoFuncToString): + (KJS::constructError): + (KJS::constructWithErrorConstructor): + (KJS::ErrorConstructor::getConstructData): + (KJS::callErrorConstructor): + (KJS::ErrorConstructor::getCallData): + (KJS::NativeErrorConstructor::construct): + (KJS::constructWithNativeErrorConstructor): + (KJS::NativeErrorConstructor::getConstructData): + (KJS::callNativeErrorConstructor): + (KJS::NativeErrorConstructor::getCallData): + * kjs/error_object.h: + (KJS::NativeErrorConstructor::classInfo): + * kjs/internal.cpp: + (KJS::JSNumberCell::toObject): + (KJS::JSNumberCell::toThisObject): + (KJS::GetterSetter::mark): + (KJS::GetterSetter::toPrimitive): + (KJS::GetterSetter::toBoolean): + (KJS::GetterSetter::toNumber): + (KJS::GetterSetter::toString): + (KJS::GetterSetter::toObject): + (KJS::InternalFunction::InternalFunction): + (KJS::InternalFunction::implementsHasInstance): + * kjs/lookup.h: + (KJS::HashEntry::): + * kjs/nodes.cpp: + (KJS::FuncDeclNode::makeFunction): + (KJS::FuncExprNode::makeFunction): + * kjs/object_object.cpp: + (KJS::objectProtoFuncValueOf): + (KJS::objectProtoFuncHasOwnProperty): + (KJS::objectProtoFuncIsPrototypeOf): + (KJS::objectProtoFuncDefineGetter): + (KJS::objectProtoFuncDefineSetter): + (KJS::objectProtoFuncLookupGetter): + (KJS::objectProtoFuncLookupSetter): + (KJS::objectProtoFuncPropertyIsEnumerable): + (KJS::objectProtoFuncToLocaleString): + (KJS::objectProtoFuncToString): + (KJS::ObjectConstructor::ObjectConstructor): + (KJS::constructObject): + (KJS::constructWithObjectConstructor): + (KJS::ObjectConstructor::getConstructData): + (KJS::callObjectConstructor): + (KJS::ObjectConstructor::getCallData): + * kjs/object_object.h: + * kjs/string_object.cpp: + (KJS::replace): + (KJS::stringProtoFuncToString): + (KJS::stringProtoFuncValueOf): + (KJS::stringProtoFuncCharAt): + (KJS::stringProtoFuncCharCodeAt): + (KJS::stringProtoFuncConcat): + (KJS::stringProtoFuncIndexOf): + (KJS::stringProtoFuncLastIndexOf): + (KJS::stringProtoFuncMatch): + (KJS::stringProtoFuncSearch): + (KJS::stringProtoFuncReplace): + (KJS::stringProtoFuncSlice): + (KJS::stringProtoFuncSplit): + (KJS::stringProtoFuncSubstr): + (KJS::stringProtoFuncSubstring): + (KJS::stringProtoFuncToLowerCase): + (KJS::stringProtoFuncToUpperCase): + (KJS::stringProtoFuncToLocaleLowerCase): + (KJS::stringProtoFuncToLocaleUpperCase): + (KJS::stringProtoFuncLocaleCompare): + (KJS::stringProtoFuncBig): + (KJS::stringProtoFuncSmall): + (KJS::stringProtoFuncBlink): + (KJS::stringProtoFuncBold): + (KJS::stringProtoFuncFixed): + (KJS::stringProtoFuncItalics): + (KJS::stringProtoFuncStrike): + (KJS::stringProtoFuncSub): + (KJS::stringProtoFuncSup): + (KJS::stringProtoFuncFontcolor): + (KJS::stringProtoFuncFontsize): + (KJS::stringProtoFuncAnchor): + (KJS::stringProtoFuncLink): + (KJS::stringFromCharCode): + (KJS::StringConstructor::StringConstructor): + (KJS::constructWithStringConstructor): + (KJS::StringConstructor::getConstructData): + (KJS::callStringConstructor): + (KJS::StringConstructor::getCallData): + * kjs/string_object.h: + +2008-06-23 Cameron Zwarich + + Reviewed by Oliver. + + Bug 19716: REGRESSION (SquirrelFish): Reproducible crash after entering a username at mint.com + + + When unwinding callframes for exceptions, check whether the callframe + was created by a reentrant native call to JavaScript after tearing off + the local variables instead of before. + + * VM/Machine.cpp: + (KJS::Machine::unwindCallFrame): + +2008-06-23 Mark Rowe + + Reviewed by Oliver Hunt. + + Get testapi passing again in a debug build. + + * API/testapi.c: + (main): Update the expected output of calling JSValueMakeString on a function object. + +2008-06-21 Mark Rowe + + Reviewed by Sam Weinig. + + Print a blank line when exiting the jsc interactive mode to ensure that the shell + prompt will start on a new line. + + * kjs/Shell.cpp: + (runInteractive): + +2008-06-21 Mark Rowe + + Rubber-stamped by Sam Weinig. + + Tweak the paths of the items in the "tests" group to clean things up a little. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-06-21 Mark Rowe + + Rubber-stamped by Sam Weinig. + + Fix jsc to link against libedit.dylib rather than libedit.2.dylib. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-06-21 Mark Rowe + + Reviewed by Sam Weinig. + + Copy the JavaScriptCore shell (jsc) into JavaScriptCore.framework so that it will + be included in nightly builds. + https://bugs.webkit.org/show_bug.cgi?id=19691 + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-06-21 Cameron Zwarich + + Reviewed by Mark Rowe. + + Fix the build for non-Mac Darwin platforms by disabling their support + for readline in the JavaScript shell. + + * kjs/config.h: + +2008-06-20 Timothy Hatcher + + Use member function pointers for the Profile::forEach function. + Eliminating a few static functions and simplified things a little. + + Reviewed by Alexey Proskuryakov. + + * JavaScriptCore.exp: Change the symbol for forEach. + * profiler/Profile.cpp: + (KJS::Profile::forEach): Use a member function pointer. + * profiler/Profile.h: + (KJS::Profile::sortTotalTimeDescending): Pass a function pointer. + (KJS::Profile::sortTotalTimeAscending): Ditto. + (KJS::Profile::sortSelfTimeDescending): Ditto. + (KJS::Profile::sortSelfTimeAscending): Ditto. + (KJS::Profile::sortCallsDescending): Ditto. + * profiler/ProfileNode.h: + (KJS::ProfileNode::sortTotalTimeDescending): No longer static. + (KJS::ProfileNode::sortTotalTimeAscending): Ditto. + (KJS::ProfileNode::sortSelfTimeDescending): Ditto. + (KJS::ProfileNode::sortSelfTimeAscending): Ditto. + (KJS::ProfileNode::sortCallsDescending): Ditto. + +2008-06-20 Cameron Zwarich + + Reviewed by Oliver. + + Remove unused destructors. + + * kjs/nodes.cpp: + * kjs/nodes.h: + +2008-06-20 Timothy Hatcher + + Fixed an ASSERT(m_actualSelfTime <= m_actualTotalTime) when starting + and stopping a profile from the Develop menu. Also prevents + inserting an incorrect parent node as the new head after profiling + is stopped from the Develop menu. + + Reviewed by Dan Bernstein. + + * profiler/Profile.cpp: + (KJS::Profile::stopProfiling): If the current node is already the head + then there is no more need to record future nodes in didExecute. + (KJS::Profile::didExecute): Move the code of setupCurrentNodeAsStopped + into here since this was the only caller. When setting the total time + keep any current total time while adding the self time of the head. + (KJS::Profile::setupCurrentNodeAsStopped): Removed. + * profiler/Profile.h: Removed setupCurrentNodeAsStopped. + +2008-06-20 Kevin Ollivier + + !USE(MULTIPLE_THREADS) on Darwin build fix + + * kjs/InitializeThreading.cpp: + (KJS::initializeThreading): + * kjs/collector.h: + +2008-06-20 Kevin McCullough + + -Leopard Build Fix. + + * profiler/Profile.cpp: + (KJS::Profile::removeProfileStart): + (KJS::Profile::removeProfileEnd): + +2008-06-20 Kevin McCullough + + Just giving credit. + + * ChangeLog: + +2008-06-20 Kevin McCullough + + Reviewed by Tim and Dan. + + JSProfiler: ASSERT hit in Profiler. + - Because InspectorController can call startProfiling() and + stopProfiling() we cannot assert that console.profile() and + console.profileEnd() will be in the profile tree. + + * profiler/Profile.cpp: + (KJS::Profile::removeProfileStart): + (KJS::Profile::removeProfileEnd): + +2008-06-20 Kevin McCullough + + Reviewed by Tim. + + JSProfiler: Time incorrectly given to (idle) + if profiling is started and finished within the same function. (19230) + - Now we profile one more stack frame up from the last frame to allocate + the time spent in it, if it exists. + + * JavaScriptCore.exp: + * VM/Machine.cpp: We need to let the profiler know when the JS program + has finished since that is what will actually stop the profiler instead + of just calling stopProfiling(). + (KJS::Machine::execute): + * profiler/Profile.cpp: + (KJS::Profile::create): Moved from Profile.h since it was getting pretty + long. + (KJS::Profile::Profile): We now have a client, which is a listener who + we will return this profile to, once it has actually finished. + (KJS::Profile::stopProfiling): Instead of fully stopping the profiler + here, we set the flag and keep it profiling in the background. + (KJS::Profile::didFinishAllExecution): This is where the profiler + actually finishes and creates the (idle) node if one should be made. + (KJS::Profile::removeProfileStart): Don't use m_currentNode since it is + needed by the profiler as it runs silently in the background. + (KJS::Profile::removeProfileEnd): Ditto. + (KJS::Profile::willExecute): Don't profile new functions if we have + stopped profiling. + (KJS::Profile::didExecute): Only record one more return as all the + remaining time will be attributed to that function. + (KJS::Profile::setupCurrentNodeAsStopped): Sets the current node's time. + * profiler/Profile.h: Added functions and variables for the above + changes. + (KJS::Profile::client): + * profiler/ProfileNode.h: + (KJS::CallIdentifier::toString): Debug method. + * profiler/Profiler.cpp: Added support for the ProfilerClient. + (KJS::Profiler::startProfiling): + (KJS::Profiler::stopProfiling): No longer return sthe profile. + (KJS::Profiler::didFinishAllExecution): Now returns the profile to the + client instead of stopProfiling. + * profiler/Profiler.h: + (KJS::ProfilerClient::~ProfilerClient): Clients will implement this + interface. + +2008-06-19 Ariya Hidayat + + Reviewed by Simon. + + Surpress compiler warning (int vs unsigned comparison). + + * wtf/unicode/qt4/UnicodeQt4.h: + (WTF::Unicode::toLower): + +2008-06-19 Ariya Hidayat + + Reviewed by Timothy Hatcher. + + Introduce compiler define for MinGW, to have COMPILER(MINGW). + + * wtf/Platform.h: + +2008-06-19 Alexey Proskuryakov + + Reviewed by Geoff. + + Make Machine per-JSGlobalData. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitOpcode): + * VM/Machine.cpp: + (KJS::callEval): + (KJS::Machine::unwindCallFrame): + (KJS::Machine::throwException): + (KJS::Machine::execute): + (KJS::Machine::debug): + * VM/Machine.h: + * kjs/DebuggerCallFrame.cpp: + (KJS::DebuggerCallFrame::evaluate): + * kjs/DebuggerCallFrame.h: + (KJS::DebuggerCallFrame::DebuggerCallFrame): + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + * kjs/ExecState.h: + (KJS::ExecState::machine): + * kjs/JSFunction.cpp: + (KJS::JSFunction::callAsFunction): + (KJS::JSFunction::argumentsGetter): + (KJS::JSFunction::callerGetter): + (KJS::JSFunction::construct): + (KJS::globalFuncEval): + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): + * kjs/JSGlobalData.h: + * kjs/interpreter.cpp: + (KJS::Interpreter::evaluate): + +2008-06-19 Alp Toker + + GTK+/autotools build fix. JSGlobalObject.cpp in now in + AllInOneFile.cpp and shouldn't be built separately. + + * GNUmakefile.am: + +2008-06-19 Alexey Proskuryakov + + Reviewed by Darin. + + Get rid of some threadInstance calls. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::init): + * kjs/Parser.cpp: + (KJS::Parser::parse): + * kjs/Shell.cpp: + (jscmain): + +2008-06-19 Alexey Proskuryakov + + Reviewed by Sam. + + Fix an assertion failure at startup. + + * kjs/JSObject.h: (KJS::JSObject::JSObject): Allow jsNull prototype in an assertion (I had + it fixed in a wrong copy of the file, so I wasn't getting the failure). + +2008-06-19 Alexey Proskuryakov + + Build fix. + + * kjs/collector.cpp: + (KJS::Heap::Heap): + (KJS::allocateBlock): + * kjs/collector.h: + No, #if PLATFORM(UNIX) was not right. I've just moved the unsafe initialization back for now, + as the platforms that use that code path do not use multiple threads yet. + +2008-06-19 Alexey Proskuryakov + + Windows and Qt build fixes. + + * kjs/collector.h: + * kjs/collector.cpp: + (KJS::Heap::Heap): + Wrapped m_pagesize in #if PLATFORM(UNIX), which should better match the sequence of #elifs + in allocateBlock(). Changed MIN_ARRAY_SIZE to be explicitly size_t, as this type is different + on different platforms. + +2008-06-17 Alexey Proskuryakov + + Reviewed by Darin. + + Prepare JavaScript heap for being per-thread. + + * kjs/ExecState.h: Shuffle includes, making it possible to include ExecState.h in JSValue.h. + (KJS::ExecState::heap): Added an accessor. + + * API/JSBase.cpp: (JSGarbageCollect): Collect both shared and per-thread heaps. + + * API/JSContextRef.cpp: (JSGlobalContextCreate): When allocating JSGlobalObject, indicate + that it belongs to a shared heap. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/AllInOneFile.cpp: + Moved JSGlobalObject.cpp to AllInOneFile, as a build fix for inlineAllocate magic. + + * VM/CodeGenerator.h: (KJS::CodeGenerator::globalExec): Added an accessor (working via + m_scopeChain). + + * VM/RegisterFile.h: + (KJS::RegisterFile::mark): + * VM/RegisterFileStack.h: + (KJS::RegisterFileStack::mark): + Made these pseudo-mark functions take Heap*. + + * kjs/InitializeThreading.cpp: + (KJS::initializeThreading): Initialize heap introspector. + + * kjs/JSGlobalData.h: Added Heap to the structure. + + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): Initialize Heap. + (KJS::JSGlobalData::sharedInstance): Added a method to access shared global data instance + for legacy clients. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::~JSGlobalObject): Changed to work with per-thread head; fixed list + maintenance logic. + (KJS::JSGlobalObject::init): Changed to work with per-thread head. + (KJS::JSGlobalObject::put): Assert that a cross-heap operation is not being attempted. + (KJS::JSGlobalObject::reset): Pass ExecState* where now required. + (KJS::JSGlobalObject::mark): Pass the current heap to RegisterFileStack::mark. + (KJS::JSGlobalObject::operator new): Overload operator new to use per-thread or shared heap. + * kjs/JSGlobalObject.h: Removed static s_head member. + + * kjs/PropertyMap.h: (KJS::PropertyMap::PropertyMap): Removed unused SavedProperty. + + * kjs/collector.h: Turned Collector into an actual object with its own data, renamed to Heap. + (KJS::Heap::initializeHeapIntrospector): Added. + (KJS::Heap::heap): Added a method to determine which heap a JSValue is in, if any. + (KJS::Heap::allocate): Made non-static. + (KJS::Heap::inlineAllocateNumber): Ditto. + (KJS::Heap::markListSet): Ditto. + (KJS::Heap::cellBlock): Ditto. + (KJS::Heap::cellOffset): Ditto. + (KJS::Heap::isCellMarked): Ditto. + (KJS::Heap::markCell): Ditto. + (KJS::Heap::reportExtraMemoryCost): Ditto. + (KJS::CollectorBlock): Added a back-reference to Heap for Heap::heap() method. + (KJS::SmallCellCollectorBlock): Ditto. + + * kjs/collector.cpp: Changed MIN_ARRAY_SIZE to a #define to avoid a PIC branch. Removed + main thread related machinery. + (KJS::Heap::Heap): Initialize the newly added data members. + (KJS::allocateBlock): Marked NEVER_INLINE, as this is a rare case that uses a PIC branch. + Moved static pagesize to the class to make it safely initialized. + (KJS::Heap::heapAllocate): Initialize heap back reference after a new block is allocated. + (KJS::Heap::registerThread): Removed introspector initialization, as it is now performed + in InitializeThreading.cpp. + (KJS::Heap::markOtherThreadConservatively): Assert that the "other thread" case only occurs + for legacy clients using a shared heap. + (KJS::Heap::markStackObjectsConservatively): Moved fastMallocForbid/Allow down here, since + it doesn't need to be forbidden during other GC phases. + + * kjs/JSImmediate.h: + (KJS::jsUndefined): + (KJS::jsNull): + (KJS::jsBoolean): + Moved from JSvalue.h, to make these usable in files that cannot include JSValue.h (such + as list.h). + + * API/JSCallbackObjectFunctions.h: + (KJS::::staticFunctionGetter): + * API/JSClassRef.cpp: + (OpaqueJSClass::prototype): + * API/JSObjectRef.cpp: + (JSObjectMake): + (JSObjectMakeFunctionWithCallback): + (JSObjectMakeConstructor): + (JSObjectMakeFunction): + * API/JSValueRef.cpp: + (JSValueMakeNumber): + (JSValueMakeString): + * JavaScriptCore.exp: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitLoad): + * VM/JSPropertyNameIterator.cpp: + (KJS::JSPropertyNameIterator::create): + (KJS::JSPropertyNameIterator::next): + * VM/Machine.cpp: + (KJS::jsAddSlowCase): + (KJS::jsAdd): + (KJS::jsTypeStringForValue): + (KJS::scopeChainForCall): + (KJS::Machine::throwException): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + (KJS::Machine::retrieveArguments): + * kjs/ArrayPrototype.cpp: + (KJS::arrayProtoFuncToString): + (KJS::arrayProtoFuncToLocaleString): + (KJS::arrayProtoFuncJoin): + (KJS::arrayProtoFuncConcat): + (KJS::arrayProtoFuncPop): + (KJS::arrayProtoFuncPush): + (KJS::arrayProtoFuncShift): + (KJS::arrayProtoFuncSlice): + (KJS::arrayProtoFuncSplice): + (KJS::arrayProtoFuncUnShift): + (KJS::arrayProtoFuncFilter): + (KJS::arrayProtoFuncMap): + (KJS::arrayProtoFuncEvery): + (KJS::arrayProtoFuncForEach): + (KJS::arrayProtoFuncSome): + (KJS::arrayProtoFuncIndexOf): + (KJS::arrayProtoFuncLastIndexOf): + (KJS::ArrayConstructor::ArrayConstructor): + (KJS::ArrayConstructor::construct): + (KJS::ArrayConstructor::callAsFunction): + * kjs/BooleanObject.cpp: + (KJS::BooleanPrototype::BooleanPrototype): + (KJS::booleanProtoFuncToString): + (KJS::BooleanConstructor::BooleanConstructor): + (KJS::BooleanConstructor::construct): + * kjs/FunctionPrototype.cpp: + (KJS::FunctionPrototype::FunctionPrototype): + (KJS::functionProtoFuncToString): + (KJS::FunctionConstructor::FunctionConstructor): + (KJS::FunctionConstructor::construct): + * kjs/JSActivation.cpp: + (KJS::JSActivation::createArgumentsObject): + * kjs/JSArray.cpp: + (KJS::JSArray::JSArray): + (KJS::JSArray::lengthGetter): + * kjs/JSFunction.cpp: + (KJS::JSFunction::lengthGetter): + (KJS::JSFunction::construct): + (KJS::Arguments::Arguments): + (KJS::encode): + (KJS::decode): + (KJS::globalFuncParseInt): + (KJS::globalFuncParseFloat): + (KJS::globalFuncEscape): + (KJS::globalFuncUnescape): + (KJS::PrototypeFunction::PrototypeFunction): + (KJS::PrototypeReflexiveFunction::PrototypeReflexiveFunction): + * kjs/JSImmediate.cpp: + (KJS::JSImmediate::toObject): + * kjs/JSLock.cpp: + (KJS::JSLock::registerThread): + * kjs/JSObject.cpp: + (KJS::JSObject::put): + (KJS::JSObject::defineGetter): + (KJS::JSObject::defineSetter): + (KJS::Error::create): + * kjs/JSObject.h: + (KJS::JSObject::putDirect): + * kjs/JSString.h: + (KJS::JSString::JSString): + * kjs/JSValue.cpp: + (KJS::JSCell::operator new): + (KJS::jsString): + (KJS::jsOwnedString): + * kjs/JSValue.h: + (KJS::JSNumberCell::operator new): + (KJS::jsNumberCell): + (KJS::jsNaN): + (KJS::jsNumber): + (KJS::JSCell::marked): + (KJS::JSCell::mark): + (KJS::JSValue::toJSNumber): + * kjs/MathObject.cpp: + (KJS::MathObject::getValueProperty): + (KJS::mathProtoFuncAbs): + (KJS::mathProtoFuncACos): + (KJS::mathProtoFuncASin): + (KJS::mathProtoFuncATan): + (KJS::mathProtoFuncATan2): + (KJS::mathProtoFuncCeil): + (KJS::mathProtoFuncCos): + (KJS::mathProtoFuncExp): + (KJS::mathProtoFuncFloor): + (KJS::mathProtoFuncLog): + (KJS::mathProtoFuncMax): + (KJS::mathProtoFuncMin): + (KJS::mathProtoFuncPow): + (KJS::mathProtoFuncRandom): + (KJS::mathProtoFuncRound): + (KJS::mathProtoFuncSin): + (KJS::mathProtoFuncSqrt): + (KJS::mathProtoFuncTan): + * kjs/NumberObject.cpp: + (KJS::NumberPrototype::NumberPrototype): + (KJS::numberProtoFuncToString): + (KJS::numberProtoFuncToLocaleString): + (KJS::numberProtoFuncToFixed): + (KJS::numberProtoFuncToExponential): + (KJS::numberProtoFuncToPrecision): + (KJS::NumberConstructor::NumberConstructor): + (KJS::NumberConstructor::getValueProperty): + (KJS::NumberConstructor::construct): + (KJS::NumberConstructor::callAsFunction): + * kjs/RegExpObject.cpp: + (KJS::RegExpPrototype::RegExpPrototype): + (KJS::regExpProtoFuncToString): + (KJS::RegExpObject::getValueProperty): + (KJS::RegExpConstructor::RegExpConstructor): + (KJS::RegExpMatchesArray::fillArrayInstance): + (KJS::RegExpConstructor::arrayOfMatches): + (KJS::RegExpConstructor::getBackref): + (KJS::RegExpConstructor::getLastParen): + (KJS::RegExpConstructor::getLeftContext): + (KJS::RegExpConstructor::getRightContext): + (KJS::RegExpConstructor::getValueProperty): + (KJS::RegExpConstructor::construct): + * kjs/RegExpObject.h: + * kjs/Shell.cpp: + (GlobalObject::GlobalObject): + (functionGC): + (functionRun): + (functionReadline): + (jscmain): + * kjs/date_object.cpp: + (KJS::formatLocaleDate): + (KJS::DatePrototype::DatePrototype): + (KJS::DateConstructor::DateConstructor): + (KJS::DateConstructor::construct): + (KJS::DateConstructor::callAsFunction): + (KJS::DateFunction::DateFunction): + (KJS::DateFunction::callAsFunction): + (KJS::dateProtoFuncToString): + (KJS::dateProtoFuncToUTCString): + (KJS::dateProtoFuncToDateString): + (KJS::dateProtoFuncToTimeString): + (KJS::dateProtoFuncToLocaleString): + (KJS::dateProtoFuncToLocaleDateString): + (KJS::dateProtoFuncToLocaleTimeString): + (KJS::dateProtoFuncValueOf): + (KJS::dateProtoFuncGetTime): + (KJS::dateProtoFuncGetFullYear): + (KJS::dateProtoFuncGetUTCFullYear): + (KJS::dateProtoFuncToGMTString): + (KJS::dateProtoFuncGetMonth): + (KJS::dateProtoFuncGetUTCMonth): + (KJS::dateProtoFuncGetDate): + (KJS::dateProtoFuncGetUTCDate): + (KJS::dateProtoFuncGetDay): + (KJS::dateProtoFuncGetUTCDay): + (KJS::dateProtoFuncGetHours): + (KJS::dateProtoFuncGetUTCHours): + (KJS::dateProtoFuncGetMinutes): + (KJS::dateProtoFuncGetUTCMinutes): + (KJS::dateProtoFuncGetSeconds): + (KJS::dateProtoFuncGetUTCSeconds): + (KJS::dateProtoFuncGetMilliSeconds): + (KJS::dateProtoFuncGetUTCMilliseconds): + (KJS::dateProtoFuncGetTimezoneOffset): + (KJS::dateProtoFuncSetTime): + (KJS::setNewValueFromTimeArgs): + (KJS::setNewValueFromDateArgs): + (KJS::dateProtoFuncSetYear): + (KJS::dateProtoFuncGetYear): + * kjs/error_object.cpp: + (KJS::ErrorPrototype::ErrorPrototype): + (KJS::errorProtoFuncToString): + (KJS::ErrorConstructor::ErrorConstructor): + (KJS::ErrorConstructor::construct): + (KJS::NativeErrorPrototype::NativeErrorPrototype): + (KJS::NativeErrorConstructor::NativeErrorConstructor): + (KJS::NativeErrorConstructor::construct): + * kjs/identifier.h: + * kjs/internal.cpp: + (KJS::StringObject::create): + (KJS::JSString::lengthGetter): + (KJS::JSString::indexGetter): + (KJS::JSString::indexNumericPropertyGetter): + * kjs/interpreter.cpp: + * kjs/list.cpp: + (KJS::ArgList::slowAppend): + * kjs/list.h: + * kjs/lookup.h: + (KJS::staticFunctionGetter): + (KJS::cacheGlobalObject): + * kjs/nodes.cpp: + (KJS::Node::emitThrowError): + (KJS::StringNode::emitCode): + (KJS::ArrayNode::emitCode): + (KJS::FuncDeclNode::makeFunction): + (KJS::FuncExprNode::makeFunction): + * kjs/nodes.h: + * kjs/object_object.cpp: + (KJS::ObjectPrototype::ObjectPrototype): + (KJS::objectProtoFuncToLocaleString): + (KJS::objectProtoFuncToString): + (KJS::ObjectConstructor::ObjectConstructor): + (KJS::ObjectConstructor::construct): + * kjs/protect.h: + (KJS::gcProtect): + (KJS::gcUnprotect): + * kjs/string_object.cpp: + (KJS::StringObject::StringObject): + (KJS::StringPrototype::StringPrototype): + (KJS::replace): + (KJS::stringProtoFuncCharAt): + (KJS::stringProtoFuncCharCodeAt): + (KJS::stringProtoFuncConcat): + (KJS::stringProtoFuncIndexOf): + (KJS::stringProtoFuncLastIndexOf): + (KJS::stringProtoFuncMatch): + (KJS::stringProtoFuncSearch): + (KJS::stringProtoFuncReplace): + (KJS::stringProtoFuncSlice): + (KJS::stringProtoFuncSplit): + (KJS::stringProtoFuncSubstr): + (KJS::stringProtoFuncSubstring): + (KJS::stringProtoFuncToLowerCase): + (KJS::stringProtoFuncToUpperCase): + (KJS::stringProtoFuncToLocaleLowerCase): + (KJS::stringProtoFuncToLocaleUpperCase): + (KJS::stringProtoFuncLocaleCompare): + (KJS::stringProtoFuncBig): + (KJS::stringProtoFuncSmall): + (KJS::stringProtoFuncBlink): + (KJS::stringProtoFuncBold): + (KJS::stringProtoFuncFixed): + (KJS::stringProtoFuncItalics): + (KJS::stringProtoFuncStrike): + (KJS::stringProtoFuncSub): + (KJS::stringProtoFuncSup): + (KJS::stringProtoFuncFontcolor): + (KJS::stringProtoFuncFontsize): + (KJS::stringProtoFuncAnchor): + (KJS::stringProtoFuncLink): + (KJS::StringConstructor::StringConstructor): + (KJS::StringConstructor::construct): + (KJS::StringConstructor::callAsFunction): + (KJS::StringConstructorFunction::StringConstructorFunction): + (KJS::StringConstructorFunction::callAsFunction): + * kjs/string_object.h: + (KJS::StringObjectThatMasqueradesAsUndefined::StringObjectThatMasqueradesAsUndefined): + * kjs/ustring.h: + Updated for the above changes. + +2008-06-17 Timothy Hatcher + + Added a type to DebuggerCallFrame so the under interface can + distinguish anonymous functions and program call frames. + + https://bugs.webkit.org/show_bug.cgi?id=19585 + + Reviewed by Geoff Garen. + + * JavaScriptCore.exp: Export the DebuggerCallFrame::type symbol. + * kjs/DebuggerCallFrame.cpp: + (KJS::DebuggerCallFrame::type): Added. + * kjs/DebuggerCallFrame.h: + +2008-06-17 Eric Seidel + + Reviewed by Tim H. + + Remove bogus ASSERT which tripped every time for those who use PAC files. + + * kjs/Parser.cpp: + (KJS::Parser::parse): + +2008-06-17 Kevin McCullough + + Reviewed by Geoff. + + JSProfiler: Don't profile console.profile() + or console.profileEnd() + + * profiler/Profile.cpp: + (KJS::Profile::stopProfiling): Moved the creation of the (idle) node to + the Profile (not ProfileNode). This makes sense since the Profile + should be the one to modify the profile tree. Also each stopProfiling() + does not need to check if it's the head node anymore. Also fixed an + oddity where I was using willExecute to create the node. + (KJS::Profile::removeProfileStart): Removes the call to console.profile + that started this profile. + (KJS::Profile::removeProfileEnd): Removes the call to console.profileEnd + that ended this profile. + * profiler/Profile.h: + * profiler/ProfileNode.cpp: Moved the creation of the (idle) node to + the Profile object. + (KJS::ProfileNode::stopProfiling): + * profiler/ProfileNode.h: Added some helper functions and whitespace to + facilitate readability and the removal of profile() and profileEnd() + from the Profile tree. + (KJS::CallIdentifier::operator const char* ): + (KJS::ProfileNode::firstChild): + (KJS::ProfileNode::lastChild): + (KJS::ProfileNode::removeChild): + (KJS::ProfileNode::toString): + +2008-06-17 Ariya Hidayat + + Rubber stamped by Adam Roben. + + Include JSGlobalObject.h to fix the build. + + * kjs/ScopeChain.cpp: + +2008-06-17 Cameron Zwarich + + Reviewed by Oliver. + + Reduce code duplication in emitReadModifyAssignment(). + + * kjs/nodes.cpp: + (KJS::emitReadModifyAssignment): + +2008-06-17 Cameron Zwarich + + Reviewed by Oliver. + + Sort includes alphabetically. + + * kjs/nodes.cpp: + +2008-06-16 Cameron Zwarich + + Reviewed by Maciej. + + Bug 19596: LEAK: Gmail leaks SegmentedVector + + + When growing SegmentedVector, we start adding segments at the position + of the last segment, overwriting it. The destructor frees allocated + segments starting at the segment of index 1, because the segment of + index 0 is assumed to be the initial inline segment. This causes a leak + of the segment that is referenced by index 0. Modifying grow() so that + it starts adding segments at the position after the last segment fixes + the leak. + + Since the initial segment is a special case in the lookup code, this + bug never manifested itself via incorrect results. + + * VM/SegmentedVector.h: + (KJS::SegmentedVector::grow): + +2008-06-16 Maciej Stachowiak + + Reviewed by Alexey. + + - removed nearly unused types.h and LocalStorageEntry.h headers + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/ExecState.h: + * kjs/LocalStorageEntry.h: Removed. + * kjs/RegExpObject.cpp: + * kjs/error_object.cpp: + * kjs/grammar.y: + * kjs/nodes.cpp: + * kjs/types.h: Removed. + +2008-06-16 Alp Toker + + Rubber-stamped by Geoff. + + Change c++ to c in minidom and testapi emacs mode line comments. + + * API/Node.h: + * API/NodeList.c: + * API/NodeList.h: + * API/testapi.c: + +2008-06-16 Alexey Proskuryakov + + Trying to fix Windows build. + + * kjs/PropertyNameArray.h: + * kjs/identifier.cpp: + Include ExecState.h + +2008-06-16 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Slight cleanup to the SymbolTableEntry class. + + Renamed isEmpty to isNull, since we usually use "empty" to mean "holds + the valid, empty value", and "null" to mean "holds no value". + + Changed an "== 0" to a "!", to match our style guidelines. + + Added some ASSERTs to verify the (possibly questionable) assumption that + all register indexes will have their high two bits set. Also clarified a + comment to make that assumption clear. + +2008-06-16 Alexey Proskuryakov + + Reviewed by Darin. + + Initialize functionQueueMutex in a safe manner. + + * wtf/MainThread.cpp: + (WTF::functionQueueMutex): Made it an AtomicallyInitializedStatic. + + (WTF::dispatchFunctionsFromMainThread): + (WTF::setMainThreadCallbacksPaused): + Assert that the current thread is main, meaning that the callbacksPaused static can be + accessed. + +2008-06-16 Alexey Proskuryakov + + Reviewed by Geoff Garen. + + Make Identifier construction use an explicitly passed IdentifierTable. + + No change on SunSpider total. + + * API/JSCallbackObjectFunctions.h: + (KJS::::getOwnPropertySlot): + (KJS::::put): + (KJS::::deleteProperty): + (KJS::::getPropertyNames): + * API/JSObjectRef.cpp: + (JSObjectMakeFunctionWithCallback): + (JSObjectMakeFunction): + (JSObjectHasProperty): + (JSObjectGetProperty): + (JSObjectSetProperty): + (JSObjectDeleteProperty): + (OpaqueJSPropertyNameArray::OpaqueJSPropertyNameArray): + (JSObjectCopyPropertyNames): + * JavaScriptCore.exp: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::registerForLocal): + (KJS::CodeGenerator::isLocal): + (KJS::CodeGenerator::addConstant): + (KJS::CodeGenerator::findScopedProperty): + * VM/CodeGenerator.h: + (KJS::CodeGenerator::globalData): + (KJS::CodeGenerator::propertyNames): + * VM/JSPropertyNameIterator.cpp: + (KJS::JSPropertyNameIterator::create): + * VM/Machine.cpp: + (KJS::Machine::throwException): + (KJS::Machine::privateExecute): + * kjs/ArrayPrototype.cpp: + (KJS::ArrayConstructor::ArrayConstructor): + * kjs/BooleanObject.cpp: + (KJS::BooleanConstructor::BooleanConstructor): + * kjs/FunctionPrototype.cpp: + (KJS::FunctionConstructor::FunctionConstructor): + (KJS::FunctionConstructor::construct): + * kjs/JSArray.cpp: + (KJS::JSArray::inlineGetOwnPropertySlot): + (KJS::JSArray::put): + (KJS::JSArray::deleteProperty): + (KJS::JSArray::getPropertyNames): + * kjs/JSFunction.cpp: + (KJS::Arguments::Arguments): + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): + * kjs/JSObject.cpp: + (KJS::JSObject::getOwnPropertySlot): + (KJS::JSObject::put): + (KJS::JSObject::putWithAttributes): + (KJS::JSObject::deleteProperty): + (KJS::JSObject::findPropertyHashEntry): + (KJS::JSObject::getPropertyNames): + (KJS::Error::create): + * kjs/JSVariableObject.cpp: + (KJS::JSVariableObject::getPropertyNames): + * kjs/NumberObject.cpp: + (KJS::NumberConstructor::NumberConstructor): + * kjs/PropertyNameArray.cpp: + (KJS::PropertyNameArray::add): + * kjs/PropertyNameArray.h: + (KJS::PropertyNameArray::PropertyNameArray): + (KJS::PropertyNameArray::addKnownUnique): + * kjs/PropertySlot.h: + (KJS::PropertySlot::getValue): + * kjs/RegExpObject.cpp: + (KJS::RegExpConstructor::RegExpConstructor): + * kjs/ScopeChain.cpp: + (KJS::ScopeChainNode::print): + * kjs/Shell.cpp: + (GlobalObject::GlobalObject): + * kjs/date_object.cpp: + (KJS::DateConstructor::DateConstructor): + * kjs/error_object.cpp: + (KJS::ErrorConstructor::ErrorConstructor): + (KJS::NativeErrorConstructor::NativeErrorConstructor): + * kjs/grammar.y: + * kjs/identifier.cpp: + (KJS::Identifier::add): + (KJS::Identifier::addSlowCase): + * kjs/identifier.h: + (KJS::Identifier::Identifier): + (KJS::Identifier::from): + (KJS::Identifier::equal): + (KJS::Identifier::add): + (KJS::operator==): + (KJS::operator!=): + * kjs/internal.cpp: + (KJS::JSString::getOwnPropertySlot): + * kjs/lexer.cpp: + (KJS::Lexer::Lexer): + (KJS::Lexer::lex): + (KJS::Lexer::makeIdentifier): + * kjs/lexer.h: + * kjs/lookup.cpp: + (KJS::HashTable::createTable): + * kjs/lookup.h: + (KJS::HashTable::initializeIfNeeded): + (KJS::HashTable::entry): + (KJS::getStaticPropertySlot): + (KJS::getStaticFunctionSlot): + (KJS::getStaticValueSlot): + (KJS::lookupPut): + * kjs/object_object.cpp: + (KJS::objectProtoFuncHasOwnProperty): + (KJS::objectProtoFuncDefineGetter): + (KJS::objectProtoFuncDefineSetter): + (KJS::objectProtoFuncLookupGetter): + (KJS::objectProtoFuncLookupSetter): + (KJS::objectProtoFuncPropertyIsEnumerable): + (KJS::ObjectConstructor::ObjectConstructor): + * kjs/string_object.cpp: + (KJS::StringObject::getOwnPropertySlot): + (KJS::StringObject::getPropertyNames): + (KJS::StringConstructor::StringConstructor): + Just pass ExecState or JSGlobalData everywhere. Identifier construction is now always + explicit. + + * kjs/nodes.cpp: (KJS::RegExpNode::emitCode): Here, Identifier was created from a non-literal + char*, which was incorrect, as that uses the pointer value as a key. + +2008-06-16 Thiago Macieira + + Reviewed by Darin. + + https://bugs.webkit.org/show_bug.cgi?id=19577 + + Fix compilation in C++ environments where C99 headers are not present + + The stdbool.h header is a C99 feature, defining the "_Bool" type as well as the + "true" and "false" constants. But it's completely unnecessary in C++ as the + language already defines the "bool" type and its two values. + + * API/JSBase.h: + * API/JSContextRef.h: + * API/JSObjectRef.h: + * API/JSStringRef.h: + * API/JSValueRef.h: + +2008-06-16 Kevin McCullough + + Reviewed by John. + + JSProfiler: %s are incorrect if you exclude a + top level node like (idle) + + * profiler/Profile.cpp: + (KJS::Profile::focus): + (KJS::Profile::exclude): Subtract the selfTime from the totalTime of the + head since its self time will only be non-zero when one of its children + were excluded. Since the head's totalTime is used to calculate %s when + its totalTime is the same as the sum of all its visible childrens' times + their %s will sum to 100%. + +2008-06-16 Kevin McCullough + + Reviewed by Sam Weinig. + + JSProfiler: Remove the recursion limit in the profiler. + + * profiler/Profile.cpp: + (KJS::Profile::willExecute): + +2008-06-16 Kevin McCullough + + Reviewed by Sam. + + JSProfiler: Remove the recursion limit in the + profiler. + - Remove the last of the uses of recursion in the profiler. + + * JavaScriptCore.exp: Export the new function's signature. + * profiler/Profile.cpp: + (KJS::calculateVisibleTotalTime): Added a new static method for + recalculating the visibleTotalTime of methods after focus has changed + which are visible. + (KJS::stopProfiling): + (KJS::Profile::focus): Implemented focus without recursion. + * profiler/Profile.h: Moved implementation into the definition file. + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::traverseNextNodePreOrder): Added an argument for + whether or not to process the children nodes, this allows focus to skip + sub trees which have been set as not visible. + (KJS::ProfileNode::calculateVisibleTotalTime): This function set's a + node's total visible time to the sum of its self time and its children's + total times. + (KJS::ProfileNode::focus): Implemented focus without recursion. + * profiler/ProfileNode.h: + (KJS::CallIdentifier::operator!= ): + (KJS::ProfileNode::setActualTotalTime): Expanded setting the total time + so that focus could modify only the visible total time. + (KJS::ProfileNode::setVisibleTotalTime): + +2008-06-16 Christian Dywan + + Reviewed by Sam. + + https://bugs.webkit.org/show_bug.cgi?id=19552 + JavaScriptCore headers use C++ style comments + + Replace all C++ style comments with C style multiline + comments and remove all "mode" lines. + + * API/JSBase.h: + * API/JSClassRef.h: + * API/JSContextRef.h: + * API/JSObjectRef.h: + * API/JSStringRef.h: + * API/JSStringRefBSTR.h: + * API/JSStringRefCF.h: + * API/JSValueRef.h: + * API/JavaScript.h: + * API/JavaScriptCore.h: + +2008-06-16 Christian Dywan + + Reviewed by Sam. + + https://bugs.webkit.org/show_bug.cgi?id=19557 + (JavaScriptCore) minidom uses C++ style comments + + Use only C style comments in minidom sources + + * API/JSNode.c: + (JSNode_appendChild): + (JSNode_removeChild): + * API/JSNode.h: + * API/JSNodeList.c: + (JSNodeList_getProperty): + * API/JSNodeList.h: + * API/Node.c: + * API/Node.h: + * API/NodeList.c: + (NodeList_new): + (NodeList_item): + * API/NodeList.h: + * API/minidom.c: + (createStringWithContentsOfFile): + * wtf/Assertions.h: + * wtf/UnusedParam.h: + +2008-06-16 Adriaan de Groot + + Reviewed by Simon. + + Fix compilation on Solaris + + On some systems, munmap takes a char* instead of a void* (contrary to POSIX and + Single Unix Specification). Since you can always convert from char* to void* + but not vice-versa, do the casting to char*. + + * kjs/collector.cpp: + (KJS::allocateBlock): + (KJS::freeBlock): + +2008-06-16 Cameron Zwarich + + Reviewed by Maciej. + + Make a UnaryOpNode class to reduce boilerplate code for UnaryPlusNode, + NegateNode, BitwiseNotNode, and LogicalNotNode. + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::emitToJSNumber): + * kjs/nodes.cpp: + (KJS::UnaryOpNode::emitCode): + * kjs/nodes.h: + (KJS::UnaryOpNode::UnaryOpNode): + (KJS::UnaryPlusNode::): + (KJS::NegateNode::): + (KJS::NegateNode::precedence): + (KJS::BitwiseNotNode::): + (KJS::BitwiseNotNode::precedence): + (KJS::LogicalNotNode::): + (KJS::LogicalNotNode::precedence): + +2008-06-16 Jan Michael Alonzo + + Gtk build fix + + * GNUmakefile.am: + +2008-06-15 Darin Adler + + - rename KJS::List to KJS::ArgList + + * API/JSCallbackConstructor.cpp: + (KJS::JSCallbackConstructor::construct): + * API/JSCallbackConstructor.h: + * API/JSCallbackFunction.cpp: + (KJS::JSCallbackFunction::callAsFunction): + * API/JSCallbackFunction.h: + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + (KJS::::construct): + (KJS::::callAsFunction): + * API/JSObjectRef.cpp: + (JSObjectMakeFunction): + (JSObjectCallAsFunction): + (JSObjectCallAsConstructor): + * JavaScriptCore.exp: + * VM/Machine.cpp: + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * VM/Machine.h: + * kjs/ArrayPrototype.cpp: + (KJS::arrayProtoFuncToString): + (KJS::arrayProtoFuncToLocaleString): + (KJS::arrayProtoFuncJoin): + (KJS::arrayProtoFuncConcat): + (KJS::arrayProtoFuncPop): + (KJS::arrayProtoFuncPush): + (KJS::arrayProtoFuncReverse): + (KJS::arrayProtoFuncShift): + (KJS::arrayProtoFuncSlice): + (KJS::arrayProtoFuncSort): + (KJS::arrayProtoFuncSplice): + (KJS::arrayProtoFuncUnShift): + (KJS::arrayProtoFuncFilter): + (KJS::arrayProtoFuncMap): + (KJS::arrayProtoFuncEvery): + (KJS::arrayProtoFuncForEach): + (KJS::arrayProtoFuncSome): + (KJS::arrayProtoFuncIndexOf): + (KJS::arrayProtoFuncLastIndexOf): + (KJS::ArrayConstructor::construct): + (KJS::ArrayConstructor::callAsFunction): + * kjs/ArrayPrototype.h: + * kjs/BooleanObject.cpp: + (KJS::booleanProtoFuncToString): + (KJS::booleanProtoFuncValueOf): + (KJS::BooleanConstructor::construct): + (KJS::BooleanConstructor::callAsFunction): + * kjs/BooleanObject.h: + * kjs/CommonIdentifiers.h: + * kjs/ExecState.h: + (KJS::ExecState::emptyList): + * kjs/FunctionPrototype.cpp: + (KJS::FunctionPrototype::callAsFunction): + (KJS::functionProtoFuncToString): + (KJS::functionProtoFuncApply): + (KJS::functionProtoFuncCall): + (KJS::FunctionConstructor::construct): + (KJS::FunctionConstructor::callAsFunction): + * kjs/FunctionPrototype.h: + * kjs/JSActivation.cpp: + (KJS::JSActivation::createArgumentsObject): + * kjs/JSArray.cpp: + (KJS::JSArray::JSArray): + (KJS::AVLTreeAbstractorForArrayCompare::compare_key_key): + * kjs/JSArray.h: + * kjs/JSFunction.cpp: + (KJS::JSFunction::callAsFunction): + (KJS::JSFunction::construct): + (KJS::IndexToNameMap::IndexToNameMap): + (KJS::Arguments::Arguments): + (KJS::encode): + (KJS::decode): + (KJS::globalFuncEval): + (KJS::globalFuncParseInt): + (KJS::globalFuncParseFloat): + (KJS::globalFuncIsNaN): + (KJS::globalFuncIsFinite): + (KJS::globalFuncDecodeURI): + (KJS::globalFuncDecodeURIComponent): + (KJS::globalFuncEncodeURI): + (KJS::globalFuncEncodeURIComponent): + (KJS::globalFuncEscape): + (KJS::globalFuncUnescape): + (KJS::globalFuncKJSPrint): + (KJS::PrototypeFunction::callAsFunction): + (KJS::PrototypeReflexiveFunction::callAsFunction): + * kjs/JSFunction.h: + * kjs/JSGlobalData.h: + * kjs/JSImmediate.cpp: + (KJS::JSImmediate::toObject): + * kjs/JSNotAnObject.cpp: + (KJS::JSNotAnObject::construct): + (KJS::JSNotAnObject::callAsFunction): + * kjs/JSNotAnObject.h: + * kjs/JSObject.cpp: + (KJS::JSObject::put): + (KJS::JSObject::construct): + (KJS::JSObject::callAsFunction): + (KJS::Error::create): + * kjs/JSObject.h: + * kjs/MathObject.cpp: + (KJS::mathProtoFuncAbs): + (KJS::mathProtoFuncACos): + (KJS::mathProtoFuncASin): + (KJS::mathProtoFuncATan): + (KJS::mathProtoFuncATan2): + (KJS::mathProtoFuncCeil): + (KJS::mathProtoFuncCos): + (KJS::mathProtoFuncExp): + (KJS::mathProtoFuncFloor): + (KJS::mathProtoFuncLog): + (KJS::mathProtoFuncMax): + (KJS::mathProtoFuncMin): + (KJS::mathProtoFuncPow): + (KJS::mathProtoFuncRandom): + (KJS::mathProtoFuncRound): + (KJS::mathProtoFuncSin): + (KJS::mathProtoFuncSqrt): + (KJS::mathProtoFuncTan): + * kjs/MathObject.h: + * kjs/NumberObject.cpp: + (KJS::numberProtoFuncToString): + (KJS::numberProtoFuncToLocaleString): + (KJS::numberProtoFuncValueOf): + (KJS::numberProtoFuncToFixed): + (KJS::numberProtoFuncToExponential): + (KJS::numberProtoFuncToPrecision): + (KJS::NumberConstructor::construct): + (KJS::NumberConstructor::callAsFunction): + * kjs/NumberObject.h: + * kjs/RegExpObject.cpp: + (KJS::regExpProtoFuncTest): + (KJS::regExpProtoFuncExec): + (KJS::regExpProtoFuncCompile): + (KJS::regExpProtoFuncToString): + (KJS::RegExpObject::match): + (KJS::RegExpObject::test): + (KJS::RegExpObject::exec): + (KJS::RegExpObject::callAsFunction): + (KJS::RegExpConstructor::construct): + (KJS::RegExpConstructor::callAsFunction): + * kjs/RegExpObject.h: + * kjs/Shell.cpp: + (functionPrint): + (functionDebug): + (functionGC): + (functionVersion): + (functionRun): + (functionLoad): + (functionReadline): + (functionQuit): + * kjs/collector.cpp: + (KJS::Collector::collect): + * kjs/collector.h: + (KJS::Collector::markListSet): + * kjs/date_object.cpp: + (KJS::formatLocaleDate): + (KJS::fillStructuresUsingTimeArgs): + (KJS::fillStructuresUsingDateArgs): + (KJS::DateConstructor::construct): + (KJS::DateConstructor::callAsFunction): + (KJS::DateFunction::callAsFunction): + (KJS::dateProtoFuncToString): + (KJS::dateProtoFuncToUTCString): + (KJS::dateProtoFuncToDateString): + (KJS::dateProtoFuncToTimeString): + (KJS::dateProtoFuncToLocaleString): + (KJS::dateProtoFuncToLocaleDateString): + (KJS::dateProtoFuncToLocaleTimeString): + (KJS::dateProtoFuncValueOf): + (KJS::dateProtoFuncGetTime): + (KJS::dateProtoFuncGetFullYear): + (KJS::dateProtoFuncGetUTCFullYear): + (KJS::dateProtoFuncToGMTString): + (KJS::dateProtoFuncGetMonth): + (KJS::dateProtoFuncGetUTCMonth): + (KJS::dateProtoFuncGetDate): + (KJS::dateProtoFuncGetUTCDate): + (KJS::dateProtoFuncGetDay): + (KJS::dateProtoFuncGetUTCDay): + (KJS::dateProtoFuncGetHours): + (KJS::dateProtoFuncGetUTCHours): + (KJS::dateProtoFuncGetMinutes): + (KJS::dateProtoFuncGetUTCMinutes): + (KJS::dateProtoFuncGetSeconds): + (KJS::dateProtoFuncGetUTCSeconds): + (KJS::dateProtoFuncGetMilliSeconds): + (KJS::dateProtoFuncGetUTCMilliseconds): + (KJS::dateProtoFuncGetTimezoneOffset): + (KJS::dateProtoFuncSetTime): + (KJS::setNewValueFromTimeArgs): + (KJS::setNewValueFromDateArgs): + (KJS::dateProtoFuncSetMilliSeconds): + (KJS::dateProtoFuncSetUTCMilliseconds): + (KJS::dateProtoFuncSetSeconds): + (KJS::dateProtoFuncSetUTCSeconds): + (KJS::dateProtoFuncSetMinutes): + (KJS::dateProtoFuncSetUTCMinutes): + (KJS::dateProtoFuncSetHours): + (KJS::dateProtoFuncSetUTCHours): + (KJS::dateProtoFuncSetDate): + (KJS::dateProtoFuncSetUTCDate): + (KJS::dateProtoFuncSetMonth): + (KJS::dateProtoFuncSetUTCMonth): + (KJS::dateProtoFuncSetFullYear): + (KJS::dateProtoFuncSetUTCFullYear): + (KJS::dateProtoFuncSetYear): + (KJS::dateProtoFuncGetYear): + * kjs/date_object.h: + * kjs/debugger.h: + * kjs/error_object.cpp: + (KJS::errorProtoFuncToString): + (KJS::ErrorConstructor::construct): + (KJS::ErrorConstructor::callAsFunction): + (KJS::NativeErrorConstructor::construct): + (KJS::NativeErrorConstructor::callAsFunction): + * kjs/error_object.h: + * kjs/internal.cpp: + (KJS::JSNumberCell::toObject): + (KJS::JSNumberCell::toThisObject): + * kjs/list.cpp: + (KJS::ArgList::getSlice): + (KJS::ArgList::markLists): + (KJS::ArgList::slowAppend): + * kjs/list.h: + (KJS::ArgList::ArgList): + (KJS::ArgList::~ArgList): + * kjs/object_object.cpp: + (KJS::objectProtoFuncValueOf): + (KJS::objectProtoFuncHasOwnProperty): + (KJS::objectProtoFuncIsPrototypeOf): + (KJS::objectProtoFuncDefineGetter): + (KJS::objectProtoFuncDefineSetter): + (KJS::objectProtoFuncLookupGetter): + (KJS::objectProtoFuncLookupSetter): + (KJS::objectProtoFuncPropertyIsEnumerable): + (KJS::objectProtoFuncToLocaleString): + (KJS::objectProtoFuncToString): + (KJS::ObjectConstructor::construct): + (KJS::ObjectConstructor::callAsFunction): + * kjs/object_object.h: + * kjs/string_object.cpp: + (KJS::replace): + (KJS::stringProtoFuncToString): + (KJS::stringProtoFuncValueOf): + (KJS::stringProtoFuncCharAt): + (KJS::stringProtoFuncCharCodeAt): + (KJS::stringProtoFuncConcat): + (KJS::stringProtoFuncIndexOf): + (KJS::stringProtoFuncLastIndexOf): + (KJS::stringProtoFuncMatch): + (KJS::stringProtoFuncSearch): + (KJS::stringProtoFuncReplace): + (KJS::stringProtoFuncSlice): + (KJS::stringProtoFuncSplit): + (KJS::stringProtoFuncSubstr): + (KJS::stringProtoFuncSubstring): + (KJS::stringProtoFuncToLowerCase): + (KJS::stringProtoFuncToUpperCase): + (KJS::stringProtoFuncToLocaleLowerCase): + (KJS::stringProtoFuncToLocaleUpperCase): + (KJS::stringProtoFuncLocaleCompare): + (KJS::stringProtoFuncBig): + (KJS::stringProtoFuncSmall): + (KJS::stringProtoFuncBlink): + (KJS::stringProtoFuncBold): + (KJS::stringProtoFuncFixed): + (KJS::stringProtoFuncItalics): + (KJS::stringProtoFuncStrike): + (KJS::stringProtoFuncSub): + (KJS::stringProtoFuncSup): + (KJS::stringProtoFuncFontcolor): + (KJS::stringProtoFuncFontsize): + (KJS::stringProtoFuncAnchor): + (KJS::stringProtoFuncLink): + (KJS::StringConstructor::construct): + (KJS::StringConstructor::callAsFunction): + (KJS::StringConstructorFunction::callAsFunction): + * kjs/string_object.h: + +2008-06-15 Darin Adler + + - new names for more JavaScriptCore files + + * API/JSCallbackFunction.cpp: + * API/JSObjectRef.cpp: + * DerivedSources.make: + * GNUmakefile.am: + * JavaScriptCore.exp: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * VM/Machine.cpp: + * kjs/AllInOneFile.cpp: + * kjs/ArrayPrototype.cpp: Copied from JavaScriptCore/kjs/array_object.cpp. + * kjs/ArrayPrototype.h: Copied from JavaScriptCore/kjs/array_object.h. + * kjs/BooleanObject.cpp: Copied from JavaScriptCore/kjs/bool_object.cpp. + * kjs/BooleanObject.h: Copied from JavaScriptCore/kjs/bool_object.h. + * kjs/ExecState.cpp: + * kjs/ExecState.h: + * kjs/FunctionPrototype.cpp: Copied from JavaScriptCore/kjs/function_object.cpp. + * kjs/FunctionPrototype.h: Copied from JavaScriptCore/kjs/function_object.h. + * kjs/JSArray.cpp: Copied from JavaScriptCore/kjs/array_instance.cpp. + * kjs/JSArray.h: Copied from JavaScriptCore/kjs/array_instance.h. + * kjs/JSFunction.cpp: + * kjs/JSFunction.h: + * kjs/JSGlobalObject.cpp: + * kjs/JSImmediate.cpp: + * kjs/JSObject.h: + * kjs/JSString.h: + * kjs/JSValue.h: + * kjs/JSVariableObject.cpp: + * kjs/MathObject.cpp: Copied from JavaScriptCore/kjs/math_object.cpp. + * kjs/MathObject.h: Copied from JavaScriptCore/kjs/math_object.h. + * kjs/NumberObject.cpp: Copied from JavaScriptCore/kjs/number_object.cpp. + * kjs/NumberObject.h: Copied from JavaScriptCore/kjs/number_object.h. + * kjs/PropertyMap.cpp: Copied from JavaScriptCore/kjs/property_map.cpp. + * kjs/PropertyMap.h: Copied from JavaScriptCore/kjs/property_map.h. + * kjs/PropertySlot.cpp: Copied from JavaScriptCore/kjs/property_slot.cpp. + * kjs/PropertySlot.h: Copied from JavaScriptCore/kjs/property_slot.h. + * kjs/RegExpObject.cpp: Copied from JavaScriptCore/kjs/regexp_object.cpp. + * kjs/RegExpObject.h: Copied from JavaScriptCore/kjs/regexp_object.h. + * kjs/ScopeChain.cpp: Copied from JavaScriptCore/kjs/scope_chain.cpp. + * kjs/ScopeChain.h: Copied from JavaScriptCore/kjs/scope_chain.h. + * kjs/ScopeChainMark.h: Copied from JavaScriptCore/kjs/scope_chain_mark.h. + * kjs/Shell.cpp: + * kjs/array_instance.cpp: Removed. + * kjs/array_instance.h: Removed. + * kjs/array_object.cpp: Removed. + * kjs/array_object.h: Removed. + * kjs/bool_object.cpp: Removed. + * kjs/bool_object.h: Removed. + * kjs/error_object.h: + * kjs/function_object.cpp: Removed. + * kjs/function_object.h: Removed. + * kjs/internal.cpp: + * kjs/math_object.cpp: Removed. + * kjs/math_object.h: Removed. + * kjs/nodes.cpp: + * kjs/number_object.cpp: Removed. + * kjs/number_object.h: Removed. + * kjs/object_object.cpp: + * kjs/property_map.cpp: Removed. + * kjs/property_map.h: Removed. + * kjs/property_slot.cpp: Removed. + * kjs/property_slot.h: Removed. + * kjs/regexp_object.cpp: Removed. + * kjs/regexp_object.h: Removed. + * kjs/scope_chain.cpp: Removed. + * kjs/scope_chain.h: Removed. + * kjs/scope_chain_mark.h: Removed. + * kjs/string_object.cpp: + * kjs/string_object.h: + +2008-06-15 Darin Adler + + - new names for a few key JavaScriptCore files + + * API/JSBase.cpp: + * API/JSCallbackConstructor.h: + * API/JSCallbackFunction.cpp: + * API/JSCallbackFunction.h: + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + * API/JSClassRef.h: + * API/JSContextRef.cpp: + * API/JSObjectRef.cpp: + * API/JSStringRef.cpp: + * API/JSStringRefCF.cpp: + * API/JSValueRef.cpp: + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * VM/CodeBlock.cpp: + * VM/CodeGenerator.cpp: + * VM/ExceptionHelpers.cpp: + * VM/ExceptionHelpers.h: + * VM/JSPropertyNameIterator.cpp: + * VM/JSPropertyNameIterator.h: + * VM/Machine.cpp: + * kjs/AllInOneFile.cpp: + * kjs/DateMath.cpp: + * kjs/DebuggerCallFrame.cpp: + * kjs/ExecState.cpp: + * kjs/JSActivation.cpp: + * kjs/JSFunction.cpp: Copied from JavaScriptCore/kjs/function.cpp. + * kjs/JSFunction.h: Copied from JavaScriptCore/kjs/function.h. + * kjs/JSImmediate.cpp: + * kjs/JSNotAnObject.h: + * kjs/JSObject.cpp: Copied from JavaScriptCore/kjs/object.cpp. + * kjs/JSObject.h: Copied from JavaScriptCore/kjs/object.h. + * kjs/JSString.h: Copied from JavaScriptCore/kjs/internal.h. + * kjs/JSValue.cpp: Copied from JavaScriptCore/kjs/value.cpp. + * kjs/JSValue.h: Copied from JavaScriptCore/kjs/value.h. + * kjs/JSVariableObject.h: + * kjs/JSWrapperObject.h: + * kjs/Shell.cpp: + * kjs/SymbolTable.h: + * kjs/array_instance.h: + * kjs/collector.cpp: + * kjs/date_object.cpp: + * kjs/date_object.h: + * kjs/error_object.cpp: + * kjs/function.cpp: Removed. + * kjs/function.h: Removed. + * kjs/function_object.cpp: + * kjs/function_object.h: + * kjs/grammar.y: + * kjs/internal.cpp: + * kjs/internal.h: Removed. + * kjs/lexer.cpp: + * kjs/list.h: + * kjs/lookup.h: + * kjs/nodes.h: + * kjs/object.cpp: Removed. + * kjs/object.h: Removed. + * kjs/object_object.h: + * kjs/operations.cpp: + * kjs/property_map.cpp: + * kjs/property_slot.cpp: + * kjs/property_slot.h: + * kjs/protect.h: + * kjs/regexp_object.cpp: + * kjs/scope_chain.cpp: + * kjs/string_object.h: + * kjs/ustring.cpp: + * kjs/value.cpp: Removed. + * kjs/value.h: Removed. + * profiler/Profile.cpp: + * profiler/Profiler.cpp: + +2008-06-15 Darin Adler + + Rubber stamped by Sam. + + - cut down on confusing uses of "Object" and "Imp" in + JavaScriptCore class names + + * API/JSCallbackFunction.cpp: + (KJS::JSCallbackFunction::JSCallbackFunction): + * API/JSCallbackFunction.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/ExecState.h: + (KJS::ExecState::regExpTable): + (KJS::ExecState::regExpConstructorTable): + * kjs/JSGlobalData.cpp: + (KJS::JSGlobalData::JSGlobalData): + (KJS::JSGlobalData::~JSGlobalData): + * kjs/JSGlobalData.h: + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::objectConstructor): + (KJS::JSGlobalObject::functionConstructor): + (KJS::JSGlobalObject::arrayConstructor): + (KJS::JSGlobalObject::booleanConstructor): + (KJS::JSGlobalObject::stringConstructor): + (KJS::JSGlobalObject::numberConstructor): + (KJS::JSGlobalObject::dateConstructor): + (KJS::JSGlobalObject::regExpConstructor): + (KJS::JSGlobalObject::errorConstructor): + (KJS::JSGlobalObject::evalErrorConstructor): + (KJS::JSGlobalObject::rangeErrorConstructor): + (KJS::JSGlobalObject::referenceErrorConstructor): + (KJS::JSGlobalObject::syntaxErrorConstructor): + (KJS::JSGlobalObject::typeErrorConstructor): + (KJS::JSGlobalObject::URIErrorConstructor): + * kjs/array_object.cpp: + (KJS::ArrayConstructor::ArrayConstructor): + (KJS::ArrayConstructor::getConstructData): + (KJS::ArrayConstructor::construct): + (KJS::ArrayConstructor::callAsFunction): + * kjs/array_object.h: + * kjs/bool_object.cpp: + (KJS::BooleanObject::BooleanObject): + (KJS::BooleanPrototype::BooleanPrototype): + (KJS::booleanProtoFuncToString): + (KJS::booleanProtoFuncValueOf): + (KJS::BooleanConstructor::BooleanConstructor): + (KJS::BooleanConstructor::getConstructData): + (KJS::BooleanConstructor::construct): + (KJS::BooleanConstructor::callAsFunction): + * kjs/bool_object.h: + * kjs/date_object.cpp: + (KJS::DatePrototype::DatePrototype): + (KJS::DateConstructor::DateConstructor): + (KJS::DateConstructor::getConstructData): + (KJS::DateConstructor::construct): + (KJS::DateConstructor::callAsFunction): + (KJS::DateFunction::DateFunction): + (KJS::DateFunction::callAsFunction): + * kjs/date_object.h: + * kjs/error_object.cpp: + (KJS::ErrorPrototype::ErrorPrototype): + (KJS::ErrorConstructor::ErrorConstructor): + (KJS::ErrorConstructor::getConstructData): + (KJS::ErrorConstructor::construct): + (KJS::ErrorConstructor::callAsFunction): + (KJS::NativeErrorConstructor::NativeErrorConstructor): + (KJS::NativeErrorConstructor::getConstructData): + (KJS::NativeErrorConstructor::construct): + (KJS::NativeErrorConstructor::callAsFunction): + (KJS::NativeErrorConstructor::mark): + * kjs/error_object.h: + * kjs/function.cpp: + (KJS::JSFunction::JSFunction): + (KJS::JSFunction::mark): + (KJS::JSFunction::getOwnPropertySlot): + (KJS::JSFunction::put): + (KJS::JSFunction::deleteProperty): + (KJS::PrototypeFunction::PrototypeFunction): + (KJS::PrototypeReflexiveFunction::PrototypeReflexiveFunction): + (KJS::PrototypeReflexiveFunction::mark): + * kjs/function.h: + * kjs/function_object.cpp: + (KJS::functionProtoFuncToString): + (KJS::FunctionConstructor::FunctionConstructor): + (KJS::FunctionConstructor::getConstructData): + (KJS::FunctionConstructor::construct): + (KJS::FunctionConstructor::callAsFunction): + * kjs/function_object.h: + * kjs/internal.cpp: + (KJS::StringObject::create): + (KJS::JSString::toObject): + (KJS::JSString::toThisObject): + (KJS::JSString::getOwnPropertySlot): + (KJS::InternalFunction::InternalFunction): + (KJS::InternalFunction::getCallData): + (KJS::InternalFunction::implementsHasInstance): + * kjs/math_object.cpp: + (KJS::MathObject::MathObject): + (KJS::MathObject::getOwnPropertySlot): + (KJS::MathObject::getValueProperty): + * kjs/math_object.h: + * kjs/number_object.cpp: + (KJS::NumberObject::NumberObject): + (KJS::NumberPrototype::NumberPrototype): + (KJS::numberProtoFuncToString): + (KJS::numberProtoFuncToLocaleString): + (KJS::numberProtoFuncValueOf): + (KJS::numberProtoFuncToFixed): + (KJS::numberProtoFuncToExponential): + (KJS::numberProtoFuncToPrecision): + (KJS::NumberConstructor::NumberConstructor): + (KJS::NumberConstructor::getOwnPropertySlot): + (KJS::NumberConstructor::getValueProperty): + (KJS::NumberConstructor::getConstructData): + (KJS::NumberConstructor::construct): + (KJS::NumberConstructor::callAsFunction): + * kjs/number_object.h: + * kjs/object.cpp: + (KJS::JSObject::putDirectFunction): + * kjs/object.h: + * kjs/object_object.cpp: + (KJS::ObjectConstructor::ObjectConstructor): + (KJS::ObjectConstructor::getConstructData): + (KJS::ObjectConstructor::construct): + (KJS::ObjectConstructor::callAsFunction): + * kjs/object_object.h: + * kjs/regexp.cpp: + (KJS::RegExp::RegExp): + * kjs/regexp_object.cpp: + (KJS::regExpProtoFuncTest): + (KJS::regExpProtoFuncExec): + (KJS::regExpProtoFuncCompile): + (KJS::regExpProtoFuncToString): + (KJS::RegExpObject::RegExpObject): + (KJS::RegExpObject::~RegExpObject): + (KJS::RegExpObject::getOwnPropertySlot): + (KJS::RegExpObject::getValueProperty): + (KJS::RegExpObject::put): + (KJS::RegExpObject::putValueProperty): + (KJS::RegExpObject::match): + (KJS::RegExpObject::test): + (KJS::RegExpObject::exec): + (KJS::RegExpObject::getCallData): + (KJS::RegExpObject::callAsFunction): + (KJS::RegExpConstructorPrivate::RegExpConstructorPrivate): + (KJS::RegExpConstructor::RegExpConstructor): + (KJS::RegExpConstructor::performMatch): + (KJS::RegExpMatchesArray::RegExpMatchesArray): + (KJS::RegExpMatchesArray::~RegExpMatchesArray): + (KJS::RegExpMatchesArray::fillArrayInstance): + (KJS::RegExpConstructor::arrayOfMatches): + (KJS::RegExpConstructor::getBackref): + (KJS::RegExpConstructor::getLastParen): + (KJS::RegExpConstructor::getLeftContext): + (KJS::RegExpConstructor::getRightContext): + (KJS::RegExpConstructor::getOwnPropertySlot): + (KJS::RegExpConstructor::getValueProperty): + (KJS::RegExpConstructor::put): + (KJS::RegExpConstructor::putValueProperty): + (KJS::RegExpConstructor::getConstructData): + (KJS::RegExpConstructor::construct): + (KJS::RegExpConstructor::callAsFunction): + (KJS::RegExpConstructor::input): + * kjs/regexp_object.h: + * kjs/string_object.cpp: + (KJS::StringObject::StringObject): + (KJS::StringObject::getOwnPropertySlot): + (KJS::StringObject::put): + (KJS::StringObject::deleteProperty): + (KJS::StringObject::getPropertyNames): + (KJS::StringPrototype::StringPrototype): + (KJS::StringPrototype::getOwnPropertySlot): + (KJS::replace): + (KJS::stringProtoFuncToString): + (KJS::stringProtoFuncValueOf): + (KJS::stringProtoFuncCharAt): + (KJS::stringProtoFuncCharCodeAt): + (KJS::stringProtoFuncConcat): + (KJS::stringProtoFuncIndexOf): + (KJS::stringProtoFuncLastIndexOf): + (KJS::stringProtoFuncMatch): + (KJS::stringProtoFuncSearch): + (KJS::stringProtoFuncReplace): + (KJS::stringProtoFuncSlice): + (KJS::stringProtoFuncSplit): + (KJS::stringProtoFuncSubstr): + (KJS::stringProtoFuncSubstring): + (KJS::stringProtoFuncToLowerCase): + (KJS::stringProtoFuncToUpperCase): + (KJS::stringProtoFuncToLocaleLowerCase): + (KJS::stringProtoFuncToLocaleUpperCase): + (KJS::stringProtoFuncLocaleCompare): + (KJS::stringProtoFuncBig): + (KJS::stringProtoFuncSmall): + (KJS::stringProtoFuncBlink): + (KJS::stringProtoFuncBold): + (KJS::stringProtoFuncFixed): + (KJS::stringProtoFuncItalics): + (KJS::stringProtoFuncStrike): + (KJS::stringProtoFuncSub): + (KJS::stringProtoFuncSup): + (KJS::stringProtoFuncFontcolor): + (KJS::stringProtoFuncFontsize): + (KJS::stringProtoFuncAnchor): + (KJS::stringProtoFuncLink): + (KJS::StringConstructor::StringConstructor): + (KJS::StringConstructor::getConstructData): + (KJS::StringConstructor::construct): + (KJS::StringConstructor::callAsFunction): + (KJS::StringConstructorFunction::StringConstructorFunction): + (KJS::StringConstructorFunction::callAsFunction): + * kjs/string_object.h: + (KJS::StringObjectThatMasqueradesAsUndefined::StringObjectThatMasqueradesAsUndefined): + * profiler/Profiler.cpp: + (KJS::createCallIdentifier): + +2008-06-15 Darin Adler + + Rubber stamped by Sam. + + - use JS prefix and simpler names for basic JavaScriptCore types, + to complement JSValue and JSObject + + * JavaScriptCore.exp: + * VM/Machine.cpp: + (KJS::jsLess): + (KJS::jsLessEq): + (KJS::jsAdd): + (KJS::callEval): + (KJS::Machine::execute): + (KJS::Machine::retrieveArguments): + (KJS::Machine::retrieveCaller): + (KJS::Machine::getCallFrame): + (KJS::Machine::getFunctionAndArguments): + * VM/Machine.h: + * VM/Register.h: + * kjs/DebuggerCallFrame.cpp: + (KJS::DebuggerCallFrame::functionName): + * kjs/ExecState.h: + * kjs/JSActivation.cpp: + (KJS::JSActivation::createArgumentsObject): + * kjs/array_instance.cpp: + (KJS::JSArray::checkConsistency): + (KJS::JSArray::JSArray): + (KJS::JSArray::~JSArray): + (KJS::JSArray::getItem): + (KJS::JSArray::lengthGetter): + (KJS::JSArray::inlineGetOwnPropertySlot): + (KJS::JSArray::getOwnPropertySlot): + (KJS::JSArray::put): + (KJS::JSArray::deleteProperty): + (KJS::JSArray::getPropertyNames): + (KJS::JSArray::increaseVectorLength): + (KJS::JSArray::setLength): + (KJS::JSArray::mark): + (KJS::JSArray::sort): + (KJS::JSArray::compactForSorting): + (KJS::JSArray::lazyCreationData): + (KJS::JSArray::setLazyCreationData): + * kjs/array_instance.h: + * kjs/array_object.cpp: + (KJS::ArrayPrototype::ArrayPrototype): + (KJS::ArrayPrototype::getOwnPropertySlot): + (KJS::arrayProtoFuncToString): + (KJS::arrayProtoFuncToLocaleString): + (KJS::arrayProtoFuncConcat): + (KJS::arrayProtoFuncSort): + (KJS::ArrayObjectImp::construct): + * kjs/array_object.h: + * kjs/completion.h: + * kjs/function.cpp: + (KJS::JSFunction::JSFunction): + (KJS::JSFunction::mark): + (KJS::JSFunction::getCallData): + (KJS::JSFunction::callAsFunction): + (KJS::JSFunction::argumentsGetter): + (KJS::JSFunction::callerGetter): + (KJS::JSFunction::lengthGetter): + (KJS::JSFunction::getOwnPropertySlot): + (KJS::JSFunction::put): + (KJS::JSFunction::deleteProperty): + (KJS::JSFunction::getParameterName): + (KJS::JSFunction::getConstructData): + (KJS::JSFunction::construct): + (KJS::IndexToNameMap::IndexToNameMap): + (KJS::Arguments::Arguments): + * kjs/function.h: + * kjs/function_object.cpp: + (KJS::functionProtoFuncToString): + (KJS::functionProtoFuncApply): + (KJS::FunctionObjectImp::construct): + * kjs/internal.cpp: + (KJS::JSString::toPrimitive): + (KJS::JSString::getPrimitiveNumber): + (KJS::JSString::toBoolean): + (KJS::JSString::toNumber): + (KJS::JSString::toString): + (KJS::StringInstance::create): + (KJS::JSString::toObject): + (KJS::JSString::toThisObject): + (KJS::JSString::lengthGetter): + (KJS::JSString::indexGetter): + (KJS::JSString::indexNumericPropertyGetter): + (KJS::JSString::getOwnPropertySlot): + (KJS::JSNumberCell::type): + (KJS::JSNumberCell::toPrimitive): + (KJS::JSNumberCell::getPrimitiveNumber): + (KJS::JSNumberCell::toBoolean): + (KJS::JSNumberCell::toNumber): + (KJS::JSNumberCell::toString): + (KJS::JSNumberCell::toObject): + (KJS::JSNumberCell::toThisObject): + (KJS::JSNumberCell::getUInt32): + (KJS::JSNumberCell::getTruncatedInt32): + (KJS::JSNumberCell::getTruncatedUInt32): + (KJS::GetterSetter::mark): + (KJS::GetterSetter::toPrimitive): + (KJS::GetterSetter::getPrimitiveNumber): + (KJS::GetterSetter::toBoolean): + (KJS::GetterSetter::toNumber): + (KJS::GetterSetter::toString): + (KJS::GetterSetter::toObject): + (KJS::GetterSetter::getOwnPropertySlot): + (KJS::GetterSetter::put): + (KJS::GetterSetter::toThisObject): + * kjs/internal.h: + (KJS::JSString::JSString): + (KJS::JSString::getStringPropertySlot): + * kjs/nodes.cpp: + (KJS::FuncDeclNode::makeFunction): + (KJS::FuncExprNode::makeFunction): + * kjs/nodes.h: + * kjs/object.cpp: + (KJS::JSObject::put): + (KJS::JSObject::deleteProperty): + (KJS::JSObject::defineGetter): + (KJS::JSObject::defineSetter): + (KJS::JSObject::lookupGetter): + (KJS::JSObject::lookupSetter): + (KJS::JSObject::fillGetterPropertySlot): + * kjs/object.h: + (KJS::GetterSetter::GetterSetter): + * kjs/operations.cpp: + (KJS::equal): + (KJS::strictEqual): + * kjs/property_map.cpp: + (KJS::PropertyMap::containsGettersOrSetters): + * kjs/regexp_object.cpp: + (KJS::RegExpMatchesArray::getOwnPropertySlot): + (KJS::RegExpMatchesArray::put): + (KJS::RegExpMatchesArray::deleteProperty): + (KJS::RegExpMatchesArray::getPropertyNames): + (KJS::RegExpMatchesArray::RegExpMatchesArray): + (KJS::RegExpMatchesArray::fillArrayInstance): + * kjs/string_object.cpp: + (KJS::StringInstance::StringInstance): + (KJS::replace): + (KJS::stringProtoFuncReplace): + (KJS::stringProtoFuncToLowerCase): + (KJS::stringProtoFuncToUpperCase): + (KJS::stringProtoFuncToLocaleLowerCase): + (KJS::stringProtoFuncToLocaleUpperCase): + * kjs/string_object.h: + (KJS::StringInstance::internalValue): + * kjs/value.cpp: + (KJS::JSCell::getNumber): + (KJS::JSCell::getString): + (KJS::JSCell::getObject): + (KJS::jsString): + (KJS::jsOwnedString): + * kjs/value.h: + (KJS::JSNumberCell::JSNumberCell): + (KJS::jsNumberCell): + (KJS::JSValue::uncheckedGetNumber): + * profiler/Profiler.cpp: + (KJS::createCallIdentifier): + (KJS::createCallIdentifierFromFunctionImp): + +2008-06-15 Maciej Stachowiak + + Reviewed by Alexey. + + - add emitUnaryOp, emitNullaryOp and emitUnaryOpNoDst; use them + + This removes some boilerplate code and also reduces the number of + places that will need to be changed to do on-demand emit of + loads (and thus support k operands). + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitUnaryOp): + (KJS::CodeGenerator::emitNullaryOp): + (KJS::CodeGenerator::emitUnaryOpNoDst): + (KJS::CodeGenerator::emitPushScope): + * VM/CodeGenerator.h: + (KJS::CodeGenerator::emitNewObject): + (KJS::CodeGenerator::emitNewArray): + (KJS::CodeGenerator::emitNot): + (KJS::CodeGenerator::emitBitNot): + (KJS::CodeGenerator::emitToJSNumber): + (KJS::CodeGenerator::emitNegate): + (KJS::CodeGenerator::emitInstanceOf): + (KJS::CodeGenerator::emitTypeOf): + (KJS::CodeGenerator::emitIn): + (KJS::CodeGenerator::emitReturn): + (KJS::CodeGenerator::emitEnd): + (KJS::CodeGenerator::emitGetPropertyNames): + +2008-06-15 Alp Toker + + Rubber-stamped by Maciej. + + Install 'jsc' application by default. + + * GNUmakefile.am: + +2008-06-15 Maciej Stachowiak + + Reviewed by Oliver. + + - rename testkjs to jsc + + * GNUmakefile.am: + * JavaScriptCore.vcproj/JavaScriptCore.sln: + * JavaScriptCore.vcproj/jsc: Added. + * JavaScriptCore.vcproj/jsc/jsc.vcproj: Copied from JavaScriptCore.vcproj/testkjs/testkjs.vcproj. + * JavaScriptCore.vcproj/testkjs: Removed. + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: Removed. + * JavaScriptCore.xcodeproj/project.pbxproj: + * jscore.bkl: + * kjs/Shell.cpp: Copied from kjs/testkjs.cpp. + (main): + (printUsageStatement): + (jscmain): + * kjs/jsc.pro: Copied from kjs/testkjs.pro. + * kjs/testkjs.cpp: Removed. + * kjs/testkjs.pro: Removed. + * tests/mozilla/expected.html: + * tests/mozilla/js1_2/Array/tostring_1.js: + * tests/mozilla/js1_2/Array/tostring_2.js: + * tests/mozilla/jsDriver.pl: + +2008-06-15 Cameron Zwarich + + Reviewed by Maciej. + + Mac build fix. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/nodes.h: + +2008-06-15 Cameron Zwarich + + Reviewed by Maciej. + + Change the spelling of PrecMultiplicitave to PrecMultiplicative. + + * kjs/nodes.h: + (KJS::MultNode::precedence): + (KJS::DivNode::precedence): + (KJS::ModNode::precedence): + +2008-06-15 Cameron Zwarich + + Reviewed by Maciej. + + Remove unused preprocessor macros related to exceptions in the old + interpreter. + + * kjs/nodes.cpp: + +2008-06-15 Cameron Zwarich + + Reviewed by Maciej. + + Bug 19484: More instructions needs to use temporary registers + + + Fix codegen for all binary operations so that temporaries are used if + necessary. This was done by making BinaryOpNode and ReverseBinaryOpNode + subclasses of ExpressionNode, and eliminating the custom emitCode() + methods for the individual node classes. + + This only adds 3 new instructions to SunSpider code, and there is no + difference in SunSpider execution time. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitBitNot): + (KJS::CodeGenerator::emitBinaryOp): + * VM/CodeGenerator.h: + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::PreIncResolveNode::emitCode): + (KJS::PreDecResolveNode::emitCode): + (KJS::BinaryOpNode::emitCode): + (KJS::ReverseBinaryOpNode::emitCode): + (KJS::emitReadModifyAssignment): + (KJS::CaseBlockNode::emitCodeForBlock): + * kjs/nodes.h: + (KJS::BinaryOpNode::BinaryOpNode): + (KJS::ReverseBinaryOpNode::ReverseBinaryOpNode): + (KJS::MultNode::): + (KJS::DivNode::): + (KJS::DivNode::precedence): + (KJS::ModNode::): + (KJS::ModNode::precedence): + (KJS::AddNode::): + (KJS::AddNode::precedence): + (KJS::SubNode::): + (KJS::SubNode::precedence): + (KJS::LeftShiftNode::): + (KJS::LeftShiftNode::precedence): + (KJS::RightShiftNode::): + (KJS::RightShiftNode::precedence): + (KJS::UnsignedRightShiftNode::): + (KJS::UnsignedRightShiftNode::precedence): + (KJS::LessNode::): + (KJS::LessNode::precedence): + (KJS::GreaterNode::): + (KJS::GreaterNode::precedence): + (KJS::LessEqNode::): + (KJS::LessEqNode::precedence): + (KJS::GreaterEqNode::): + (KJS::GreaterEqNode::precedence): + (KJS::InstanceOfNode::): + (KJS::InstanceOfNode::precedence): + (KJS::InNode::): + (KJS::InNode::precedence): + (KJS::EqualNode::): + (KJS::EqualNode::precedence): + (KJS::NotEqualNode::): + (KJS::NotEqualNode::precedence): + (KJS::StrictEqualNode::): + (KJS::StrictEqualNode::precedence): + (KJS::NotStrictEqualNode::): + (KJS::NotStrictEqualNode::precedence): + (KJS::BitAndNode::): + (KJS::BitAndNode::precedence): + (KJS::BitOrNode::): + (KJS::BitOrNode::precedence): + (KJS::BitXOrNode::): + (KJS::BitXOrNode::precedence): + * kjs/nodes2string.cpp: + (KJS::LessNode::streamTo): + (KJS::GreaterNode::streamTo): + (KJS::LessEqNode::streamTo): + (KJS::GreaterEqNode::streamTo): + (KJS::InstanceOfNode::streamTo): + (KJS::InNode::streamTo): + (KJS::EqualNode::streamTo): + (KJS::NotEqualNode::streamTo): + (KJS::StrictEqualNode::streamTo): + (KJS::NotStrictEqualNode::streamTo): + (KJS::BitAndNode::streamTo): + (KJS::BitXOrNode::streamTo): + (KJS::BitOrNode::streamTo): + +2008-06-14 Darin Adler + + Rubber stamped by Sam. + + - rename a bunch of local symbols within the regular expression code to + follow our usual coding style, and do a few other name tweaks + + * pcre/pcre_compile.cpp: + (CompileData::CompileData): + (checkEscape): + (readRepeatCounts): + (compileBranch): + (compileBracket): + (calculateCompiledPatternLength): + (returnError): + (jsRegExpCompile): + * pcre/pcre_exec.cpp: + (MatchStack::MatchStack): + (MatchStack::canUseStackBufferForNextFrame): + (MatchStack::popCurrentFrame): + (match): + (tryFirstByteOptimization): + (tryRequiredByteOptimization): + (jsRegExpExecute): + * pcre/pcre_internal.h: + +2008-06-14 Cameron Zwarich + + Reviewed by Darin. + + Remove redundant uses of get(). + + * kjs/nodes.cpp: + (KJS::BracketAccessorNode::emitCode): + (KJS::AddNode::emitCode): + (KJS::SubNode::emitCode): + (KJS::ReadModifyResolveNode::emitCode): + (KJS::AssignDotNode::emitCode): + (KJS::ReadModifyDotNode::emitCode): + (KJS::AssignBracketNode::emitCode): + (KJS::ReadModifyBracketNode::emitCode): + +2008-06-14 Cameron Zwarich + + Reviewed by Maciej. + + Make code generation not use a temporary for the left-hand side of an + expression if the right-hand side is a local variable. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::isLocal): + * VM/CodeGenerator.h: + (KJS::CodeGenerator::leftHandSideNeedsCopy): + (KJS::CodeGenerator::emitNodeForLeftHandSide): + * kjs/nodes.cpp: + (KJS::ResolveNode::isPure): + (KJS::BracketAccessorNode::emitCode): + (KJS::AddNode::emitCode): + (KJS::SubNode::emitCode): + (KJS::ReadModifyResolveNode::emitCode): + (KJS::AssignDotNode::emitCode): + (KJS::ReadModifyDotNode::emitCode): + (KJS::AssignBracketNode::emitCode): + (KJS::ReadModifyBracketNode::emitCode): + * kjs/nodes.h: + (KJS::ExpressionNode::): + (KJS::BooleanNode::): + (KJS::NumberNode::): + (KJS::StringNode::): + +2008-06-14 Darin Adler + + Reviewed by Sam. + + - more of https://bugs.webkit.org/show_bug.cgi?id=17257 + start ref counts at 1 instead of 0 for speed + + * kjs/nodes.cpp: + (KJS::ParserRefCounted::hasOneRef): Added. Replaces refcount. + * kjs/nodes.h: Replaced refcount with hasOneRef. + + * wtf/ListRefPtr.h: + (WTF::ListRefPtr::~ListRefPtr): Changed to use hasOneRef instead of + refcount, so this class can be used with the RefCounted template. + + * wtf/RefCounted.h: + (WTF::RefCounted::hasOneRef): Made const, since there's no reason for + it to be non-const. + +2008-06-14 Maciej Stachowiak + + Reviewed by Oliver. + + - initialize local vars as side effect of call instead of in bytecode + 1.004x speedup on SunSpider. + + This removes just the dispatch overhead for these loads - in the + future, dead store elimination might be able to eliminate them + entirely. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): For function blocks, don't + emit loads of undefined for var initialization. + * VM/Machine.cpp: + (KJS::slideRegisterWindowForCall): Instead, initialize locals + as part of the call. + +2008-06-14 Cameron Zwarich + + Reviewed by Oliver. + + Remove helper functions in the parser that are no longer needed. + + * kjs/grammar.y: + +2008-06-14 Cameron Zwarich + + Reviewed by Oliver. + + Bug 19484: More instructions needs to use temporary registers + + + Make code generation for AddNode and SubNode use temporaries when + necessary. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::AddNode::emitCode): + (KJS::SubNode::emitCode): + * kjs/nodes.h: + (KJS::AddNode::): + (KJS::SubNode::): + +2008-06-13 Cameron Zwarich + + Reviewed by Maciej. + + Combine TrueNode and FalseNode to make BooleanNode, and remove the + unused class PlaceholderTrueNode. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::BooleanNode::emitCode): + * kjs/nodes.h: + (KJS::BooleanNode::): + (KJS::BooleanNode::precedence): + * kjs/nodes2string.cpp: + (KJS::BooleanNode::streamTo): + +2008-06-13 Cameron Zwarich + + Reviewed by Maciej. + + Eliminate the use of temporaries to store the left hand side of an + expression when the right hand side is a constant. This slightly + improves the generated bytecode for a few SunSpider tests, but it is + mostly in preparation for fixing + + Bug 19484: More instructions needs to use temporary registers + + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::leftHandSideNeedsCopy): + (KJS::CodeGenerator::emitNodeForLeftHandSide): + * kjs/nodes.cpp: + (KJS::BracketAccessorNode::emitCode): + (KJS::ReadModifyResolveNode::emitCode): + (KJS::AssignDotNode::emitCode): + (KJS::ReadModifyDotNode::emitCode): + (KJS::AssignBracketNode::emitCode): + (KJS::ReadModifyBracketNode::emitCode): + * kjs/nodes.h: + (KJS::ExpressionNode::): + (KJS::FalseNode::): + (KJS::TrueNode::): + (KJS::NumberNode::): + (KJS::StringNode::): + +2008-06-13 Maciej Stachowiak + + Reviewed by Oliver. + + - prettify opcode stats output + + I changed things to be a bit more aligned, also there is a new + section listing most common opcodes and most common sequences that + include them. + + * VM/Opcode.cpp: + (KJS::OpcodeStats::~OpcodeStats): + * VM/Opcode.h: + +2008-06-13 Kevin McCullough + + Reviewed by Geoff. + + JSProfiler: Remove the recursion limit in the + profiler. + - Remove recursion from exclude(). This leaves only focus() to fix. + + * JavaScriptCore.exp: Change the signatures of the exported functions. + * profiler/Profile.cpp: + (KJS::Profile::forEach): I added a traverseNextNodePreOrder() function + and so needed to distinguish the other function by labeling it + traverseNextNodePostOrder(). + (KJS::Profile::exclude): All new exclude that iteratively walks the tree + * profiler/Profile.h: + (KJS::Profile::focus): Add a null check for m_head. + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::traverseNextNodePostOrder): Renamed + (KJS::ProfileNode::traverseNextNodePreOrder): Walks the tree in pre- + order, where the parent is processed before the children. + (KJS::ProfileNode::setTreeVisible): Iterate over the sub-tree and set + all of the nodes visible value. This changes another function that used + recursion. + (KJS::ProfileNode::exclude): Remove recursion from this function. + Because we now check for m_visible and we are walking the tree in pre- + order we do not need to check if an excluded node is in an excluded + sub-tree. + * profiler/ProfileNode.h: Added specific selfTime functions to + facilitate exclude(). + (KJS::ProfileNode::setSelfTime): + (KJS::ProfileNode::setActualSelfTime): + (KJS::ProfileNode::setVisibleSelfTime): + +2008-06-12 Darin Adler + + Reviewed by Maciej. + + - https://bugs.webkit.org/show_bug.cgi?id=19434 + speed up SunSpider by avoiding some string boxing + + Speeds up SunSpider by 1.1%. + + Optimized code path for getting built-in properties from strings -- avoid + boxing with a string object in that case. We can make further changes to avoid + even more boxing, but this change alone is a win. + + * API/JSCallbackObjectFunctions.h: + (KJS::JSCallbackObject::staticValueGetter): Use isObject instead of inherits + in asssert, since the type of slotBase() is now JSValue, not JSObject. + (KJS::JSCallbackObject::staticFunctionGetter): Ditto. + (KJS::JSCallbackObject::callbackGetter): Ditto. + + * kjs/internal.cpp: + (KJS::StringImp::getPrimitiveNumber): Updated for change of data member name. + (KJS::StringImp::toBoolean): Ditto. + (KJS::StringImp::toNumber): Ditto. + (KJS::StringImp::toString): Ditto. + (KJS::StringInstance::create): Added; avoids a bit of cut and paste code. + (KJS::StringImp::toObject): Use StringInstance::create. + (KJS::StringImp::toThisObject): Ditto. + (KJS::StringImp::lengthGetter): Added. Replaces the getter that used to live in + the StringInstance class. + (KJS::StringImp::indexGetter): Ditto. + (KJS::StringImp::indexNumericPropertyGetter): Ditto. + (KJS::StringImp::getOwnPropertySlot): Added. Deals with built in properties of + the string class without creating a StringInstance. + + * kjs/internal.h: + (KJS::StringImp::getStringPropertySlot): Added. To be used by both the string + and string object getOwnPropertySlot function. + + * kjs/lookup.h: + (KJS::staticFunctionGetter): Updated since slotBase() is now a JSValue rather + than a JSObject. + + * kjs/object.h: Removed PropertySlot::slotBase() function, which can now move + back into property_slot.h where it belongs since it doesn't have to cast to + JSObject*. + + * kjs/property_slot.cpp: + (KJS::PropertySlot::functionGetter): Updated since slot.slotBase() is now a JSValue* + instead of JSObject*. setGetterSlot still guarantees the base is a JSObject*. + * kjs/property_slot.h: + (KJS::PropertySlot::PropertySlot): Changed base to JSValue* intead of JSCell*. + (KJS::PropertySlot::setStaticEntry): Ditto. + (KJS::PropertySlot::setCustom): Ditto. + (KJS::PropertySlot::setCustomIndex): Ditto. + (KJS::PropertySlot::setCustomNumeric): Ditto. + (KJS::PropertySlot::slotBase): Moved inline here since it no longer involves a + downcast to JSObject*. + (KJS::PropertySlot::setBase): Changed to JSValue*. + + * kjs/string_object.cpp: + (KJS::StringInstance::getOwnPropertySlot): Changed to use getStringPropertySlot + instead of coding the properties here. This allows sharing the code with StringImp. + + * kjs/string_object.h: Removed inlineGetOwnPropertySlot, lengthGetter, and indexGetter. + Made one of the constructors protected. + + * kjs/value.h: Made getOwnPropertySlot private in the JSCell class -- this is better + since it's not the real JSObject getOwnPropertySlot semantic and most callers shouldn't + use it. + +2008-06-12 Alexey Proskuryakov + + Reviewed by Maciej. + + Preparation to making JavaScript heap per-thread. + + * kjs/collector.cpp: + (KJS::Collector::collect): + * kjs/collector.h: + (KJS::Collector::markListSet): + The collector now holds the list of protected lists itself, to be made per-instance. + + * kjs/list.h: Changed to hold a pointer to a mark set this list is in, if any. + (KJS::List::List): Explicitly initialize m_size with zero, as m_vector.size() is + guaranteed to be such anyway. + (KJS::List::append): Changed the fast case to only be executed as long as inline buffer + is used, because otherwise, we now do more expensive checks. + + * kjs/list.cpp: + (KJS::List::markLists): Renamed from markProtectedListsSlowCase, made it take the list set + as a parameter. + (KJS::List::slowAppend): If a non-immediate value is appended, the list needs to be added + to an appropriate Heap's protected list. For now, a static Collector::markListSet() is + used, but the code is layed out in preparation to making the switch to multiple heaps. + + * JavaScriptCore.exp: Updated export list. + +2008-06-12 Cameron Zwarich + + Reviewed by Maciej. + + Bug 19510: CodeBlock::needsFullScopeChain not always set for global code + + + This fixes the symptoms by using CodeGenerator::m_codeType to determine + when to use temporaries instead of CodeBlock::needsFullScopeChain, but + it does not fix the problem itself. + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::leftHandSideNeedsCopy): + +2008-06-11 Cameron Zwarich + + Reviewed by Maciej. + + Bug 19498: REGRESSION (r34497): crash while loading GMail + + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitJumpIfTrueMayCombine): + (KJS::CodeGenerator::emitJumpIfTrue): + * VM/CodeGenerator.h: + * kjs/nodes.cpp: + (KJS::DoWhileNode::emitCode): + (KJS::WhileNode::emitCode): + (KJS::ForNode::emitCode): + (KJS::CaseBlockNode::emitCodeForBlock): + +2008-06-11 Darin Adler + + Reviewed by Maciej. + + - a little bit of cleanup and prep for some upcoming optimizations + + * JavaScriptCore.exp: Re-sorted this file (with sort command line tool). + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): Fixed printf to avoid warnings -- to use %lu we + need to make sure the type is unsigned long. + * kjs/object.cpp: + (KJS::Error::create): Eliminated unused error names array, and also put + the strings into the code since there was already a switch statment. + This also avoids having to contemplate a hypothetical access past the + end of the array. + * kjs/object.h: Got rid of errorNames. + * kjs/property_slot.cpp: Deleted unused ungettableGetter. + * kjs/property_slot.h: Ditto. + * wtf/AlwaysInline.h: Added LIKELY alongside UNLIKELY. + +2008-06-11 Cameron Zwarich + + Reviewed by Darin. + + Bug 19457: Create fused opcodes for tests and conditional jumps + + + Add a new jless instruction, and modify the code generator to emit it + instead of the pair (less, jtrue). + + Gives a 3.6% improvement on SunSpider. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::emitOpcode): + (KJS::CodeGenerator::retrieveLastBinaryOp): + (KJS::CodeGenerator::rewindBinaryOp): + (KJS::CodeGenerator::emitJump): + (KJS::CodeGenerator::emitJumpIfTrue): + (KJS::CodeGenerator::emitJumpIfFalse): + (KJS::CodeGenerator::emitMove): + (KJS::CodeGenerator::emitNot): + (KJS::CodeGenerator::emitEqual): + (KJS::CodeGenerator::emitNotEqual): + (KJS::CodeGenerator::emitStrictEqual): + (KJS::CodeGenerator::emitNotStrictEqual): + (KJS::CodeGenerator::emitLess): + (KJS::CodeGenerator::emitLessEq): + (KJS::CodeGenerator::emitPreInc): + (KJS::CodeGenerator::emitPreDec): + (KJS::CodeGenerator::emitPostInc): + (KJS::CodeGenerator::emitPostDec): + (KJS::CodeGenerator::emitToJSNumber): + (KJS::CodeGenerator::emitNegate): + (KJS::CodeGenerator::emitAdd): + (KJS::CodeGenerator::emitMul): + (KJS::CodeGenerator::emitDiv): + (KJS::CodeGenerator::emitMod): + (KJS::CodeGenerator::emitSub): + (KJS::CodeGenerator::emitLeftShift): + (KJS::CodeGenerator::emitRightShift): + (KJS::CodeGenerator::emitUnsignedRightShift): + (KJS::CodeGenerator::emitBitAnd): + (KJS::CodeGenerator::emitBitXOr): + (KJS::CodeGenerator::emitBitOr): + (KJS::CodeGenerator::emitBitNot): + (KJS::CodeGenerator::emitInstanceOf): + (KJS::CodeGenerator::emitTypeOf): + (KJS::CodeGenerator::emitIn): + (KJS::CodeGenerator::emitLoad): + (KJS::CodeGenerator::emitNewObject): + (KJS::CodeGenerator::emitNewArray): + (KJS::CodeGenerator::emitResolve): + (KJS::CodeGenerator::emitGetScopedVar): + (KJS::CodeGenerator::emitPutScopedVar): + (KJS::CodeGenerator::emitResolveBase): + (KJS::CodeGenerator::emitResolveWithBase): + (KJS::CodeGenerator::emitResolveFunction): + (KJS::CodeGenerator::emitGetById): + (KJS::CodeGenerator::emitPutById): + (KJS::CodeGenerator::emitPutGetter): + (KJS::CodeGenerator::emitPutSetter): + (KJS::CodeGenerator::emitDeleteById): + (KJS::CodeGenerator::emitGetByVal): + (KJS::CodeGenerator::emitPutByVal): + (KJS::CodeGenerator::emitDeleteByVal): + (KJS::CodeGenerator::emitPutByIndex): + (KJS::CodeGenerator::emitNewFunction): + (KJS::CodeGenerator::emitNewRegExp): + (KJS::CodeGenerator::emitNewFunctionExpression): + (KJS::CodeGenerator::emitCall): + (KJS::CodeGenerator::emitReturn): + (KJS::CodeGenerator::emitEnd): + (KJS::CodeGenerator::emitConstruct): + (KJS::CodeGenerator::emitPushScope): + (KJS::CodeGenerator::emitPopScope): + (KJS::CodeGenerator::emitDebugHook): + (KJS::CodeGenerator::emitComplexJumpScopes): + (KJS::CodeGenerator::emitJumpScopes): + (KJS::CodeGenerator::emitNextPropertyName): + (KJS::CodeGenerator::emitGetPropertyNames): + (KJS::CodeGenerator::emitCatch): + (KJS::CodeGenerator::emitThrow): + (KJS::CodeGenerator::emitNewError): + (KJS::CodeGenerator::emitJumpSubroutine): + (KJS::CodeGenerator::emitSubroutineReturn): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.cpp: + * VM/Opcode.h: + +2008-06-11 Darin Adler + + Reviewed by Alexey. + + - fix https://bugs.webkit.org/show_bug.cgi?id=19442 + JavaScript array implementation doesn't maintain m_numValuesInVector when sorting + + * kjs/array_instance.cpp: + (KJS::ArrayInstance::checkConsistency): Added. Empty inline version for when + consistency checks are turned off. + (KJS::ArrayInstance::ArrayInstance): Check consistency after construction. + (KJS::ArrayInstance::~ArrayInstance): Check consistency before destruction. + (KJS::ArrayInstance::put): Check consistency before and after. + (KJS::ArrayInstance::deleteProperty): Ditto. + (KJS::ArrayInstance::setLength): Ditto. + (KJS::compareByStringPairForQSort): Use typedef for clarity. + (KJS::ArrayInstance::sort): Check consistency before and after. Also broke the loop + to set up sorting into two separate passes. Added FIXMEs about various exception + safety issues. Added code to set m_numValuesInVector after sorting. + (KJS::ArrayInstance::compactForSorting): Ditto. + + * kjs/array_instance.h: Added a definition of an enum for the types of consistency + check and a declaration of the consistency checking function. + +2008-06-10 Kevin Ollivier + + wx build fix. Link against libedit on Mac since HAVE(READLINE) is defined there. + + * jscore.bkl: + +2008-06-10 Alexey Proskuryakov + + Reviewed by Darin. + + https://bugs.webkit.org/show_bug.cgi?id=16503 + match limit takes at least 13% of the time on the SunSpider regexp-dna test + + Make the limit test slightly more efficient. It is not clear how much of a win it is, + as the improvement on regexp-dna varies from 2.3% to 0.6% depending on what revision I + apply the patch to. Today, the win on regexp-dna was minimal, but the total win was whopping + 0.5%, due to random code generation changes. + + * pcre/pcre_exec.cpp: (match): Avoid loading a constant on each iteration. + +2008-06-09 Alp Toker + + gcc3/autotools build fix. Add explicit -O2 -fno-strict-aliasing to + each of the tools since these are no longer set globally. + + * GNUmakefile.am: + +2008-06-09 Cameron Zwarich + + Reviewed by Sam. + + Add an include for readline/history.h to fix the build for Darwin users + with the GNU readline library installed. Also, clean up the style of + the HAVE(READLINE) check. + + * kjs/testkjs.cpp: + (runInteractive): + +2008-06-09 Cameron Zwarich + + Reviewed by Darin. + + Bug 17531: Add interactive mode to testkjs + + + This is a cleaned up version of Sam's earlier patch to add an + interactive mode to testkjs. + + Readline support is only enabled on Darwin platforms for now, but + other ports can enable it by defining HAVE_READLINE in kjs/config.h. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/config.h: + * kjs/testkjs.cpp: + (Options::Options): + (runWithScripts): + (runInteractive): + (printUsageStatement): + (parseArguments): + (kjsmain): + +2008-06-08 Cameron Zwarich + + Reviewed by Darin. + + Bug 19346: REGRESSION: Mootools 1.2 Class inheritance broken in post-SquirrelFish merge + + + A check for whether a function's caller is eval code accidentally included + the case where the caller's caller is native code. Add a CodeType field to + CodeBlock and use this for the eval caller test instead. + + * VM/CodeBlock.h: + (KJS::CodeBlock::CodeBlock): + (KJS::ProgramCodeBlock::ProgramCodeBlock): + (KJS::EvalCodeBlock::EvalCodeBlock): + * VM/Machine.cpp: + (KJS::getCallerFunctionOffset): + * kjs/nodes.cpp: + (KJS::FunctionBodyNode::generateCode): + (KJS::ProgramNode::generateCode): + +2008-06-07 Cameron Zwarich + + Reviewed by Dan Bernstein. + + Bug 17928: testkjs shouldn't require "-f" + + + * kjs/testkjs.cpp: + (printUsageStatement): + (parseArguments): + +2008-06-07 Cameron Zwarich + + Reviewed by Eric. + + Bug 17548: JavaScriptCore print(a, b) differs from Spidermonkey Behavior + + + * kjs/testkjs.cpp: + (functionPrint): + +2008-06-07 Cameron Zwarich + + Reviewed by Sam. + + Bug 17547: JavaScriptCore print() differs from Spidermonkey Behavior + + + * kjs/testkjs.cpp: + (functionPrint): + +2008-06-07 Alexey Proskuryakov + + More build fixes. + + * kjs/JSGlobalData.cpp: Fixed an included file name for case-sensitive file systems, fixed + JSGlobalData::threadInstance() for non-multithreaded builds. + +2008-06-07 Alexey Proskuryakov + + Build fix - actually adding JSGlobalData.cpp to non-Mac builds! + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCoreSources.bkl: + +2008-06-07 Alexey Proskuryakov + + Try to fix Gtk/gcc 4.3 build. + + * kjs/JSGlobalData.h: Include ustring.h instead of forward-declaring UString::Rep. + +2008-06-06 Alexey Proskuryakov + + Reviewed by Darin. + + Combine per-thread objects into one, to make it easier to support legacy clients (for + which they shouldn't be really per-thread). + + No change on SunSpider total. + + * JavaScriptCore.xcodeproj/project.pbxproj: Added JSGlobalData.{h,cpp} + + * kjs/JSGlobalData.cpp: Added. + (KJS::JSGlobalData::JSGlobalData): + (KJS::JSGlobalData::~JSGlobalData): + (KJS::JSGlobalData::threadInstance): + * kjs/JSGlobalData.h: Added. + This class encapsulates all data that should be per-thread (or shared between legacy clients). + It will also keep a Heap pointer, but right now, Heap (Collector) methods are all static. + + * kjs/identifier.h: + (KJS::Identifier::Identifier): + Added a constructor explicitly taking JSGlobalData to access IdentifierTable. Actually, + all of them should, but this will be a separate patch. + + * kjs/identifier.cpp: + (KJS::IdentifierTable::literalTable): + (KJS::createIdentifierTable): + (KJS::deleteIdentifierTable): + (KJS::Identifier::add): + (KJS::Identifier::addSlowCase): + Combined IdentifierTable and LiteralIdentifierTable into a single class for simplicity. + + * kjs/grammar.y: kjsyyparse now takes JSGlobalData, not just a Lexer. + + * kjs/nodes.cpp: + (KJS::Node::Node): + (KJS::EvalFunctionCallNode::emitCode): + (KJS::ScopeNode::ScopeNode): + Changed to access Lexer and Parser via JSGlobalData::threadInstance(). This is also a + temporary measure, they will need to use JSGlobalData explicitly. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::callEval): + * kjs/CommonIdentifiers.cpp: + (KJS::CommonIdentifiers::CommonIdentifiers): + * kjs/CommonIdentifiers.h: + * kjs/DebuggerCallFrame.cpp: + (KJS::DebuggerCallFrame::evaluate): + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + * kjs/ExecState.h: + (KJS::ExecState::globalData): + (KJS::ExecState::identifierTable): + (KJS::ExecState::propertyNames): + (KJS::ExecState::emptyList): + (KJS::ExecState::lexer): + (KJS::ExecState::parser): + (KJS::ExecState::arrayTable): + (KJS::ExecState::dateTable): + (KJS::ExecState::mathTable): + (KJS::ExecState::numberTable): + (KJS::ExecState::RegExpImpTable): + (KJS::ExecState::RegExpObjectImpTable): + (KJS::ExecState::stringTable): + * kjs/InitializeThreading.cpp: + (KJS::initializeThreadingOnce): + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::init): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): + (KJS::JSGlobalObject::head): + (KJS::JSGlobalObject::globalData): + * kjs/Parser.cpp: + (KJS::Parser::parse): + * kjs/Parser.h: + * kjs/function.cpp: + (KJS::FunctionImp::getParameterName): + (KJS::IndexToNameMap::unMap): + (KJS::globalFuncEval): + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::construct): + * kjs/interpreter.cpp: + (KJS::Interpreter::checkSyntax): + (KJS::Interpreter::evaluate): + * kjs/lexer.cpp: + (kjsyylex): + * kjs/lexer.h: + * kjs/testkjs.cpp: + (prettyPrintScript): + Updated for the above changes. Most of threadInstance uses here will need to be replaced with + explicitly passed pointers to support legacy JSC clients. + + * JavaScriptCore.exp: Removed KJS::parser(). + +2008-06-06 Cameron Zwarich + + Reviewed by Oliver. + + Bug 19424: Add support for logging opcode pair counts + + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.cpp: + (KJS::OpcodeStats::OpcodeStats): + (KJS::compareOpcodeIndices): + (KJS::compareOpcodePairIndices): + (KJS::OpcodeStats::~OpcodeStats): + (KJS::OpcodeStats::recordInstruction): + (KJS::OpcodeStats::resetLastInstruction): + * VM/Opcode.h: + +2008-06-06 Kevin McCullough + + Reviewed by Adam. + + JSProfiler: Remove the recursion limit in the + profiler. + - Change the remaining functions that do not take arguments, from using + recursion to using iteration. + + * JavaScriptCore.exp: + * profiler/Profile.cpp: + (KJS::stopProfiling): + (KJS::restoreAll): + (KJS::Profile::stopProfiling): Use foreach instead of recursion. + (KJS::Profile::restoreAll): Ditto. + * profiler/Profile.h: + * profiler/ProfileNode.cpp: Remove recursion. + (KJS::ProfileNode::stopProfiling): + (KJS::ProfileNode::restore): + * profiler/ProfileNode.h: + +2008-06-05 Oliver Hunt + + Reviewed by Alexey. + + Fix Greater and GreaterEq nodes to emit code for the left + and right sub-expressions in the correct order. + + * kjs/nodes.cpp: + (KJS::GreaterNode::emitCode): + (KJS::GreaterEqNode::emitCode): + +2008-06-05 Antti Koivisto + + Reviewed by Alp Toker. + + Fix whitespaces. + + * kjs/collector.cpp: + (KJS::getPlatformThreadRegisters): + +2008-06-05 Antti Koivisto + + Reviewed by Darin. + + Support compiling JavaScriptCore for ARM. + + * kjs/collector.cpp: + (KJS::getPlatformThreadRegisters): + (KJS::otherThreadStackPointer): + +2008-06-05 Kevin McCullough + + Reviewed by Jon. + + - Name changes. + + * JavaScriptCore.exp: + * profiler/Profile.cpp: + (KJS::Profile::Profile): + (KJS::Profile::stopProfiling): + (KJS::Profile::didExecute): + (KJS::Profile::forEach): + (KJS::Profile::debugPrintData): + (KJS::Profile::debugPrintDataSampleStyle): + * profiler/Profile.h: + (KJS::Profile::callTree): + (KJS::Profile::totalTime): + (KJS::Profile::sortTotalTimeDescending): + (KJS::Profile::sortTotalTimeAscending): + (KJS::Profile::sortSelfTimeDescending): + (KJS::Profile::sortSelfTimeAscending): + (KJS::Profile::sortCallsDescending): + (KJS::Profile::sortCallsAscending): + (KJS::Profile::sortFunctionNameDescending): + (KJS::Profile::sortFunctionNameAscending): + (KJS::Profile::focus): + (KJS::Profile::exclude): + (KJS::Profile::restoreAll): + +2008-06-05 Geoffrey Garen + + Reviewed by Stephanie Lewis. + + Added the -fno-move-loop-invariants flag to the pcre_exec.cpp build, to + tell GCC not to perform loop invariant motion, since GCC's loop + invariant motion doesn't do very well with computed goto code. + + SunSpider reports no change. + +2008-06-05 Geoffrey Garen + + Reviewed by Stephanie Lewis. + + Added the -fno-tree-pre flag to the Machine.cpp build, to tell GCC not + to perform Partial Redundancy Elimination (PRE) on trees in Machine.cpp, + since GCC's PRE doesn't do very well with computed goto code. + + SunSpider reports a .7% speedup. + +2008-06-05 Geoffrey Garen + + Reviewed by Stephanie Lewis (or maybe the other way around). + + Minor change to PCRE to help out certain compilers. + + SunSpider reports no change, maybe a small speedup. + + * pcre/pcre_exec.cpp: + (match): Use instructionPtr++ a little less, to avoid confusing the + optimizer. + +2008-06-05 Alexey Proskuryakov + + Re-landing an independent part of a previously rolled out threading patch. + + * wtf/ThreadSpecific.h: Make sure to initialize POD thread-specific varaibles, too + (replaced "new T" with "new T()"). + +2008-06-05 Maciej Stachowiak + + Reviewed by Hyatt. + + - force inlining of a template function that only has one call site per specialization + 1.3% speedup on SunSpider + + * kjs/collector.cpp: + (KJS::Collector::heapAllocate): This template function is only + called from allocate() and allocateNumber() (once per + specialization) and the extra call overhead for GC allocation + shows up, so force inlining. + +2008-06-05 Maciej Stachowiak + + Reviewed by Alexey and Oliver. + + - remove profiler fetch hack + I measure an 0.5% progression from this, others show a wash. It seems not needed any more. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-06-05 Cameron Zwarich + + Reviewed by Maciej. + + Bug 19400: subscript operator does not protect base when necessary + + + Use a temporary for the base in BracketAccessorNode if the subscript + might possibly modify it. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::BracketAccessorNode::emitCode): + * kjs/nodes.h: + (KJS::BracketAccessorNode::): + +2008-06-04 Sam Weinig + + Reviewed by Maciej Stachowiak. + + Big cleanup of formatting and whitespace. + +2008-06-04 Cameron Zwarich + + Reviewed by Oliver. + + Add an option to dump statistics on executed instructions. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.cpp: + (KJS::OpcodeStats::~OpcodeStats): + (KJS::OpcodeStats::recordInstruction): + * VM/Opcode.h: + +2008-06-04 Kevin McCullough + + Reviewed by Geoff. + + JSProfiler: Remove the recursion limit in the + profiler. + - This patch removes the use of recursion for the sort functions. + + * JavaScriptCore.exp: Change the signatures of the functions being + exported. + * profiler/Profile.cpp: + (KJS::Profile::sort): This generic function will accept any of the + static sort functions and apply them to the whole tree. + * profiler/Profile.h: All of the sorting functions now call the new + sort() function. + (KJS::Profile::sortTotalTimeDescending): + (KJS::Profile::sortTotalTimeAscending): + (KJS::Profile::sortSelfTimeDescending): + (KJS::Profile::sortSelfTimeAscending): + (KJS::Profile::sortCallsDescending): + (KJS::Profile::sortCallsAscending): + (KJS::Profile::sortFunctionNameDescending): + (KJS::Profile::sortFunctionNameAscending): + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::ProfileNode): m_head used to point to the head node + if this was the head node. It now points to null to make iteration easy + (KJS::ProfileNode::willExecute): Now must check if m_head is null, this + check used to happend in the constructor. + (KJS::ProfileNode::stopProfiling): Again the check is slightly different + to determine if this is the head. + (KJS::ProfileNode::traverseNextNode): This function returns the next + node in post order. + (KJS::ProfileNode::sort): This generic function will sort according to + the comparator passed in, then reset the children pointers to macth the + new order. + * profiler/ProfileNode.h: The sorting function were removed from the + definition file and instead use the new generic sort() function + (KJS::ProfileNode::totalPercent): because the head can now be empty we + need to check here too for the head node. + (KJS::ProfileNode::selfPercent): Ditto + (KJS::ProfileNode::firstChild): This function is necessary for the + iterative algorithm in Profile.cpp. + (KJS::ProfileNode::sortTotalTimeDescending): + (KJS::ProfileNode::sortTotalTimeAscending): + (KJS::ProfileNode::sortSelfTimeDescending): + (KJS::ProfileNode::sortSelfTimeAscending): + (KJS::ProfileNode::sortCallsDescending): + (KJS::ProfileNode::sortCallsAscending): + (KJS::ProfileNode::sortFunctionNameDescending): + (KJS::ProfileNode::sortFunctionNameAscending): + (KJS::ProfileNode::childrenBegin): + (KJS::ProfileNode::childrenEnd): + (KJS::ProfileNode::totalTimeDescendingComparator): + (KJS::ProfileNode::totalTimeAscendingComparator): + (KJS::ProfileNode::selfTimeDescendingComparator): + (KJS::ProfileNode::selfTimeAscendingComparator): + (KJS::ProfileNode::callsDescendingComparator): + (KJS::ProfileNode::callsAscendingComparator): + (KJS::ProfileNode::functionNameDescendingComparator): + (KJS::ProfileNode::functionNameAscendingComparator): + +2008-06-04 Alexey Proskuryakov + + Reviewed by Darin. + + Fix JSClassCreate to work with old JSCore API threading model. + + No change on SunSpider. + + * API/JSClassRef.cpp: (OpaqueJSClass::OpaqueJSClass): Since JSClass is constructed without + a context, there is no way for it to create Identifiers. + Also, added initializeThreading(), just for good measure. + + * API/JSCallbackObjectFunctions.h: (KJS::::getPropertyNames): Make an Identifier out of the + string here, because propertyNames.add() needs that. + + * kjs/identifier.cpp: + * kjs/identifier.h: + (KJS::Identifier::equal): + * kjs/ustring.cpp: + (KJS::equal): + Moved equal() from identifier.h to ustring.h, because it's not really about Identifiers, + and to make it possible to use it from StrHash. + Include StrHash.h from ustring.h to avoid having the behavior depend on headers that happen + to be included. + + * wtf/StrHash.h: Removed. + * kjs/ustring.h: Made RefPtr use the same default hash as UString::Rep* (it + used to default to pointer equality). Moved the whole StrHash header into ustring.h. + + * JavaScriptCore.exp: Export equal() for WebCore use (this StrHash is used in c_class.cpp, + jni_class.cpp, and npruntime.cpp). + +2008-06-04 Alexey Proskuryakov + + Rubber-stamped by Darin. + + Fix spacing in collector.{h,cpp}. + + * kjs/collector.cpp: + * kjs/collector.h: + +2008-06-03 Cameron Zwarich + + Reviewed by Maciej. + + Build fix. The cleanup in r34355 missed a method. + + * kjs/nodes.cpp: + * kjs/nodes.h: + +2008-06-03 Darin Adler + + Reviewed by Geoff. + + - https://bugs.webkit.org/show_bug.cgi?id=19269 + speed up SunSpider by eliminating the toObject call for most get/put/delete + + Makes standalone SunSpider 1.025x as fast as before. + + The getOwnPropertySlot virtual function now takes care of the toObject call + for get. Similarly, the put function (and later deleteProperty) does the + same for those operations. To do this, the virtual functions were moved from + the JSObject class to the JSCell class. Also, since the caller no longer knows + the identity of the "original object", which is used by JavaScript-function + based getters, changed the PropertySlot class so the original object is + already stored in the slot when getOwnPropertySlot is called, if the caller + intends to call getValue. + + This affected the old interpreter code enough that the easiest thing for me + was to just delete it. While I am not certain the mysterious slowdown is not + still occurring, the net change is definitely a significant speedup. + + * JavaScriptCore.exp: Updated. + + * VM/Machine.cpp: Moved the UNLIKELY macro into AlwaysInline.h. + (KJS::resolve): Set up the originalObject in the PropertySlot before + calling getPropertySlot. Also removed the originalObject argument from + getValue. + (KJS::resolve_skip): Ditto. + (KJS::resolveBaseAndProperty): Ditto. + (KJS::resolveBaseAndFunc): Ditto. + (KJS::Machine::privateExecute): Removed the toObject calls from the get and + put functions where possible, instead calling directly with JSValue and letting + the JSValue and JSCell calls handle toObject. Same for toThisObject. + + * kjs/ExecState.h: Removed OldInterpreterExecState. + + * API/JSBase.cpp: Updated includes. + + * kjs/LocalStorageEntry.h: Removed contents. Later we can remove the file too. + + * kjs/array_instance.cpp: + (KJS::ArrayInstance::lengthGetter): Removed originalObject argumet. + (KJS::ArrayInstance::inlineGetOwnPropertySlot): Don't pass a base value to + setValueSlot. Also use UNLIKELY around the "getting elements past the end of + the array" code path; less common than successfully getting an element. + + * kjs/array_object.cpp: + (KJS::getProperty): Initialize the PropertySlot with the original object. + Don't pass the original object to the get function. + (KJS::arrayProtoFuncFilter): Ditto. + (KJS::arrayProtoFuncMap): Ditto. + (KJS::arrayProtoFuncEvery): Ditto. + (KJS::arrayProtoFuncForEach): Ditto. + (KJS::arrayProtoFuncSome): Ditto. + + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::construct): Removed an obsolete comment. + + * kjs/grammar.y: Eliminated support for some of the node types that were + used to optimize executing from the syntax tree. + + * kjs/internal.cpp: + (KJS::StringImp::toThisObject): Added. Same as toObject. + (KJS::NumberImp::toThisObject): Ditto. + (KJS::GetterSetterImp::getOwnPropertySlot): Added. Not reached. + (KJS::GetterSetterImp::put): Ditto. + (KJS::GetterSetterImp::toThisObject): Ditto. + + * kjs/internal.h: Added toThisObject to NumberImp for speed. + + * kjs/lexer.cpp: + (KJS::Lexer::shift): Changed shift to just do a single character, to unroll + the loop and especially to make the one character case faster. + (KJS::Lexer::setCode): Call shift multiple times instead of passing a number. + (KJS::Lexer::lex): Ditto. + (KJS::Lexer::matchPunctuator): Ditto. Also removed unneeded elses after returns. + (KJS::Lexer::scanRegExp): Ditto. + * kjs/lexer.h: Removed the count argument from shift. + + * kjs/math_object.cpp: + (KJS::mathProtoFuncPow): Call jsNaN instead of jsNumber(NaN). + + * kjs/nodes.cpp: Removed some of the things needed only for the pre-SquirrelFish + execution model. + (KJS::ForNode::emitCode): Handle cases where some expressions are missing by + not emitting any code at all. The old way was to emit code for "true", but + this is an unnecessary remnant of the old way of doing things. + + * kjs/nodes.h: Removed some of the things needed only for the pre-SquirrelFish + execution model. + + * kjs/object.cpp: + (KJS::JSObject::fillGetterPropertySlot): Changed to only pass in the getter + function. The old code passed in a base, but it was never used when + actually getting the property; the toThisObject call was pointless. Also + changed to not pass a base for setUndefined. + + * kjs/object.h: Added the new JSCell operations to GetterSetterImp. + Never called. + (KJS::JSObject::get): Initialize the object in the PropertySlot and don't + pass it in getValue. + (KJS::JSObject::getOwnPropertySlotForWrite): Removed the base argument + in calls to setValueSlot. + (KJS::JSObject::getOwnPropertySlot): Ditto. + (KJS::JSValue::get): Added. Here because it calls through to JSObject. + A version of JSObject::get that also handles the other types of JSValue + by creating the appropriate wrapper. Saves the virtual call to toObject. + (KJS::JSValue::put): Ditto. + (KJS::JSValue::deleteProperty): Ditto. + + * kjs/property_slot.cpp: + (KJS::PropertySlot::undefinedGetter): Removed the originalObject argument. + (KJS::PropertySlot::ungettableGetter): Ditto. + (KJS::PropertySlot::functionGetter): Ditto. Use the value in the base + as the "this" object, which will be set to the original object by the new + PropertySlot initialization code. Also call toThisObject. The old code did + not do this, but needed to so we can properly handle the activation object + like the other similar code paths. + + * kjs/property_slot.h: + (KJS::PropertySlot::PropertySlot): Added a constructor that takes a base + object. In debug builds, set the base to 0 if you don't pass one. + (KJS::PropertySlot::getValue): Don't take or pass the originalObject. + (KJS::PropertySlot::setValueSlot): Don't take a base object, and clear the + base object in debug builds. + (KJS::PropertySlot::setGetterSlot): Ditto. + (KJS::PropertySlot::setUndefined): Ditto. + (KJS::PropertySlot::setUngettable): Ditto. + (KJS::PropertySlot::slotBase): Assert that a base object is present. + This will fire if someone actually calls the get function without having + passed in a base object and the getter needs it. + (KJS::PropertySlot::setBase): Added. Used by the code that implements + toObject so it can supply the original object after the fact. + (KJS::PropertySlot::clearBase): Added. Clears the base, but is debug-only + code because it's an error to fetch the base if you don't have a guarantee + it was set. + + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + (KJS::JSCallbackObject::cachedValueGetter): + (KJS::JSCallbackObject::staticValueGetter): + (KJS::JSCallbackObject::staticFunctionGetter): + (KJS::JSCallbackObject::callbackGetter): + * kjs/JSActivation.cpp: + (KJS::JSActivation::getOwnPropertySlot): + (KJS::JSActivation::argumentsGetter): + * kjs/JSActivation.h: + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTableGet): + * kjs/array_instance.h: + * kjs/function.cpp: + (KJS::FunctionImp::argumentsGetter): + (KJS::FunctionImp::callerGetter): + (KJS::FunctionImp::lengthGetter): + (KJS::Arguments::mappedIndexGetter): + * kjs/function.h: + * kjs/lookup.h: + (KJS::staticFunctionGetter): + (KJS::staticValueGetter): + * kjs/string_object.cpp: + (KJS::StringInstance::lengthGetter): + (KJS::StringInstance::indexGetter): + (KJS::stringInstanceNumericPropertyGetter): + * kjs/string_object.h: + Removed originalObject arguments from getters. Don't pass base values to + the various PropertySlot functions that no longer take them. + + * kjs/value.cpp: + (KJS::JSCell::getOwnPropertySlot): Added. Calls toObject and then sets the slot. + This function has to always return true, because the caller can't walk the prototype + chain. Because of that, we do a getPropertySlot, not getOwnPropertySlot, which works + for the caller. This is private, only called by getOwnPropertySlotInternal. + (KJS::JSCell::put): Added. Calls toObject and then put. + (KJS::JSCell::toThisObject): Added. Calls toObject. + + * kjs/value.h: Added get, put, and toThisObject to both JSValue + and JSCell. These take care of the toObject operation without an additional virtual + function call, and so make the common "already an object" case faster. + + * wtf/AlwaysInline.h: Moved the UNLIKELY macro here for now. Maybe we can find a + better place later, or rename this header. + +2008-06-03 Oliver Hunt + + Reviewed by Tim. + + Bug 12983: Web Inspector break on the debugger keyword + + + Added a DebuggerStatementNode to handle codegen, and added a new + DidReachBreakPoint debug event (which will hopefully be useful + if we ever move breakpoint management into JSC proper). Also + added didReachBreakpoint to Debugger to allow us to actually respond + to this event. + + * VM/CodeBlock.cpp: + (KJS::debugHookName): + * VM/Machine.cpp: + (KJS::Machine::debug): + * VM/Machine.h: + * kjs/debugger.h: + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::DebuggerStatementNode::emitCode): + (KJS::DebuggerStatementNode::execute): + * kjs/nodes.h: + (KJS::DebuggerStatementNode::): + * kjs/nodes2string.cpp: + (KJS::DebuggerStatementNode::streamTo): + +2008-06-03 Maciej Stachowiak + + Reviewed by Oliver. + + - document remaining opcodes. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Document call, call_eval, + construct, ret and end opcodes. + +2008-06-03 Maciej Stachowiak + + Reviewed by Oliver. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Document throw and catch opcodes. + +2008-06-02 Geoffrey Garen + + Reviewed by Alexey Proskuryakov. + + Removed JSObject::call, since it just called JSObject::callAsFunction. + + SunSpider reports no change. + +2008-06-02 Geoffrey Garen + + Reviewed by Darin Adler. + + A little cleanup in the CodeGenerator. + + * VM/CodeGenerator.cpp: A few changes here. + + (1) Removed remaining cases of the old hack of putting "this" into the + symbol table; replaced with explicit tracking of m_thisRegister. + + (2) Made m_thisRegister behave the same for function, eval, and program + code, removing the static programCodeThis() function. + + (3) Added a feature to nix a ScopeNode's declaration stacks when done + compiling, to save memory. + + (4) Removed code that copied eval declarations into special vectors: we + just use the originals in the ScopeNode now. + + * VM/CodeGenerator.h: Removed unneded parameters from the CodeGenerator + constructor: we just use get that data from the ScopeNode now. + + * VM/Machine.cpp: + (KJS::Machine::execute): When executing an eval node, don't iterate a + special copy of its declarations; iterate the originals, instead. + + * kjs/nodes.cpp: Moved responsibility for knowing what AST data to throw + away into the CodeGenerator. Nodes no longer call shrinkCapacity on + their data directly. + + * kjs/nodes.h: Changed FunctionStack to ref its contents, so declaration + data stays around even after we've thrown away the AST, unless we explicitly + throw away the declaration data, too. This is useful for eval code, which + needs to reference its declaration data at execution time. (Soon, it will + be useful for program code, too, since program code should do the same.) + +2008-06-02 Adam Roben + + Build fix for non-AllInOne builds + + * kjs/array_object.cpp: Added a missing #include. + +2008-06-02 Kevin McCullough + + Took out accidental confilct lines I checked in. + + * ChangeLog: + +2008-06-02 Kevin McCullough + + Reviewed by Darin. + + JSProfiler: Remove the recursion limit in the + profiler + Implement Next Sibling pointers as groundwork for removing the recursion + limit in the profiler. + + * profiler/ProfileNode.cpp: Also I renamed parentNode and headNode since + 'node' is redundant. + (KJS::ProfileNode::ProfileNode): Initialize the nextSibling. + (KJS::ProfileNode::willExecute): If there are already children then the + new child needs to be the nextSibling of the last child. + (KJS::ProfileNode::didExecute): + (KJS::ProfileNode::addChild): Ditto. + (KJS::ProfileNode::stopProfiling): + (KJS::ProfileNode::sortTotalTimeDescending): For all of the sorting + algorithms once the children are sorted their nextSibling pointers need + to be reset to reflect the new order. + (KJS::ProfileNode::sortTotalTimeAscending): + (KJS::ProfileNode::sortSelfTimeDescending): + (KJS::ProfileNode::sortSelfTimeAscending): + (KJS::ProfileNode::sortCallsDescending): + (KJS::ProfileNode::sortCallsAscending): + (KJS::ProfileNode::sortFunctionNameDescending): + (KJS::ProfileNode::sortFunctionNameAscending): + (KJS::ProfileNode::resetChildrensSiblings): This new function simply + loops over all of the children and sets their nextSibling pointers to + the next child in the Vector + (KJS::ProfileNode::debugPrintData): + * profiler/ProfileNode.h: + (KJS::ProfileNode::parent): + (KJS::ProfileNode::setParent): + (KJS::ProfileNode::nextSibling): + (KJS::ProfileNode::setNextSibling): + (KJS::ProfileNode::totalPercent): + (KJS::ProfileNode::selfPercent): + +2008-06-02 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Removed the recursion limit from JSObject::call, since the VM does + recursion checking now. + + This should allow us to remove JSObject::call entirely, netting a small + speedup. + + * kjs/object.cpp: + (KJS::JSObject::call): + +2008-06-02 Geoffrey Garen + + Reviewed by Adele Peterson. + + Added a specific affordance for avoiding stack overflow when converting + recursive arrays to string, in preparation for removing generic stack + overflow checking from JSObject::call. + + Tested by fast/js/toString-stack-overflow.html. + +2008-06-02 Geoffrey Garen + + Reviewed by Alice Liu. + + Refactored some hand-rolled code to call ScopeChain::globalObject instead. + +2008-06-02 Geoffrey Garen + + Reviewed by Darin Adler. + + Fixed ASSERT due to execution continuing after an exception is thrown + during array sort. + + * kjs/array_instance.cpp: + (KJS::AVLTreeAbstractorForArrayCompare::compare_key_key): Don't call the + custom comparator function if an exception has been thrown. Just return + 1 for everything, so the sort completes quickly. (The result will be + thrown away.) + +2008-05-30 Timothy Hatcher + + Made the starting line number of scripts be 1-based throughout the engine. + This cleans up script line numbers so they are all consistent now and fixes + some cases where script execution was shown as off by one line in the debugger. + + No change in SunSpider. + + Reviewed by Oliver Hunt. + + * API/minidom.c: + (main): Pass a line number of 1 instead of 0 to parser().parse(). + * API/testapi.c: + (main): Ditto. And removes a FIXME and changed an assertEqualsAsNumber + to use 1 instead of 2 for the line number. + * VM/Machine.cpp: + (KJS::callEval): Pass a line number of 1 instead of 0. + (KJS::Machine::debug): Use firstLine for WillExecuteProgram instead of + lastLine. Use lastLine for DidExecuteProgram instead of firstLine. + * kjs/DebuggerCallFrame.cpp: + (KJS::DebuggerCallFrame::evaluate): Pass a line number of 1 instead of + 0 to parser().parse(). + * kjs/Parser.cpp: + (KJS::Parser::parse): ASSERT startingLineNumber is greatter than 0. Change + the startingLineNumber to be 1 if it was less than or equal to 0. This is needed + for release builds to maintain compatibility with the JavaScriptCore API. + * kjs/function.cpp: + (KJS::globalFuncEval): Pass a line number of 1 instead of 0 to parser().parse(). + * kjs/function_object.cpp: + (FunctionObjectImp::construct): Pass a line number of 1 instead of 0 to construct(). + * kjs/lexer.cpp: + (Lexer::setCode): Made yylineno = startingLineNumber instead of adding 1. + * kjs/testkjs.cpp: + (functionRun): Pass a line number of 1 instead of 0 to Interpreter::evaluate(). + (functionLoad): Ditto. + (prettyPrintScript): Ditto. + (runWithScripts): Ditto. + * profiler/Profiler.cpp: + (WebCore::createCallIdentifier): Removed a plus 1 of startingLineNumber. + +2008-05-30 Alexey Proskuryakov + + Reviewed by Darin. + + https://bugs.webkit.org/show_bug.cgi?id=19180 + speed up SunSpider by optimizing immediate number cases + + Also fixed a JavaScriptCore regression seen on PowerPC - we didn't clip left shift + parameter to 0...31. + + 0.5% improvement on SunSpider overall, although a 8.5 regression on bitops-3bit-bits-in-byte. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + + * kjs/JSImmediate.h: + (KJS::JSImmediate::toTruncatedUInt32): Added. Same as getTruncatedInt32, but casts the result + to unsigned. + +2008-05-30 Alexey Proskuryakov + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=19180 + speed up SunSpider by optimizing immediate number cases + + Also fixed two JavaScriptCore regressions seen on PowerPC - we didn't clip right shift + parameter to 0...31. + + 1.6% improvement on SunSpider, without significant regressions on any tests. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + Added fast paths for >>, ==, ===, !=, !==. Changed order of memory accesses in many + cases, making them less dependent on gcc's ability to properly assign registers. With this, + I could move exception checks back into slow code paths, and saw less randomness in general. + + * kjs/JSImmediate.h: + (KJS::JSImmediate::rightShiftImmediateNumbers): + Added. + +2008-05-29 Maciej Stachowiak + + Reviewed by Oliver. + + - fixed REGRESSION(r33979): Flash clips do not play on cnn.com + + Finally blocks could clobber registers that had to remain live + until they returned. This patch takes a conservative approach and + makes sure that finally blocks do not reuse any registers that + were previously allocated for the function. In the future this + could probably be tightened up to be less profligate with the + register allocation. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::highestUsedRegister): + * VM/CodeGenerator.h: + * kjs/nodes.cpp: + (KJS::TryNode::emitCode): + +2008-05-29 Steve Falkenburg + + Build fix. + + * kjs/array_instance.cpp: + +2008-05-29 Alexey Proskuryakov + + Reviewed by Darin. + + https://bugs.webkit.org/show_bug.cgi?id=19294 + A crash when iterating over a sparse array backwards. + + * kjs/array_instance.cpp: Turned sparseArrayCutoff into a macro, so that using max() on it + doesn't cause a PIC branch. + (KJS::ArrayInstance::increaseVectorLength): Added a comment about this function not + preserving class invariants. + (KJS::ArrayInstance::put): Update m_storage after reallocation. Move values that fit to + the vector from the map in all code paths. + +2008-05-29 Thiago Macieira + + Reviewed by Simon. + + Fix compilation in Solaris with Sun CC + + Lots of WebKit code uses C99 functions that, strict as it + is, the Solaris system doesn't provide in C++. So we must define them + for both GCC and the Sun CC. + + * wtf/MathExtras.h: + +2008-05-28 Oliver Hunt + + Reviewed by Anders. + + Fix codegen for assignment being used as a function. + + FunctionCallValueNode::emitCode failed to account for the + potential of the function expression to allocate arbitrary + registers. + + * kjs/nodes.cpp: + (KJS::FunctionCallValueNode::emitCode): + +2008-05-27 Geoffrey Garen + + Reviewed by Tim Hatcher. + + Fixed https://bugs.webkit.org/show_bug.cgi?id=19183 + REGRESSION (r33979): Crash in DebuggerCallFrame::functionName when + clicking button in returnEvent-crash.html + + Added two new debugger hooks, willExecuteProgram and didExecuteProgram, + along with code to generate them, code to invoke them when unwinding + due to an exception, and code to dump them. + + SunSpider reports no change. + + * VM/CodeBlock.cpp: + (KJS::debugHookName): I had to mark this function NEVER_INLINE to avoid + a .4% performance regression. The mind boggles. + +2008-05-28 Adam Roben + + Fix JavaScriptCore tests on OS X + + We were quoting the path to testkjs too late, after it had already + been combined with spaces and other options. + + * tests/mozilla/jsDriver.pl: + (top level): Move path quoting from here... + (sub get_kjs_engine_command): ...to here. + +2008-05-28 Anders Carlsson + + Reviewed by Oliver. + + "const f" crashes in JavaScriptCore + + Make sure to null check the initializer. + + * kjs/nodes.cpp: + (KJS::ConstDeclNode::emitCodeSingle): + +2008-05-28 Adam Roben + + Make run-javascriptcore-tests work with a space in the path to testkjs + + Reviewed by Alexey Proskuryakov. + + * tests/mozilla/jsDriver.pl: Quote the path to the engine so that + spaces will be interpreted correctly. + +2008-05-28 Alexey Proskuryakov + + Fixed a misguiding comment - my measurement for negative numbers only included cases + where both operands were negative, which is not very interesting. + + * VM/Machine.cpp: + +2008-05-28 Alexey Proskuryakov + + Reviewed by Maciej. + + Based on a patch by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=19180 + speed up SunSpider by optimizing immediate number cases + + 1.4% speedup on SunSpider. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/JSImmediate.h: + (KJS::JSImmediate::incImmediateNumber): + (KJS::JSImmediate::decImmediateNumber): + Added fast paths for ++ and --. + + (KJS::JSImmediate::canDoFastAdditiveOperations): Corrected a comment. + +2008-05-28 Alexey Proskuryakov + + Reviewed by Darin. + + https://bugs.webkit.org/show_bug.cgi?id=19180 + speed up SunSpider by optimizing immediate number cases + + 2% speedup overall, maximum 10% on controlflow-recursive and bitops-3bit-bits-in-byte, + but a 4% regression on bitops-bits-in-byte and bitops-bitwise-and. + + * kjs/JSImmediate.h: + (KJS::JSImmediate::canDoFastAdditiveOperations): + (KJS::JSImmediate::addImmediateNumbers): + (KJS::JSImmediate::subImmediateNumbers): + Added fast cases that work with positive values less than 2^30. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Use the above operations. Also updated SunSpider frequencies + with my results (looks like tag values have changed, not sure what caused the minor variation + in actual frequencies). + +2008-05-27 Adam Roben + + Windows build fix + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make: + Remove code that appended Cygwin's /bin directory to PATH. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.vcproj: + Prepend Cygwin's /bin directory to PATH. We prepend instead of append + so that Cygwin's utilities will win out over Win32 versions of the + same utilities (particularly perl). We do the prepend here instead of + in the Makefile because nmake doesn't seem to like prepending to PATH + inside the Makefile. This also matches the way WebCoreGenerated works. + +2008-05-27 Adam Roben + + Roll out r34163 + + A better fix is on the way. + + * DerivedSources.make: + * JavaScriptCore.vcproj/JavaScriptCore/build-generated-files.sh: + +2008-05-27 Adam Roben + + Windows build fix + + * DerivedSources.make: Don't generate the bytecode docs if + OMIT_BYTECODE_DOCS is set to 1. + * JavaScriptCore.vcproj/JavaScriptCore/build-generated-files.sh: Set + OMIT_BYTECODE_DOCS for production builds. + +2008-05-27 Anders Carlsson + + Reviewed by Geoff and Maciej. + + + https://bugs.webkit.org/show_bug.cgi?id=17925 + Crash in KJS::JSObject::put after setting this.__proto__ + + Set slotIsWriteable to false for __proto__, we want setting __proto__ to go through JSObject::put instead. + + * kjs/object.h: + (KJS::JSObject::getOwnPropertySlotForWrite): + +2008-05-27 Kevin Ollivier + + wx build fixes to catch up with SquirrelFish, etc. + + * JavaScriptCoreSources.bkl: + * jscore.bkl: + * wtf/Platform.h: + +2008-05-27 Darin Adler + + Reviewed by Tim Hatcher. + + - https://bugs.webkit.org/show_bug.cgi?id=19180 + speed up SunSpider by optimizing immediate number cases + + Add immediate number cases for the &, |, and ^ operators. + Makes standalone SunSpider 1.010x faster. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Add areBothImmediateNumbers special cases + for the &, |, and ^ operators. + + * kjs/JSImmediate.h: + (KJS::JSImmediate::xorImmediateNumbers): Added. + (KJS::JSImmediate::orImmediateNumbers): Added. + +2008-05-26 Stephanie Lewis + + Windows build fix. + + * kjs/testkjs.cpp: + +2008-05-26 Maciej Stachowiak + + Reviewed by Anders. + + - make addStaticGlobals protected instead of private so subclasses can use it + + * JavaScriptCore.exp: + * kjs/JSGlobalObject.h: + +2008-05-26 Geoffrey Garen + + Reviewed by Darin Adler. + + Fixed After an eval of a non-string or a syntax + error, all profile stack frames are incorrect + + SunSpider reports a .3% speedup, possibly because eval of a string is a + little more efficient now. + + * VM/Machine.cpp: + (KJS::callEval): Make sure to call didExecute when returning early. I + simplified this function to remove one early return, making the job + of adding special code to early returns easier. + + (KJS::Machine::execute): Use the new function ExecState when notifying + the profiler. (This doesn't change behavior now, but it might prevent + subtle errors in the future.) + +2008-05-23 Tor Arne Vestbø + + Reviewed by Simon. + + Fixed toLower and toUpper implementations to allow being called + with a null result pointer and resultLength, to determine the + number of characters needed for the case conversion. + + * wtf/unicode/qt4/UnicodeQt4.h: + (WTF::Unicode::toLower): + (WTF::Unicode::toUpper): + +2008-05-25 Alexey Proskuryakov + + Fixing a typo in the previous commit made as a last minute change. + + * kjs/regexp_object.cpp: + +2008-05-24 Alexey Proskuryakov + + Reviewed by Darin. + + Changed regular expression matching result array to be lazily filled, because many callers + only care about it being non-null. + + 2% improvement on Acid3 test 26. + + * kjs/array_instance.cpp: Added a void* member to ArrayStorage for ArrayInstance subclasses + to use. + * kjs/array_instance.h: + (KJS::ArrayInstance::lazyCreationData): + (KJS::ArrayInstance::setLazyCreationData): + Added methods to access it from subclasses. + + * kjs/regexp_object.cpp: + (KJS::RegExpMatchesArray::RegExpMatchesArray): + (KJS::RegExpMatchesArray::getOwnPropertySlot): + (KJS::RegExpMatchesArray::put): + (KJS::RegExpMatchesArray::deleteProperty): + (KJS::RegExpMatchesArray::getPropertyNames): + (KJS::RegExpMatchesArray::fillArrayInstanceIfNeeded): + (KJS::RegExpMatchesArray::~RegExpMatchesArray): + (KJS::RegExpObjectImp::arrayOfMatches): + RegExpMatchesArray is a subclass of ArrayInstance that isn't filled until + accessed for the first time. + +2008-05-24 Alp Toker + + Win32/gcc build fix. Remove MSVC assumption. + + * wtf/TCSpinLock.h: + (TCMalloc_SlowLock): + +2008-05-24 Oleg Finkelshteyn + + Rubber-stamped, tweaked and landed by Alexey. + + Build fix for gcc 4.3. + + * JavaScriptCore/kjs/testkjs.cpp: + * JavaScriptCore/VM/CodeBlock.cpp: + Add missing standard includes. + +2008-05-23 Anders Carlsson + + Reviewed by Geoff. + + REGRESSION: Assertion failure in JSImmediate::toString when loading GMail (19217) + + Change List to store a JSValue*** pointer + an offset instead of a JSValue** pointer to protect against the case where + a register file changes while a list object points to its buffer. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/JSActivation.cpp: + (KJS::JSActivation::createArgumentsObject): + * kjs/list.cpp: + (KJS::List::getSlice): + * kjs/list.h: + (KJS::List::List): + (KJS::List::at): + (KJS::List::append): + (KJS::List::begin): + (KJS::List::end): + (KJS::List::buffer): + +2008-05-23 Kevin McCullough + + Reviewed by Sam. + + JSProfiler: Stack overflow if recursion is + too deep. + -Use a simple depth limit to restrict too deep of recursion. + + * profiler/Profile.cpp: + (KJS::Profile::willExecute): + (KJS::Profile::didExecute): + * profiler/Profile.h: + +2008-05-23 Geoffrey Garen + + Rolling back in r34085, with performance resolved. + + Apparently, passing the eval function to callEval gave GCC a hernia. + + Reviewed by Darin Adler, Kevin McCullough, and Oliver Hunt. + + Fixed Crashes and incorrect reporting in the + JavaScript profiler + + * VM/Machine.cpp: + (KJS::Machine::unwindCallFrame): Fixed incorrect reporting / a crash + when unwinding from inside eval and/or program code: detect the + difference, and do the right thing. Also, be sure to notify the profiler + *before* deref'ing the scope chain, since the profiler uses the scope chain. + + (KJS::Machine::execute): Fixed incorrect reporting / crash when calling + a JS function re-entrently: Machine::execute(FunctionBodyNode*...) + should not invoke the didExecute hook, because op_ret already does that. + Also, use the new function's ExecState when calling out to the profiler. + (Not important now, but could have become a subtle bug later.) + + (KJS::Machine::privateExecute): Fixed a hard to reproduce crash when + profiling JS functions: notify the profiler *before* deref'ing the scope + chain, since the profiler uses the scope chain. + + * kjs/object.cpp: + (KJS::JSObject::call): Removed these hooks, because they are now unnecessary. + + * profiler/Profile.cpp: Added a comment to explain a subtlety that only + Kevin and I understood previously. (Now, the whole world can understand!) + + * profiler/Profiler.cpp: + (KJS::shouldExcludeFunction): Don't exclude .call and .apply. That was + a hack to fix bugs that no longer exist. + + Finally, sped things up a little bit by changing the "Is the profiler + running?" check into an ASSERT, since we only call into the profiler + when it's running: + + (KJS::Profiler::willExecute): + (KJS::Profiler::didExecute): + +2008-05-23 Geoffrey Garen + + Reviewed by Oliver Hunt. + + - fixed REGRESSION(r33943-r33980): Can't send email , attach file or save as draft from hotmail.com + + SunSpider reports no change. + + This is a reworking of r34073, which I rolled out because it caused + lots of crashes. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): Use removeDirect to nix old + properties whose names collide with new functions. (Don't use putWithAttributes + because that tries to write to the register file, which hasn't grown to + fit this program yet.) + +2008-05-23 Darin Adler + + Reviewed by Mark Rowe. + + As allocateNumber is used via jsNumberCell outside of JavaScriptCore, + we need to provide a non-inlined version of it to avoid creating a + weak external symbol. + + * JavaScriptCore.exp: + * kjs/AllInOneFile.cpp: + * kjs/collector.cpp: + (KJS::Collector::allocate): + (KJS::Collector::allocateNumber): + * kjs/collector.h: + (KJS::Collector::allocate): + (KJS::Collector::inlineAllocateNumber): + * kjs/value.h: + (KJS::NumberImp::operator new): + +2008-05-23 Geoffrey Garen + + Rolled out r34073 because it caused lots of layout test crashes. + +2008-05-23 Geoffrey Garen + + Rolled out r34085 because it measured as a 7.6% performance regression. + +2008-05-23 Adam Roben + + Windows build fix + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Add the + profiler directory to the include path. + +2008-05-23 Oliver Hunt + + Reviewed by Anders. + + SQUIRRELFISH: JavaScript error messages are missing informative text + + Partial fix. + Tidy up error messages, makes a couple of them provide slightly more info. + Inexplicably leads to a 1% SunSpider Progression. + + * VM/ExceptionHelpers.cpp: + (KJS::createError): + (KJS::createInvalidParamError): + (KJS::createNotAConstructorError): + (KJS::createNotAFunctionError): + * VM/ExceptionHelpers.h: + * VM/Machine.cpp: + (KJS::isNotObject): + +2008-05-23 Oliver Hunt + + Reviewed by Tim H. + + Fix call stack reported by profiler when entering event handlers. + + JSObject::call was arbitrarily notifying the profiler when it was + called, even if it was JS code, which notifies the profile on entry + in any case. + + * kjs/object.cpp: + (KJS::JSObject::call): + +2008-05-16 Alp Toker + + Build fix for gcc 3. Default constructor required in ExecState, + used by OldInterpreterExecState. + + * kjs/ExecState.h: + (KJS::ExecState::ExecState): + +2008-05-23 Mark Rowe + + Reviewed by Oliver Hunt. + + Fix global-recursion-on-full-stack.html crashes under guardmalloc. + + Growing the register file with uncheckedGrow from within Machine::execute is not safe as the + register file may be too close to its maximum size to grow successfully. By using grow, + checking the result and throwing a stack overflow error we can avoid crashing. + + * VM/Machine.cpp: + (KJS::Machine::execute): + * VM/RegisterFile.h: Remove the now-unused uncheckedGrow. + +2008-05-23 Oliver Hunt + + RS=Kevin McCullough + + Remove JAVASCRIPT_PROFILER define + + * VM/Machine.cpp: + (KJS::callEval): + (KJS::Machine::unwindCallFrame): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * kjs/config.h: + * kjs/object.cpp: + (KJS::JSObject::call): + +2008-05-23 Oliver Hunt + + Turn on JavaScript Profiler + + Reviewed by Kevin McCullough. + + Flipped the switch on the profiler, rearranged how we + signal the the profiler is active so that calls aren't + needed in the general case. + + Also fixed the entry point for Machine::execute(FunctionBodyNode..) + to correctly indicate function exit. + + Results in a 0.7-1.0% regression in SunSpider :-( + + * VM/Machine.cpp: + (KJS::callEval): + (KJS::Machine::unwindCallFrame): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * kjs/config.h: + * profiler/Profiler.cpp: + (KJS::Profiler::profiler): + (KJS::Profiler::startProfiling): + (KJS::Profiler::stopProfiling): + * profiler/Profiler.h: + (KJS::Profiler::enabledProfilerReference): + +2008-05-23 Simon Hausmann + + Fix the Qt build by adding profiler/ to the include search path. + + * JavaScriptCore.pri: + +2008-05-22 Kevin McCullough + + Reviewed by Adam. + + Fix a bug in the profiler where time in the current function is given to + (idle). + + * profiler/Profile.cpp: + (KJS::Profile::didExecute): Set the start time and then call didExecute + to calculate the time spent in this function. + * profiler/ProfileNode.cpp: Remove confusing calculations that are no + longer necessary. + (KJS::ProfileNode::insertNode): + * profiler/ProfileNode.h: Expose access to the start time to allow the + simpler time calculations above. + (KJS::ProfileNode::startTime): + (KJS::ProfileNode::setStartTime): + +2008-05-22 Adam Roben + + Show "(Function object)" instead of "(JSInpectorCallbackWrapper + object)" in profiles + + Reviewed by Kevin McCullough. + + * profiler/Profiler.cpp: + (KJS::createCallIdentifier): Use JSObject::className instead of + getting the class name from the ClassInfo directly. JSObject + subclasses can override className to provide a custom class name, and + it seems like we should honor that. + +2008-05-22 Timothy Hatcher + + Added Profile::restoreAll and added ProfileNode::restoreAll + to the export file. + + Reviewed by Adam Roben. + + * JavaScriptCore.exp: + * profiler/Profile.h: + +2008-05-22 Alp Toker + + GTK+ build fix. Add JavaScriptCore/profiler to include path. + + * GNUmakefile.am: + +2008-05-22 Adam Roben + + Implement sub-millisecond profiling on Windows + + Reviewed by Kevin McCullough. + + * profiler/ProfileNode.cpp: + (KJS::getCount): Added. On Windows, we use QueryPerformanceCounter. On + other platforms, we use getCurrentUTCTimeWithMicroseconds. + (KJS::ProfileNode::endAndRecordCall): Use getCount instead of + getCurrentUTCTimeWithMicroseconds. + (KJS::ProfileNode::startTimer): Ditto. + +2008-05-22 Adam Roben + + Fix a profiler assertion when calling a NodeList as a function + + Reviewed by Kevin McCullough. + + * profiler/Profiler.cpp: + (KJS::createCallIdentifier): Don't assert when a non-function object + is called as a function. Instead, build up a CallIdentifier using the + object's class name. + +2008-05-22 Kevin McCullough + + Reviewed by Darin. + + JSProfiler: Allow the profiler to "Exclude" a + profile node. + -Implement 'exclude'; where the excluded node attributes its time to its + parent's self time. + + * JavaScriptCore.exp: Export the exclude function. + * profiler/Profile.h: + (KJS::Profile::exclude): + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::setTreeVisible): New function that allows a change in + visiblitiy to be propogated to all the children of a node. + (KJS::ProfileNode::exclude): If the node matches the callIdentifier then + set the visiblity of this node and all of its children to false and + attribute it's total time to it's caller's self time. + * profiler/ProfileNode.h: + +2008-05-22 Mark Rowe + + Reviewed by Oliver Hunt. + + Fix access to static global variables in Windows release builds. + + * kjs/JSGlobalObject.h: Don't store a reference to an Identifier + in GlobalPropertyInfo as the Identifier is likely to be a temporary + and therefore may be destroyed before the GlobalPropertyInfo. + +2008-05-22 Kevin McCullough + + Build fix. + + * VM/Machine.cpp: + (KJS::callEval): + +2008-05-22 Kevin McCullough + + Reviewed by Sam. + + Turn on JavaScript Profiler + Get basic JS profiling working. + Even with this patch the profiler will not be compiled in because we do + not know the extend, if any, of the performance regression it would cause + when it is not in use. However with these changes, if the profiler were + on, it would not crash and show good profiling data. + + * VM/Machine.cpp: Instrument the calls sites that are needed for profiling. + (KJS::callEval): + (KJS::Machine::unwindCallFrame): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * kjs/function.cpp: Ditto. + (KJS::globalFuncEval): + * kjs/interpreter.cpp: Ditto. + (KJS::Interpreter::evaluate): + * profiler/Profile.cpp: + (KJS::Profile::willExecute): + (KJS::Profile::didExecute): Because we do not get a good context when + startProfiling is called it is possible that m_currentNode will be at the + top of the known stack when a didExecute() is called. What we then do is + create a new node that represents the function being exited and insert + it between the head and the currently known children, since they should + be children of this new node. + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::ProfileNode): + (KJS::ProfileNode::willExecute): Rename the add function for consistency. + (KJS::ProfileNode::addChild): Appends the child to this node but also + sets the parent pointer of the children to this node. + (KJS::ProfileNode::insertNode): Insert a node between this node and its + children. Also set the time for the new node since it is now exiting + and we don't really know when it started. + (KJS::ProfileNode::stopProfiling): + (KJS::ProfileNode::startTimer): + * profiler/ProfileNode.h: + (KJS::CallIdentifier::toString): Added for debugging. + (KJS::ProfileNode::setParent): + (KJS::ProfileNode::setSelfTime): Fixed an old bug where we set the + visibleTotalTime not the visibleSelfTime. + (KJS::ProfileNode::children): + (KJS::ProfileNode::toString): Added for debugging. + * profiler/Profiler.cpp: remove unecessary calls. + (KJS::Profiler::startProfiling): + +2008-05-22 Sam Weinig + + Reviewed by Oliver Hunt. + + Rename register arguments for op_call, op_call_eval, op_end, and op_construct + to document what they are for. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitCall): + (KJS::CodeGenerator::emitCallEval): + (KJS::CodeGenerator::emitEnd): + (KJS::CodeGenerator::emitConstruct): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-05-22 Oliver Hunt + + Reviewed by Darin. + + Bug 19116: SquirrelFish shouldn't regress on variable lookups + + + Last of the multiscope look up optimisations. This is a wash overall on SunSpider + but is a factor of 5-10 improvement in multiscope read/write/modify (eg. ++, --, +=, + ... applied to any non-local var). + + * kjs/nodes.cpp: + (KJS::PostIncResolveNode::emitCode): + (KJS::PostDecResolveNode::emitCode): + (KJS::PreIncResolveNode::emitCode): + (KJS::PreDecResolveNode::emitCode): + (KJS::ReadModifyResolveNode::emitCode): + +2008-05-22 David Kilzer + + Add method to release free memory from FastMalloc + + Patch suggested by Mark Rowe. Rubber-stamped by Maciej. + + * JavaScriptCore.exp: Export _releaseFastMallocFreeMemory. + * wtf/FastMalloc.cpp: + (WTF::TCMallocStats::): Added releaseFastMallocFreeMemory() for both + system malloc and FastMalloc code paths. + * wtf/FastMalloc.h: Define releaseFastMallocFreeMemory(). + +2008-05-22 Oliver Hunt + + RS=Maciej. + + Roll out r34020 as it causes recursion tests to fail. + + * kjs/object.cpp: + (KJS::JSObject::call): + +2008-05-22 Oliver Hunt + + Reviewed by Mark. + + Don't leak the SymbolTable when compiling eval code. + + * kjs/nodes.cpp: + (KJS::EvalNode::generateCode): + +2008-05-22 Simon Hausmann + + Reviewed by Oliver. + + Qt build fix. + + * JavaScriptCore.pri: Added DebuggerCallFrame to the build. + * VM/LabelID.h: Include limits.h for UINT_MAX. + * wtf/VectorTraits.h: Include memory for std::auto_ptr. + +2008-05-22 Geoffrey Garen + + Reviewed by Adam Roben. + + Removed the old recursion guard mechanism, since squirrelfish has its + own mechanism. Also removed some old JS call tracing code, since we + have other ways to do that, too. + + SunSpider reports no change. + + * kjs/object.cpp: + (KJS::JSObject::call): + +2008-05-22 Maciej Stachowiak + + Reviewed by Oliver. + + - fixed crash on celtic kane JS benchmark + + * kjs/nodes.cpp: + (KJS::WithNode::emitCode): + (KJS::TryNode::emitCode): + +2008-05-21 Kevin McCullough + + Reviewed by Maciej and Geoff. + + Turn on JavaScript Profiler + -As part of the effort to turn on the profiler it would be helpful if it + did not need ExecStates to represent the stack location of the currently + executing statement. + -We now create each node as necessary with a reference to the current + node and each node knows its parent so that the tree can be made without + the entire stack. + + * profiler/Profile.cpp: + (KJS::Profile::Profile): The current node starts at the head. + (KJS::Profile::stopProfiling): The current node is cleared when profiling + stops. + (KJS::Profile::willExecute): The current node either adds a new child or + starts and returns a reference to an already existing child if the call + ID that is requested already exists. + (KJS::Profile::didExecute): The current node finishes and returns its + parent. + * profiler/Profile.h: Use a single callIdentifier instead of a vector + since we no longer use the whole stack. + * profiler/ProfileNode.cpp: Now profile nodes keep a reference to their + parent. + (KJS::ProfileNode::ProfileNode): Initialize the parent. + (KJS::ProfileNode::didExecute): Record the time and return the parent. + (KJS::ProfileNode::addOrStartChild): If the given callIdentifier is + already a child, start it and return it, otherwise create a new one and + return that. + (KJS::ProfileNode::stopProfiling): Same logic, just use the new function. + * profiler/ProfileNode.h: Utilize the parent. + (KJS::ProfileNode::create): + (KJS::ProfileNode::parent): + * profiler/Profiler.cpp: + (KJS::Profiler::startProfiling): Here is the only place where the + ExecState is used to figure out where in the stack the profiler is + currently profiling. + (KJS::dispatchFunctionToProfiles): Only send one CallIdentifier instead + of a vector of them. + (KJS::Profiler::willExecute): Ditto. + (KJS::Profiler::didExecute): Ditto. + (KJS::createCallIdentifier): Create only one CallIdentifier. + (KJS::createCallIdentifierFromFunctionImp): Ditto. + * profiler/Profiler.h: + +2008-05-21 Darin Adler + + Reviewed by Maciej. + + - https://bugs.webkit.org/show_bug.cgi?id=19180 + speed up the < operator for the case when both values are integers + + Makes standalone SunSpider 1.022x faster. + + * VM/Machine.cpp: + (KJS::jsLess): Add a special case for when both are numbers that fit in a JSImmediate. + +2008-05-21 Maciej Stachowiak + + Reviewed by Oliver and Sam. + + - fixed REGRESSION (r31239): Multiscope optimisation of function calls results in incorrect this value (breaks tvtv.de) + + Track global this value in the scope chain so we can retrieve it + efficiently but it follows lexical scope properly. + + * kjs/ExecState.h: + (KJS::ExecState::globalThisValue): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::construct): + * kjs/scope_chain.h: + (KJS::ScopeChainNode::ScopeChainNode): + (KJS::ScopeChainNode::globalThisObject): + (KJS::ScopeChainNode::push): + (KJS::ScopeChain::ScopeChain): + +2008-05-21 Kevin McCullough + + Sadness :( + + * kjs/config.h: + +2008-05-21 Kevin McCullough + + Reviewed by Maciej. + + JSProfiler: Allow the profiler to "Focus" a + profile node. + - This patch updatest the times of the visible nodes correctly, but to do + so, some of the design of the ProfileNode changed. + + * JavaScriptCore.exp: export focus' symbol. + * profiler/Profile.cpp: ProfileNodes now take a reference to the head of + the profile tree to get up-to-date accurate total profile time. + (KJS::Profile::Profile): Pass 0 for the head node. + (KJS::Profile::stopProfiling): stopProfiling no longer needs the time + passed into it, since it can get it from the head and it does not need to + be told it is the head because it can figure it out on it's own. + (KJS::Profile::willExecute): Set the head node for each created node. + * profiler/Profile.h: + (KJS::Profile::focus): Instead of taking a CallIdentifier that the caller + would have to create, now focus() takes a ProfileNode that they should + already have a reference to and focus() can extract the CallIdentifier + from it. + * profiler/ProfileNode.cpp: Create actual and visible versions fo the + total and self times for focus and exclude. Also add a head node + reference so that nodes can get information from their head. + (KJS::ProfileNode::ProfileNode): + (KJS::ProfileNode::stopProfiling): Rename the total and self time + variables and set the visual ones to the actual ones, so that without any + changes to the visual versions of these variables, their times will match + the actual times. + (KJS::ProfileNode::focus): Now focus() has a bool to force it's children + to be visible if this node is visible. If this node does not match the + CallIdentifier being focused then the visibleTotalTime is only updated if + one or more of it's children is the CallIdentifier being focused. + (KJS::ProfileNode::restoreAll): Restores all variables with respect to + the visible data in the ProfileNode. + (KJS::ProfileNode::endAndRecordCall): Name change. + (KJS::ProfileNode::debugPrintData): Dump the new variables. + (KJS::ProfileNode::debugPrintDataSampleStyle): Name change. + * profiler/ProfileNode.h: Use the new variables and reference to the head + node. + (KJS::ProfileNode::create): + (KJS::ProfileNode::totalTime): + (KJS::ProfileNode::setTotalTime): + (KJS::ProfileNode::selfTime): + (KJS::ProfileNode::setSelfTime): + (KJS::ProfileNode::totalPercent): + (KJS::ProfileNode::selfPercent): + (KJS::ProfileNode::setVisible): + +2008-05-21 Alp Toker + + GTK+/UNIX testkjs build fix. Include signal.h. + + * kjs/testkjs.cpp: + +2008-05-21 Oliver Hunt + + Yet more windows build fixes + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2008-05-21 Oliver Hunt + + Yet more windows build fixes + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2008-05-21 Alp Toker + + GTK+ build fix. Add DebuggerCallFrame.cpp and take AllInOneFile.cpp + changes into account. + + * GNUmakefile.am: + +2008-05-21 Oliver Hunt + + Add DebuggerCallFrame.{h,cpp} to the project file + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2008-05-21 Alp Toker + + GTK+ port build fixes following squirrelfish merge r33979. + + * GNUmakefile.am: + +2008-05-21 Maciej Stachowiak + + Reviewed by Darin. + + - save a hash lookup wne writing to global properties + 0.3% speedup on SunSpider, 7% on bitops-bitwise-and + + * VM/Machine.cpp: + (KJS::resolveBase): Check for being a the end of the scope chain + before hash lookup. + +2008-05-21 Alp Toker + + Rubber-stamped by Maciej. + + Replace non-standard #pragma marks with comments to avoid compiler + warnings. + + * profiler/ProfileNode.cpp: + +2008-05-21 Geoffrey Garen + + Reviewed by Mark Rowe. + + Fix layout test failure in fast/dom/getter-on-window-object2 introduced in r33961. + + * JavaScriptCore.exp: + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::defineGetter): + (KJS::JSGlobalObject::defineSetter): + * kjs/JSGlobalObject.h: + +=== End merge of squirrelfish === + +2008-05-21 Geoffrey Garen + + Reviewed by Tim Hatcher. + + Merged with trunk WebCore's new debugger. + + * kjs/DebuggerCallFrame.cpp: + (KJS::DebuggerCallFrame::evaluate): Changed this function to separate + the exception value from the return value. The WebKit debugger treats + them as one, but the WebCore debugger doesn't. + + * kjs/DebuggerCallFrame.h: + (KJS::DebuggerCallFrame::dynamicGlobalObject): Added a new accessor for + the dynamic global object, since the debugger doesn't want the lexical + global object. + +2008-05-21 Oliver Hunt + + Reviewed by Maciej. + + Bug 19116: SquirrelFish shouldn't regress on variable lookups + + + Optimise cross scope assignment, 0.4% progression in sunspider. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitPutScopedVar): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::AssignResolveNode::emitCode): + +2008-05-21 Maciej Stachowiak + + Reviewed by Oliver. + + - check property map before symbol table in JSGlobalObject::getOwnPropertySlot + 0.5% speedup on SunSpider + + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::getOwnPropertySlot): Check property map before symbol table + because symbol table access is likely to have been optimized. + +2008-05-21 Oliver Hunt + + Reviewed by Maciej. + + Bug 19116: SquirrelFish shouldn't regress on variable lookups + + + Optimise multiscope lookup of statically resolvable function calls. + SunSpider reports a 1.5% improvement, including 37% on + controlflow-recursive for some reason :D + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitResolve): + * VM/CodeGenerator.h: + * kjs/nodes.cpp: + (KJS::FunctionCallResolveNode::emitCode): + +2008-05-21 Maciej Stachowiak + + Reviewed by Oliver. + + - give JSGlobalObject a special version of getOwnPropertySlot that tells you if the slot is directly writable + (WebCore change using this is a 2.6% speedup on in-browser SunSpider). + + * JavaScriptCore.exp: + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::getOwnPropertySlot): + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTableGet): + * kjs/object.h: + (KJS::JSObject::getDirectLocation): + (KJS::JSObject::getOwnPropertySlotForWrite): + * kjs/property_map.cpp: + (KJS::PropertyMap::getLocation): + * kjs/property_map.h: + * kjs/property_slot.h: + (KJS::PropertySlot::putValue): + +2008-05-20 Oliver Hunt + + Reviewed by Maciej. + + Bug 19116: SquirrelFish shouldn't regress on variable lookups + + + This restores multiscope optimisation to simple resolve, producing + a 2.6% progression in SunSpider. Have verified that none of the + sites broken by the multiscope optimisation in trunk were effected + by this change. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeBlock.h: + (KJS::CodeBlock::CodeBlock): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::findScopedProperty): + (KJS::CodeGenerator::emitResolve): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::resolve_n): + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/JSVariableObject.h: + +2008-05-20 Oliver Hunt + + Fixerate the windows build. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * VM/CodeGenerator.cpp: + * VM/RegisterFile.h: + * kjs/JSGlobalObject.h: + * kjs/Parser.cpp: + * kjs/interpreter.h: + +2008-05-20 Oliver Hunt + + Reviewed by Geoff. + + Bug 19110: SquirrelFish: Google Maps - no maps + + + Correct a comedy of errors present in my original patch to "fix" + exceptions occurring midway through pre and post increment. This + solution is cleaner than the original, doesn't need the additional + opcodes, and as an added benefit does not break Google Maps. + + Sunspider reports a 0.4% progression. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::PreIncResolveNode::emitCode): + (KJS::PreDecResolveNode::emitCode): + (KJS::PreIncBracketNode::emitCode): + (KJS::PreDecBracketNode::emitCode): + (KJS::PreIncDotNode::emitCode): + (KJS::PreDecDotNode::emitCode): + +2008-05-20 Maciej Stachowiak + + Reviewed by Oliver. + + - inline JSGlobalObject::getOwnPropertySlot + 1% improvement on in-browser SunSpider (a wash command-line) + + * kjs/JSGlobalObject.cpp: + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::getOwnPropertySlot): + +2008-05-18 Oliver Hunt + + Reviewed by Maciej. + + Bug 18752: SQUIRRELFISH: exceptions are not always handled by the vm + + + Handle exceptions thrown by toString conversion in subscript operators, + this should basically complete exception handling in SquirrelFish. + + Sunspider reports no regression. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-05-17 Geoffrey Garen + + Reviewed by Oliver Hunt. + + [Reapplying patch with previously missing files from r33553 -- Oliver] + + Behold: debugging. + + SunSpider reports no change. + + * JavaScriptCore.xcodeproj/project.pbxproj: Added DebuggerCallFrame.h/.cpp, + and created a debugger folder. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::generate): If the debugger is attached, always + generate full scope chains for its sake. + + * VM/Machine.cpp: + (KJS::Machine::unwindCallFrame): Notify the debugger when unwinding + due to an exception, so it doesn't keep stale call frames around. + + (KJS::Machine::execute): Set Callee to 0 in eval frames, so the + debugger can distinguish them from function call frames. + + (KJS::Machine::debug): Simplified this function, since the debugger + doesn't actually need all the information we used to provide. + + (KJS::Machine::privateExecute): Treat debugging hooks like other function + calls, so the code we hook into (the debugger UI) can be optimized. + + * kjs/debugger.cpp: Nixed these default callback implementations and + made the callbacks pure virtual instead, so the compiler could tell me + if I made a mistake in one of the subclasses. + + * kjs/debugger.h: Removed a bunch of irrelevent data from the debugger + callbacks. Changed from passing an ExecState* to passing a + DebuggerCallFrame*, since an ExecState* doesn't contain sufficient + information anymore. + + * kjs/function.cpp: + (KJS::globalFuncEval): Easiest bug fix evar! + + [Previously missing files from r33553] + * kjs/DebuggerCallFrame.cpp: Copied from JavaScriptCore/profiler/FunctionCallProfile.h. + (KJS::DebuggerCallFrame::functionName): + (KJS::DebuggerCallFrame::thisObject): + (KJS::DebuggerCallFrame::evaluateScript): + * kjs/DebuggerCallFrame.h: Copied from JavaScriptCore/VM/Register.h. + (KJS::DebuggerCallFrame::DebuggerCallFrame): + (KJS::DebuggerCallFrame::scopeChain): + (KJS::DebuggerCallFrame::exception): + +2008-05-17 Cameron Zwarich + + Reviewed by Oliver. + + Bug 18991: SquirrelFish: Major codegen issue in a.b=expr, a[b]=expr + + + Fix the last remaining blocking cases of this bug. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::ReadModifyResolveNode::emitCode): + +2008-05-17 Cameron Zwarich + + Reviewed by Oliver. + + Partial fix for: + + Bug 18991: SquirrelFish: Major codegen issue in a.b=expr, a[b]=expr + + + Ensure that the code generated for assignments uses temporaries whenever + necessary. This patch covers the vast majority of situations, but there + are still a few left. + + This patch also adds some missing cases to CodeBlock::dump(). + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.h: + (KJS::CodeGenerator::destinationForAssignResult): + (KJS::CodeGenerator::leftHandSideNeedsCopy): + (KJS::CodeGenerator::emitNodeForLeftHandSide): + * kjs/NodeInfo.h: + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::AssignDotNode::emitCode): + (KJS::ReadModifyDotNode::emitCode): + (KJS::AssignBracketNode::emitCode): + (KJS::ReadModifyBracketNode::emitCode): + (KJS::ForInNode::ForInNode): + * kjs/nodes.h: + (KJS::ReadModifyResolveNode::): + (KJS::AssignResolveNode::): + (KJS::ReadModifyBracketNode::): + (KJS::AssignBracketNode::): + (KJS::AssignDotNode::): + (KJS::ReadModifyDotNode::): + +2008-05-17 Oliver Hunt + + Reviewed by Maciej. + + Bug 19106: SquirrelFish: Activation is not marked correctly + + + We can't rely on the symbol table for a count of the number of globals + we need to mark as that misses duplicate parameters and 'this'. Now we + use the actual local register count from the codeBlock. + + * kjs/JSActivation.cpp: + (KJS::JSActivation::mark): + +2008-05-16 Oliver Hunt + + Reviewed by Geoff. + + Bug 19076: SquirrelFish: RegisterFile can be corrupted if implictly reenter global scope with no declared vars + + + Don't delay allocation of initial global RegisterFile, as we can't guarantee we will be able + to allocate the global 'this' register safely at any point after initialisation of the Global + Object. + + Unfortunately this initial allocation caused a regression of 0.2-0.3%, however this patch adds + support for the static slot optimisation for the global Math object which brings it to a 0.3% + progression. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::programCodeThis): + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::addParameter): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::execute): + * kjs/ExecState.h: + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::GlobalPropertyInfo::GlobalPropertyInfo): + (KJS::JSGlobalObject::addStaticGlobals): + * kjs/nodes.cpp: + +2008-05-16 Cameron Zwarich + + Reviewed by Oliver Hunt. + + Bug 19098: SquirrelFish: Ref'd temporaries can be clobbered + + + When doing code generation for a statement list, increase the reference + count on a register that might eventually be returned, so that it doesn't + get clobbered by a request for a new temporary. + + * kjs/nodes.cpp: + (KJS::statementListEmitCode): + +2008-05-16 Maciej Stachowiak + + Reviewed by Oliver. + + - fixed Bug 19044: SquirrelFish: Bogus values enter evaluation when closing over scope with parameter and var with same name + https://bugs.webkit.org/show_bug.cgi?id=19044 + + * kjs/JSActivation.cpp: + (KJS::JSActivation::copyRegisters): Use numLocals from the code + block rather than the size of the symbol table for the number of + registers to copy, to account for duplicate parameters and vars + with the same name as parameters (we still have potentially + suboptimal codegen in that we allocate a local register for the + var in the latter case but it is never used). + +2008-05-15 Geoffrey Garen + + Not reviewed. + + We regret to inform you that your program is crashing because you were + stupid. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Math is hard. + +2008-05-14 Geoffrey Garen + + Reviewed by Oliver Hunt. + + A little more debugger action: filled in op_debug. All debugger control + flow works now, but variable inspection and backtraces still don't. + + SunSpider reports no change. + + * VM/CodeGenerator.cpp: Changed op_debug to accept line number parameters. + + * VM/Machine.cpp: + (KJS::Machine::getFunctionAndArguments): Moved op_debug into a + NEVER_INLINE function to avoid a stunning 10% performance regression. + Also factored out a common function for retrieving the function and + arguments from a call frame. + + * kjs/JSActivation.cpp: + (KJS::JSActivation::createArgumentsObject): Use the new factored out + function mentioned above. + + * kjs/Parser.cpp: + (KJS::Parser::parse): Increment m_sourceId before assigning it, so the + sourceId we send to the debugger matches the sourceId recorded in the + node. + + * kjs/nodes.cpp: Emit debugging hooks. + +2008-05-14 Oliver Hunt + + Reviewed by Maciej. + + Bug 19024: SQUIRRELFISH: ASSERTION FAILED: activation->isActivationObject() in Machine::unwindCallFrame + + + This fixes a number of issues. The most important is that we now check every register + file for tainting rather than just looking for function register files as that was + insufficient. Additionally guarded against implicit re-entry into Eval code. + + Also added a few additional assertions to reduce the amout of time between something + going wrong and us seeing the error. + + * VM/Machine.cpp: + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * VM/RegisterFile.cpp: + (KJS::RegisterFile::growBuffer): + (KJS::RegisterFile::addGlobalSlots): + * VM/RegisterFileStack.cpp: + (KJS::RegisterFileStack::pushGlobalRegisterFile): + (KJS::RegisterFileStack::pushFunctionRegisterFile): + * VM/RegisterFileStack.h: + (KJS::RegisterFileStack::inImplicitCall): + +2008-05-14 Geoffrey Garen + + Reviewed by Oliver Hunt. + + A little more debugger action: emit opcodes for debugger hooks. Right + now, the opcode implementation is just a stub. + + SunSpider reports no change. + + Some example codegen for "function f() { 1; }": + + [ 0] dbg DidEnterCallFrame + [ 2] dbg WillExecuteStatement + [ 4] load tr0, 1(@k0) + [ 7] load tr0, undefined(@k1) + [ 10] dbg WillLeaveCallFrame + [ 12] ret tr0 + +2008-05-14 Oliver Hunt + + Reviewed by Geoff. + + Bug 19025: SQUIRRELFISH: malformed syntax in onload handler causes crash + + + Simple fix -- move the use of functionBodyNode to after the null check. + + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::construct): + +2008-05-13 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed a codegen crash with run-time parse errors. + + SunSpider reports no change. + + emitThrowError needs to return the temporary holding the error, not dst, + since dst may be NULL. In fact, emitThrowError shouldn't take a dst + parameter at all, since exceptions should not modify the destination + register. + +2008-05-13 Oliver Hunt + + Reviewed by Geoff. + + Bug 19027: SquirrelFish: Incorrect codegen for pre-increment + + + This fixes the codegen issues for the pre-inc/decrement operators + to prevent incorrectly clobbering the destination in the event of + an exception. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitPreInc): + (KJS::CodeGenerator::emitPreDec): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::PreIncResolveNode::emitCode): + (KJS::PreDecResolveNode::emitCode): + (KJS::PreIncBracketNode::emitCode): + (KJS::PreDecBracketNode::emitCode): + (KJS::PreIncDotNode::emitCode): + (KJS::PreDecDotNode::emitCode): + +2008-05-13 Geoffrey Garen + + Reviewed by Oliver Hunt. + + A little more debugger action: supply a real line number, sourceId, + and sourceURL in op_new_error. + + SunSpider reports a .2% speedup. Not sure what that's about. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Use the new good stuff in op_new_error. + + * kjs/nodes.cpp: + (KJS::RegExpNode::emitCode): Use the shared emitThrowError instead of + rolling our own. + +2008-05-13 Geoffrey Garen + + Reviewed by Oliver Hunt. + + A little more debugger action: implemented the exception callback. + + SunSpider reports a .2% speedup. Not sure what that's about. + + * VM/CodeBlock.h: A little refactoring here. Store a pointer to our + owner ScopeNode so we can retrieve data from it. This allows us to + stop storing copies of the data ourselves. Also, store a "this" register + instead of a code type, since we were only using the code type to + calculate the "this" register. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::generate): Calculate the "this" register mentioned + above. Also, take care of removing "this" from the symbol table after + codegen is done, since relying on the timing of a destructor for correct + behavior is not so good. + + * VM/Machine.cpp: + (KJS::Machine::throwException): Invoke the debugger's exception callback. + (KJS::Machine::privateExecute): Use the "this" register mentioned above. + +2008-05-13 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Removed some unused exception machinery. + + SunSpider reports a .3% speedup. + + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + * JavaScriptCore.exp: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/internal.cpp: + * kjs/object.cpp: + * kjs/object.h: + * kjs/value.h: + +2008-05-13 Geoffrey Garen + + Reviewed by Oliver Hunt. + + A little more debugger action. + + * kjs/debugger.cpp: + * kjs/debugger.h: Removed debuggersPresent because it was unused. + Replaced AttachedGlobalObject linked list with a HashSet because HashSet + is faster and simpler. Changed all functions to return void instead of + bool, because no clients ever return false, and we don't want to support + it. + + * kjs/nodes.cpp: Did some up-keep to avoid build bustage. + (KJS::Node::handleException): + (KJS::BreakpointCheckStatement::execute): + (KJS::FunctionBodyNodeWithDebuggerHooks::execute): + +2008-05-13 Oliver Hunt + + Reviewed by Darin. + + Bug 18752: SQUIRRELFISH: exceptions are not always handled by the vm + + + Replace old attempt at "branchless" exceptions as the extra information + being passed made gcc an unhappy compiler, replacing these custom toNumber + calls with ordinary toNumber logic (by relying on toNumber now preventing + side effects after an exception has been thrown) provided sufficient leeway + to add the additional checks for the remaining unchecked cases. + + This leaves only toString conversions in certain contexts as possibly + misbehaving. + + * VM/Machine.cpp: + (KJS::jsAdd): + (KJS::resolve): + (KJS::resolveBaseAndProperty): + (KJS::resolveBaseAndFunc): + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/value.h: + (KJS::JSValue::safeGetNumber): + +2008-05-13 Geoffrey Garen + + Reviewed by Oliver Hunt. + + First steps toward supporting the debugger API: support the sourceParsed + callback; plus some minor fixups. + + SunSpider reports no regression. + + * VM/CodeGenerator.h: Removed a misleading comment. + + * kjs/Parser.h: Changed the parser to take an ExecState*, so it can + implement the sourceParsed callback -- that way, we only have to + implement the callback in one place. + + * kjs/debugger.cpp: Nixed DebuggerImp, because its sole purpose in life + was to demonstrate the misapplication of design patterns. + + * kjs/debugger.h: Changed sourceParsed to take a SourceProvider, to + reduce copying, and not to return a value, because pausing execution + after parsing is complicated, and no clients needed that ability, anyway. + + * kjs/grammar.y: Make sure never to pass a NULL SourceElements* to + didFinishParsing -- that simplifies some code down the road. + + * kjs/nodes.cpp: Don't generate special AST nodes just because the + debugger is attached -- that's a relic of the old AST execution model, + and those nodes haven't been maintained. + +2008-05-13 Oliver Hunt + + Reviewed by Geoff. + + Bug 18752: SQUIRRELFISH: exceptions are not always handled by the vm + + + First step: prevent incorrect evaluation of valueOf/toString conversion + in right hand side of expression after earlier conversion throws. + + * API/JSCallbackObjectFunctions.h: + (KJS::::toNumber): + * kjs/object.cpp: + (KJS::JSObject::defaultValue): + +2008-05-12 Oliver Hunt + + Reviewed by Geoff. + + Bug 18934: SQUIRRELFISH: ASSERT @ nytimes.com due to RegisterFile being clobbered + + + Unfortunately we cannot create new statically optimised globals if there are any + tainted RegisterFiles on the RegisterFileStack. To handle this we re-introduce + (in a slightly cleaner form) the inImplicitCall concept to the RegisterFileStack. + + * VM/Machine.cpp: + (KJS::Machine::execute): + * VM/RegisterFileStack.cpp: + (KJS::RegisterFileStack::pushFunctionRegisterFile): + * VM/RegisterFileStack.h: + +2008-05-12 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Introduced support for function.caller. + + Improved support for walking interesting scopes for function introspection. + + This fixes all remaining layout tests not blocked by rebasing to trunk. + + SunSpider reports no change. + + * VM/Machine.cpp: + (KJS::Machine::dumpRegisters): Fixed a spacing issue. + +2008-05-11 Cameron Zwarich + + Reviewed by Oliver. + + Bug 18961: SQUIRRELFISH: Gmail doesn't load + + + Fix codegen for logical nodes so that they don't use their destination + as a temporary. + + * kjs/nodes.cpp: + (KJS::LogicalAndNode::emitCode): + (KJS::LogicalOrNode::emitCode): + +2008-05-10 Maciej Stachowiak + + Reviewed by Oliver. + + - JavaScriptCore part of fix for: "SQUIRRELFISH: function toString broken after calling" + https://bugs.webkit.org/show_bug.cgi?id=18869 + + Three layout tests are fixed: + fast/js/toString-elision-trailing-comma.html + fast/js/toString-prefix-postfix-preserve-parens.html + fast/js/kde/lval-exceptions.html + + Functions now save a shared subrange of the original source used + to make them (so in the common case this adds no storage above the + memory cache). + + * kjs/SourceProvider.h: Added. + (KJS::SourceProvider): New abstract base class for classes that provide on-demand access + to the source for a JavaScript program. This allows function objects to have access to their + original source without copying. + (KJS::UStringSourceProvider): SourceProvider subclass backed by a KJS::UString. + (KJS::UStringSourceProvider::create): + (KJS::UStringSourceProvider::getRange): + (KJS::UStringSourceProvider::data): + (KJS::UStringSourceProvider::length): + (KJS::UStringSourceProvider::UStringSourceProvider): + * kjs/SourceRange.h: Added. + (KJS::SourceRange::SourceRange): Class that holds a SourceProvider and a character range into + the source, to encapsulate on-demand access to the source of a function. + (KJS::SourceRange::toString): + * VM/Machine.cpp: + (KJS::eval): Pass a UStringSourceProvider to the parser. + * kjs/Parser.cpp: + (KJS::Parser::parse): Take a SourceProvider and pass it on to the lexer. + * kjs/Parser.h: + (KJS::Parser::parse): Take a SourceProvider. + * kjs/lexer.cpp: + (KJS::Lexer::setCode): Take a SourceProvider; keep it around, and + use it to get the raw buffer and length. + * kjs/lexer.h: + (KJS::Lexer::sourceRange): Convenience function to get a source + range based on the lexer's source provieder, and char offsets + right before and after the desired range. + * kjs/function.cpp: + (KJS::globalFuncEval): Pass a UStringSourceProvider to the parser. + * kjs/function_object.cpp: + (KJS::functionProtoFuncToString): Use toSourceString to get the source. + (KJS::FunctionObjectImp::construct): Give the parser a UStringSourceProvider. + * kjs/grammar.y: When parsing a function declaration, function + expression, or getter or setter, tell the function body about its + SourceRange. + * kjs/interpreter.cpp: + (KJS::Interpreter::checkSyntax): Pass a SourceProvider to the parser. + (KJS::Interpreter::evaluate): Pass a SourceProvider to the parser. + * kjs/interpreter.h: + * kjs/nodes.h: + (KJS::FunctionBodyNode::setSource): Establish a SourceRange for this function. + (KJS::FunctionBodyNode::toSourceString): Get the source string out + of the SourceRange. + (KJS::FuncExprNode::): Take a SourceRange and set it on the body. + (KJS::FuncDeclNode::): ditto + * kjs/testkjs.cpp: + (prettyPrintScript): Use a SourceProvider appropriately. + * JavaScriptCore.exp: Export new symbols. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Add new files. + * JavaScriptCore.xcodeproj/project.pbxproj: Add new files. + +2008-05-09 Oliver Hunt + + Reviewed by Maciej. + + Bring back RegisterFile tainting in order to correctly handle + natively implemented getters and setters that re-enter JavaScript + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/RegisterFile.h: + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + * kjs/object.cpp: + (KJS::JSObject::put): + (KJS::tryGetAndCallProperty): + * kjs/property_slot.cpp: + (KJS::PropertySlot::functionGetter): + +2008-05-09 Maciej Stachowiak + + Reviewed by Oliver. + + - track character offsets of open and close braces, in preparation for saving function source + + I verified that there is no performance regression from this change. + + * kjs/grammar.y: + * kjs/lexer.cpp: + (KJS::Lexer::lex): + (KJS::Lexer::matchPunctuator): + * kjs/lexer.h: + +2008-05-09 Oliver Hunt + + Debug build fix + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::restoreLocalStorage): + +2008-05-09 Oliver Hunt + + Reviewed by Geoff. + + Build fixes for SquirrelFish on windows. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: + * VM/Register.h: + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::restoreLocalStorage): + * kjs/collector.cpp: + (KJS::Collector::allocate): + (KJS::Collector::allocateNumber): + * kjs/collector.h: + (KJS::Collector::allocate): + (KJS::Collector::allocateNumber): + * kjs/property_slot.cpp: + +2008-05-08 Maciej Stachowiak + + Reviewed by Geoff. + + - fix activation tearoff in the case where functions are called with too many arguments + + Fixes: + fast/canvas/patternfill-repeat.html + fast/dom/SelectorAPI/bug-17313.html + + * VM/Machine.cpp: + (KJS::slideRegisterWindowForCall): + (KJS::scopeChainForCall): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + +2008-05-08 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed failure in fast/canvas/canvas-pattern-behaviour.html. + + SunSpider reports a small speedup. Not sure what that's about. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): Fixed op_call_eval to dump as "op_call_eval". + This helped me while debugging. + + * VM/Machine.cpp: + (KJS::Machine::unwindCallFrame): When looking for an activation to tear + off, don't use the scope chain. Inside eval, the scope chain doesn't + belong to us; it belongs to our calling function. + + Also, don't use the needsFullScopeChain flag to decide whether to tear + off the activation. "function.arguments" can create an activation + for a function whose needsFullScopeChain flag is set to false. + +2008-05-08 Maciej Stachowiak + + Reviewed by Oliver. + + - fix function.call for calls of more than 8 arguments + + Fixes svg/carto.net/button.svg + + * kjs/list.cpp: + (KJS::List::getSlice): properly set up the m_buffer of the target list. + +2008-05-08 Maciej Stachowiak + + Reviewed by Oliver. + + - don't return a null RegisterID from RegExpNode in the exception case, since the caller may need a real register + + Fixes: + - fast/regex/early-acid3-86.html + - http/tests/misc/acid3.html + + * kjs/nodes.cpp: + (KJS::RegExpNode::emitCode): + +2008-05-07 Cameron Zwarich + + Reviewed by Oliver. + + Fix a performance regression caused by the introduction of property + attributes to SymbolTable in r32859 by encoding the attributes and the + register index into a single field of SymbolTableEntry. + + This leaves Node::optimizeVariableAccess() definitely broken, although + it was probably not entirely correct in SquirrelFish before this change. + + * VM/CodeBlock.h: + (KJS::missingThisObjectMarker): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addVar): + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::registerForLocal): + (KJS::CodeGenerator::registerForLocalConstInit): + (KJS::CodeGenerator::isLocalConstant): + (KJS::CodeGenerator::addConstant): + (KJS::CodeGenerator::emitCall): + * VM/CodeGenerator.h: + (KJS::CodeGenerator::IdentifierMapIndexHashTraits::emptyValue): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::saveLocalStorage): + * kjs/JSVariableObject.cpp: + (KJS::JSVariableObject::getPropertyNames): + (KJS::JSVariableObject::getPropertyAttributes): + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTableGet): + (KJS::JSVariableObject::symbolTablePut): + (KJS::JSVariableObject::symbolTablePutWithAttributes): + * kjs/SymbolTable.h: + (KJS::SymbolTableEntry::SymbolTableEntry): + (KJS::SymbolTableEntry::isEmpty): + (KJS::SymbolTableEntry::getIndex): + (KJS::SymbolTableEntry::getAttributes): + (KJS::SymbolTableEntry::setAttributes): + (KJS::SymbolTableEntry::isReadOnly): + * kjs/nodes.cpp: + (KJS::getSymbolTableEntry): + (KJS::PostIncResolveNode::optimizeVariableAccess): + (KJS::PostDecResolveNode::optimizeVariableAccess): + (KJS::DeleteResolveNode::optimizeVariableAccess): + (KJS::TypeOfResolveNode::optimizeVariableAccess): + (KJS::PreIncResolveNode::optimizeVariableAccess): + (KJS::PreDecResolveNode::optimizeVariableAccess): + (KJS::ReadModifyResolveNode::optimizeVariableAccess): + (KJS::AssignResolveNode::optimizeVariableAccess): + (KJS::ProgramNode::initializeSymbolTable): + +2008-05-06 Maciej Stachowiak + + Rubber stamped by Oliver. + + - add missing ! in an assert that I failed to reverse + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + +2008-05-06 Maciej Stachowiak + + Reviewed by Oliver. + + - fixed "SQUIRRELFISH: window.this shows up as a property, but it shouldn't" + https://bugs.webkit.org/show_bug.cgi?id=18868 + + The basic approach is to have "this" only be present in the symbol + table at compile time, not runtime. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::~CodeGenerator): Remove "this" from symbol table. + (KJS::CodeGenerator::CodeGenerator): Add "this" back when re-using + a symbol table. + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::execute): Don't assert that "this" is in the symbol table. + +2008-05-06 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Trivial support for function.arguments: Currently, we only support + function.arguments from within the scope of function. + + This fixes the remaining Mozilla JS test failures. + + SunSpider reports no change. + + * JavaScriptCore.exp: + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Separated scope chain deref from + activation register copying: since it is now possible for client code + to create an activation on behalf of a function that otherwise wouldn't + need one, having an activation no longer necessarily means that you need + to deref the scope chain. + + (KJS::Machine::getCallFrame): For now, this function only examines the + current scope. Walking parent scopes requires some refactoring in the + way we track execution stacks. + + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): We use a negative call frame offset to + indicate that a given scope is not a function call scope. + +2008-05-05 Oliver Hunt + + Reviewed by Geoff. + + Fix call frame set up for native -> JS function calls. + + * VM/Machine.cpp: + (KJS::Machine::execute): + +2008-05-05 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed ecma_3/Object/8.6.2.6-001.js, and similar bugs. + + SunSpider reports a .4% speedup. Not sure what that's about. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Check for exception return from equal, + since toPrimitive can throw. + + * kjs/operations.cpp: + (KJS::strictEqual): In response to an error I made in an earlier version + of this patch, I changed strictEqual to make clear the fact that it + performs no conversions and can't throw, making it slightly more efficient + in the process. + +2008-05-05 Maciej Stachowiak + + Reviewed by Oliver. + + - fix some dumb mistakes in my last patch + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitPushScope): + (KJS::CodeGenerator::emitGetPropertyNames): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-05-05 Maciej Stachowiak + + Reviewed by Oliver. + + - document opcodes relating to jumps, scopes, and property name iteration + + Documented jmp, jtrue, false, push_scope, pop_scope, get_pnames, + next_pname and jmp_scopes. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitJump): + (KJS::CodeGenerator::emitJumpIfTrue): + (KJS::CodeGenerator::emitJumpIfFalse): + (KJS::CodeGenerator::emitPushScope): + (KJS::CodeGenerator::emitNextPropertyName): + (KJS::CodeGenerator::emitGetPropertyNames): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/nodes.cpp: + (KJS::LogicalAndNode::emitCode): + (KJS::LogicalOrNode::emitCode): + (KJS::ConditionalNode::emitCode): + (KJS::IfNode::emitCode): + (KJS::IfElseNode::emitCode): + (KJS::DoWhileNode::emitCode): + (KJS::WhileNode::emitCode): + (KJS::ForNode::emitCode): + (KJS::ForInNode::emitCode): + (KJS::WithNode::emitCode): + +2008-05-05 Cameron Zwarich + + Reviewed by Oliver. + + Bug 18749: SQUIRRELFISH: const support is broken + + + Adds support for const during code generation. + + Fixes 2 layout tests. + + * ChangeLog: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addVar): + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::isLocalConstant): + * VM/CodeGenerator.h: + (KJS::CodeGenerator::addVar): + * kjs/nodes.cpp: + (KJS::PostIncResolveNode::emitCode): + (KJS::PostDecResolveNode::emitCode): + (KJS::PreIncResolveNode::emitCode): + (KJS::PreDecResolveNode::emitCode): + (KJS::ReadModifyResolveNode::emitCode): + (KJS::AssignResolveNode::emitCode): + +2008-05-04 Maciej Stachowiak + + Reviewed by Geoff. + + - document some more opcodes (and fix argument names) + + Added docs for eq, neq, stricteq, nstriceq, less and lesseq. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitEqual): + (KJS::CodeGenerator::emitNotEqual): + (KJS::CodeGenerator::emitStrictEqual): + (KJS::CodeGenerator::emitNotStrictEqual): + (KJS::CodeGenerator::emitLess): + (KJS::CodeGenerator::emitLessEq): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/nodes.cpp: + (KJS::LessNode::emitCode): + (KJS::GreaterNode::emitCode): + (KJS::LessEqNode::emitCode): + (KJS::GreaterEqNode::emitCode): + (KJS::EqualNode::emitCode): + (KJS::NotEqualNode::emitCode): + (KJS::StrictEqualNode::emitCode): + (KJS::NotStrictEqualNode::emitCode): + (KJS::CaseBlockNode::emitCodeForBlock): + +2008-05-04 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + More scaffolding for f.arguments. + + Track the offset of the last call frame in the ExecState, so we can + produce a backtrace at any time. + + Also, record numLocals, the sum of numVars + numParameters, in each code + block, to make updates to the ExecState a little cheaper than they + would be otherwise. + + We now use numLocals in a bunch of places where we used to calculate + numVars + numParameters or -numVars - numParameters. + + Reports are mixed, but all in all, this seems to be a wash on SunSpider. + +2008-05-04 Oliver Hunt + + Reviewed by Geoff. + + Whoops, correctly handle properties that don't exist in the + symbol table. + + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTablePutWithAttributes): + +2008-05-04 Oliver Hunt + + Reviewed by Geoff. + + Add attribute information to SymbolTable as ground work for + various DontEnum and ReadOnly issues. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addVar): + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::registerForLocal): + (KJS::CodeGenerator::registerForLocalConstInit): + (KJS::CodeGenerator::addConstant): + * VM/Machine.cpp: + (KJS::Machine::execute): + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::saveLocalStorage): + * kjs/JSVariableObject.cpp: + (KJS::JSVariableObject::getPropertyNames): + (KJS::JSVariableObject::getPropertyAttributes): + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTablePut): + (KJS::JSVariableObject::symbolTablePutWithAttributes): + * kjs/SymbolTable.h: + (KJS::SymbolTableEntry::SymbolTableEntry): + (KJS::SymbolTableIndexHashTraits::emptyValue): + * kjs/nodes.cpp: + (KJS::getSymbolTableEntry): + (KJS::ReadModifyResolveNode::optimizeVariableAccess): + (KJS::AssignResolveNode::optimizeVariableAccess): + (KJS::ProgramNode::initializeSymbolTable): + +2008-05-04 Geoffrey Garen + + Reviewed by Oliver Hunt. + + More scaffolding for f.arguments. + + Store the register file associated with an ExecState in the ExecState. + + SunSpider reports no change. + + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): Moved + registerFileStack above globalExec, so it gets initialized first. + Removed remnants of old activation scheme. + +2008-05-04 Maciej Stachowiak + + Rubber stamped by Oliver. + + - renamed a few opcodes and fixed assembly formatting to accomodate the longest opcode + + equal --> eq + nequal --> neq + resolve_base_and_property --> resolve_with_base + resolve_base_and_func --> resolve_func + get_prop_id --> get_by_id + put_prop_id --> put_by_id + delete_prop_id --> del_by_id + get_prop_val --> get_by_val + put_prop_val --> put_by_val + delete_prop_val --> del_by_val + put_prop_index --> put_by_index + + * VM/CodeBlock.cpp: + (KJS::printUnaryOp): + (KJS::printBinaryOp): + (KJS::printConditionalJump): + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitEqual): + (KJS::CodeGenerator::emitNotEqual): + (KJS::CodeGenerator::emitResolveWithBase): + (KJS::CodeGenerator::emitResolveFunction): + (KJS::CodeGenerator::emitGetById): + (KJS::CodeGenerator::emitPutById): + (KJS::CodeGenerator::emitDeleteById): + (KJS::CodeGenerator::emitGetByVal): + (KJS::CodeGenerator::emitPutByVal): + (KJS::CodeGenerator::emitDeleteByVal): + (KJS::CodeGenerator::emitPutByIndex): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::ArrayNode::emitCode): + (KJS::PropertyListNode::emitCode): + (KJS::BracketAccessorNode::emitCode): + (KJS::DotAccessorNode::emitCode): + (KJS::EvalFunctionCallNode::emitCode): + (KJS::FunctionCallResolveNode::emitCode): + (KJS::FunctionCallBracketNode::emitCode): + (KJS::FunctionCallDotNode::emitCode): + (KJS::PostIncResolveNode::emitCode): + (KJS::PostDecResolveNode::emitCode): + (KJS::PostIncBracketNode::emitCode): + (KJS::PostDecBracketNode::emitCode): + (KJS::PostIncDotNode::emitCode): + (KJS::PostDecDotNode::emitCode): + (KJS::DeleteResolveNode::emitCode): + (KJS::DeleteBracketNode::emitCode): + (KJS::DeleteDotNode::emitCode): + (KJS::TypeOfResolveNode::emitCode): + (KJS::PreIncResolveNode::emitCode): + (KJS::PreDecResolveNode::emitCode): + (KJS::PreIncBracketNode::emitCode): + (KJS::PreDecBracketNode::emitCode): + (KJS::PreIncDotNode::emitCode): + (KJS::PreDecDotNode::emitCode): + (KJS::ReadModifyResolveNode::emitCode): + (KJS::AssignResolveNode::emitCode): + (KJS::AssignDotNode::emitCode): + (KJS::ReadModifyDotNode::emitCode): + (KJS::AssignBracketNode::emitCode): + (KJS::ReadModifyBracketNode::emitCode): + (KJS::ConstDeclNode::emitCodeSingle): + (KJS::ForInNode::emitCode): + (KJS::TryNode::emitCode): + +2008-05-04 Oliver Hunt + + Reviewed by Maciej. + + Fix assertion when accessing arguments object with too many arguments provided + + The arguments constructor was assuming that the register offset given for argv + was an absolute offset into the registerfile, rather than the offset from the + frame. This patches corrects that issue. + + * kjs/JSActivation.cpp: + (KJS::JSActivation::createArgumentsObject): + +2008-05-04 Geoffrey Garen + + Rubber stamped by Sam Weinig. + + Cleaned up Machine.cpp according to our style guidelines: moved static + data to the top of the file; moved stand-alone functions below that; + moved the Machine constructor above other Machine member functions. + +2008-05-03 Maciej Stachowiak + + Reviewed by Sam. + + - fix accidental breakage from last patch + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-05-03 Maciej Stachowiak + + Reviewed by Geoff. + + - a bunch more opcode documentation and corresponding parameter name fixes + + I renamed a few opcodes: + + type_of --> typeof (that's what the JS operator is named) + instance_of --> instanceof (ditto) + create_error --> new_error (for consistency with other new_* opcodes) + + I documented the following opcodes: + + - load + - new_object + - new_array + - new_regexp + - mov + - pre_inc + - pre_dec + - post_inc + - post_dec + - to_jsnumber + - negate + - bitnot + - not + - instanceof + - typeof + - in + - new_func + - new_funcexp + - new_error + + I also fixed formatting on some existing opcode docs. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitMove): + (KJS::CodeGenerator::emitNot): + (KJS::CodeGenerator::emitPreInc): + (KJS::CodeGenerator::emitPreDec): + (KJS::CodeGenerator::emitPostInc): + (KJS::CodeGenerator::emitPostDec): + (KJS::CodeGenerator::emitToJSNumber): + (KJS::CodeGenerator::emitNegate): + (KJS::CodeGenerator::emitBitNot): + (KJS::CodeGenerator::emitInstanceOf): + (KJS::CodeGenerator::emitTypeOf): + (KJS::CodeGenerator::emitIn): + (KJS::CodeGenerator::emitLoad): + (KJS::CodeGenerator::emitNewObject): + (KJS::CodeGenerator::emitNewArray): + (KJS::CodeGenerator::emitNewRegExp): + (KJS::CodeGenerator::emitNewError): + * VM/CodeGenerator.h: + (KJS::CodeGenerator::scopeDepth): + (KJS::CodeGenerator::addVar): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::Node::emitThrowError): + (KJS::RegExpNode::emitCode): + (KJS::TypeOfValueNode::emitCode): + (KJS::UnaryPlusNode::emitCode): + (KJS::NegateNode::emitCode): + (KJS::BitwiseNotNode::emitCode): + (KJS::LogicalNotNode::emitCode): + (KJS::InstanceOfNode::emitCode): + (KJS::InNode::emitCode): + +2008-05-03 Maciej Stachowiak + + Reviewed by Geoff and Sam. + + - generate HTML bytecode docs at build time + + * DerivedSources.make: + * docs: Added. + * docs/make-bytecode-docs.pl: Added. + +2008-05-03 Geoffrey Garen + + Reviewed by Sam Weinig. + + Update ExecState::m_scopeChain when switching scope chains inside the + machine. + + This fixes uses of lexicalGlobalObject, such as, in a subframe + + alert(top.makeArray() instanceof Array ? "FAIL" : "PASS"); + + and a bunch of the security failures listed in + https://bugs.webkit.org/show_bug.cgi?id=18870. (Those tests still fail, + seemingly because of regressions in exception messages). + + SunSpider reports no change. + + * VM/Machine.cpp: Factored out scope chain updating into a common + function that takes care to update ExecState::m_scopeChain, too. + + * kjs/ExecState.h: I made Machine a friend of ExecState so that Machine + could update ExecState::m_scopeChain, even though that value is + read-only for everyone else. + + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): Changed + this client to be a little friendlier to ExecState's internal + storage type for scope chain data. + +2008-05-03 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed https://bugs.webkit.org/show_bug.cgi?id=18876 + Squirrelfish: ScopeChainNode leak in op_jmp_scopes. + + SunSpider reports no change. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Don't construct a ScopeChain object, + since the direct threaded interpreter will goto across its destructor. + +2008-05-03 Geoffrey Garen + + Reviewed by Oliver Hunt. + + A bit more efficient fix than r32832: Don't copy globals into function + register files; instead, have the RegisterFileStack track only the base + of the last *global* register file, so the global object's register + references stay good. + + SunSpider reports a .3% speedup. Not sure what that's about. + +2008-05-03 Oliver Hunt + + Reviewed by Maciej. + + Bug 18864: SquirrelFish: Support getter and setter definition in object literals + + + Add new opcodes to allow us to add getters and setters to an object. These are + only used by the codegen for object literals. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitPutGetter): + (KJS::CodeGenerator::emitPutSetter): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::PropertyListNode::emitCode): + +2008-05-02 Maciej Stachowiak + + Reviewed by Oliver. + + - properly copy globals into and out of implicit call register + files, otherwise they will fail at global lookup + + Fixes fast/js/array-tostring-and-join.html layout test. + + * VM/RegisterFileStack.cpp: + (KJS::RegisterFileStack::pushGlobalRegisterFile): + (KJS::RegisterFileStack::popGlobalRegisterFile): + (KJS::RegisterFileStack::pushFunctionRegisterFile): + (KJS::RegisterFileStack::popFunctionRegisterFile): + +2008-05-02 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed https://bugs.webkit.org/show_bug.cgi?id=18822 + SQUIRRELFISH: incorrect eval used in some cases + + Changed all code inside the machine to fetch the lexical global object + directly from the scope chain, instead of from the ExecState. + + Clients who fetch the lexical global object through the ExecState + still don't work. + + SunSpider reports no change. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Fetch the lexical global object from + the scope chain. + + * kjs/ExecState.h: + (KJS::ExecState::ExecState::lexicalGlobalObject): Moved the logic for + this function into ScopeChainNode, but kept this function around to + support existing clients. + +2008-05-02 Geoffrey Garen + + Rubber stamped by Oliver Hunt. + + Removed ExecState.cpp from AllInOneFile.cpp, for a .2% speedup. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/AllInOneFile.cpp: + +2008-05-01 Oliver Hunt + + Reviewed by Geoff and Maciej. + + Bug 18827: SquirrelFish: Prevent getters and setters from destroying the current RegisterFile + + + Remove safe/unsafe RegisterFile concept, and instead just add additional + logic to ensure we always push/pop RegisterFiles when executing getters + and setters, similar to the logic for valueOf and toString. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/RegisterFile.h: + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + * kjs/object.cpp: + (KJS::JSObject::put): + * kjs/property_slot.cpp: + (KJS::PropertySlot::functionGetter): + +2008-05-01 Oliver Hunt + + RS=Geoff + + Rename unsafeForReentry to safeForReentry to avoid double negatives. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/RegisterFile.h: + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + +2008-05-01 Oliver Hunt + + Reviewed by Maciej. + + Bug 18827: SquirrelFish: Prevent getters and setters from destroying the current RegisterFile + + + This patch makes getters and setters work. It does this by + tracking whether the RegisterFile is "safe", that is whether + the interpreter is in a state that in which it can handle + the RegisterFile being reallocated. + + * VM/Machine.cpp: + (KJS::resolve): + (KJS::Machine::privateExecute): + * VM/RegisterFile.h: + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + +2008-04-30 Geoffrey Garen + + Release build fix: Always compile in "isGlobalObject", since it's + listed in our .exp file. + + * kjs/ExecState.cpp: + (KJS::ExecState::isGlobalObject): + * kjs/ExecState.h: + +2008-04-30 Oliver Hunt + + Reviewed by Maciej. + + Minor code restructuring to prepare for getters and setters, + also helps exception semantics a bit. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-30 Geoffrey Garen + + Fixed tyop. + + * kjs/ExecState.h: + +2008-04-30 Geoffrey Garen + + Debug build fix: export a missing symbol. + + * JavaScriptCore.exp: + +2008-04-30 Geoffrey Garen + + Reviewed by Oliver Hunt. + + A little more ExecState refactoring: Now, only the global object creates + an ExecState. + + Also inlined ExecState::lexicalGlobalObject(). + + SunSpider reports no change. + +2008-04-30 Geoffrey Garen + + WebCore build fix: forward-declare ScopeChain. + + * kjs/interpreter.h: + +2008-04-30 Geoffrey Garen + + Build fix for JavaScriptGlue: export a missing symbol. + + * JavaScriptCore.exp: + +2008-04-30 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Removed a lot of unused bits from ExecState, moving them into + OldInterpreterExecState, the fake scaffolding class. + + The clutter was making it hard to see the forest from the trees. + + .4% SunSpider speedup, probably because ExecState::lexicalGlobalObject() + is faster now. + +2008-04-29 Oliver Hunt + + Reviewed by Maciej. + + Bug 18643: SQUIRRELFISH: need to support implicit function calls (valueOf, toString, getters/setters) + + + Prevent static slot optimisation for new variables and functions in + globally re-entrant code called from an an implicit function call. + + This is necessary to prevent us from needing to resize the global + slot portion of the root RegisterFile during an implicit (and hence + unguarded) function call. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::execute): + * VM/RegisterFile.h: + * VM/RegisterFileStack.cpp: + (KJS::RegisterFileStack::pushGlobalRegisterFile): + (KJS::RegisterFileStack::popGlobalRegisterFile): + (KJS::RegisterFileStack::pushFunctionRegisterFile): + (KJS::RegisterFileStack::popFunctionRegisterFile): + * VM/RegisterFileStack.h: + (KJS::RegisterFileStack::inImplicitFunctionCall): + (KJS::RegisterFileStack::lastGlobal): + * kjs/nodes.cpp: + (KJS::ProgramNode::generateCode): + * kjs/nodes.h: + (KJS::ProgramNode::): + +2008-04-29 Geoffrey Garen + + Reviewed by Oliver Hunt. + + In nested program code, don't propogate "this" back to the parent + register file. ("this" should remain constant in the parent register + file, regardless of the scripts it invokes.) + + * VM/RegisterFile.cpp: + (KJS::RegisterFile::copyGlobals): + +2008-04-28 Oliver Hunt + + Reviewed by Geoff. + + Restore base pointer when popping a global RegisterFile + + * VM/RegisterFileStack.cpp: + (KJS::RegisterFileStack::popGlobalRegisterFile): + +2008-04-28 Oliver Hunt + + Reviewed by Geoff. + + Bug 18643: SQUIRRELFISH: need to support implicit function calls (valueOf, toString, getters/setters) + + + Partial fix. This results in all implicit calls to toString or valueOf + executing in a separate RegisterFile, so ensuring that the the pointers + in the triggering interpreter don't get trashed. This still leaves the + task of preventing new global re-entry from toString and valueOf from + clobbering the RegisterFile. + + * VM/Machine.cpp: + (KJS::Machine::execute): + * VM/RegisterFileStack.cpp: + (KJS::RegisterFileStack::pushFunctionRegisterFile): + (KJS::RegisterFileStack::popFunctionRegisterFile): + * VM/RegisterFileStack.h: + * kjs/object.cpp: + (KJS::tryGetAndCallProperty): + +2008-04-28 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Simplified activation object a bit: No need to store the callee + in the activation object -- we can pull it out of the call frame + when needed, instead. + + SunSpider reports no change. + +2008-04-28 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + RS by Oliver Hunt on moving JSArguments.cpp out of AllInOneFile.cpp. + + Substantially more handling of "arguments": "arguments" works fully + now, but "f.arguments" still doesn't work. + + Fixes 10 regression tests. + + SunSpider reports no regression. + + * kjs/JSActivation.cpp: + (KJS::JSActivation::createArgumentsObject): Reconstruct an arguments + List to pass to the arguments object constructor. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/AllInOneFile.cpp: Removed JSActivation.cpp from AllInOneFile.cpp + because that seems to make GCC happy. (Previously, I had added + JSActivation.cpp to AllInOneFile.cpp because *that* seemed to make GCC + happy. So it goes.) + +2008-04-28 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Groundwork for more handling of "arguments". I'm not checking in the + actual handling of "arguments" yet, because it still needs a little + fiddling to avoid a performance regression. + + SunSpider reports no change. + + * VM/Machine.cpp: + (KJS::initializeCallFrame): Put argc in the register file, so the + arguments object can find it later, to determine arguments.length. + + * kjs/nodes.h: + (KJS::FunctionBodyNode::): Added a special code accessor for when you + know the code has already been generated, and you don't have a scopeChain + to supply for potential code generation. (This is the case when the + activation object creates the arguments object.) + +2008-04-28 Oliver Hunt + + Reviewed by Geoff. + + Replace unsafe use of auto_ptr in Vector with manual memory + management. + + * VM/RegisterFileStack.cpp: + (KJS::RegisterFileStack::~RegisterFileStack): + (KJS::RegisterFileStack::popRegisterFile): + * VM/RegisterFileStack.h: + +2008-04-27 Cameron Zwarich + + Reviewed by Maciej. + + Bug 18746: SQUIRRELFISH: indirect eval used when direct eval should be used + + + Change the base to the correct value of the 'this' object after the direct + eval test instead of before. + + Fixes 5 layout tests. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/nodes.cpp: + (KJS::EvalFunctionCallNode::emitCode): + +2008-04-26 Maciej Stachowiak + + Reviewed by Oliver. + + - document all property getting, setting and deleting opcodes + + (And fix function parameter names to match corresponding opcode parameter names.) + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitResolve): + (KJS::CodeGenerator::emitResolveBase): + (KJS::CodeGenerator::emitResolveBaseAndProperty): + (KJS::CodeGenerator::emitResolveBaseAndFunc): + (KJS::CodeGenerator::emitGetPropId): + (KJS::CodeGenerator::emitPutPropId): + (KJS::CodeGenerator::emitDeletePropId): + (KJS::CodeGenerator::emitPutPropVal): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::resolve): + (KJS::resolveBase): + (KJS::resolveBaseAndProperty): + (KJS::resolveBaseAndFunc): + (KJS::Machine::privateExecute): + * kjs/nodes.cpp: + (KJS::ResolveNode::emitCode): + (KJS::ArrayNode::emitCode): + (KJS::PropertyListNode::emitCode): + (KJS::BracketAccessorNode::emitCode): + (KJS::EvalFunctionCallNode::emitCode): + (KJS::FunctionCallResolveNode::emitCode): + (KJS::FunctionCallBracketNode::emitCode): + (KJS::PostIncResolveNode::emitCode): + (KJS::PostDecResolveNode::emitCode): + (KJS::PostIncBracketNode::emitCode): + (KJS::PostDecBracketNode::emitCode): + (KJS::PostIncDotNode::emitCode): + (KJS::PostDecDotNode::emitCode): + (KJS::DeleteResolveNode::emitCode): + (KJS::TypeOfResolveNode::emitCode): + (KJS::PreIncResolveNode::emitCode): + (KJS::PreDecResolveNode::emitCode): + (KJS::PreIncBracketNode::emitCode): + (KJS::PreDecBracketNode::emitCode): + (KJS::AssignResolveNode::emitCode): + (KJS::AssignDotNode::emitCode): + (KJS::ReadModifyDotNode::emitCode): + (KJS::AssignBracketNode::emitCode): + (KJS::ReadModifyBracketNode::emitCode): + (KJS::ConstDeclNode::emitCodeSingle): + +2008-04-26 Oliver Hunt + + Reviewed by Maciej. + + Bug 18628: SQUIRRELFISH: need to support recursion limit + + + Basically completes recursion limiting. There is still some + tuning we may want to do to make things better in the face of + very bad code, but certainly nothing worse than anything already + possible in trunk. + + Also fixes a WebKit test by fixing the exception text :D + + * JavaScriptCore.exp: + * VM/ExceptionHelpers.cpp: + * VM/Machine.cpp: + (KJS::Machine::execute): + * VM/RegisterFile.cpp: + (KJS::RegisterFile::growBuffer): + (KJS::RegisterFile::addGlobalSlots): + * VM/RegisterFile.h: + (KJS::RegisterFile::grow): + (KJS::RegisterFile::uncheckedGrow): + * VM/RegisterFileStack.cpp: + (KJS::RegisterFileStack::pushRegisterFile): + * VM/RegisterFileStack.h: + +2008-04-25 Oliver Hunt + + Reviewed by Geoff. + + Bug 18628: SQUIRRELFISH: need to support recursion limit + + + Put a limit on the level of reentry recursion. 128 levels of re-entrant recursion + seems reasonable as it is greater than the old eval limit, and a long way short of + the reentry depth needed to overflow the stack. + + * VM/Machine.cpp: + (KJS::Machine::execute): + * VM/Machine.h: + +2008-04-25 Geoffrey Garen + + Reviewed by Sam Weinig. + + A tiny bit of cleanup to the regexp code. + + Removed some static_cast. + + Removed createRegExpImp because it's no longer used. + +2008-04-25 Oliver Hunt + + Reviewed by Maciej. + + Bug 18736: SQUIRRELFISH: switch statements with no default have incorrect codegen + + + Ensure the "default" target is correct in the absence of an explicit default handler. + + * kjs/nodes.cpp: + (KJS::CaseBlockNode::emitCodeForBlock): + +2008-04-25 Oliver Hunt + + Reviewed by Maciej. + + Bug 18628: SQUIRRELFISH: need to support recursion limit + + + More bounds checking. + + * VM/Machine.cpp: + (KJS::Machine::execute): + * VM/RegisterFile.cpp: + (KJS::RegisterFile::growBuffer): + * VM/RegisterFile.h: + +2008-04-25 Maciej Stachowiak + + Reviewed by Oliver. + + - fix signal catching magic + + The signal handlers are restored to _exit but are only set when + running under run-javascriptcore-tests. fprintf from a signal + handler is not safe. + + * kjs/testkjs.cpp: + (main): + (parseArguments): + * tests/mozilla/jsDriver.pl: + +2008-04-25 Cameron Zwarich + + Reviewed by Maciej. + + Bug 18732: SQUIRRELFISH: exceptions thrown by native constructors are ignored + + + Fixes another regression test. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-25 Cameron Zwarich + + Reviewed by Maciej. + + Bug 18728: SQUIRRELFISH: invalid regular expression constants should throw exceptions + + + Fixes another regression test. + + * kjs/nodes.cpp: + (KJS::RegExpNode::emitCode): + +2008-04-24 Cameron Zwarich + + Reviewed by Geoffrey Garen. + + Bug 18735: SQUIRRELFISH: closures are sometimes given an incorrect 'this' value when called + + + The overloaded toThisObject method was not copied over to JSActivation. + + Fixes two regression tests. + + * kjs/JSActivation.cpp: + (KJS::JSActivation::toThisObject): + * kjs/JSActivation.h: + +2008-04-24 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Added support for arguments.callee. + +2008-04-24 Oliver Hunt + + Reviewed by Maciej. + + Bug 18628: SQUIRRELFISH: need to support recursion limit + + + Partial fix -- this gets us some of the required bounds checking, but not + complete coverage. But it does manage to do them without regressing :D + + * VM/ExceptionHelpers.cpp: + (KJS::createError): + (KJS::createStackOverflowError): + * VM/ExceptionHelpers.h: + * VM/Machine.cpp: + (KJS::slideRegisterWindowForCall): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * VM/RegisterFile.cpp: + * VM/RegisterFile.h: + (KJS::RegisterFile::): + (KJS::RegisterFile::RegisterFile): + (KJS::RegisterFile::grow): + +2008-04-24 Geoffrey Garen + + Reviewed by Oliver Hunt. + + A tiny bit more handling of "arguments": create a real, but mostly + hollow, arguments object. + + Fixes 2 regression tests. + +2008-04-24 Cameron Zwarich + + Reviewed by Oliver. + + Bug 18717: SQUIRRELFISH: eval returns the wrong value for a variable declaration statement + + + Fixes a regression test, but exposes the failure of another due to the + lack of getters and setters. + + * kjs/nodes.cpp: + (KJS::ConstDeclNode::emitCodeSingle): + (KJS::ConstDeclNode::emitCode): + (KJS::ConstStatementNode::emitCode): + (KJS::VarStatementNode::emitCode): + * kjs/nodes.h: + +2008-04-24 Geoffrey Garen + + Reviewed by Sam Weinig. + + Print a CRASH statement when crashing, so test failures are not a + mystery. + + * kjs/testkjs.cpp: + (handleCrash): + (main): + +2008-04-24 Cameron Zwarich + + Reviewed by Geoffrey Garen. + + Bug 18716: SQUIRRELFISH: typeof should return undefined for an undefined variable reference + + + This fixes 2 more regression tests. + + * kjs/nodes.cpp: + (KJS::TypeOfResolveNode::emitCode): + +2008-04-24 Geoffrey Garen + + Reviewed by Sam Weinig. + + Put the callee in the call frame. + + Necessary in order to support "arguments" and "arguments.callee". + + Also fixes a latent GC bug, where an executing function could be + subject to GC if the register holding it were overwritten. Here's + an example that would have caused problems: + + function f() + { + // Flood the machine stack to eliminate any old pointers to f. + g.call({}); + + // Overwrite f in the register file. + f = 1; + + // Force a GC. + for (var i = 0; i < 5000; ++i) { + ({}); + } + + // Welcome to crash-ville. + } + + function g() + { + } + + f(); + + * VM/Machine.h: Changed the order of arguments to + execute(FunctionBodyNode*...) to match the other execute functions. + * kjs/function.cpp: Updated to match new argument requirements from + execute(FunctionBodyNode*...). Renamed newObj to thisObj to match the + rest of JavaScriptCore. + + SunSpider reports no change. + +2008-04-23 Cameron Zwarich + + Reviewed by Maciej. + + Bug 18707: SQUIRRELFISH: eval always performs toString() on its argument + + + This fixes 4 more regression tests. + + * VM/Machine.cpp: + (KJS::eval): + +2008-04-23 Maciej Stachowiak + + Reviewed by Oliver. + + - fix logic bug in SegmentedVector::grow which would sometimes fail to resize a segment when needed + + Fixes 3 JSC tests. + + * VM/SegmentedVector.h: + (KJS::SegmentedVector::grow): + +2008-04-23 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Degenerate handling of "arguments" as a property of the activation + object. Currently, we just return a vanilla object. + + SunSpider reports no change. + + Fixes: + + ecma_3/Function/regress-94506.js. + + Reveals to have been secretly broken: + + ecma_3/Function/15.3.4.3-1.js + ecma_3/Function/15.3.4.4-1.js + + These tests were passing incorrectly. testkjs creates a global array + named "arguments" to hold command-line arguments. That array was + tricking these tests into thinking that an arguments object with length + 0 had been created. Since our new vanilla object shadows the global + property named arguments, that object no longer fools these tests into + passing. + + Net change: +1 failing test. + + * kjs/AllInOneFile.cpp: Had to put JSActivation.cpp into AllInOneFile.cpp + to solve a surprising 8.6% regression in bitops-3bit-bits-in-byte. + +2008-04-23 Maciej Stachowiak + + Reviewed by Oliver. + + - save and restore callFrame + + * VM/Machine.cpp: + (KJS::slideRegisterWindowForCall): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * kjs/testkjs.cpp: + (main): + +2008-04-23 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed scopes for named function expressions. + + Fixes one regression test. + + Two changes here: + + (1) The function's name is supposed to have attributes DontDelete, + ReadOnly, regardless of the type of code executing. + + (2) Push the name object on the function's scope chain, rather than + the ExecState's scope chain because, well, that's where it belongs. + +2008-04-23 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Inlined JSObject::putDirect, for a .4% SunSpider speedup. + + I did this as a first step toward removing nodes.cpp from + AllInOneFile.cpp, but I'm putting that larger project aside for now. + +2008-04-23 Maciej Stachowiak + + Rubber stamped by Geoff. + + - add OldInterpreterExecState class and use it in dead code + + This will allow removing things from the real ExecState class + without having to figure out how to remove all this code without + getting a perf regression. + + * kjs/nodes.cpp: + (KJS::ExpressionNode::evaluateToNumber): + (KJS::ExpressionNode::evaluateToBoolean): + (KJS::ExpressionNode::evaluateToInt32): + (KJS::ExpressionNode::evaluateToUInt32): + (KJS::Node::setErrorCompletion): + (KJS::Node::throwError): + (KJS::Node::throwUndefinedVariableError): + (KJS::Node::handleException): + (KJS::Node::rethrowException): + (KJS::BreakpointCheckStatement::execute): + (KJS::BreakpointCheckStatement::optimizeVariableAccess): + (KJS::NullNode::evaluate): + (KJS::FalseNode::evaluate): + (KJS::TrueNode::evaluate): + (KJS::NumberNode::evaluate): + (KJS::NumberNode::evaluateToNumber): + (KJS::NumberNode::evaluateToBoolean): + (KJS::NumberNode::evaluateToInt32): + (KJS::NumberNode::evaluateToUInt32): + (KJS::ImmediateNumberNode::evaluate): + (KJS::ImmediateNumberNode::evaluateToInt32): + (KJS::ImmediateNumberNode::evaluateToUInt32): + (KJS::StringNode::evaluate): + (KJS::StringNode::evaluateToNumber): + (KJS::StringNode::evaluateToBoolean): + (KJS::RegExpNode::evaluate): + (KJS::ThisNode::evaluate): + (KJS::ResolveNode::inlineEvaluate): + (KJS::ResolveNode::evaluate): + (KJS::ResolveNode::evaluateToNumber): + (KJS::ResolveNode::evaluateToBoolean): + (KJS::ResolveNode::evaluateToInt32): + (KJS::ResolveNode::evaluateToUInt32): + (KJS::getSymbolTableEntry): + (KJS::ResolveNode::optimizeVariableAccess): + (KJS::LocalVarAccessNode::inlineEvaluate): + (KJS::LocalVarAccessNode::evaluate): + (KJS::LocalVarAccessNode::evaluateToNumber): + (KJS::LocalVarAccessNode::evaluateToBoolean): + (KJS::LocalVarAccessNode::evaluateToInt32): + (KJS::LocalVarAccessNode::evaluateToUInt32): + (KJS::getNonLocalSymbol): + (KJS::ScopedVarAccessNode::inlineEvaluate): + (KJS::ScopedVarAccessNode::evaluate): + (KJS::ScopedVarAccessNode::evaluateToNumber): + (KJS::ScopedVarAccessNode::evaluateToBoolean): + (KJS::ScopedVarAccessNode::evaluateToInt32): + (KJS::ScopedVarAccessNode::evaluateToUInt32): + (KJS::NonLocalVarAccessNode::inlineEvaluate): + (KJS::NonLocalVarAccessNode::evaluate): + (KJS::NonLocalVarAccessNode::evaluateToNumber): + (KJS::NonLocalVarAccessNode::evaluateToBoolean): + (KJS::NonLocalVarAccessNode::evaluateToInt32): + (KJS::NonLocalVarAccessNode::evaluateToUInt32): + (KJS::ElementNode::optimizeVariableAccess): + (KJS::ElementNode::evaluate): + (KJS::ArrayNode::optimizeVariableAccess): + (KJS::ArrayNode::evaluate): + (KJS::ObjectLiteralNode::optimizeVariableAccess): + (KJS::ObjectLiteralNode::evaluate): + (KJS::PropertyListNode::optimizeVariableAccess): + (KJS::PropertyListNode::evaluate): + (KJS::PropertyNode::optimizeVariableAccess): + (KJS::PropertyNode::evaluate): + (KJS::BracketAccessorNode::optimizeVariableAccess): + (KJS::BracketAccessorNode::inlineEvaluate): + (KJS::BracketAccessorNode::evaluate): + (KJS::BracketAccessorNode::evaluateToNumber): + (KJS::BracketAccessorNode::evaluateToBoolean): + (KJS::BracketAccessorNode::evaluateToInt32): + (KJS::BracketAccessorNode::evaluateToUInt32): + (KJS::DotAccessorNode::optimizeVariableAccess): + (KJS::DotAccessorNode::inlineEvaluate): + (KJS::DotAccessorNode::evaluate): + (KJS::DotAccessorNode::evaluateToNumber): + (KJS::DotAccessorNode::evaluateToBoolean): + (KJS::DotAccessorNode::evaluateToInt32): + (KJS::DotAccessorNode::evaluateToUInt32): + (KJS::ArgumentListNode::optimizeVariableAccess): + (KJS::ArgumentListNode::evaluateList): + (KJS::ArgumentsNode::optimizeVariableAccess): + (KJS::NewExprNode::optimizeVariableAccess): + (KJS::NewExprNode::inlineEvaluate): + (KJS::NewExprNode::evaluate): + (KJS::NewExprNode::evaluateToNumber): + (KJS::NewExprNode::evaluateToBoolean): + (KJS::NewExprNode::evaluateToInt32): + (KJS::NewExprNode::evaluateToUInt32): + (KJS::ExpressionNode::resolveAndCall): + (KJS::EvalFunctionCallNode::optimizeVariableAccess): + (KJS::EvalFunctionCallNode::evaluate): + (KJS::FunctionCallValueNode::optimizeVariableAccess): + (KJS::FunctionCallValueNode::evaluate): + (KJS::FunctionCallResolveNode::optimizeVariableAccess): + (KJS::FunctionCallResolveNode::inlineEvaluate): + (KJS::FunctionCallResolveNode::evaluate): + (KJS::FunctionCallResolveNode::evaluateToNumber): + (KJS::FunctionCallResolveNode::evaluateToBoolean): + (KJS::FunctionCallResolveNode::evaluateToInt32): + (KJS::FunctionCallResolveNode::evaluateToUInt32): + (KJS::LocalVarFunctionCallNode::inlineEvaluate): + (KJS::LocalVarFunctionCallNode::evaluate): + (KJS::LocalVarFunctionCallNode::evaluateToNumber): + (KJS::LocalVarFunctionCallNode::evaluateToBoolean): + (KJS::LocalVarFunctionCallNode::evaluateToInt32): + (KJS::LocalVarFunctionCallNode::evaluateToUInt32): + (KJS::ScopedVarFunctionCallNode::inlineEvaluate): + (KJS::ScopedVarFunctionCallNode::evaluate): + (KJS::ScopedVarFunctionCallNode::evaluateToNumber): + (KJS::ScopedVarFunctionCallNode::evaluateToBoolean): + (KJS::ScopedVarFunctionCallNode::evaluateToInt32): + (KJS::ScopedVarFunctionCallNode::evaluateToUInt32): + (KJS::NonLocalVarFunctionCallNode::inlineEvaluate): + (KJS::NonLocalVarFunctionCallNode::evaluate): + (KJS::NonLocalVarFunctionCallNode::evaluateToNumber): + (KJS::NonLocalVarFunctionCallNode::evaluateToBoolean): + (KJS::NonLocalVarFunctionCallNode::evaluateToInt32): + (KJS::NonLocalVarFunctionCallNode::evaluateToUInt32): + (KJS::FunctionCallBracketNode::optimizeVariableAccess): + (KJS::FunctionCallBracketNode::evaluate): + (KJS::FunctionCallDotNode::optimizeVariableAccess): + (KJS::FunctionCallDotNode::inlineEvaluate): + (KJS::FunctionCallDotNode::evaluate): + (KJS::FunctionCallDotNode::evaluateToNumber): + (KJS::FunctionCallDotNode::evaluateToBoolean): + (KJS::FunctionCallDotNode::evaluateToInt32): + (KJS::FunctionCallDotNode::evaluateToUInt32): + (KJS::PostIncResolveNode::optimizeVariableAccess): + (KJS::PostIncResolveNode::evaluate): + (KJS::PostIncLocalVarNode::evaluate): + (KJS::PostDecResolveNode::optimizeVariableAccess): + (KJS::PostDecResolveNode::evaluate): + (KJS::PostDecLocalVarNode::evaluate): + (KJS::PostDecLocalVarNode::inlineEvaluateToNumber): + (KJS::PostDecLocalVarNode::evaluateToNumber): + (KJS::PostDecLocalVarNode::evaluateToBoolean): + (KJS::PostDecLocalVarNode::evaluateToInt32): + (KJS::PostDecLocalVarNode::evaluateToUInt32): + (KJS::PostfixBracketNode::optimizeVariableAccess): + (KJS::PostIncBracketNode::evaluate): + (KJS::PostDecBracketNode::evaluate): + (KJS::PostfixDotNode::optimizeVariableAccess): + (KJS::PostIncDotNode::evaluate): + (KJS::PostDecDotNode::evaluate): + (KJS::PostfixErrorNode::evaluate): + (KJS::DeleteResolveNode::optimizeVariableAccess): + (KJS::DeleteResolveNode::evaluate): + (KJS::LocalVarDeleteNode::evaluate): + (KJS::DeleteBracketNode::optimizeVariableAccess): + (KJS::DeleteBracketNode::evaluate): + (KJS::DeleteDotNode::optimizeVariableAccess): + (KJS::DeleteDotNode::evaluate): + (KJS::DeleteValueNode::optimizeVariableAccess): + (KJS::DeleteValueNode::evaluate): + (KJS::VoidNode::optimizeVariableAccess): + (KJS::VoidNode::evaluate): + (KJS::TypeOfValueNode::optimizeVariableAccess): + (KJS::TypeOfResolveNode::optimizeVariableAccess): + (KJS::LocalVarTypeOfNode::evaluate): + (KJS::TypeOfResolveNode::evaluate): + (KJS::TypeOfValueNode::evaluate): + (KJS::PreIncResolveNode::optimizeVariableAccess): + (KJS::PreIncLocalVarNode::evaluate): + (KJS::PreIncResolveNode::evaluate): + (KJS::PreDecResolveNode::optimizeVariableAccess): + (KJS::PreDecLocalVarNode::evaluate): + (KJS::PreDecResolveNode::evaluate): + (KJS::PreIncConstNode::evaluate): + (KJS::PreDecConstNode::evaluate): + (KJS::PostIncConstNode::evaluate): + (KJS::PostDecConstNode::evaluate): + (KJS::PrefixBracketNode::optimizeVariableAccess): + (KJS::PreIncBracketNode::evaluate): + (KJS::PreDecBracketNode::evaluate): + (KJS::PrefixDotNode::optimizeVariableAccess): + (KJS::PreIncDotNode::evaluate): + (KJS::PreDecDotNode::evaluate): + (KJS::PrefixErrorNode::evaluate): + (KJS::UnaryPlusNode::optimizeVariableAccess): + (KJS::UnaryPlusNode::evaluate): + (KJS::UnaryPlusNode::evaluateToBoolean): + (KJS::UnaryPlusNode::evaluateToNumber): + (KJS::UnaryPlusNode::evaluateToInt32): + (KJS::UnaryPlusNode::evaluateToUInt32): + (KJS::NegateNode::optimizeVariableAccess): + (KJS::NegateNode::evaluate): + (KJS::NegateNode::evaluateToNumber): + (KJS::BitwiseNotNode::optimizeVariableAccess): + (KJS::BitwiseNotNode::inlineEvaluateToInt32): + (KJS::BitwiseNotNode::evaluate): + (KJS::BitwiseNotNode::evaluateToNumber): + (KJS::BitwiseNotNode::evaluateToBoolean): + (KJS::BitwiseNotNode::evaluateToInt32): + (KJS::BitwiseNotNode::evaluateToUInt32): + (KJS::LogicalNotNode::optimizeVariableAccess): + (KJS::LogicalNotNode::evaluate): + (KJS::LogicalNotNode::evaluateToBoolean): + (KJS::MultNode::optimizeVariableAccess): + (KJS::MultNode::inlineEvaluateToNumber): + (KJS::MultNode::evaluate): + (KJS::MultNode::evaluateToNumber): + (KJS::MultNode::evaluateToBoolean): + (KJS::MultNode::evaluateToInt32): + (KJS::MultNode::evaluateToUInt32): + (KJS::DivNode::optimizeVariableAccess): + (KJS::DivNode::inlineEvaluateToNumber): + (KJS::DivNode::evaluate): + (KJS::DivNode::evaluateToNumber): + (KJS::DivNode::evaluateToInt32): + (KJS::DivNode::evaluateToUInt32): + (KJS::ModNode::optimizeVariableAccess): + (KJS::ModNode::inlineEvaluateToNumber): + (KJS::ModNode::evaluate): + (KJS::ModNode::evaluateToNumber): + (KJS::ModNode::evaluateToBoolean): + (KJS::ModNode::evaluateToInt32): + (KJS::ModNode::evaluateToUInt32): + (KJS::throwOutOfMemoryErrorToNumber): + (KJS::addSlowCase): + (KJS::addSlowCaseToNumber): + (KJS::add): + (KJS::addToNumber): + (KJS::AddNode::optimizeVariableAccess): + (KJS::AddNode::evaluate): + (KJS::AddNode::inlineEvaluateToNumber): + (KJS::AddNode::evaluateToNumber): + (KJS::AddNode::evaluateToInt32): + (KJS::AddNode::evaluateToUInt32): + (KJS::AddNumbersNode::inlineEvaluateToNumber): + (KJS::AddNumbersNode::evaluate): + (KJS::AddNumbersNode::evaluateToNumber): + (KJS::AddNumbersNode::evaluateToInt32): + (KJS::AddNumbersNode::evaluateToUInt32): + (KJS::AddStringsNode::evaluate): + (KJS::AddStringLeftNode::evaluate): + (KJS::AddStringRightNode::evaluate): + (KJS::SubNode::optimizeVariableAccess): + (KJS::SubNode::inlineEvaluateToNumber): + (KJS::SubNode::evaluate): + (KJS::SubNode::evaluateToNumber): + (KJS::SubNode::evaluateToInt32): + (KJS::SubNode::evaluateToUInt32): + (KJS::LeftShiftNode::optimizeVariableAccess): + (KJS::LeftShiftNode::inlineEvaluateToInt32): + (KJS::LeftShiftNode::evaluate): + (KJS::LeftShiftNode::evaluateToNumber): + (KJS::LeftShiftNode::evaluateToInt32): + (KJS::LeftShiftNode::evaluateToUInt32): + (KJS::RightShiftNode::optimizeVariableAccess): + (KJS::RightShiftNode::inlineEvaluateToInt32): + (KJS::RightShiftNode::evaluate): + (KJS::RightShiftNode::evaluateToNumber): + (KJS::RightShiftNode::evaluateToInt32): + (KJS::RightShiftNode::evaluateToUInt32): + (KJS::UnsignedRightShiftNode::optimizeVariableAccess): + (KJS::UnsignedRightShiftNode::inlineEvaluateToUInt32): + (KJS::UnsignedRightShiftNode::evaluate): + (KJS::UnsignedRightShiftNode::evaluateToNumber): + (KJS::UnsignedRightShiftNode::evaluateToInt32): + (KJS::UnsignedRightShiftNode::evaluateToUInt32): + (KJS::lessThan): + (KJS::lessThanEq): + (KJS::LessNode::optimizeVariableAccess): + (KJS::LessNode::inlineEvaluateToBoolean): + (KJS::LessNode::evaluate): + (KJS::LessNode::evaluateToBoolean): + (KJS::LessNumbersNode::inlineEvaluateToBoolean): + (KJS::LessNumbersNode::evaluate): + (KJS::LessNumbersNode::evaluateToBoolean): + (KJS::LessStringsNode::inlineEvaluateToBoolean): + (KJS::LessStringsNode::evaluate): + (KJS::LessStringsNode::evaluateToBoolean): + (KJS::GreaterNode::optimizeVariableAccess): + (KJS::GreaterNode::inlineEvaluateToBoolean): + (KJS::GreaterNode::evaluate): + (KJS::GreaterNode::evaluateToBoolean): + (KJS::LessEqNode::optimizeVariableAccess): + (KJS::LessEqNode::inlineEvaluateToBoolean): + (KJS::LessEqNode::evaluate): + (KJS::LessEqNode::evaluateToBoolean): + (KJS::GreaterEqNode::optimizeVariableAccess): + (KJS::GreaterEqNode::inlineEvaluateToBoolean): + (KJS::GreaterEqNode::evaluate): + (KJS::GreaterEqNode::evaluateToBoolean): + (KJS::InstanceOfNode::optimizeVariableAccess): + (KJS::InstanceOfNode::evaluate): + (KJS::InstanceOfNode::evaluateToBoolean): + (KJS::InNode::optimizeVariableAccess): + (KJS::InNode::evaluate): + (KJS::InNode::evaluateToBoolean): + (KJS::EqualNode::optimizeVariableAccess): + (KJS::EqualNode::inlineEvaluateToBoolean): + (KJS::EqualNode::evaluate): + (KJS::EqualNode::evaluateToBoolean): + (KJS::NotEqualNode::optimizeVariableAccess): + (KJS::NotEqualNode::inlineEvaluateToBoolean): + (KJS::NotEqualNode::evaluate): + (KJS::NotEqualNode::evaluateToBoolean): + (KJS::StrictEqualNode::optimizeVariableAccess): + (KJS::StrictEqualNode::inlineEvaluateToBoolean): + (KJS::StrictEqualNode::evaluate): + (KJS::StrictEqualNode::evaluateToBoolean): + (KJS::NotStrictEqualNode::optimizeVariableAccess): + (KJS::NotStrictEqualNode::inlineEvaluateToBoolean): + (KJS::NotStrictEqualNode::evaluate): + (KJS::NotStrictEqualNode::evaluateToBoolean): + (KJS::BitAndNode::optimizeVariableAccess): + (KJS::BitAndNode::evaluate): + (KJS::BitAndNode::inlineEvaluateToInt32): + (KJS::BitAndNode::evaluateToNumber): + (KJS::BitAndNode::evaluateToBoolean): + (KJS::BitAndNode::evaluateToInt32): + (KJS::BitAndNode::evaluateToUInt32): + (KJS::BitXOrNode::optimizeVariableAccess): + (KJS::BitXOrNode::inlineEvaluateToInt32): + (KJS::BitXOrNode::evaluate): + (KJS::BitXOrNode::evaluateToNumber): + (KJS::BitXOrNode::evaluateToBoolean): + (KJS::BitXOrNode::evaluateToInt32): + (KJS::BitXOrNode::evaluateToUInt32): + (KJS::BitOrNode::optimizeVariableAccess): + (KJS::BitOrNode::inlineEvaluateToInt32): + (KJS::BitOrNode::evaluate): + (KJS::BitOrNode::evaluateToNumber): + (KJS::BitOrNode::evaluateToBoolean): + (KJS::BitOrNode::evaluateToInt32): + (KJS::BitOrNode::evaluateToUInt32): + (KJS::LogicalAndNode::optimizeVariableAccess): + (KJS::LogicalAndNode::evaluate): + (KJS::LogicalAndNode::evaluateToBoolean): + (KJS::LogicalOrNode::optimizeVariableAccess): + (KJS::LogicalOrNode::evaluate): + (KJS::LogicalOrNode::evaluateToBoolean): + (KJS::ConditionalNode::optimizeVariableAccess): + (KJS::ConditionalNode::evaluate): + (KJS::ConditionalNode::evaluateToBoolean): + (KJS::ConditionalNode::evaluateToNumber): + (KJS::ConditionalNode::evaluateToInt32): + (KJS::ConditionalNode::evaluateToUInt32): + (KJS::valueForReadModifyAssignment): + (KJS::ReadModifyResolveNode::optimizeVariableAccess): + (KJS::AssignResolveNode::optimizeVariableAccess): + (KJS::ReadModifyLocalVarNode::evaluate): + (KJS::AssignLocalVarNode::evaluate): + (KJS::ReadModifyConstNode::evaluate): + (KJS::AssignConstNode::evaluate): + (KJS::ReadModifyResolveNode::evaluate): + (KJS::AssignResolveNode::evaluate): + (KJS::AssignDotNode::optimizeVariableAccess): + (KJS::AssignDotNode::evaluate): + (KJS::ReadModifyDotNode::optimizeVariableAccess): + (KJS::ReadModifyDotNode::evaluate): + (KJS::AssignErrorNode::evaluate): + (KJS::AssignBracketNode::optimizeVariableAccess): + (KJS::AssignBracketNode::evaluate): + (KJS::ReadModifyBracketNode::optimizeVariableAccess): + (KJS::ReadModifyBracketNode::evaluate): + (KJS::CommaNode::optimizeVariableAccess): + (KJS::CommaNode::evaluate): + (KJS::ConstDeclNode::optimizeVariableAccess): + (KJS::ConstDeclNode::handleSlowCase): + (KJS::ConstDeclNode::evaluateSingle): + (KJS::ConstDeclNode::evaluate): + (KJS::ConstStatementNode::optimizeVariableAccess): + (KJS::ConstStatementNode::execute): + (KJS::statementListExecute): + (KJS::BlockNode::optimizeVariableAccess): + (KJS::BlockNode::execute): + (KJS::EmptyStatementNode::execute): + (KJS::ExprStatementNode::optimizeVariableAccess): + (KJS::ExprStatementNode::execute): + (KJS::VarStatementNode::optimizeVariableAccess): + (KJS::VarStatementNode::execute): + (KJS::IfNode::optimizeVariableAccess): + (KJS::IfNode::execute): + (KJS::IfElseNode::optimizeVariableAccess): + (KJS::IfElseNode::execute): + (KJS::DoWhileNode::optimizeVariableAccess): + (KJS::DoWhileNode::execute): + (KJS::WhileNode::optimizeVariableAccess): + (KJS::WhileNode::execute): + (KJS::ForNode::optimizeVariableAccess): + (KJS::ForNode::execute): + (KJS::ForInNode::optimizeVariableAccess): + (KJS::ForInNode::execute): + (KJS::ContinueNode::execute): + (KJS::BreakNode::execute): + (KJS::ReturnNode::optimizeVariableAccess): + (KJS::ReturnNode::execute): + (KJS::WithNode::optimizeVariableAccess): + (KJS::WithNode::execute): + (KJS::CaseClauseNode::optimizeVariableAccess): + (KJS::CaseClauseNode::evaluate): + (KJS::CaseClauseNode::executeStatements): + (KJS::ClauseListNode::optimizeVariableAccess): + (KJS::CaseBlockNode::optimizeVariableAccess): + (KJS::CaseBlockNode::executeBlock): + (KJS::SwitchNode::optimizeVariableAccess): + (KJS::SwitchNode::execute): + (KJS::LabelNode::optimizeVariableAccess): + (KJS::LabelNode::execute): + (KJS::ThrowNode::optimizeVariableAccess): + (KJS::ThrowNode::execute): + (KJS::TryNode::optimizeVariableAccess): + (KJS::TryNode::execute): + (KJS::ProgramNode::initializeSymbolTable): + (KJS::ScopeNode::optimizeVariableAccess): + (KJS::ProgramNode::processDeclarations): + (KJS::EvalNode::processDeclarations): + (KJS::ProgramNode::execute): + (KJS::EvalNode::execute): + (KJS::FunctionBodyNodeWithDebuggerHooks::execute): + (KJS::FuncDeclNode::execute): + (KJS::FuncExprNode::evaluate): + * kjs/nodes.h: + (KJS::Node::): + (KJS::FalseNode::): + (KJS::TrueNode::): + (KJS::ArgumentsNode::): + +2008-04-23 Oliver Hunt + + Reviewed by Geoff. + + Bug 18672: SQUIRRELFISH: codegen fails with a large number of temporaries + + + Add a SegmentedVector type, which provides a Vector which maintains + existing memory locations during resize. This allows dynamically sizing + local, temporary and label "vectors" in CodeGenerator. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addVar): + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::newTemporary): + (KJS::CodeGenerator::newLabel): + * VM/CodeGenerator.h: + * VM/SegmentedVector.h: Added. + (KJS::SegmentedVector::SegmentedVector): + (KJS::SegmentedVector::~SegmentedVector): + (KJS::SegmentedVector::last): + (KJS::SegmentedVector::append): + (KJS::SegmentedVector::removeLast): + (KJS::SegmentedVector::size): + (KJS::SegmentedVector::operator[]): + (KJS::SegmentedVector::resize): + (KJS::SegmentedVector::shrink): + (KJS::SegmentedVector::grow): + +2008-04-23 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + A little refactoring in preparation for supporting 'arguments'. + + Fixes 2 regression tests. + + SunSpider reports no change. + + We now check the activation register, instead of the codeBlock, to + determine whether we need to tear off the activation. This is to support + "f.arguments", which will create an activation/arguments pair for f, + even though the needsFullScopeChain flag is false for f's codeBlock. + + The test fixes resulted from calling initializeCallFrame for re-entrant + function code, instead of initializing (not enough) parts of the call + frame by hand. + +2008-04-22 Maciej Stachowiak + + Reviewed by Sam. + + - propagate the "this" value properly to local eval + + (fixes a measly one regression test) + + * VM/CodeBlock.h: + (KJS::CodeBlock::CodeBlock): + (KJS::ProgramCodeBlock::ProgramCodeBlock): + (KJS::EvalCodeBlock::EvalCodeBlock): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-22 Cameron Zwarich + + Reviewed by Maciej. + + Add support for function declarations in eval code. + + (this fixes 12 more regression tests) + + * VM/CodeBlock.h: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::execute): + * kjs/nodes.cpp: + (KJS::EvalNode::generateCode): + +2008-04-22 Cameron Zwarich + + Reviewed by Oliver. + + Implement LabelNode. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::pushJumpContext): + (KJS::CodeGenerator::jumpContextForContinue): + (KJS::CodeGenerator::jumpContextForBreak): + * VM/CodeGenerator.h: + * kjs/nodes.cpp: + (KJS::DoWhileNode::emitCode): + (KJS::WhileNode::emitCode): + (KJS::ForNode::emitCode): + (KJS::ForInNode::emitCode): + (KJS::ContinueNode::emitCode): + (KJS::BreakNode::emitCode): + (KJS::SwitchNode::emitCode): + (KJS::LabelNode::emitCode): + +2008-04-22 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed crash when unwinding from exceptions inside eval. + + * VM/Machine.cpp: + (KJS::Machine::unwindCallFrame): Don't assume that the top of the + current call frame's scope chain is an activation: it can be the global + object, instead. + +2008-04-22 Maciej Stachowiak + + Reviewed by Geoff. + + * kjs/testkjs.cpp: + (main): Convert signals to exit codes, so that crashing tests are + detected as regression test failures. + +2008-04-22 Geoffrey Garen + + Reviewed by Oliver Hunt and Maciej Stachowiak. + + Renamed "needsActivation" to "needsFullScopeChain" because lying will + make hair grow on the backs of your hands. + +2008-04-21 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed ScopeChainNode lifetime problems: + + (1) In "with" and "catch" scopes, we would construct a ScopeChain + object and then jump across its destructor, leaking the ScopeChainNode + we had pushed. + + (2) In global and eval scopes, we would fail to initially ref + "scopeChain", causing us to overrelease it later. Now that we ref + "scopeChain" properly, we also need to deref it when the script + terminates. + + SunSpider reports a .2% regression, but an earlier round of ScopeChain + refactoring was a .4% speedup, so there. + +2008-04-22 Maciej Stachowiak + + Reviewed by Alexey. + + - use global object instead of null for "this" on unqualified calls + + This fixes 10 more JSC test regressions. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-22 Maciej Stachowiak + + Reviewed by Oliver. + + - throw proper exceptions for objects that don't implement call or construct + + This fixes 21 more JSC test regressions. It is also seemingly an + 0.5% progression. + + * VM/ExceptionHelpers.cpp: + (KJS::createNotAnObjectError): + (KJS::createNotAConstructorError): + (KJS::createNotAFunctionError): + * VM/ExceptionHelpers.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-21 Oliver Hunt + + Reviewed by Geoff. + + Implement emitCode for ConstDeclNode. + + This fixes the crash (assertion) in js1_5/Scope/scope-001.js + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::registerForLocalConstInit): + * VM/CodeGenerator.h: + * kjs/nodes.cpp: + (KJS::AssignResolveNode::emitCode): + (KJS::ConstDeclNode::emitCodeSingle): + (KJS::ConstDeclNode::emitCode): + (KJS::ConstStatementNode::emitCode): + * kjs/nodes.h: + +2008-04-21 Maciej Stachowiak + + Reviewed by Sam. + + - add some support for the split window object + + This fixes many layout tests. + + * VM/Machine.cpp: + (KJS::resolveBaseAndFunc): Use toThisObject() to ensure we get the + wrapper global, if one exists, as the "this" object. + * kjs/function.cpp: + (KJS::globalFuncEval): Use toGlobalObject() to handle the wrapper + case properly. + +2008-04-21 Maciej Stachowiak + + Reviewed by Oliver. + + - restore ScopeChain::operator= to avoid crash on many layout tests + + Otherwise, FunctionImp::setScope would cause a reference + underflow. I implemented using the copy construct and swap idiom. + + * kjs/scope_chain.h: + (KJS::ScopeChain::swap): + (KJS::ScopeChain::operator=): + +2008-04-21 Oliver Hunt + + Reviewed by Geoff. + + Bug 18649: SQUIRRELFISH: correctly handle exceptions in eval code + + + Allocate a callframe for eval() and initialise with a null codeBlock to + indicate native code. This prevents the unwinder from clobbering the + register stack. + + * VM/Machine.cpp: + (KJS::Machine::execute): + +2008-04-21 Geoffrey Garen + + Reviewed by Sam Weinig. + + Removed ScopeChain::push(ScopeChain&) because it was unused. Moved + ScopeChain::print to ScopeChainNode. + + ScopeChain is now nothing more than a resource-handling wrapper around + ScopeChainNode. + +2008-04-21 Cameron Zwarich + + Reviewed by Maciej. + + Bug 18671: SquirrelFish: continue inside switch fails + + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::jumpContextForLabel): + * VM/CodeGenerator.h: + * kjs/nodes.cpp: + (KJS::ContinueNode::emitCode): + +2008-04-21 Geoffrey Garen + + Reviewed by Sam Weinig. + + Moved push(JSObject*) and pop() from ScopeChain to ScopeChainNode, + rearranging scope_chain.h a bit. + + SunSpider reports no change. + +2008-04-21 Geoffrey Garen + + Reviewed by Sam Weinig. + + Moved bottom() from ScopeChain to ScopeChainNode, simplifying it based + on the knowledge that the ScopeChain is never empty. + + SunSpider reports no change. + +2008-04-21 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Moved begin() and end() from ScopeChain to ScopeChainNode. + + Also marked a few methods "const". + + SunSpider reports no change. + +2008-04-21 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Turned ScopeChain::depth into a stand-alone function, and simplified it + a bit. + + I also moved ScopeChain::depth to Machine.cpp because it doesn't report + the true depth of the ScopeChain -- just the Machine's perspective of + its depth within a given call frame. + + SunSpider reports no change. + +2008-04-21 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Removed indirection in ScopeChain::ref / ScopeChain::deref. + + SunSpider reports no change. + + * kjs/scope_chain.h: + (KJS::ScopeChain::ScopeChain): + (KJS::ScopeChain::~ScopeChain): + (KJS::ScopeChain::clear): + +2008-04-21 Oliver Hunt + + Fix debug build + + * kjs/nodes.cpp: + (KJS::ConstDeclNode::evaluateSingle): + +2008-04-21 Cameron Zwarich + + Reviewed by Oliver. + + Bug 18664: SQUIRRELFISH: correctly throw a SyntaxError when parsing of eval code fails + + + Correctly throw a SyntaxError when parsing of eval code fails. + + * VM/Machine.cpp: + (KJS::eval): + +2008-04-21 Oliver Hunt + + Reviewed by Geoff. + + Partial fix for Bug 18649: SQUIRRELFISH: correctly handle exceptions in eval code + + Make sure we correct the register state before jumping to vm_throw. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-21 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Simplified ScopeChain ref/deref. + + SunSpider reports a .4% speedup. + + * kjs/scope_chain.h: + (KJS::ScopeChainNode::ref): Removed this function because it was nonsense. + ScopeChainNodes are initialized with a refCount of 1, so the loop was + guaranteed to iterate exactly once. + +2008-04-21 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Removed support for empty ScopeChains. + + SunSpider reports no change. + +2008-04-21 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Removed some completely unused ScopeChain member functions. + + SunSpider reports no change. + +2008-04-21 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Avoid creating unnecessary ScopeChain objects, to reduce refcount churn. + + SunSpider reports no change. + +2008-04-21 Maciej Stachowiak + + Rubber stamped by Alexey. + + Add some braces.x + + * kjs/testkjs.cpp: + (runWithScripts): + +2008-04-21 Maciej Stachowiak + + Reviewed by Oliver. + + - only print "End:" output when -d flag is passed. + + This fixes half of our failing JSC regression tests. + + * kjs/testkjs.cpp: + (runWithScripts): + +2008-04-21 Cameron Zwarich + + Reviewed by Maciej. + + Add support for variable declarations in eval code. + + * VM/CodeBlock.h: + (KJS::EvalCodeBlock::EvalCodeBlock): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::execute): + * VM/Machine.h: + * kjs/function.cpp: + (KJS::globalFuncEval): + * kjs/nodes.cpp: + (KJS::EvalNode::generateCode): + * kjs/nodes.h: + (KJS::EvalNode::): + +2008-04-20 Oliver Hunt + + Reviewed by Maciej. + + Throw exceptions for invalid continue, break, and return statements. + + Simple refactoring and extension of Cameron's AssignErrorNode, etc patch + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::pushJumpContext): + (KJS::CodeGenerator::popJumpContext): + (KJS::CodeGenerator::jumpContextForLabel): + * VM/CodeGenerator.h: + * kjs/nodes.cpp: + (KJS::Node::emitThrowError): + (KJS::ContinueNode::emitCode): + (KJS::BreakNode::emitCode): + (KJS::ReturnNode::emitCode): + * kjs/nodes.h: + +2008-04-20 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Removed Machine.cpp from AllInOneFile.cpp, and manually inlined a few + things that used to be inlined automatically. + + 1.9% speedup on SunSpider. + + My hope is that we'll face fewer surprises in Machine.cpp codegen, now + that GCC is making fewer decisions. The speedup seems to confirm that. + +2008-04-20 Oliver Hunt + + Reviewed by Maciej. + + Bug 18642: Iterator context may get placed into the return register, leading to much badness + + + To prevent incorrectly reusing what will become the result register for + eval and global code execution, we need to request and ref the destination + in advance of codegen. Unfortunately this may lead to unnecessary copying, + although in future we can probably limit this. Curiously SunSpider shows + a progression in a number of tests, although it comes out as a wash overall. + + * kjs/nodes.cpp: + (KJS::EvalNode::emitCode): + (KJS::ProgramNode::emitCode): + +2008-04-20 Cameron Zwarich + + Reviewed by Maciej. + + Add support for AssignErrorNode, PrefixErrorNode, and PostfixErrorNode. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitCreateError): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::PostfixErrorNode::emitCode): + (KJS::PrefixErrorNode::emitCode): + (KJS::AssignErrorNode::emitCode): + * kjs/nodes.h: + +2008-04-20 Oliver Hunt + + Reviewed by Geoff and Mark. + + Provide line number information in exceptions + + Simple patch, adds line number information metadata to CodeBlock + and a simple method to get the line number responsible for a given + Instruction*. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::lineNumberForVPC): + * VM/CodeBlock.h: + * VM/CodeGenerator.h: + (KJS::CodeGenerator::emitNode): + * VM/Machine.cpp: + (KJS::Machine::throwException): + +2008-04-20 Oliver Hunt + + Reviewed by Maciej. + + Provide "sourceURL" in exceptions + + * VM/CodeBlock.h: + * VM/Machine.cpp: + (KJS::Machine::throwException): + * kjs/nodes.cpp: + (KJS::EvalNode::generateCode): + (KJS::ProgramNode::generateCode): + +2008-04-19 Oliver Hunt + + Reviewed by Maciej. + + Don't call emitCode directly on subnodes, instead use CodeGenerator::emitNode + + This patch just a preparation for tracking line numbers. + + * kjs/nodes.cpp: + (KJS::ObjectLiteralNode::emitCode): + (KJS::PropertyListNode::emitCode): + (KJS::ArgumentListNode::emitCode): + (KJS::TryNode::emitCode): + +2008-04-19 Oliver Hunt + + Reviewed by Maciej. + + Bug 18619: Support continue, break, and return in try .. finally blocks + + + This patch replaces the current partial finally support (which uses code + duplication to achieve what it does) with a subroutine based approach. + This has a number of advantages over code duplication: + * Reduced code size + * Simplified exception handling as the finaliser code only exists in + one place, so no "magic" is needed to get the correct handler for a + finaliser. + * When we support instruction to line number mapping we won't need to + worry about the dramatic code movement caused by duplication + + On the downside it is necessary to add two new opcodes, op_jsr and op_sret + to enter and exit the finaliser subroutines, happily SunSpider reports + a performance progression (gcc amazes me) and ubench reports a wash. + + While jsr and sret provide a mechanism that allows us to enter and exit + any arbitrary finaliser we need to, it was still necessary to increase + the amount of information tracked when entering and exiting both finaliser + scopes and dynamic scopes ("with"). This means "scopeDepth" is now + the combination of "finaliserDepth" and "dynamicScopeDepth". We also + now use a scopeContextStack to ensure that we pop scopes and execute + finalisers in the correct order. This increases the cost of "with" nodes + during codegen, but it should not be significant enough to effect real + world performance and greatly simplifies codegen for return, break and + continue when interacting with finalisers. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + Pretty printing of jsr/sret opcodes + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::emitPushScope): + (KJS::CodeGenerator::emitPopScope): + Dynamic scopes need to be tracked on the scopeContextStack now + + (KJS::CodeGenerator::pushFinallyContext): + (KJS::CodeGenerator::popFinallyContext): + Handle entry and exit from code regions with finalisers. This is + needed solely to support return, continue and break inside finaliser + regions. + + (KJS::CodeGenerator::emitComplexJumpScopes): + Helper function for emitJumpScopes to handle the complex codegen + needed to handle return, continue and break inside a finaliser region + + (KJS::CodeGenerator::emitJumpScopes): + Updated to be aware of finalisers, if a cross-scope jump occurs inside + a finaliser we hand off codegen to emitComplexJumpScopes, otherwise + we can handle the normal (trivial) case with a single instruction. + + (KJS::CodeGenerator::emitJumpSubroutine): + (KJS::CodeGenerator::emitSubroutineReturn): + Trivial opcode emitter functions. + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::scopeDepth): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + Implement op_jsr and op_sret. + + * VM/Opcode.h: + Ad op_jsr and op_sret + + * kjs/nodes.cpp: + (KJS::TryNode::emitCode): + Fix codegen for new finaliser model. + +2008-04-17 Mark Rowe + + Rubber-stamped by Oliver Hunt. + + Remove unnecessary files from testkjs, testapi and minidom targets. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-04-17 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed ASSERT seen during run-sunspider of a debug build. + + * VM/CodeGenerator.h: Made the default codegen buffers bigger. SunSpider + runs all tests in one global environment, so you end up with more than + 128 locals. This is just a stop-gap until we code up a real + solution to arbitrary symbol and label limits. + +2008-04-17 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed a bug in exception unwinding, where we wouldn't deref the scope + chain in global scope, so we would leak ScopeChainNodes when exceptions + were thrown inside "with" and "catch" scopes. + + Also did some cleanup of the unwinding code along the way. + + Scope chain reference counting is still wrong in a few ways. I thought + I would fix this portion of it first. + + run-sunspider shows no change. + + * VM/Machine.cpp: + (KJS::Machine::unwindCallFrame): + (KJS::Machine::throwException): + (KJS::Machine::privateExecute): + * VM/Machine.h: + +2008-04-17 Oliver Hunt + + Reviewed by Maciej. + + Add more exception checking to toNumber conversions + + This corrects op_pre_dec, op_negate, op_mod and op_sub. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-17 Geoffrey Garen and Cameron Zwarich + + Reviewed by Oliver Hunt. + + Behold: eval. + + Introduced a new opcode: op_call_eval. In the normal case, it performs + an eval. In the case where eval has been overridden in some way, it + performs a function call. + + * VM/CodeGenerator.h: Added a feature so the code generator knows not + to optimized locals in eval code. + +2008-04-17 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added some ASSERTs to document codegen failures in + run-javascriptcore-tests. + + For all tests, program-level codegen now either succeeds, or fails with + an ASSERT. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addVar): + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::newTemporary): + (KJS::CodeGenerator::newLabel): + +2008-04-17 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed another case of a dst register being an unreferenced temporary + (caused an ASSERT when running the full sunspider suite). + + * kjs/nodes.cpp: + (KJS::CaseBlockNode::emitCodeForBlock): + +2008-04-16 Maciej Stachowiak + + Reviewed by Geoff. + + - add documentation (and meaningful parameter names) for arithmetic and bitwise binary ops + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitMul): + (KJS::CodeGenerator::emitDiv): + (KJS::CodeGenerator::emitMod): + (KJS::CodeGenerator::emitSub): + (KJS::CodeGenerator::emitLeftShift): + (KJS::CodeGenerator::emitRightShift): + (KJS::CodeGenerator::emitUnsignedRightShift): + (KJS::CodeGenerator::emitBitAnd): + (KJS::CodeGenerator::emitBitXOr): + (KJS::CodeGenerator::emitBitOr): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::MultNode::emitCode): + (KJS::DivNode::emitCode): + (KJS::ModNode::emitCode): + (KJS::SubNode::emitCode): + (KJS::LeftShiftNode::emitCode): + (KJS::RightShiftNode::emitCode): + (KJS::UnsignedRightShiftNode::emitCode): + (KJS::BitAndNode::emitCode): + (KJS::BitXOrNode::emitCode): + (KJS::BitOrNode::emitCode): + (KJS::emitReadModifyAssignment): + (KJS::ReadModifyResolveNode::emitCode): + +2008-04-16 Oliver Hunt + + Reviewed by Geoff. + + Exception checks for toNumber in op_pre_inc + + This is somewhat more convoluted than the simple hadException checks + we currently use. Instead we use special toNumber conversions that + select between the exception and ordinary vPC. This allows us to + remove any branches in the common case (incrementing a number). + + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + (KJS::::toNumber): + * ChangeLog: + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * VM/JSPropertyNameIterator.cpp: + (KJS::JSPropertyNameIterator::toNumber): + * VM/JSPropertyNameIterator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + * kjs/ExecState.h: + * kjs/JSNotAnObject.cpp: + (KJS::JSNotAnObject::toNumber): + * kjs/JSNotAnObject.h: + * kjs/internal.cpp: + (KJS::StringImp::toNumber): + (KJS::NumberImp::toNumber): + (KJS::GetterSetterImp::toNumber): + * kjs/internal.h: + * kjs/object.cpp: + (KJS::JSObject::toNumber): + * kjs/object.h: + * kjs/value.h: + (KJS::JSValue::toNumber): + +2008-04-16 Maciej Stachowiak + + Reviewed by Geoff. + + - ensure that activations are kept in a register to protect them from GC + + Also renamed OptionalCalleeScopeChain constant to OptionalCalleeActivation, since + that is what is now kept there, and there is no more need to keep the scope chain in + the register file. + + * VM/Machine.cpp: + (KJS::initializeCallFrame): + (KJS::scopeChainForCall): + * VM/Machine.h: + (KJS::Machine::): + +2008-04-16 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Made "this" work in program code / global scope. + + The machine can initialize "this" prior to execution because it knows + that, for program code, "this" is always stored in lr1. + + * VM/Machine.cpp: + (KJS::Machine::execute): + * VM/Machine.h: + (KJS::Machine::): + * kjs/interpreter.cpp: + (KJS::Interpreter::evaluate): + +2008-04-16 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed a codegen bug when returning from inside a dynamic scope (a with + or catch block): we need to pop any dynamic scope(s) that have been + added so op_ret can find the activation object at the top of the scope + chain. + + * kjs/nodes.cpp: + (KJS::ReturnNode::emitCode): If we're returning from inside a dynamic + scope, emit a jmp_scopes to take care of popping any dynamic scope(s) + and then branching to the return instruction. + +2008-04-16 Maciej Stachowiak + + Reviewed by Geoff. + + - document the add and get_prop_id opcodes + + In addition to adding documentation in comments, I changed + references to register IDs or indices relating to these opcodes to + have meaningful names instead of r0 r1 r2. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitAdd): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/nodes.cpp: + (KJS::DotAccessorNode::emitCode): + (KJS::FunctionCallDotNode::emitCode): + (KJS::PostIncDotNode::emitCode): + (KJS::PostDecDotNode::emitCode): + (KJS::PreIncDotNode::emitCode): + (KJS::PreDecDotNode::emitCode): + (KJS::AddNode::emitCode): + (KJS::ReadModifyDotNode::emitCode): + +2008-04-15 Geoffrey Garen + + Reviewed by Oliver Hunt and Maciej Stachowiak. + + Fixed a codegen bug in with and switch, and added an ASSERT to + make sure it doesn't happen again. + + emitCode() assumes that dst, if non-zero, is either referenced or + non-temporary (i.e., it assumes that newTemporary() will return a + register not equal to dst). Certain callers to emitCode() weren't + guaranteeing that to be so, so temporary register values were being + overwritten. + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::emitNode): ASSERT that dst is referenced or non-temporary. + + * kjs/nodes.cpp: + (KJS::CommaNode::emitCode): Reference the dst we pass. + + (KJS::WithNode::emitCode): No need to pass an explicit dst register. + + (KJS::CaseBlockNode::emitCodeForBlock): No need to pass an explicit dst register. + (KJS::SwitchNode::emitCode): No need to pass an explicit dst register. + + * kjs/nodes.h: Made dst the last parameter to emitCodeForBlock, to match + emitCode. + +2008-04-15 Oliver Hunt + + Reviewed by Maciej. + + Bug 18526: Throw exceptions when resolve fails for op_resolve_base_and_func. + + + Very simple fix, sunspider shows a 0.7% progression, ubench shows a 0.4% regression. + + * VM/Machine.cpp: + (KJS::resolveBaseAndFunc): + (KJS::Machine::privateExecute): + +2008-04-15 Maciej Stachowiak + + Reviewed by Oliver. + + - fix incorrect result on 3d-raytrace test + + Oliver found and tracked down this bug, I just typed in the fix. + + * VM/Machine.cpp: + (KJS::slideRegisterWindowForCall): When setting omitted parameters to undefined, + account for the space for local variables. + +2008-04-15 Maciej Stachowiak + + Reviewed by Oliver. + + - fix codegen handling of dst registers + + 1.006x speedup (not sure why). + + Most emitCode functions take an optional "dst" parameter that says + where the output of the instruction should be written. I made some + functions for convenient handling of the dst register: + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::tempDestination): Takes the dst register. Returns it if + it is not null and is a temporary, otherwise allocates a new temporary. This is + intended for cases where an intermediate value might be written into the dst + + (KJS::CodeGenerator::finalDestination): Takes the dst register and an optional + register that was used as a temp destination. Picks the right thing for the final + output. Intended to be used as the output register for the instruction that generates + the final value of a particular node. + + (KJS::CodeGenerator::moveToDestinationIfNeeded): Takes dst and a + RegisterID; moves from the register to dst if dst is defined and + different from the register. This is intended for cases where the + result of a node is already in a specific register (likely a + local), and so no code needs to be generated unless a specific + destination has been requested, in which case a move is needed. + + I also applied these methods throughout emitCode functions. In + some cases this was just cleanup, in other cases I fixed actual + codegen bugs. Below I have given specific comments for the cases + where I believe I fixed a codegen bug, or improved quality of codegen. + + * kjs/nodes.cpp: + (KJS::NullNode::emitCode): + (KJS::FalseNode::emitCode): + (KJS::TrueNode::emitCode): + (KJS::NumberNode::emitCode): + (KJS::StringNode::emitCode): + (KJS::RegExpNode::emitCode): + (KJS::ThisNode::emitCode): Now avoids emitting a mov when dst is + the same as the this register (the unlikely case of "this = this"); + (KJS::ResolveNode::emitCode): Now avoids emitting a mov when dst + is the same as the local regiester, in the local var case (the + unlikely case of "x = x"); + (KJS::ArrayNode::emitCode): Fixed a codegen bug where array + literal element expressions may have observed an intermediate + value of constructing the array. + (KJS::ObjectLiteralNode::emitCode): + (KJS::PropertyListNode::emitCode): Fixed a codegen bug where object literal + property definition expressions may have obesrved an intermediate value of + constructing the object. + (KJS::BracketAccessorNode::emitCode): + (KJS::DotAccessorNode::emitCode): + (KJS::NewExprNode::emitCode): + (KJS::FunctionCallValueNode::emitCode): + (KJS::FunctionCallBracketNode::emitCode): + (KJS::FunctionCallDotNode::emitCode): + (KJS::PostIncResolveNode::emitCode): + (KJS::PostDecResolveNode::emitCode): + (KJS::PostIncBracketNode::emitCode): + (KJS::PostDecBracketNode::emitCode): + (KJS::PostIncDotNode::emitCode): + (KJS::PostDecDotNode::emitCode): + (KJS::DeleteResolveNode::emitCode): + (KJS::DeleteBracketNode::emitCode): + (KJS::DeleteDotNode::emitCode): + (KJS::DeleteValueNode::emitCode): + (KJS::VoidNode::emitCode): + (KJS::TypeOfResolveNode::emitCode): + (KJS::TypeOfValueNode::emitCode): + (KJS::PreIncResolveNode::emitCode): Fixed a codegen bug where the final + value would not be output to the dst register in the local var case. + (KJS::PreDecResolveNode::emitCode): Fixed a codegen bug where the final + value would not be output to the dst register in the local var case. + (KJS::PreIncBracketNode::emitCode): + (KJS::PreDecBracketNode::emitCode): + (KJS::PreIncDotNode::emitCode): + (KJS::PreDecDotNode::emitCode): + (KJS::UnaryPlusNode::emitCode): + (KJS::NegateNode::emitCode): + (KJS::BitwiseNotNode::emitCode): + (KJS::LogicalNotNode::emitCode): + (KJS::MultNode::emitCode): + (KJS::DivNode::emitCode): + (KJS::ModNode::emitCode): + (KJS::AddNode::emitCode): + (KJS::SubNode::emitCode): + (KJS::LeftShiftNode::emitCode): + (KJS::RightShiftNode::emitCode): + (KJS::UnsignedRightShiftNode::emitCode): + (KJS::LessNode::emitCode): + (KJS::GreaterNode::emitCode): + (KJS::LessEqNode::emitCode): + (KJS::GreaterEqNode::emitCode): + (KJS::InstanceOfNode::emitCode): + (KJS::InNode::emitCode): + (KJS::EqualNode::emitCode): + (KJS::NotEqualNode::emitCode): + (KJS::StrictEqualNode::emitCode): + (KJS::NotStrictEqualNode::emitCode): + (KJS::BitAndNode::emitCode): + (KJS::BitXOrNode::emitCode): + (KJS::BitOrNode::emitCode): + (KJS::LogicalAndNode::emitCode): + (KJS::LogicalOrNode::emitCode): + (KJS::ConditionalNode::emitCode): + (KJS::emitReadModifyAssignment): Allow an out argument separate from the operands, + needed for fixes below. + (KJS::ReadModifyResolveNode::emitCode): Fixed a codegen bug where the right side of + the expression may observe an intermediate value. + (KJS::AssignResolveNode::emitCode): Fixed a codegen bug where the right side of the + expression may observe an intermediate value. + (KJS::ReadModifyDotNode::emitCode): Fixed a codegen bug where the right side of the + expression may observe an intermediate value. + (KJS::ReadModifyBracketNode::emitCode): Fixed a codegen bug where the right side of the + expression may observe an intermediate value. + (KJS::CommaNode::emitCode): Avoid writing temporary value to dst register. + (KJS::ReturnNode::emitCode): Void return should return undefined, not null. + (KJS::FuncExprNode::emitCode): + +2008-04-15 Maciej Stachowiak + + Reviewed by Geoff. + + - fix huge performance regression (from trunk) in string-unpack-code + + This restores string-unpack-code performance to parity with + trunk (2.27x speedup relative to previous SquirrelFish) + + * VM/Machine.cpp: + (KJS::Machine::execute): Shrink register file after call to avoid + growing repeatedly. + +2008-04-15 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed dumpCallFrame to match our new convention of passing around a + ScopeChainNode* instead of a ScopeChain*. + + * JavaScriptCore.exp: + * VM/Machine.cpp: + (KJS::Machine::dumpCallFrame): + * VM/Machine.h: + +2008-04-15 Oliver Hunt + + Reviewed by Maciej. + + Bug 18436: Need to throw exception on read/modify/write or similar resolve for nonexistent property + + + Add op_resolve_base_and_property for read/modify/write operations, + this adds a "superinstruction" to resolve the base and value of a + property simultaneously. Just using resolveBase and resolve results + in an 5% regression in ubench, 30% in loop-empty-resolve (which is + expected). 1.3% progression in sunspider, 2.1% in ubench, with a + 21% gain in loop-empty-resolve. The only outlier is function-missing-args + which gets a 3% regression that I could never resolve. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitResolveBaseAndProperty): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::resolveBaseAndProperty): + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::PostIncResolveNode::emitCode): + (KJS::PostDecResolveNode::emitCode): + (KJS::PreIncResolveNode::emitCode): + (KJS::PreDecResolveNode::emitCode): + (KJS::ReadModifyResolveNode::emitCode): + +2008-04-15 Maciej Stachowiak + + Reviewed by Oliver. + + - fixed "SquirrelFish crashes due to bad scope chain on some SunSpider tests" + https://bugs.webkit.org/show_bug.cgi?id=18508 + + 3d-raytrace and string-unpack-code now run. + + The basic approach is to pass around ScopeChainNode* instead of + ScopeChain*, which in addition to not becoming suddenly an invalid + pointer also saves an indirection. + + This is an 0.4% speedup on SunSpider --squirrelfish (1.8% on --ubench) + + * VM/Machine.cpp: + (KJS::resolve): + (KJS::resolveBase): + (KJS::resolveBaseAndFunc): + (KJS::initializeCallFrame): + (KJS::scopeChainForCall): + (KJS::Machine::unwindCallFrame): + (KJS::Machine::throwException): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * VM/Machine.h: + * VM/Register.h: + (KJS::Register::): + * kjs/nodes.cpp: + (KJS::EvalNode::generateCode): + (KJS::FunctionBodyNode::generateCode): + (KJS::ProgramNode::generateCode): + (KJS::ProgramNode::processDeclarations): + (KJS::EvalNode::processDeclarations): + (KJS::FuncDeclNode::makeFunction): + (KJS::FuncExprNode::makeFunction): + * kjs/nodes.h: + (KJS::ProgramNode::): + (KJS::EvalNode::): + (KJS::FunctionBodyNode::): + * kjs/object.h: + * kjs/scope_chain.h: + (KJS::ScopeChainNode::ScopeChainNode): + (KJS::ScopeChainNode::deref): + (KJS::ScopeChainIterator::ScopeChainIterator): + (KJS::ScopeChainIterator::operator*): + (KJS::ScopeChainIterator::operator->): + (KJS::ScopeChain::ScopeChain): + (KJS::ScopeChain::node): + (KJS::ScopeChain::deref): + (KJS::ScopeChain::ref): + (KJS::ScopeChainNode::ref): + (KJS::ScopeChainNode::release): + (KJS::ScopeChainNode::begin): + (KJS::ScopeChainNode::end): + +2008-04-14 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed crash when accessing registers in a torn-off activation object. + + * kjs/JSActivation.cpp: + (KJS::JSActivation::copyRegisters): Update our registerOffset after + copying our registers, since our offset should now be relative to + our private register array, not the shared register file. + +2008-04-14 Maciej Stachowiak + + Reviewed by Oliver. + + - fix a codegen flaw that makes some tests run way too fast or way too slow + + The basic problem was that FunctionCallResolveNode results in + codegen which can incorrectly write an intermediate value into the + dst register even when that is a local. I added convenience + functions to CodeGenerator for getting this right, but for now I + only fixed FunctionCallResolve. + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::tempDestination): + (KJS::CodeGenerator::): + * kjs/nodes.cpp: + (KJS::FunctionCallResolveNode::emitCode): + +2008-04-14 Gabor Loki + + Reviewed and slightly tweaked by Geoffrey Garen. + + Bug 18489: Squirrelfish doesn't build on linux + + + * JavaScriptCore.pri: Add VM into include path and its files into + source set + * VM/JSPropertyNameIterator.cpp: Fix include name + * VM/Machine.cpp: Add UNLIKELY macro for GCC + * VM/Machine.h: Add missing includes + * VM/RegisterFile.cpp: Add missing include + * kjs/testkjs.pro: Add VM into include path + +2008-04-14 Geoffrey Garen + + Reviewed by Sam Weinig. + + Restored OwnPtr in some places where I had removed it previously. We + can have an OwnPtr to an undefined class in a header as long as the + class's destructor isn't in the header. + +2008-04-14 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed access to "this" inside dynamic scopes. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::registerForLocal): Always return a register for + "this", even if we're not optimizing access to other locals. Because + "this" is a keyword, it's always in a register and always accessible. + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::shouldOptimizeLocals): Factored out a function + for determining whether we should optimize access to locals, since + eval will need to make this test a little more complicated. + +2008-04-14 Maciej Stachowiak + + Reviewed by Adam. + + - fix crash when running SunSpider full harness + + When growing the register file's buffer to make space for new globals, + make sure to copy accounting for the fact that the new space is logically + at the beginning of the buffer in this case, instead of at the end as when + growing for a new call frame. + + * VM/RegisterFile.cpp: + (KJS::RegisterFile::newBuffer): + (KJS::RegisterFile::growBuffer): + (KJS::RegisterFile::addGlobalSlots): + * VM/RegisterFile.h: + +2008-04-11 Geoffrey Garen + + Reviewed by Sam Weinig. + + Mark constant pools for global and eval code (collectively known as + "program code"). (Constant pools for function code are already marked by + their functions.) + + The global object is responsible for marking program code constant + pools. Code blocks add themselves to the mark set at creation time, and + remove themselves from the mark set at destruction time. + + sunspider --squirrelfish reports a 1% speedup, perhaps because + generateCode() is now non-virtual. + + * kjs/nodes.cpp: I had to use manual init and delete in this file + because putting an OwnPtr into the header would have created a circular + header dependency. + +2008-04-10 Cameron Zwarich + + Reviewed by Maciej. + + Bug 18231: Improve support for function call nodes in SquirrelFish + + + Use correct value of 'this' for function calls. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitResolveBaseAndFunc): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::resolveBaseAndFunc): + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::FunctionCallResolveNode::emitCode): + +2008-04-10 Geoffrey Garen + + This time for sure. + + * kjs/interpreter.cpp: + (KJS::Interpreter::evaluate): + +2008-04-10 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed Interpreter::execute to honor the new model for returning non-NULL + values when an exception is thrown. + + * kjs/interpreter.cpp: + (KJS::Interpreter::evaluate): + +2008-04-10 Oliver Hunt + + Reviewed by Geoff. + + Fix SquirrelFish interpreter to pass internal exceptions back to + native code correctly. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-10 Sam Weinig + + Reviewed by Geoffrey Garen. + + Replace the use of getCallData in op_construct with the new + getConstructData function that replaces implementsConstruct. + + * API/JSCallbackConstructor.cpp: + (KJS::JSCallbackConstructor::getConstructData): + * API/JSCallbackConstructor.h: + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + (KJS::::getConstructData): + (KJS::::construct): + * API/JSObjectRef.cpp: + (JSObjectIsConstructor): + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/CallData.h: + * kjs/ConstructData.h: Copied from JavaScriptCore/kjs/CallData.h. + * kjs/array_object.cpp: + (KJS::ArrayObjectImp::getConstructData): + * kjs/array_object.h: + * kjs/bool_object.cpp: + (KJS::BooleanObjectImp::getConstructData): + * kjs/bool_object.h: + * kjs/date_object.cpp: + (KJS::DateObjectImp::getConstructData): + * kjs/date_object.h: + * kjs/error_object.cpp: + (KJS::ErrorObjectImp::getConstructData): + (KJS::NativeErrorImp::getConstructData): + * kjs/error_object.h: + * kjs/function.cpp: + (KJS::FunctionImp::getCallData): + (KJS::FunctionImp::getConstructData): + (KJS::FunctionImp::construct): + * kjs/function.h: + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::getConstructData): + * kjs/function_object.h: + * kjs/nodes.cpp: + (KJS::NewExprNode::inlineEvaluate): + * kjs/number_object.cpp: + (KJS::NumberObjectImp::getConstructData): + * kjs/number_object.h: + * kjs/object.cpp: + * kjs/object.h: + * kjs/object_object.cpp: + (KJS::ObjectObjectImp::getConstructData): + * kjs/object_object.h: + * kjs/regexp_object.cpp: + (KJS::RegExpObjectImp::getConstructData): + * kjs/regexp_object.h: + * kjs/string_object.cpp: + (KJS::StringObjectImp::getConstructData): + * kjs/string_object.h: + * kjs/value.cpp: + (KJS::JSCell::getConstructData): + * kjs/value.h: + (KJS::JSValue::getConstructData): + +2008-04-10 Oliver Hunt + + Reviewed by Geoff. + + Bug 18420: SquirrelFish: need to throw Reference and Type errors + when attempting invalid operations on JSValues + + Add validation and exception checks to SquirrelFish so that the + correct exceptions are thrown for undefined variables, type errors + and toObject failure. Also handle exceptions thrown by native + function calls. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * VM/ExceptionHelpers.cpp: Added. + (KJS::substitute): + (KJS::createError): + (KJS::createUndefinedVariableError): + * VM/ExceptionHelpers.h: Added. + Helper functions + * VM/Machine.cpp: + (KJS::resolve): + Modified to signal failure + (KJS::isNotObject): + Wrapper for JSValue::isObject and exception creation (these need + to be merged, lest GCC go off the deep end) + (KJS::Machine::privateExecute): + Adding the many exception and validity checks. + + * kjs/JSNotAnObject.cpp: Added. + Stub object used to reduce the need for multiple exception checks + when toObject fails. + (KJS::JSNotAnObject::toPrimitive): + (KJS::JSNotAnObject::getPrimitiveNumber): + (KJS::JSNotAnObject::toBoolean): + (KJS::JSNotAnObject::toNumber): + (KJS::JSNotAnObject::toString): + (KJS::JSNotAnObject::toObject): + (KJS::JSNotAnObject::mark): + (KJS::JSNotAnObject::getOwnPropertySlot): + (KJS::JSNotAnObject::put): + (KJS::JSNotAnObject::deleteProperty): + (KJS::JSNotAnObject::defaultValue): + (KJS::JSNotAnObject::construct): + (KJS::JSNotAnObject::callAsFunction): + (KJS::JSNotAnObject::getPropertyNames): + * kjs/JSNotAnObject.h: Added. + (KJS::JSNotAnObject::JSNotAnObject): + * kjs/JSImmediate.cpp: + (KJS::JSImmediate::toObject): + modified to create an JSNotAnObject rather than throwing an exception + directly. + +2008-04-10 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Pass a function body node its function's scope chain, rather than the + current execution context's scope chain, when compiling it. + + This doesn't matter yet, but it will once we start using the scope + chain during compilation. + + sunspider --squirrelfish notes a tiny speedup. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-10 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fix two bugs when throwing exceptions from re-entrant JS calls: + + (1) Don't shrink the register file to 0, since our caller may still + be using it. + + (2) In case of exception, return jsNull() instead of 0 because, + surprisingly, some JavaScriptCore clients rely on a function's return + value being safe to operate on even if the function threw an exception. + + Also: + + - Changed FunctionImp::callAsFunction to honor the new semantics of + exceptions not returning 0. + + - Renamed "handlerPC" to "handlerVPC" to match other uses of "VPC". + + - Renamed "exceptionData" to "exceptionValue", because "data" seemed to + imply something more than just a JSValue. + + - Merged prepareException into throwException, since throwException was + its only caller, and it seemed weird that throwException didn't take + an exception as an argument. + + sunspider --squirrelfish does not seem to complain on my machine, but it + complains a little (.6%) on Oliver's. + +2008-04-10 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed op_construct for CallTypeNative to reacquire "r" before setting + its return value, since registerBase can theoretically change during the + execution of arbitrary code. (Not sure if any native constructors + actually make this possible.) + + sunspider --squirrelfish does not seem to complain. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-10 Geoffrey Garen + + Reviewed by Oliver Hunt and Sam Weinig. + + Re-entrant execution of function code (global code -> built-in function + -> JS function): + + Miraculously, sunspider --squirrelfish does not seem to complain. + + A re-entrant function call is the same as a normal function call with + one exception: the re-entrant call leaves everything except for + CallerCodeBlock in the call frame header uninitialized, since the call + doesn't need to return to JS code. (It sets CallerCodeBlock to 0, to + indicate that the call shouldn't return to JS code.) + + Also fixed a few issues along the way: + + - Fixed two bugs in the read-write List implementation that caused + m_size and m_buffer to go stale. + + - Changed native call code to update "r" *before* setting the return + value, since the call may in turn call JS code, which changes the value + of "r". + + - Migrated initialization of "r" outside of Machine::privateExecute, + because global code and function code initialize "r" differently. + + - Migrated a codegen warning from Machine::privateExecute to the wiki. + + - Removed unnecessary "r" parameter from slideRegisterWindowForCall + + * VM/Machine.cpp: + (KJS::slideRegisterWindowForCall): + (KJS::scopeChainForCall): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * VM/Machine.h: + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + * kjs/list.cpp: + (KJS::List::getSlice): + * kjs/list.h: + (KJS::List::clear): + +2008-04-10 Maciej Stachowiak + + Reviewed by Oliver. + + - fix problem with code generation for return with no argument + + 3d-cube now runs + + * kjs/nodes.cpp: + (KJS::ReturnNode::emitCode): + +2008-04-10 Maciej Stachowiak + + Reviewed by Oliver. + + - Implement support for JS constructors + + access-binary-trees and access-nbody now run. + + Inexplicably a 1% speedup. + + * VM/Machine.cpp: + (KJS::initializeCallFrame): + (KJS::Machine::privateExecute): + * VM/Machine.h: + (KJS::Machine::): + +2008-04-10 Maciej Stachowiak + + Reviewed by Oliver. + + - More code cleanup in preparation for JS constructors + + Factor the remaining interesting parts of JS function calls into + slideRegisterWindowForCall and scopeChainForCall. + + * VM/Machine.cpp: + (KJS::slideRegisterWindowForCall): + (KJS::scopeChainForCall): + (KJS::Machine::privateExecute): + +2008-04-10 Maciej Stachowiak + + Reviewed by Geoff. + + - Code cleanup in preparation for JS constructors + + - Renamed returnInfo to callFrame. + - Made an enum which defines what goes where in the call frame. + - Factored out initializeCallFrame function from op_call + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitCall): + (KJS::CodeGenerator::emitConstruct): + * VM/Machine.cpp: + (KJS::Machine::dumpRegisters): + (KJS::initializeCallFrame): + (KJS::Machine::unwindCallFrame): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * VM/Machine.h: + (KJS::Machine::): + +2008-04-10 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed two bugs in register allocation for function calls: + + (1) op_call used to allocate codeBlock->numVars too many registers for + each call frame, due to duplicated math. Fixing this revealed... + + (2) By unconditionally calling resize(), op_call used to truncate the + register file when calling a function whose registers fit wholly within + the register file already allocated by its caller. + + sunspider --squirrelfish reports no regression. + + I also threw in a little extra formatting to dumpCallFrame, because it + helped me debug these issues. + + * VM/Machine.cpp: + (KJS::Machine::dumpRegisters): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * VM/RegisterFile.h: + (KJS::RegisterFile::shrink): + (KJS::RegisterFile::grow): + * VM/RegisterFileStack.cpp: + (KJS::RegisterFileStack::popRegisterFile): + +2008-04-09 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Next step toward re-entrant execution of function code (global code -> + built-in function -> JS function): + + Made op_ret return from Machine::privateExecute if its calling codeBlock + is NULL. + + I'm checking this in by itself to demonstrate that a more clever + mechanism is not necessary for performance. + + sunspider --squirrelfish reports no regression. + + * ChangeLog: + * VM/Machine.cpp: + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + +2008-04-09 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Next step toward re-entrant execution of function code (global code -> + built-in function -> JS function): + + Made Machine::execute return a value. + + Sketched out some code for Machine::execute for functions -- still + doesn't work yet, though. + + sunspider --squirrelfish reports no regression. + + * VM/Machine.cpp: + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * VM/Machine.h: + * kjs/interpreter.cpp: + (KJS::Interpreter::evaluate): + * kjs/testkjs.cpp: + (runWithScripts): + +2008-04-09 Geoffrey Garen + + Reviewed by Sam Weinig. + + First step toward re-entrant execution of function code (global code -> + built-in function -> JS function): + + Tiny bit of refactoring in the Machine class. + + sunspider --squirrelfish reports no regression. + + * VM/Machine.cpp: + (KJS::Machine::dumpRegisters): + (KJS::Machine::unwindCallFrame): + (KJS::Machine::execute): + (KJS::Machine::privateExecute): + * VM/Machine.h: + (KJS::Machine::isGlobalCallFrame): + * kjs/interpreter.cpp: + (KJS::Interpreter::evaluate): + +2008-04-08 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Support for re-entrant execution of global code (global code -> built-in + function -> global code). + + Keep a stack of register files instead of just one. Globals propogate + between register files as the register files enter and exit the stack. + + An activation still uses its own register file's base as its + registerBase, but the global object uses the register file *stack*'s + registerBase, which updates dynamically to match the register file at + the top of the stack. + + sunspider --squirrelfish reports no regression. + +2008-04-08 Maciej Stachowiak + + Reviewed by Geoff. + + - initial preparatory work for JS constructors + + 1) Allocate registers for the returnInfo block and "this" value when generating code for + op_construct. These are not used yet, but the JS branch of op_construct will use them. + + 2) Adjust argc and argv appropriately for native constructor calls. + + 3) Assign return value in a more straightforward way in op_ret since this is actually + a bit faster (and makes up for the allocation of extra registers above). + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitConstruct): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-07 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed crashing SunSpider tests. + + Let's just pretend this never happened, bokay? + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::CodeGenerator): + * VM/CodeGenerator.h: + * VM/RegisterFile.cpp: + (KJS::RegisterFile::addGlobals): + +2008-04-07 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Restored dumping of generated code as a command-line switch: + run-testkjs -d will do it. + +2008-04-07 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Next step toward supporting re-entrant evaluation: Moved register file + maintenance code into a proper "RegisterFile" class. + + There's a subtle change to the register file's internal layout: for + global code / the global object, registerOffset is always 0 now. In + other words, all register counting starts at 0, not 0 + (number of + global variables). The helps simplify accounting when the number of + global variables changes. + +2008-04-07 Oliver Hunt + + Reviewed by Geoff. + + Bug 18338: Support exceptions in SquirrelFish + + Initial support for exceptions in SquirrelFish, only supports finalisers in the + simple cases (eg. exceptions and non-goto/return across finaliser boundaries). + This doesn't add the required exception checks to existing code, it merely adds + support for throw, catch, and the required stack unwinding. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + (KJS::CodeBlock::getHandlerForVPC): + * VM/CodeBlock.h: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitCatch): + (KJS::CodeGenerator::emitThrow): + * VM/CodeGenerator.h: + * VM/JSPropertyNameIterator.cpp: + (KJS::JSPropertyNameIterator::create): + * VM/Machine.cpp: + (KJS::prepareException): + (KJS::Machine::unwindCallFrame): + (KJS::Machine::throwException): + (KJS::Machine::privateExecute): + * VM/Machine.h: + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::ThrowNode::emitCode): + (KJS::TryNode::emitCode): + * kjs/nodes.h: + * kjs/scope_chain.cpp: + (KJS::ScopeChain::depth): + * kjs/scope_chain.h: + +2008-04-06 Geoffrey Garen + + Reviewed by Oliver Hunt. + + First step toward supporting re-entrant evaluation: Switch register + clients from using "registers", a pointer to a register vector, to + "registerBase", an indirect pointer to the logical first entry in the + register file. (The logical first entry is the first entry that is not + a global variable). + + With a vector, offsets into the register file remain good when the + underlying buffer reallocates, but they go bad when the logical + first entry moves. (The logical first entry moves when new global + variables get added to the beginning of the register file.) With an + indirect pointer to the logical first entry, offsets will remain good + regardless. + + 1.4% speedup on sunspider --squirrelfish. I suspect this is due to + reduced allocation when creating closures, and reduced indirection + through the register vector. + + * wtf/Vector.h: Added an accessor for an indirect pointer to the vector's + buffer, which we currently use (incorrectly) for registerBase. This is + temporary scaffolding to allow us to change client code without + changing behavior. + +2008-04-06 Sam Weinig + + Reviewed by Oliver Hunt. + + Implement codegen for ReadModifyDotNode. + + * kjs/nodes.cpp: + (KJS::ReadModifyDotNode::emitCode): + * kjs/nodes.h: + +2008-04-06 Sam Weinig + + Reviewed by Oliver Hunt. + + Fix codegen for PostIncDotNode and implement codegen for PostIncBracketNode, + PostDecBracketNode and PostDecDotNode. + + * kjs/nodes.cpp: + (KJS::PostIncBracketNode::emitCode): + (KJS::PostDecBracketNode::emitCode): + (KJS::PostIncDotNode::emitCode): + (KJS::PostDecDotNode::emitCode): + * kjs/nodes.h: + +2008-04-06 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement codegen for PreDecResolveNode, PreIncBracketNode, PreDecBracketNode, + PreIncDotNode and PreDecDotNode. This required adding one new op code, op_pre_dec. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitPreDec): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::PreDecResolveNode::emitCode): + (KJS::PreIncBracketNode::emitCode): + (KJS::PreDecBracketNode::emitCode): + (KJS::PreIncDotNode::emitCode): + (KJS::PreDecDotNode::emitCode): + * kjs/nodes.h: + +2008-04-06 Geoffrey Garen + + Reviewed by Sam Weinig. + + Improved register dumping, plus a liberal smattering of "const". Here's + what the new format looks like: + + (gdb) call (void)dumpCallFrame(codeBlock, scopeChain, registers->begin(), r) + 4 instructions; 48 bytes at 0x509210; 3 locals (2 parameters); 1 temporaries + + [ 0] load lr1, undefined(@k0) + [ 3] load lr1, 2(@k1) + [ 6] add tr0, lr2, lr1 + [ 10] ret tr0 + + Constants: + k0 = undefined + k1 = 2 + + Register frame: + + ---------------------------------------- + use | address | value + ---------------------------------------- + [return info] | 0x80ac08 | 0x5081c0 + [return info] | 0x80ac0c | 0x508e90 + [return info] | 0x80ac10 | 0x504acc + [return info] | 0x80ac14 | 0x2 + [return info] | 0x80ac18 | 0x0 + [return info] | 0x80ac1c | 0x7 + [return info] | 0x80ac20 | 0x0 + ---------------------------------------- + [param] | 0x80ac24 | 0x1 + [param] | 0x80ac28 | 0x7 + [var] | 0x80ac2c | 0xb + [temp] | 0x80ac30 | 0xf + +2008-04-06 Geoffrey Garen + + Reviewed by Sam Weinig. + + Support for evaluating multiple scripts in the same global environment. + (Still don't support re-entrant evaluation yet.) + + The main changes here are: + + (1) Obey the ECMA 10.1.3 rules regarding how to resolve collisions when + a given symbol is declared more than once. (This patch fixes the same + issue for function code, too.) + + (2) In the case of var and/or function collisions, reuse the existing + storage slot. For global code, this is required for previously + generated instructions to continue to work. For function code, it's + more of a "nice to have": it makes register layout in the case of + collisions easier to understand, and has the added benefit of saving + memory. + + (3) Allocate slots in the CodeGenerator's m_locals vector in parallel + to register indexes in the symbol table. This ensures that, given an + index in the symbol table, we can find the corresponding RegisterID + without hashing, which speeds up codegen. + + I moved responsibility for emitting var and function initialization + instructions into the CodeGenerator, because bookkeeping in cases where + var, function, and/or parameter names collide requires a lot of + internal knowledge about the CodeGenerator. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addVar): Removed responsibility for checking whether + a var declaration overwrites "arguments", because the check is + inappropriate for global code, which may not have a pre-existing + "arguments" symbol in scope. Also changed this function to return a + boolean indicating whether addVar actually created a new RegisterID, + or just reused an old one. + + (KJS::CodeGenerator::CodeGenerator): Split out the constructors for + function code and global code, since they're quite different now. + + (KJS::CodeGenerator::registerForLocal): This function does its job + without any hashing now. + + * VM/Machine.cpp: Move old globals and update "r" before executing a + new script. That way, old globals stay at a constant offset from "r", + and previously optimized code still works. + + * VM/RegisterID.h: Added the ability to allocate a RegisterID before + initializing its index field. We use this for parameters now. + + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTableGet): Changed the ungettable getter + ASSERT to account for the fact that symbol indexes are all negative. + +2008-04-05 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement codegen for InNode. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitIn): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::InNode::emitCode): + * kjs/nodes.h: + +2008-04-05 Sam Weinig + + Reviewed by Oliver Hunt. + + - Implement codegen for DeleteResolveNode, DeleteBracketNode, DeleteDotNode and DeleteValueNode. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitGetPropId): + (KJS::CodeGenerator::emitPutPropId): + (KJS::CodeGenerator::emitDeletePropId): + (KJS::CodeGenerator::emitDeletePropVal): + (KJS::CodeGenerator::emitPutPropIndex): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::DeleteResolveNode::emitCode): + (KJS::DeleteBracketNode::emitCode): + (KJS::DeleteDotNode::emitCode): + (KJS::DeleteValueNode::emitCode): + * kjs/nodes.h: + +2008-04-04 Sam Weinig + + Reviewed by Oliver Hunt. + + - Implement codegen for Switch statements. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::pushJumpContext): + (KJS::CodeGenerator::popJumpContext): + (KJS::CodeGenerator::jumpContextForLabel): + * VM/CodeGenerator.h: + Rename LoopContext to JumpContext now that it used of Switch statements in addition + to loops. + + * kjs/nodes.cpp: + (KJS::DoWhileNode::emitCode): + (KJS::WhileNode::emitCode): + (KJS::ForNode::emitCode): + (KJS::ForInNode::emitCode): + (KJS::ContinueNode::emitCode): + (KJS::BreakNode::emitCode): + (KJS::CaseBlockNode::emitCodeForBlock): + (KJS::SwitchNode::emitCode): + * kjs/nodes.h: + (KJS::CaseClauseNode::expr): + (KJS::CaseClauseNode::children): + (KJS::CaseBlockNode::): + +2008-04-03 Maciej Stachowiak + + Reviewed by Sam. + + - fix crash in codegen from new nodes + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitConstruct): + * kjs/nodes.h: + +2008-04-03 Maciej Stachowiak + + Reviewed by Geoff. + + * kjs/nodes.cpp: + (KJS::ReadModifyResolveNode::emitCode): + (KJS::ReadModifyBracketNode::emitCode): + * kjs/nodes.h: + +2008-04-02 Maciej Stachowiak + + Reviewed by Geoff. + + - take a shot at marking constant pools for global and eval code + + Geoff says this won't really work in all cases but is an ok stopgap. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::mark): + +2008-04-02 Maciej Stachowiak + + Reviewed by Geoff. + + - fix 2x perf regression in 3d-morph + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): If we subbed in null for the global object, + don't toObject it, since that will throw an exception (very slowly). + +2008-04-02 Maciej Stachowiak + + Rubber stamped by Geoff + + - fix Release build + + * kjs/nodes.cpp: + (KJS::getNonLocalSymbol): + +2008-04-02 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Removed the last vestiges of LocalStorage from JSVariableObject and + JSGlobalObject. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::saveLocalStorage): Save and restore from/to + registers. Use stub isReadOnly and isDontEnum methods for now, until + we really implement attributes in the symbol table. + (KJS::JSGlobalObject::restoreLocalStorage): + (KJS::JSGlobalObject::reset): + + * kjs/JSVariableObject.cpp: + (KJS::JSVariableObject::getPropertyNames): Use stub isDontEnum method + for now, as above. + (KJS::JSVariableObject::getPropertyAttributes): ditto + + * kjs/JSVariableObject.h: Removed LocalStorage from JSVariableObjectData. + Removed mark method, because subclasses implement different strategies for + marking registers. + (KJS::JSVariableObject::isReadOnly): Stub method + (KJS::JSVariableObject::isDontEnum): ditto + + Changed the code below to ASSERT_NOT_REACHED() and return 0, since it + can no longer retrieve LocalStorage from the ExecState. (Eventually, + we'll just remove this code and all its friends, but that's a task for + later.) + + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + * kjs/function.cpp: + (KJS::ActivationImp::markChildren): + * kjs/function.h: + * kjs/nodes.cpp: + (KJS::getNonLocalSymbol): + (KJS::ScopeNode::optimizeVariableAccess): + (KJS::ProgramNode::processDeclarations): + +2008-04-01 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Got globals? + + To get things working, I had to roll out + http://trac.webkit.org/projects/webkit/changeset/31226 for the time + being. + + * VM/CodeBlock.h: Removed obsolete function. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): For the sake of re-entrancy, we track + and restore the global object's old rOffset value. (No way to test this + yet, but I think it will work.) + +2008-04-01 Maciej Stachowiak + + Reviewed by Geoff. + + - mark the constant pool (at least for function code blocks) + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::mark): + * VM/CodeBlock.h: + * kjs/function.cpp: + (KJS::FunctionImp::mark): + * kjs/nodes.cpp: + (KJS::ScopeNode::mark): + * kjs/nodes.h: + (KJS::FuncExprNode::body): + (KJS::FuncDeclNode::body): + +2008-04-01 Geoffrey Garen + + Reviewed by Beth Dakin. + + Cleaned up a few loose ends. + + * JavaScriptCore.exp: Export dumpRegisters, so it's visible to gdb even + if we don't explicitly call it in the source text. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): No need to call dumpRegisters anymore, + since that was just a hack for gdb's sake. + + * kjs/JSActivation.h: Removed obsolete comment. + + * VM/CodeGenerator.cpp: Added ASSERTs to verify that the localCount + we're given matches the number of locals actually allocated. + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::CodeGenerator): Changed "localCount" to include + the parameter count, since we're using the word "local" to mean + parameter, var, function, or "this". Renamed "m_nextLocal" to + "m_nextVar", since "m_nextLocal" doesn't contrast well with + "m_nextParameter". + + Also moved tracking of implicit "this" parameter from here... + + * kjs/nodes.cpp: + (KJS::FunctionBodyNode::generateCode): ... to here + (KJS::ProgramNode::generateCode): ... and here + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): Added missing "\n". + +2008-04-01 Cameron Zwarich + + Reviewed by Oliver. + + Bug 18274: ResolveNode::emitCode() doesn't make a new temporary when dst + is 0, leading to incorrect codegen + + + * kjs/nodes.cpp: + (KJS::FunctionCallBracketNode::emitCode): + (KJS::FunctionCallDotNode::emitCode): + +2008-04-01 Maciej Stachowiak + + Reviewed by Oliver. + + - fix bug in for..in codegen (gotta use ident, not m_ident) + + * kjs/nodes.cpp: + (KJS::ForInNode::emitCode): + +2008-04-01 Maciej Stachowiak + + Reviewed by Oliver. + + - Add suport for regexp literals + + * VM/CodeBlock.cpp: + (KJS::regexpToSourceString): + (KJS::regexpName): + (KJS::CodeBlock::dump): + * VM/CodeBlock.h: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addRegExp): + (KJS::CodeGenerator::emitNewRegExp): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::RegExpNode::emitCode): + * kjs/nodes.h: + +2008-04-01 Oliver Hunt + + Reviewed by Geoff + + Add support for for..in nodes + + Added two new opcodes to get_pnames and next_pname to handle iterating + over the set of properties on an object. This iterator is explicitly + invalidated and the property name array is released on standard exit + from the loop, otherwise we rely on GC to do the clean up for us. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitNextPropertyName): + (KJS::CodeGenerator::emitGetPropertyNames): + * VM/CodeGenerator.h: + * VM/JSPropertyNameIterator.cpp: Added. + (KJS::JSPropertyNameIterator::JSPropertyNameIterator): + (KJS::JSPropertyNameIterator::type): + (KJS::JSPropertyNameIterator::toPrimitive): + (KJS::JSPropertyNameIterator::getPrimitiveNumber): + (KJS::JSPropertyNameIterator::toBoolean): + (KJS::JSPropertyNameIterator::toNumber): + (KJS::JSPropertyNameIterator::toString): + (KJS::JSPropertyNameIterator::toObject): + (KJS::JSPropertyNameIterator::mark): + (KJS::JSPropertyNameIterator::next): + (KJS::JSPropertyNameIterator::invalidate): + (KJS::JSPropertyNameIterator::~JSPropertyNameIterator): + (KJS::JSPropertyNameIterator::create): + * VM/JSPropertyNameIterator.h: Added. + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * VM/Register.h: + (KJS::Register::): + * kjs/PropertyNameArray.h: + * kjs/nodes.cpp: + (KJS::ForInNode::emitCode): + * kjs/nodes.h: + * kjs/value.h: + +2008-04-01 Cameron Zwarich + + Reviewed by Maciej. + + Change CodeGenerator::emitCall() so it increments the reference count of + registers passed to it, and change its callers so they don't needlessly + increment the reference count of the registers they are passing. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitCall): + * kjs/nodes.cpp: + (KJS::FunctionCallResolveNode::emitCode): + (KJS::FunctionCallDotNode::emitCode): + +2008-04-01 Maciej Stachowiak + + Reviewed by Oliver. + + - generate call for PostIncDotNode + + * kjs/nodes.cpp: + (KJS::PostIncDotNode::emitCode): + * kjs/nodes.h: + +2008-04-01 Maciej Stachowiak + + Build fix. + + - fix build (not sure how this ever worked?) + + * kjs/nodes.cpp: + (KJS::FunctionCallBracketNode::emitCode): + +2008-04-01 Maciej Stachowiak + + Reviewed by Geoff. + + - generate code for FunctionCallBracketNode + + * kjs/nodes.cpp: + (KJS::FunctionCallBracketNode::emitCode): + * kjs/nodes.h: + +2008-04-01 Maciej Stachowiak + + Reviewed by Geoff. + + - Fix two crashing SunSpider tests + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): set up 'this' properly for native calls. + * kjs/list.h: + (KJS::List::List): Fix intialization of buffer and size from + vector, the initialization order was wrong. + +2008-04-01 Geoffrey Garen + + Build fix: marked ASSERT-only variables as UNUSED_PARAMs. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTableInitializeVariable): + +2008-04-01 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Next step toward global code: Moved get, put, and initializeVariable + functionality up into JSVariableObject, and changed JSActivation to + rely on it. + + * kjs/JSActivation.cpp: + (KJS::JSActivation::JSActivation): + (KJS::JSActivation::getOwnPropertySlot): + (KJS::JSActivation::put): + (KJS::JSActivation::initializeVariable): + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::valueAt): + (KJS::JSVariableObject::isReadOnly): + (KJS::JSVariableObject::symbolTableGet): + (KJS::JSVariableObject::symbolTablePut): + (KJS::JSVariableObject::symbolTableInitializeVariable): + +2008-04-01 Maciej Stachowiak + + Reviewed by Sam. + + - fix HashTable assertion on some SunSpider tests + + Don't use -1 as the deleted value for JSValue*-keyed hashtables, + since it is a valid value (it's the immediate for -1). + + * VM/CodeGenerator.h: + (KJS::CodeGenerator::JSValueHashTraits::emptyValue): + (KJS::CodeGenerator::JSValueHashTraits::deletedValue): + * kjs/JSImmediate.h: + (KJS::JSImmediate::impossibleValue): + +2008-04-01 Sam Weinig + + Reviewed by Maciej Stachowiak. + + Add support for calling Native constructors like new Array(). + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitConstruct): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::NewExprNode::emitCode): + * kjs/nodes.h: + +2008-04-01 Maciej Stachowiak + + Reviewed by Sam. + + - add some missing toOpbject calls to avoid crashing when calling methods on primitives + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-04-01 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Changed Machine::dumpRegisters to take a pointer instead of a reference, + so gdb understands how to call it. + + * VM/Machine.cpp: + (KJS::Machine::dumpRegisters): + (KJS::Machine::privateExecute): + * VM/Machine.h: + +2008-03-31 Cameron Zwarich + + Reviewed by Maciej. + + Fix CodeGenerator::addConstant() so it uses the functionExpressions + counter for function expressions, not the functions counter. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addConstant): + +2008-03-31 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add emitCode support for TypeOfResolveNode and TypeOfValueNode. + Added new opcode op_type_of to handle them. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitNot): + (KJS::CodeGenerator::emitInstanceOf): + (KJS::CodeGenerator::emitTypeOf): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::jsTypeStringForValue): + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::TypeOfResolveNode::emitCode): + (KJS::TypeOfValueNode::emitCode): + * kjs/nodes.h: + +2008-03-31 Sam Weinig + + Reviewed by Oliver Hunt. + + Fix non-computed goto version of isOpcode. op_end is a valid opcode. + + * VM/Machine.cpp: + (KJS::Machine::isOpcode): + +2008-03-31 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Added op_post_dec. + +2008-03-31 Cameron Zwarich + + Reviewed by Geoffrey Garen. + + Add support for FunctionCallDotNode. + + * kjs/nodes.cpp: + (KJS::FunctionCallDotNode::emitCode): + * kjs/nodes.h: + +2008-03-31 Geoffrey Garen + + Reviewed by Beth Dakin. + + Next step toward global code: Removed more obsolete API, moved + saveLocalStorage and restoreLocalStorage to JSGlobalObject subclass, + since it's only intended for use there. + + * ChangeLog: + * JavaScriptCore.exp: + * kjs/Activation.h: + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::saveLocalStorage): + (KJS::JSGlobalObject::restoreLocalStorage): + * kjs/JSGlobalObject.h: + * kjs/JSVariableObject.cpp: + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::JSVariableObjectData::JSVariableObjectData): + * kjs/function.cpp: + (KJS::ActivationImp::ActivationImp): + +2008-03-31 Geoffrey Garen + + Reviewed by Beth Dakin. + + Next step toward global code: subclass JSActivation + JSActivationData + from JSVariableObject + JSVariableObjectData. + + JSActivation now relies on JSVariableObject for access to registers and + symbol table, and for some delete functionality, but not for anything + else yet. + + (KJS::JSActivation::mark): Cleaned up the style here a little bit. + +2008-03-31 Geoffrey Garen + + Reviewed by Beth Dakin. + + Next step toward global code: store "rOffset" in JSVariableObjectData. + + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::JSVariableObjectData::JSVariableObjectData): + +2008-03-31 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Next steps toward global code: + + * Moved access to the register file into JSVariableObject. + + * Added more ASSERTs to indicate obsolete APIs there are just hanging + around to stave off build failures. + + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::registers): + (KJS::JSVariableObject::JSVariableObjectData::JSVariableObjectData): + (KJS::JSVariableObject::JSVariableObject): + +2008-03-31 Sam Weinig + + Reviewed by Oliver. Tweaked somewhat by Maciej. + + - implement codegen for ReadModifyResolveNode + + * kjs/nodes.cpp: + (KJS::emitReadModifyAssignment): + (KJS::ReadModifyResolveNode::emitCode): + * kjs/nodes.h: + +2008-03-31 Cameron Zwarich + + Reviewed by Geoff. + + Fix the build -- r31492 removed activation tear-off, but r31493 used it. + + * kjs/nodes.cpp: + (KJS::FuncExprNode::makeFunction): + +2008-03-31 Cameron Zwarich + + Reviewed by Maciej. + + Add support for FuncExprNode to SquirrelFish. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeBlock.h: + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::addConstant): + (KJS::CodeGenerator::emitNewFunctionExpression): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::FuncExprNode::emitCode): + (KJS::FuncExprNode::makeFunction): + * kjs/nodes.h: + +2008-03-31 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + First step toward global code: removed some obsolete JSGlobalObject + APIs, changing clients to ASSERT_NOT_REACHED. + + Activation tear-off and scope chain pushing is obsolete because we + statically detect whether an activation + scope node is required. + + The variableObject() and activationObject() accessors are obsolete + because they haven't been maintained, and they're mostly used by + node evaluation code, anyway. + + The localStorage() accessor is obsolete because everything is in + registers now, and it's mostly used by node evaluation code, anyway. + +2008-03-31 Maciej Stachowiak + + Reviewed by Darin. + + - implement codegen for bracket accessor and bracket assign + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitGetPropVal): + (KJS::CodeGenerator::emitPutPropVal): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::BracketAccessorNode::emitCode): + (KJS::AssignBracketNode::emitCode): + * kjs/nodes.h: + +2008-03-31 Geoffrey Garen + + Not reviewed. + + Removed FIXME that I just fixed. + + Added ASSERT to cover an error previously only covered by a FIXME. + + * kjs/JSActivation.cpp: + (KJS::JSActivation::getOwnPropertySlot): + +2008-03-31 Geoffrey Garen + + Not reviewed. + + Fixed indentation inside op_call. (I had left this code badly indented + to make the behavior-changing diff clearer.) + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-03-31 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed up logging of jump instructions to follow the following style: + + jump offset(->absoluteTarget) + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + +2008-03-31 Geoffrey Garen + + Reviewed by Sam Weinig. + + Changed the SymbolTable API to use int instead of size_t. It has been + using int internally for a while now (since squirrelfish symbols can + have negative indices). + +2008-03-31 Cameron Zwarich + + Reviewed by Maciej. + + Add support for FunctionCallValueNode. + + * kjs/nodes.cpp: + (KJS::FunctionCallValueNode::emitCode): + * kjs/nodes.h: + +2008-03-31 Maciej Stachowiak + + Reviewed by Oliver. + + 1) Implemented array literals + + 2) Renamed op_object_get and op_object_put to op_get_prop_id and + op_put_prop_id in preparation for new variants. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitNewArray): + (KJS::CodeGenerator::emitGetPropId): + (KJS::CodeGenerator::emitPutPropId): + (KJS::CodeGenerator::emitPutPropIndex): + * VM/CodeGenerator.h: + (KJS::CodeGenerator::CodeGenerator): + (KJS::CodeGenerator::propertyNames): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::ArrayNode::emitCode): + (KJS::PropertyListNode::emitCode): + (KJS::DotAccessorNode::emitCode): + (KJS::PostIncResolveNode::emitCode): + (KJS::PreIncResolveNode::emitCode): + (KJS::AssignResolveNode::emitCode): + (KJS::AssignDotNode::emitCode): + * kjs/nodes.h: + +2008-03-30 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Implemented native function calls. (Re-entering from native code back + to JS doesn't work yet, though.) + + 0.2% speedup overall, due to some inlining tweaks. 3.6% regression on + function-empty.js, since we're making a new virtual call and taking a + new branch inside every op_call. + + I adjusted the JavaScriptCore calling convention to minimize overhead, + like so: + + The machine calls a single virtual function, "getCallData", to get all + the data it needs for a function call. Native code still uses the old + "isObject()" check followed by an "implementsCall()" check, which + aliases to "getCallData". (We can optimize native code to use getCallData + at our leisure.) + + To supply a list of arguments, the machine calls a new List constructor + that just takes a pointer and a length, without copying. Native code + still appends to the list one argument at a time. (We can optimize + native code to use the new List constructor at our leisure.) + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Changed resize() call to grow() call, + to encourage the compiler to inline the Vector code. + + * kjs/CallData.h: Added. + (KJS::): CallData is a union because eventually native calls will stuff + a function pointer into it, to eliminate the callAsFunction virtual call. + + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): Changed this to an ASSERT since + it's not implemented yet. + + * kjs/list.h: Made the List class two-faced, to support the old way and + the new way during this transition phase: lists can be made read-only + with just a pointer and a legnth, or you can append to them one item + at a time. + + * kjs/value.h: + (KJS::jsUndefined): Marked this function ALWAYS_INLINE for the benefit + of a certain compiler that doesn't know what's best for it. + +2008-03-30 Maciej Stachowiak + + Reviewed by Oliver. + + Dump code that codegen can't handle yet, so it's easier to prioritize missing nodes. + + * kjs/nodes.h: + (KJS::Node::emitCode): + +2008-03-30 Maciej Stachowiak + + Reviewed by Oliver. + + Improve dumping of bytecode and fix coding style accordingly. + + Registers are printed as lr1 for locals, tr1 for temp registers. Identifiers print as + foobar(@id0) and constants print as "foo"(@k1) or 312.4(@k2) or the like. Constant and + identifier tables are dumped for reference. + + * VM/CodeBlock.cpp: + (KJS::escapeQuotes): + (KJS::valueToSourceString): + (KJS::registerName): + (KJS::constantName): + (KJS::idName): + (KJS::printUnaryOp): + (KJS::printBinaryOp): + (KJS::CodeBlock::dump): + * VM/Machine.cpp: + (KJS::resolve): + (KJS::resolveBase): + (KJS::Machine::privateExecute): + +2008-03-30 Maciej Stachowiak + + Reviewed by Oliver. + + Implement StringNode and VoidNode (both pretty trivial). + + * kjs/nodes.cpp: + (KJS::StringNode::emitCode): + (KJS::VoidNode::emitCode): + * kjs/nodes.h: + +2008-03-30 Maciej Stachowiak + + Reviewed by Sam. + + Implement CommaNode. + + * kjs/nodes.cpp: + (KJS::CommaNode::emitCode): + * kjs/nodes.h: + +2008-03-30 Cameron Zwarich + + Reviewed by Maciej. + + Adds support for dot notation and object literals. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitNewObject): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::ObjectLiteralNode::emitCode): + (KJS::PropertyListNode::emitCode): + (KJS::DotAccessorNode::emitCode): + (KJS::AssignDotNode::emitCode): + * kjs/nodes.h: + +2008-03-29 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Mark the register file. + + It's a conservative mark for now, but once registers are typed, we can + do an exact mark. + + 1.4% regression regardless of whether we actually do the marking. + GCC is is worth every penny. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Most of the changes here are just for + the fact that "registers" is a pointer now. + + * kjs/JSGlobalObject.cpp: The global object owns the register file now. + +2008-03-28 Oliver Hunt + + Reviewed by Maciej. + + Bug 18204: SquirrelFish: continue/break do not correctly handle scope popping + + + We now track the scope depth as part of a loop context, and add an + extra instruction op_jump_scopes that is used to perform a jump across + dynamic scope boundaries. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitJumpScopes): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::ContinueNode::emitCode): + (KJS::BreakNode::emitCode): + +2008-03-28 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add emitCode support for ConditionalNode. + + * kjs/nodes.cpp: + (KJS::ConditionalNode::emitCode): + * kjs/nodes.h: + +2008-03-28 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Responding to feedback, added some comments, fixed up a few names, and + clarified that "locals" always means all local variables, functions, + and parameters. + +2008-03-28 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Added support for "this". + + Supply an implicit "this" value as the first argument to every function. + Alias the "this" keyword to that argument. + + 1% regression overall, 2.5% regression on empty function calls. Seems + like a reasonable cost for now, since we're doing more work. + (Eventually, we might decide to create a version of op_call specialized + for a known null "this" value.) + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitCall): + * VM/CodeGenerator.h: + (KJS::CodeGenerator::CodeGenerator): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * kjs/CommonIdentifiers.cpp: + (KJS::CommonIdentifiers::CommonIdentifiers): + * kjs/CommonIdentifiers.h: + * kjs/nodes.cpp: + (KJS::ThisNode::emitCode): + (KJS::FunctionCallResolveNode::emitCode): + * kjs/nodes.h: + +2008-03-28 Oliver Hunt + + Reviewed by Geoff. + + Bug 18192: Squirrelfish needs support for break and continue + + + Added a loop context stack to the code generator to provide the + correct jump labels for continue and goto. Added logic to the + currently implemented loop constructs to manage entry and exit + from the loop contexts. Finally, implemented codegen for break + and continue (and a pass through for LabelNode) + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::pushLoopContext): + (KJS::CodeGenerator::popLoopContext): + (KJS::CodeGenerator::loopContextForIdentifier): + (KJS::CodeGenerator::labelForContinue): + (KJS::CodeGenerator::labelForBreak): + * VM/CodeGenerator.h: + * kjs/nodes.cpp: + (KJS::DoWhileNode::emitCode): + (KJS::WhileNode::emitCode): + (KJS::ForNode::emitCode): + (KJS::ContinueNode::emitCode): + (KJS::BreakNode::emitCode): + (KJS::LabelNode::emitCode): + * kjs/nodes.h: + +2008-03-27 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add emitCode support for UnaryPlusNode, NegateNode, BitwiseNotNode and LogicalNotNode. + + * VM/CodeBlock.cpp: + (KJS::printUnaryOp): + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitToJSNumber): + (KJS::CodeGenerator::emitNegate): + (KJS::CodeGenerator::emitBitNot): + (KJS::CodeGenerator::emitNot): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::UnaryPlusNode::emitCode): + (KJS::NegateNode::emitCode): + (KJS::BitwiseNotNode::emitCode): + (KJS::LogicalNotNode::emitCode): + * kjs/nodes.h: + +2008-03-27 Cameron Zwarich + + Reviewed by Maciej Stachowiak. + + Add support for LogicalAndNode and LogicalOrNode. + + * kjs/nodes.cpp: + (KJS::LogicalAndNode::emitCode): + (KJS::LogicalOrNode::emitCode): + * kjs/nodes.h: + +2008-03-27 Sam Weinig + + Clean up code and debug output. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-03-27 Geoffrey Garen + + Moved an ASSERT to a more logical place. + + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-03-27 Sam Weinig + + Reviewed by Oliver Hunt. + + Add emitCode support for InstanceOfNode. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitInstanceOf): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::InstanceOfNode::emitCode): + * kjs/nodes.h: + +2008-03-27 Oliver Hunt + + Reviewed by Maciej. + + Bug 18142: squirrelfish needs to support dynamic scoping/with + + + Add support for dynamic scoping and add code to handle 'with' + statements. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeBlock.h: + (KJS::CodeBlock::CodeBlock): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::getRegister): + (KJS::CodeGenerator::emitPushScope): + (KJS::CodeGenerator::emitPopScope): + * VM/CodeGenerator.h: + (KJS::CodeGenerator::CodeGenerator): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::WithNode::emitCode): + * kjs/nodes.h: + +2008-03-27 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add emitCode support for NullNode, FalseNode, TrueNode, IfNode, IfElseNode, DoWhileNode and WhileNode + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): Dump op_jfalse opcode. + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitJumpIfFalse): Identical to emitJumpIfTrue except it emits the op_jfalse opcode. + (KJS::CodeGenerator::emitLoad): Add and emitLoad override for booleans. + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::Machine::privateExecute): Adds execution of op_jfalse. It is identical to op_jtrue, except the + the condition is reversed. + * VM/Opcode.h: Add op_jfalse. + * kjs/nodes.cpp: + (KJS::NullNode::emitCode): Added. + (KJS::FalseNode::emitCode): Added. + (KJS::TrueNode::emitCode): Added. + (KJS::IfNode::emitCode): Added. + (KJS::IfElseNode::emitCode): Added. + (KJS::DoWhileNode::emitCode): Added. + (KJS::WhileNode::emitCode): Added. + * kjs/nodes.h: + +2008-03-26 Geoffrey Garen + + Nixed an unused List. + + The calm before my stormy war against the List class. + + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::construct): + +2008-03-26 Cameron Zwarich + + Reviewed by Geoffrey Garen. + + Adds support for EqualNode, NotEqualNode, StrictEqualNode, NotStrictEqualNode, + LessEqNode, GreaterNode, GreaterEqNode, MultNode, DivNode, ModNode, SubNode, + LeftShiftNode, RightShiftNode, UnsignedRightShiftNode, BitAndNode, BitXOrNode, + and BitOrNode. + + * VM/CodeBlock.cpp: + (KJS::CodeBlock::dump): + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::emitEqual): + (KJS::CodeGenerator::emitNotEqual): + (KJS::CodeGenerator::emitStrictEqual): + (KJS::CodeGenerator::emitNotStrictEqual): + (KJS::CodeGenerator::emitLessEq): + (KJS::CodeGenerator::emitMult): + (KJS::CodeGenerator::emitDiv): + (KJS::CodeGenerator::emitMod): + (KJS::CodeGenerator::emitSub): + (KJS::CodeGenerator::emitLeftShift): + (KJS::CodeGenerator::emitRightShift): + (KJS::CodeGenerator::emitUnsignedRightShift): + (KJS::CodeGenerator::emitBitAnd): + (KJS::CodeGenerator::emitBitXOr): + (KJS::CodeGenerator::emitBitOr): + * VM/CodeGenerator.h: + * VM/Machine.cpp: + (KJS::jsLessEq): + (KJS::Machine::privateExecute): + * VM/Opcode.h: + * kjs/nodes.cpp: + (KJS::MultNode::emitCode): + (KJS::DivNode::emitCode): + (KJS::ModNode::emitCode): + (KJS::SubNode::emitCode): + (KJS::LeftShiftNode::emitCode): + (KJS::RightShiftNode::emitCode): + (KJS::UnsignedRightShiftNode::emitCode): + (KJS::GreaterNode::emitCode): + (KJS::LessEqNode::emitCode): + (KJS::GreaterEqNode::emitCode): + (KJS::EqualNode::emitCode): + (KJS::NotEqualNode::emitCode): + (KJS::StrictEqualNode::emitCode): + (KJS::NotStrictEqualNode::emitCode): + (KJS::BitAndNode::emitCode): + (KJS::BitXOrNode::emitCode): + (KJS::BitOrNode::emitCode): + * kjs/nodes.h: + +2008-03-26 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Only print debug dumps in debug builds. + + * VM/CodeGenerator.cpp: + (KJS::CodeGenerator::generate): + * VM/Machine.cpp: + (KJS::Machine::privateExecute): + +2008-03-26 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Moved a few files around in the XCode project. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-03-26 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Made closures work. + + An activation object aliases to the register file until its associated + function returns, at which point it copies the registers for locals and + parameters into an independent storage buffer. + +2008-03-24 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed recent 25% regression on simple for loop test. GCC seems to be + very finicky about the code that gets inlined into + Machine::privateExecute. + + Everything in this patch is simply the result of experiment. + + The resolve and resolve_base opcodes do not seem to have gotten slower + from this change. + + * VM/Machine.cpp: + (KJS::resolve): + (KJS::resolveBase): + (KJS::Machine::privateExecute): + * kjs/nodes.h: + +2008-03-24 Oliver Hunt + + Reviewed by Geoff Garen. + + Bug 18059: squirrelfish needs to compile on platforms without computed goto + + + "Standard" macro style support for conditionalising the use of computed goto. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * VM/Machine.cpp: + (KJS::Machine::isOpcode): + (KJS::Machine::privateExecute): + * VM/Machine.h: + (KJS::Machine::getOpcode): + (KJS::Machine::getOpcodeID): + * VM/Opcode.h: + * wtf/Platform.h: + +2008-03-24 Geoffrey Garen + + Moved my notes from nodes.h to the wiki. + + * kjs/nodes.h: + +2008-03-24 Geoffrey Garen + + SquirrelFish lives. + + Initial check-in of the code I've been carrying around. Lots of stuff + doesn't work. Plus a bunch of empty files. + +=== Start merge of squirrelfish === + +2008-05-21 Darin Adler + + - try to fix the Windows build + + * profiler/Profiler.cpp: + (KJS::Profiler::stopProfiling): Use ptrdiff_t instead of the less-common but incredibly + similar ssize_t type. + * wtf/AVLTree.h: + (KJS::AVLTree::search): Added a typename for a dependent name that's a type. + +2008-05-21 Darin Adler + + Reviewed by Anders. + + - fix bug in JavaScript arguments object property lookup + + Test: fast/js/arguments-bad-index.html + + * kjs/function.cpp: + (KJS::IndexToNameMap::IndexToNameMap): Use unsigned instead of int. + (KJS::IndexToNameMap::isMapped): Use unsigned instead of int, and also use the + strict version of the numeric conversion function, since we don't want to allow + trailing junk. + (KJS::IndexToNameMap::unMap): Ditto. + (KJS::IndexToNameMap::operator[]): Ditto. + * kjs/function.h: Changed IndexToNameMap::size type from int to unsigned. + +2008-05-21 Timothy Hatcher + + Change the Profiler to allow multiple profiles to be running at + the same time. This can happen when you have nested console.profile() + calls. This required two changes. First, the Profiler needed to keep a + Vector of current profiles, instead of one. Second, a Profile needs + to keep track of the global ExecState it started in and the page group + identifier it is tracking. + + The stopProfiling call now takes the same arguments as startProfiling. + This makes sure the correct profile is stopped. Passing a null UString + as the title will stop the last profile for the matching ExecState. + + Multiple pages profiling can interfere with each other + + Reviewed by Kevin McCullough. + + * JavaScriptCore.exp: Added new exports. Removed old symbols. + * profiler/Profile.cpp: + (KJS::Profile::Profile): New constructor arguments for the + originatingGlobalExec and pageGroupIdentifier. + (KJS::Profile::stopProfiling): Set the m_originatingGlobalExec to null. + * profiler/Profile.h: + (KJS::Profile::create): Additional arguments. + (KJS::Profile::originatingGlobalExec): Return m_originatingGlobalExec. + (KJS::Profile::pageGroupIdentifier): Return m_pageGroupIdentifier. + * profiler/Profiler.cpp: + (KJS::Profiler::findProfile): Added. Finds a Profile that matches + the ExecState and title. + (KJS::Profiler::startProfiling): Return early if there is already + a Profile with the ExecState and title. If not, create a new profile + and append it to m_currentProfiles. + (KJS::Profiler::stopProfiling): Loops through m_currentProfiles + and find the one matching the ExecState and title. If one is found + call stopProfiling and return the Profile after removing it + from m_currentProfiles. + (KJS::dispatchFunctionToProfiles): Helper inline function to loop through + m_currentProfiles and call a Profile function. + (KJS::Profiler::willExecute): Call dispatchFunctionToProfiles. + (KJS::Profiler::didExecute): Ditto. + * profiler/Profiler.h: + +2008-05-21 Alexey Proskuryakov + + Reviewed by Darin. + + REGRESSION (3.1.1-r33033): Crash in WebKit when opening or + refreshing page on people.com + + The problem was that STL algorithms do not work with non-conformant comparators, and the + site used sort(function() { return 0.5 - Math.random(); } to randomly shuffle an array. + + https://bugs.webkit.org/show_bug.cgi?id=18687 + REGRESSION(r32220): ecma/Array/15.4.4.5-3.js test now fails in GMT(BST) + + Besides relying on sort stability, this test was just broken, and kept failing with the + new stable sort. + + Tests: fast/js/sort-randomly.html + fast/js/sort-stability.html + fast/js/comparefn-sort-stability.html + + * kjs/avl_tree.h: Added an AVL tree implementation. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * wtf/AVLTree.h: Added. + Added an AVL tree implementation. + + * kjs/array_instance.cpp: + (KJS::ArrayInstance::increaseVectorLength): + (KJS::ArrayInstance::sort): + (KJS::AVLTreeAbstractorForArrayCompare::get_less): + (KJS::AVLTreeAbstractorForArrayCompare::set_less): + (KJS::AVLTreeAbstractorForArrayCompare::get_greater): + (KJS::AVLTreeAbstractorForArrayCompare::set_greater): + (KJS::AVLTreeAbstractorForArrayCompare::get_balance_factor): + (KJS::AVLTreeAbstractorForArrayCompare::set_balance_factor): + (KJS::AVLTreeAbstractorForArrayCompare::compare_key_key): + (KJS::AVLTreeAbstractorForArrayCompare::compare_key_node): + (KJS::AVLTreeAbstractorForArrayCompare::compare_node_node): + (KJS::AVLTreeAbstractorForArrayCompare::null): + (KJS::ArrayInstance::compactForSorting): + + * kjs/array_instance.h: increaseVectorLength() now returns a bool to indicate whether it was + successful. + + * wtf/Vector.h: + (WTF::Vector::Vector): + (WTF::::operator=): + (WTF::::fill): + Make these methods fail instead of crash when allocation fails, matching resize() and + reserveCapacity(), which already had this behavior. Callers need to check for null buffer + after making any Vector call that can try to allocate. + + * tests/mozilla/ecma/Array/15.4.4.5-3.js: Fixed the test to use a consistent sort function, + as suggested in comments to a Mozilla bug filed about it (I'll keep tracking the bug to see + what the final resolution is). + +2008-05-20 Kevin McCullough + + Reviewed by Tim. + + JSProfiler: Allow the profiler to "Focus" a + profile node. + - Implements focus by adding the idea of a profileNode being visible and + adding the ability to reset all of the visible flags. + + * profiler/Profile.h: + (KJS::Profile::focus): + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::ProfileNode): Initialize the visible flag. + (KJS::ProfileNode::setTreeVisible): Set the visibility of this node and + all of its descendents. + (KJS::ProfileNode::focus): Determine if this node should be visible when + focusing, if the functionName matches this node's function name or if any + of this node's children are visible. + (KJS::ProfileNode::restoreAll): Restore all nodes' visible flag. + (KJS::ProfileNode::debugPrintData): + * profiler/ProfileNode.h: + (KJS::ProfileNode::visible): + (KJS::ProfileNode::setVisible): + +2008-05-20 Timothy Hatcher + + Fixes a couple performance issues with the profiler. Also fixes + a regression where some nodes wouldn't be added to the tree. + + Reviewed by Kevin McCullough. + + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::addChild): Compare callIdentifier instead + of functionName. + * profiler/ProfileNode.h: + (CallIdentifier.operator==): Compare the CallIdentifiers in + an order that fails sooner for non-matches. + (CallIdentifier.callIdentifier): Return the CallIdentifier by + reference to prevent making a new copy each time. + +2008-05-20 Kevin McCullough + + Reviewed by Darin. + + JSProfiler: dump functions are in the code + Removed dump and logging functions from the Release version of the code + and renamed them to be obviously for debugging only. + + * JavaScriptCore.exp: + * profiler/Profile.cpp: + (KJS::Profile::debugPrintData): + (KJS::Profile::debugPrintDataSampleStyle): + * profiler/Profile.h: + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::debugPrintData): + (KJS::ProfileNode::debugPrintDataSampleStyle): + * profiler/ProfileNode.h: + * profiler/Profiler.cpp: + * profiler/Profiler.h: + +2008-05-20 Kevin McCullough + + Reviewed by Adam. + + JSProfiler: Keep track of non-JS execution time + We now have an extra node that represents the excess non-JS time. + - Also changed "SCRIPT" and "anonymous function" to be more consistent + with the debugger. + + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::stopProfiling): If this ProfileNode is the head node + create a new child that has the excess execution time. + (KJS::ProfileNode::calculatePercentages): Moved calculation of the + percentages into a function since it's called from multiple places. + * profiler/ProfileNode.h: Add the newly needed functions used above. + (KJS::ProfileNode::setTotalTime): + (KJS::ProfileNode::setSelfTime): + (KJS::ProfileNode::setNumberOfCalls): + * profiler/Profiler.cpp: renamed "SCRIPT" and "anonymous function" to be + consistent with the debugger and use constants that can be localized + more easily. + (KJS::getCallIdentifiers): + (KJS::getCallIdentifierFromFunctionImp): + +2008-05-20 Kevin McCullough + + Reviewed by Tim. + + JavaScript profiler (10928) + Removed only profiler-internal use of currentProfile since that concept + is changing. + + * profiler/Profile.h: Now stopProfiling takes a time and bool as + arguments. The time is used to calculate %s from and the bool tells + if this node is the head node and should be the one calculating the time. + (KJS::Profile::stopProfiling): + * profiler/ProfileNode.cpp: Ditto. + (KJS::ProfileNode::stopProfiling): + * profiler/ProfileNode.h: Ditto. + +2008-05-20 Kevin McCullough + + Accidentally turned on the profiler. + + * kjs/config.h: + + +2008-05-20 Kevin McCullough + + Reviewed by Tim. + + JavaScript profiler (10928) + Split function name into 3 parts so that the Web Inspector can link it to + the resource location from whence it came. + + * kjs/ustring.cpp: Implemented operator> for UStrings + (KJS::operator>): + * kjs/ustring.h: + * profiler/Profile.cpp: + (KJS::Profile::Profile): Initialize all 3 values. + (KJS::Profile::willExecute): Use CallIdentifier struct. + (KJS::Profile::didExecute): Ditto. + * profiler/Profile.h: Ditto and remove unused function. + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::ProfileNode): Use CallIdentifier struct. + (KJS::ProfileNode::willExecute): Ditto and fix an issue where we + restarted the m_startTime even though it was already started. + (KJS::ProfileNode::didExecute): Ditto. + (KJS::ProfileNode::findChild): Ditto. + (KJS::functionNameDescendingComparator): Ditto and use new comparator. + (KJS::functionNameAscendingComparator): Ditto. + (KJS::ProfileNode::printDataInspectorStyle): Use CallIdentifier struct. + (KJS::ProfileNode::printDataSampleStyle): Ditto. + * profiler/ProfileNode.h: + (KJS::CallIdentifier::CallIdentifier): Describe the CallIdentifier struct + (KJS::CallIdentifier::operator== ): + (KJS::ProfileNode::create): Use the CallIdentifier struct. + (KJS::ProfileNode::callIdentifier): + (KJS::ProfileNode::functionName): Now only return the function name, not + the url and line number too. + (KJS::ProfileNode::url): + (KJS::ProfileNode::lineNumber): + * profiler/Profiler.cpp: Use the CallIdentifier struct. + (KJS::Profiler::startProfiling): + (KJS::Profiler::willExecute): + (KJS::Profiler::didExecute): + (KJS::getCallIdentifiers): + (KJS::getCallIdentifierFromFunctionImp): + +2008-05-20 Timothy Hatcher + + Rename sortFileName{Ascending,Descending} to + sortFunctionName{Ascending,Descending}. + + Reviewed by Kevin McCullough. + + * JavaScriptCore.exp: + * kjs/config.h: + * profiler/Profile.h: + * profiler/ProfileNode.cpp: + (KJS::functionNameDescendingComparator): + (KJS::ProfileNode::sortFunctionNameDescending): + (KJS::functionNameAscendingComparator): + (KJS::ProfileNode::sortFunctionNameAscending): + * profiler/ProfileNode.h: + +2008-05-19 Timothy Hatcher + + Make the profiler use higher than millisecond resolution time-stamps. + + Reviewed by Kevin McCullough. + + * kjs/DateMath.cpp: + (KJS::getCurrentUTCTime): Call getCurrentUTCTimeWithMicroseconds and + floor the result. + (KJS::getCurrentUTCTimeWithMicroseconds): Copied from the previous + implementation of getCurrentUTCTime without the floor call. + * kjs/DateMath.h: Addded getCurrentUTCTimeWithMicroseconds. + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::ProfileNode): Use getCurrentUTCTimeWithMicroseconds. + +2008-05-19 Timothy Hatcher + + Fixes a bug in the profiler where call and apply would show up + and double the time spent in a function. We don't want to show call + and apply at all in the profiles. This change excludes them. + + Reviewed by Kevin McCullough. + + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::stopProfiling): Remove a second for loop and + calculate self time in the existing loop. + * profiler/Profiler.cpp: + (KJS::shouldExcludeFunction): Helper inline function that returns + true in the current function in an InternalFunctionImp and it is + has the functionName call or apply. + (KJS::Profiler::willExecute): Call shouldExcludeFunction and return + early if if returns true. + (KJS::Profiler::didExecute): Ditto. + +2008-05-19 Kevin McCullough + + Reviewed by Tim. + + JavaScript profiler (10928) + - Implement sorting by function name. + + * JavaScriptCore.exp: + * profiler/Profile.h: + (KJS::Profile::sortFileNameDescending): + (KJS::Profile::sortFileNameAscending): + * profiler/ProfileNode.cpp: + (KJS::fileNameDescendingComparator): + (KJS::ProfileNode::sortFileNameDescending): + (KJS::fileNameAscendingComparator): + (KJS::ProfileNode::sortFileNameAscending): + * profiler/ProfileNode.h: + +2008-05-19 Kevin McCullough + + Reviewed by Adam. + + JavaScript profiler (10928) + - Pass the exec state to profiler when calling startProfiling so that if + profiling is started within an execution context that location is + recorded correctly. + + * JavaScriptCore.exp: + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::printDataInspectorStyle): Dump more info for debugging + purposes. + * profiler/Profiler.cpp: + (KJS::Profiler::startProfiling): + * profiler/Profiler.h: + +2008-05-19 Kevin McCullough + + Rubberstamped by Geoff. + + Turn off the profiler because it is a performance regression. + + * kjs/config.h: + +2008-05-19 Alp Toker + + Reviewed by Anders and Beth. + + http://bugs.webkit.org/show_bug.cgi?id=16495 + [GTK] Accessibility support with ATK/AT-SPI + + Initial ATK/AT-SPI accessibility support for the GTK+ port. + + * wtf/Platform.h: + +2008-05-19 Kevin McCullough + + Reviewed by Tim. + + JavaScript profiler (10928) + -In an effort to make the profiler as efficient as possible instead of + prepending to a vector we keep the vector in reverse order and operate + over it backwards. + + * profiler/Profile.cpp: + (KJS::Profile::willExecute): + (KJS::Profile::didExecute): + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::didExecute): + (KJS::ProfileNode::endAndRecordCall): + * profiler/ProfileNode.h: + * profiler/Profiler.cpp: + (KJS::getStackNames): + +2008-05-16 Kevin McCullough + + Reviewed by Tim. + + JavaScript profiler (10928) + Implement sorting for the profiler. + I chose to sort the profileNodes in place since there is no reason they + need to retain their original order. + + * JavaScriptCore.exp: Export the symbols. + * profiler/Profile.h: Add the different ways a profile can be sorted. + (KJS::Profile::sortTotalTimeDescending): + (KJS::Profile::sortTotalTimeAscending): + (KJS::Profile::sortSelfTimeDescending): + (KJS::Profile::sortSelfTimeAscending): + (KJS::Profile::sortCallsDescending): + (KJS::Profile::sortCallsAscending): + * profiler/ProfileNode.cpp: Implement those ways. + (KJS::totalTimeDescendingComparator): + (KJS::ProfileNode::sortTotalTimeDescending): + (KJS::totalTimeAscendingComparator): + (KJS::ProfileNode::sortTotalTimeAscending): + (KJS::selfTimeDescendingComparator): + (KJS::ProfileNode::sortSelfTimeDescending): + (KJS::selfTimeAscendingComparator): + (KJS::ProfileNode::sortSelfTimeAscending): + (KJS::callsDescendingComparator): + (KJS::ProfileNode::sortCallsDescending): + (KJS::callsAscendingComparator): + (KJS::ProfileNode::sortCallsAscending): + * profiler/ProfileNode.h: No longer use a Deque since it cannot be + sorted by std::sort and there was no reason not to use a Vector. I + previously had though I would do prepending but am not. + (KJS::ProfileNode::selfTime): + (KJS::ProfileNode::totalPercent): + (KJS::ProfileNode::selfPercent): + (KJS::ProfileNode::children): + * profiler/Profiler.cpp: Removed these functions as they can be called + directoy on the Profile object after getting the Vector of them. + (KJS::getStackNames): + * profiler/Profiler.h: + +2008-05-15 Ariya Hidayat + + Reviewed by Simon. + + Since WebKitGtk is fully using autotools now, clean-up the .pro/.pri files + from gtk-port. + + * JavaScriptCore.pro: + * kjs/testkjs.pro: + +2008-05-15 Kevin McCullough + + - Build fix. + + * JavaScriptCore.exp: + +2008-05-15 Kevin McCullough + + Reviewed by Tim. + + JavaScript profiler (10928) + - Cache some values to save on computing them repetitively. This will be + a big savings when we sort since we won't have to walk the tree for + every comparison! + - We cache these values when we end profiling because otherwise we won't + know which profile to get the totalTime for the whole profile from without + retaining a reference to the head profile or looking up the profile from + the list of all profiles. + - Also it's safe to assume we won't be asked for these values while we + are still profiling since the WebInspector only get's profileNodes from + profiles that are in the allProfiles() list and a profile is only added + to that list after it has finished and these values will no longer + change. + + * JavaScriptCore.exp: + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::ProfileNode): + (KJS::ProfileNode::stopProfiling): + (KJS::ProfileNode::printDataInspectorStyle): + (KJS::ProfileNode::printDataSampleStyle): + (KJS::ProfileNode::endAndRecordCall): + * profiler/ProfileNode.h: + (KJS::ProfileNode::totalTime): + (KJS::ProfileNode::selfTime): + (KJS::ProfileNode::totalPercent): + (KJS::ProfileNode::selfPercent): + * profiler/Profiler.cpp: + (KJS::Profiler::stopProfiling): + +2008-05-15 Simon Hausmann + + Reviewed by Holger. + + Fix compilation when compiling with MSVC and wchar_t support. + + * wtf/unicode/qt4/UnicodeQt4.h: + (WTF::Unicode::foldCase): + (WTF::Unicode::umemcasecmp): + +2008-05-14 Kevin McCullough + + Reviewed by Tim. + + JavaScript profiler (10928) + - Turn on the profiler. + + * kjs/config.h: + +2008-05-14 Kevin McCullough + + Reviewed by Tim. + + JavaScript profiler (10928) + - Expose the new profiler functions to the WebInspector. + + * JavaScriptCore.exp: + +2008-05-14 Kevin McCullough + + Giving credit where credit is due. + + * ChangeLog: + +2008-05-14 Kevin McCullough + + Reviewed by Geoff and Sam. + + JavaScript profiler (10928) + Add the ability to get percentages of total and self time for displaying + in the WebInspector. + + * profiler/Profile.h: + (KJS::Profile::totalProfileTime): + * profiler/ProfileNode.cpp: + (KJS::ProfileNode::totalPercent): + (KJS::ProfileNode::selfPercent): + * profiler/ProfileNode.h: + * profiler/Profiler.h: + (KJS::Profiler::currentProfile): + +2008-05-14 Kevin McCullough + + Reviewed by Sam. + + JavaScript profiler (10928) + - Rename FunctionCallProfile to ProfileNode. + + * GNUmakefile.am: + * JavaScriptCore.exp: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * profiler/FunctionCallProfile.cpp: Removed. + * profiler/FunctionCallProfile.h: Removed. + * profiler/Profile.cpp: + (KJS::Profile::Profile): + (KJS::Profile::willExecute): + * profiler/Profile.h: + (KJS::Profile::callTree): + * profiler/ProfileNode.cpp: Copied from profiler/FunctionCallProfile.cpp. + (KJS::ProfileNode::ProfileNode): + (KJS::ProfileNode::willExecute): + (KJS::ProfileNode::didExecute): + (KJS::ProfileNode::addChild): + (KJS::ProfileNode::findChild): + (KJS::ProfileNode::stopProfiling): + (KJS::ProfileNode::selfTime): + (KJS::ProfileNode::printDataInspectorStyle): + (KJS::ProfileNode::printDataSampleStyle): + (KJS::ProfileNode::endAndRecordCall): + * profiler/ProfileNode.h: Copied from profiler/FunctionCallProfile.h. + (KJS::ProfileNode::create): + (KJS::ProfileNode::children): + * profiler/Profiler.cpp: + +2008-05-14 Kevin McCullough + + Reviewed by John. + + JavaScript profiler (10928) + - Have each FunctionCallProfile be able to return it's total and self time. + + * JavaScriptCore.exp: + * profiler/FunctionCallProfile.cpp: + (KJS::FunctionCallProfile::selfTime): + * profiler/FunctionCallProfile.h: + (KJS::FunctionCallProfile::totalTime): + +2008-05-14 Alexey Proskuryakov + + Reviewed by Darin. + + REGRESSION: A script fails because of a straw BOM character in it. + + + Unicode format characters (Cf) should be removed from JavaScript source + + Of all Cf characters, we are only removing BOM, because this is what Firefox trunk has + settled upon, after extensive discussion and investigation. + + Based on Darin's work on this bug. + + Test: fast/js/removing-Cf-characters.html + + * kjs/lexer.cpp: + (KJS::Lexer::setCode): Tweak formatting. Use a call to shift(4) to read in the + first characters, instead of having special case code here. + (KJS::Lexer::shift): Add a loop when reading a character to skip BOM characters. + +2008-05-13 Matt Lilek + + Not reviewed, build fix. + + * kjs/date_object.cpp: + (KJS::DateObjectFuncImp::callAsFunction): + +2008-05-13 Anders Carlsson + + Reviewed by Sam. + + Implement Date.now + + Implement Date.now which returns the number of milliseconds since the epoch. + + * kjs/CommonIdentifiers.h: + * kjs/date_object.cpp: + (KJS::DateObjectFuncImp::): + (KJS::DateObjectImp::DateObjectImp): + (KJS::DateObjectFuncImp::callAsFunction): + +2008-05-13 Kevin McCullough + + Giving credit where credit is due. + + * ChangeLog: + +2008-05-13 Kevin McCullough + + Reviewed by Adam and Geoff. + + JavaScript profiler (10928) + Use PassRefPtrs instead of RefPtrs when appropriate. + + * profiler/FunctionCallProfile.cpp: + (KJS::FunctionCallProfile::addChild): + * profiler/FunctionCallProfile.h: + * profiler/Profile.h: + (KJS::Profile::callTree): + +2008-05-13 Kevin McCullough + + Reviewed by Sam. + + JavaScript profiler (10928) + - Made some functions static (as per Adam) and changed from using raw + pointers to RefPtr for making these JavaScript Objects. + + * profiler/FunctionCallProfile.cpp: + (KJS::FunctionCallProfile::addChild): + (KJS::FunctionCallProfile::findChild): + * profiler/FunctionCallProfile.h: + (KJS::FunctionCallProfile::create): + * profiler/Profile.cpp: + (KJS::Profile::Profile): + (KJS::Profile::willExecute): + (KJS::Profile::didExecute): + (KJS::functionNameCountPairComparator): + * profiler/Profile.h: + (KJS::Profile::create): + (KJS::Profile::title): + (KJS::Profile::callTree): + * profiler/Profiler.cpp: + (KJS::Profiler::startProfiling): + * profiler/Profiler.h: + (KJS::Profiler::allProfiles): + (KJS::Profiler::clearProfiles): + +2008-05-13 Alexey Proskuryakov + + Reviewed by Geoffrey Garen. + + JavaScriptCore API claims to work with UTF8 strings, but only works + with ASCII strings + + * kjs/ustring.h: + * kjs/ustring.cpp: + (KJS::UString::Rep::createFromUTF8): + Added. Implementation adapted from JSStringCreateWithUTF8CString(). + + * API/JSStringRef.cpp: + (JSStringCreateWithUTF8CString): + * API/JSClassRef.cpp: + (OpaqueJSClass::OpaqueJSClass): + Use UString::Rep::createFromUTF8(). + +2008-05-12 Mark Rowe + + Reviewed by Tim Hatcher. + + WebKit needs availability macros in order to deprecate APIs + + Create WebKit availability macros that key off the Mac OS X version being targeted to + determine the WebKit version being targeted. Applications can define + WEBKIT_VERSION_MIN_REQUIRED before including WebKit headers in order to target a specific + version of WebKit. + + The availability header is being added to JavaScriptCore rather than WebKit as JavaScriptCore + is the lowest-level portion of the public WebKit API. + + * API/WebKitAvailability.h: Added. + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-05-12 Alexey Proskuryakov + + Reviewed by Maciej. + + https://bugs.webkit.org/show_bug.cgi?id=18828 + Reproducible crash with PAC file + + Naively moving JavaScriptCore into thread-specific data was inappropriate in the face of + exiting JavaScriptCore API clients, which expect a different therading model. Temporarily + disabling ThreadSpecific implementation until this can be sorted out. + + * wtf/ThreadSpecific.h: + (WTF::::ThreadSpecific): + (WTF::::~ThreadSpecific): + (WTF::::get): + (WTF::::set): + +2008-05-12 Alexey Proskuryakov + + Roll out recent threading changes (r32807, r32810, r32819, r32822) to simplify + SquirrelFish merging. + + * API/JSBase.cpp: + (JSGarbageCollect): + * API/JSCallbackObjectFunctions.h: + (KJS::::staticFunctionGetter): + * API/JSClassRef.cpp: + (OpaqueJSClass::prototype): + * API/JSObjectRef.cpp: + (JSObjectMake): + (JSObjectMakeFunctionWithCallback): + (JSObjectMakeConstructor): + (JSObjectMakeFunction): + * API/JSValueRef.cpp: + (JSValueMakeNumber): + (JSValueMakeString): + * JavaScriptCore.exp: + * kjs/ExecState.h: + * kjs/InitializeThreading.cpp: + (KJS::initializeThreadingOnce): + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::~JSGlobalObject): + (KJS::JSGlobalObject::init): + (KJS::JSGlobalObject::put): + (KJS::JSGlobalObject::reset): + (KJS::JSGlobalObject::tearOffActivation): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::head): + (KJS::JSGlobalObject::perThreadData): + * kjs/JSLock.cpp: + (KJS::JSLock::registerThread): + * kjs/JSLock.h: + (KJS::JSLock::JSLock): + * kjs/array_instance.cpp: + (KJS::ArrayInstance::ArrayInstance): + (KJS::ArrayInstance::lengthGetter): + * kjs/array_object.cpp: + (KJS::arrayProtoFuncToString): + (KJS::arrayProtoFuncToLocaleString): + (KJS::arrayProtoFuncJoin): + (KJS::arrayProtoFuncConcat): + (KJS::arrayProtoFuncPop): + (KJS::arrayProtoFuncPush): + (KJS::arrayProtoFuncShift): + (KJS::arrayProtoFuncSlice): + (KJS::arrayProtoFuncSplice): + (KJS::arrayProtoFuncUnShift): + (KJS::arrayProtoFuncFilter): + (KJS::arrayProtoFuncMap): + (KJS::arrayProtoFuncEvery): + (KJS::arrayProtoFuncForEach): + (KJS::arrayProtoFuncSome): + (KJS::arrayProtoFuncIndexOf): + (KJS::arrayProtoFuncLastIndexOf): + (KJS::ArrayObjectImp::ArrayObjectImp): + (KJS::ArrayObjectImp::construct): + * kjs/bool_object.cpp: + (KJS::BooleanPrototype::BooleanPrototype): + (KJS::booleanProtoFuncToString): + (KJS::BooleanObjectImp::BooleanObjectImp): + (KJS::BooleanObjectImp::construct): + * kjs/collector.cpp: + (KJS::allocateBlock): + (KJS::Collector::recordExtraCost): + (KJS::Collector::heapAllocate): + (KJS::Collector::allocate): + (KJS::Collector::allocateNumber): + (KJS::Collector::registerAsMainThread): + (KJS::onMainThread): + (KJS::PlatformThread::PlatformThread): + (KJS::getCurrentPlatformThread): + (KJS::Collector::Thread::Thread): + (KJS::destroyRegisteredThread): + (KJS::initializeRegisteredThreadKey): + (KJS::Collector::registerThread): + (KJS::Collector::markStackObjectsConservatively): + (KJS::Collector::markCurrentThreadConservativelyInternal): + (KJS::Collector::markCurrentThreadConservatively): + (KJS::suspendThread): + (KJS::resumeThread): + (KJS::getPlatformThreadRegisters): + (KJS::otherThreadStackPointer): + (KJS::Collector::markOtherThreadConservatively): + (KJS::protectedValues): + (KJS::Collector::protect): + (KJS::Collector::unprotect): + (KJS::Collector::collectOnMainThreadOnly): + (KJS::Collector::markProtectedObjects): + (KJS::Collector::markMainThreadOnlyObjects): + (KJS::Collector::sweep): + (KJS::Collector::collect): + (KJS::Collector::size): + (KJS::Collector::globalObjectCount): + (KJS::Collector::protectedGlobalObjectCount): + (KJS::Collector::protectedObjectCount): + (KJS::Collector::protectedObjectTypeCounts): + (KJS::Collector::isBusy): + (KJS::Collector::reportOutOfMemoryToAllExecStates): + * kjs/collector.h: + (KJS::Collector::cellBlock): + (KJS::Collector::cellOffset): + (KJS::Collector::isCellMarked): + (KJS::Collector::markCell): + (KJS::Collector::reportExtraMemoryCost): + * kjs/date_object.cpp: + (KJS::formatLocaleDate): + (KJS::DatePrototype::DatePrototype): + (KJS::DateObjectImp::DateObjectImp): + (KJS::DateObjectImp::construct): + (KJS::DateObjectImp::callAsFunction): + (KJS::DateObjectFuncImp::DateObjectFuncImp): + (KJS::DateObjectFuncImp::callAsFunction): + (KJS::dateProtoFuncToString): + (KJS::dateProtoFuncToUTCString): + (KJS::dateProtoFuncToDateString): + (KJS::dateProtoFuncToTimeString): + (KJS::dateProtoFuncToLocaleString): + (KJS::dateProtoFuncToLocaleDateString): + (KJS::dateProtoFuncToLocaleTimeString): + (KJS::dateProtoFuncValueOf): + (KJS::dateProtoFuncGetTime): + (KJS::dateProtoFuncGetFullYear): + (KJS::dateProtoFuncGetUTCFullYear): + (KJS::dateProtoFuncToGMTString): + (KJS::dateProtoFuncGetMonth): + (KJS::dateProtoFuncGetUTCMonth): + (KJS::dateProtoFuncGetDate): + (KJS::dateProtoFuncGetUTCDate): + (KJS::dateProtoFuncGetDay): + (KJS::dateProtoFuncGetUTCDay): + (KJS::dateProtoFuncGetHours): + (KJS::dateProtoFuncGetUTCHours): + (KJS::dateProtoFuncGetMinutes): + (KJS::dateProtoFuncGetUTCMinutes): + (KJS::dateProtoFuncGetSeconds): + (KJS::dateProtoFuncGetUTCSeconds): + (KJS::dateProtoFuncGetMilliSeconds): + (KJS::dateProtoFuncGetUTCMilliseconds): + (KJS::dateProtoFuncGetTimezoneOffset): + (KJS::dateProtoFuncSetTime): + (KJS::setNewValueFromTimeArgs): + (KJS::setNewValueFromDateArgs): + (KJS::dateProtoFuncSetYear): + (KJS::dateProtoFuncGetYear): + * kjs/error_object.cpp: + (KJS::ErrorPrototype::ErrorPrototype): + (KJS::errorProtoFuncToString): + (KJS::ErrorObjectImp::ErrorObjectImp): + (KJS::ErrorObjectImp::construct): + (KJS::NativeErrorPrototype::NativeErrorPrototype): + (KJS::NativeErrorImp::NativeErrorImp): + (KJS::NativeErrorImp::construct): + * kjs/function.cpp: + (KJS::FunctionImp::lengthGetter): + (KJS::FunctionImp::construct): + (KJS::Arguments::Arguments): + (KJS::ActivationImp::createArgumentsObject): + (KJS::encode): + (KJS::decode): + (KJS::globalFuncParseInt): + (KJS::globalFuncParseFloat): + (KJS::globalFuncEscape): + (KJS::globalFuncUnescape): + (KJS::PrototypeFunction::PrototypeFunction): + (KJS::PrototypeReflexiveFunction::PrototypeReflexiveFunction): + * kjs/function_object.cpp: + (KJS::FunctionPrototype::FunctionPrototype): + (KJS::functionProtoFuncToString): + (KJS::FunctionObjectImp::FunctionObjectImp): + (KJS::FunctionObjectImp::construct): + * kjs/internal.cpp: + (KJS::StringImp::toObject): + * kjs/internal.h: + (KJS::StringImp::StringImp): + (KJS::NumberImp::operator new): + * kjs/list.cpp: + (KJS::List::markSet): + (KJS::List::markProtectedListsSlowCase): + (KJS::List::expandAndAppend): + * kjs/list.h: + (KJS::List::List): + (KJS::List::~List): + (KJS::List::markProtectedLists): + * kjs/lookup.h: + (KJS::staticFunctionGetter): + (KJS::cacheGlobalObject): + * kjs/math_object.cpp: + (KJS::MathObjectImp::getValueProperty): + (KJS::mathProtoFuncAbs): + (KJS::mathProtoFuncACos): + (KJS::mathProtoFuncASin): + (KJS::mathProtoFuncATan): + (KJS::mathProtoFuncATan2): + (KJS::mathProtoFuncCeil): + (KJS::mathProtoFuncCos): + (KJS::mathProtoFuncExp): + (KJS::mathProtoFuncFloor): + (KJS::mathProtoFuncLog): + (KJS::mathProtoFuncMax): + (KJS::mathProtoFuncMin): + (KJS::mathProtoFuncPow): + (KJS::mathProtoFuncRandom): + (KJS::mathProtoFuncRound): + (KJS::mathProtoFuncSin): + (KJS::mathProtoFuncSqrt): + (KJS::mathProtoFuncTan): + * kjs/nodes.cpp: + (KJS::ParserRefCounted::ParserRefCounted): + (KJS::ParserRefCounted::ref): + (KJS::ParserRefCounted::deref): + (KJS::ParserRefCounted::refcount): + (KJS::ParserRefCounted::deleteNewObjects): + (KJS::Node::handleException): + (KJS::NumberNode::evaluate): + (KJS::StringNode::evaluate): + (KJS::ArrayNode::evaluate): + (KJS::PostIncResolveNode::evaluate): + (KJS::PostIncLocalVarNode::evaluate): + (KJS::PostDecResolveNode::evaluate): + (KJS::PostDecLocalVarNode::evaluate): + (KJS::PostDecLocalVarNode::inlineEvaluateToNumber): + (KJS::PostIncBracketNode::evaluate): + (KJS::PostDecBracketNode::evaluate): + (KJS::PostIncDotNode::evaluate): + (KJS::PostDecDotNode::evaluate): + (KJS::typeStringForValue): + (KJS::LocalVarTypeOfNode::evaluate): + (KJS::TypeOfResolveNode::evaluate): + (KJS::TypeOfValueNode::evaluate): + (KJS::PreIncLocalVarNode::evaluate): + (KJS::PreIncResolveNode::evaluate): + (KJS::PreDecLocalVarNode::evaluate): + (KJS::PreDecResolveNode::evaluate): + (KJS::PreIncConstNode::evaluate): + (KJS::PreDecConstNode::evaluate): + (KJS::PostIncConstNode::evaluate): + (KJS::PostDecConstNode::evaluate): + (KJS::PreIncBracketNode::evaluate): + (KJS::PreDecBracketNode::evaluate): + (KJS::PreIncDotNode::evaluate): + (KJS::PreDecDotNode::evaluate): + (KJS::NegateNode::evaluate): + (KJS::BitwiseNotNode::evaluate): + (KJS::MultNode::evaluate): + (KJS::DivNode::evaluate): + (KJS::ModNode::evaluate): + (KJS::addSlowCase): + (KJS::add): + (KJS::AddNumbersNode::evaluate): + (KJS::AddStringsNode::evaluate): + (KJS::AddStringLeftNode::evaluate): + (KJS::AddStringRightNode::evaluate): + (KJS::SubNode::evaluate): + (KJS::LeftShiftNode::evaluate): + (KJS::RightShiftNode::evaluate): + (KJS::UnsignedRightShiftNode::evaluate): + (KJS::BitXOrNode::evaluate): + (KJS::BitOrNode::evaluate): + (KJS::valueForReadModifyAssignment): + (KJS::ForInNode::execute): + (KJS::TryNode::execute): + (KJS::FuncDeclNode::makeFunction): + (KJS::FuncExprNode::evaluate): + * kjs/nodes.h: + * kjs/number_object.cpp: + (KJS::NumberPrototype::NumberPrototype): + (KJS::numberProtoFuncToString): + (KJS::numberProtoFuncToLocaleString): + (KJS::numberProtoFuncToFixed): + (KJS::numberProtoFuncToExponential): + (KJS::numberProtoFuncToPrecision): + (KJS::NumberObjectImp::NumberObjectImp): + (KJS::NumberObjectImp::getValueProperty): + (KJS::NumberObjectImp::construct): + (KJS::NumberObjectImp::callAsFunction): + * kjs/object.cpp: + (KJS::JSObject::call): + (KJS::JSObject::get): + (KJS::JSObject::put): + (KJS::JSObject::defineGetter): + (KJS::JSObject::defineSetter): + (KJS::JSObject::putDirect): + (KJS::Error::create): + * kjs/object.h: + * kjs/object_object.cpp: + (KJS::ObjectPrototype::ObjectPrototype): + (KJS::objectProtoFuncToLocaleString): + (KJS::objectProtoFuncToString): + (KJS::ObjectObjectImp::ObjectObjectImp): + (KJS::ObjectObjectImp::construct): + * kjs/property_map.h: + (KJS::SavedProperty::SavedProperty): + (KJS::SavedProperty::init): + (KJS::SavedProperty::~SavedProperty): + (KJS::SavedProperty::name): + (KJS::SavedProperty::value): + (KJS::SavedProperty::attributes): + * kjs/protect.h: + (KJS::gcProtect): + (KJS::gcUnprotect): + * kjs/regexp_object.cpp: + (KJS::RegExpPrototype::RegExpPrototype): + (KJS::regExpProtoFuncToString): + (KJS::RegExpImp::getValueProperty): + (KJS::RegExpObjectImp::RegExpObjectImp): + (KJS::RegExpObjectImp::arrayOfMatches): + (KJS::RegExpObjectImp::getBackref): + (KJS::RegExpObjectImp::getLastParen): + (KJS::RegExpObjectImp::getLeftContext): + (KJS::RegExpObjectImp::getRightContext): + (KJS::RegExpObjectImp::getValueProperty): + (KJS::RegExpObjectImp::createRegExpImp): + * kjs/regexp_object.h: + * kjs/string_object.cpp: + (KJS::StringInstance::StringInstance): + (KJS::StringInstance::lengthGetter): + (KJS::StringInstance::indexGetter): + (KJS::stringInstanceNumericPropertyGetter): + (KJS::StringPrototype::StringPrototype): + (KJS::replace): + (KJS::stringProtoFuncCharAt): + (KJS::stringProtoFuncCharCodeAt): + (KJS::stringProtoFuncConcat): + (KJS::stringProtoFuncIndexOf): + (KJS::stringProtoFuncLastIndexOf): + (KJS::stringProtoFuncMatch): + (KJS::stringProtoFuncSearch): + (KJS::stringProtoFuncReplace): + (KJS::stringProtoFuncSlice): + (KJS::stringProtoFuncSplit): + (KJS::stringProtoFuncSubstr): + (KJS::stringProtoFuncSubstring): + (KJS::stringProtoFuncToLowerCase): + (KJS::stringProtoFuncToUpperCase): + (KJS::stringProtoFuncToLocaleLowerCase): + (KJS::stringProtoFuncToLocaleUpperCase): + (KJS::stringProtoFuncLocaleCompare): + (KJS::stringProtoFuncBig): + (KJS::stringProtoFuncSmall): + (KJS::stringProtoFuncBlink): + (KJS::stringProtoFuncBold): + (KJS::stringProtoFuncFixed): + (KJS::stringProtoFuncItalics): + (KJS::stringProtoFuncStrike): + (KJS::stringProtoFuncSub): + (KJS::stringProtoFuncSup): + (KJS::stringProtoFuncFontcolor): + (KJS::stringProtoFuncFontsize): + (KJS::stringProtoFuncAnchor): + (KJS::stringProtoFuncLink): + (KJS::StringObjectImp::StringObjectImp): + (KJS::StringObjectImp::construct): + (KJS::StringObjectImp::callAsFunction): + (KJS::StringObjectFuncImp::StringObjectFuncImp): + (KJS::StringObjectFuncImp::callAsFunction): + * kjs/string_object.h: + (KJS::StringInstanceThatMasqueradesAsUndefined::StringInstanceThatMasqueradesAsUndefined): + * kjs/testkjs.cpp: + (GlobalObject::GlobalObject): + (functionGC): + (functionRun): + (functionReadline): + (kjsmain): + * kjs/ustring.h: + * kjs/value.cpp: + (KJS::JSCell::operator new): + (KJS::jsString): + (KJS::jsOwnedString): + (KJS::jsNumberCell): + * kjs/value.h: + (KJS::jsNaN): + (KJS::jsNumber): + (KJS::jsNumberFromAnd): + (KJS::JSCell::marked): + (KJS::JSCell::mark): + (KJS::JSValue::toJSNumber): + * wtf/ThreadSpecific.h: + (WTF::T): + +2008-05-10 Julien Chaffraix + + Qt & wx build fix. + + * JavaScriptCore.pri: Add profiler/Profile.cpp. + * JavaScriptCoreSources.bkl: Ditto. + +2008-05-10 Jan Michael Alonzo + + Reviewed by Maciej. + + Gtk+ build fix + + * GNUmakefile.am: Add Profile.cpp in _sources + +2008-05-09 Brady Eidson + + Build Fix. Kevin is an idiot. + ("My name is Kevin McCullough and I approve this message.") + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2008-05-09 Kevin McCullough + + Reviewed by Tim. + + - JavaScript profiler (10928) + -Add Profile class so that all profiles can be stored and retrieved by + the WebInspector when that time comes. + + * JavaScriptCore.exp: Export the new function signatures. + * JavaScriptCore.xcodeproj/project.pbxproj: Add the new files to the + project + * profiler/Profile.cpp: Added. This class represents a single run of the + profiler. + (KJS::Profile::Profile): + (KJS::Profile::willExecute): + (KJS::Profile::didExecute): + (KJS::Profile::printDataInspectorStyle): + (KJS::functionNameCountPairComparator): + (KJS::Profile::printDataSampleStyle): + * profiler/Profile.h: Added. Ditto + (KJS::Profile::stopProfiling): + * profiler/Profiler.cpp: Now the profiler keeps track of many profiles + but only runs one at a time. + (KJS::Profiler::startProfiling): + (KJS::Profiler::stopProfiling): + (KJS::Profiler::willExecute): + (KJS::Profiler::didExecute): + (KJS::Profiler::printDataInspectorStyle): + (KJS::Profiler::printDataSampleStyle): + * profiler/Profiler.h: Ditto. + (KJS::Profiler::~Profiler): + (KJS::Profiler::allProfiles): + (KJS::Profiler::clearProfiles): + +2008-05-08 Anders Carlsson + + Reviewed by Mark. + + Enable NPAPI plug-ins on 64-bit. + + * wtf/Platform.h: + +2008-05-07 Julien Chaffraix + + Reviewed by Adam Roben. + + wx & Gtk build fix. + + Add SIZE_MAX definition for the wx port. + + * os-win32/stdint.h: + +2008-05-07 Ariya Hidayat + + Reviewed by Simon. + + Support for isMainThread in the Qt port. + + * wtf/ThreadingQt.cpp: + (WTF::initializeThreading): Adjusted. + (WTF::isMainThread): Added. + +2008-05-05 Darin Adler + + Reviewed by John Sullivan. + + - fix debug-only leak seen on buildbot + + * wtf/HashTable.h: + (WTF::HashTable::checkKey): After writing an empty value in, but before constructing a + deleted value on top of it, call the destructor so the empty value doesn't leak. + +2008-05-02 Alexey Proskuryakov + + Reviewed by Geoffrey Garen. + + Get rid of static data in nodes.cpp (well, at least of non-debug one). + + No measurable change on SunSpider. + + * kjs/InitializeThreading.cpp: + (KJS::initializeThreadingOnce): + * kjs/nodes.cpp: + (KJS::newTrackedObjects): + (KJS::trackedObjectExtraRefCounts): + (KJS::initializeNodesThreading): + (KJS::ParserRefCounted::ParserRefCounted): + (KJS::ParserRefCounted::ref): + (KJS::ParserRefCounted::deref): + (KJS::ParserRefCounted::refcount): + (KJS::ParserRefCounted::deleteNewObjects): + * kjs/nodes.h: + Made newTrackedObjects and trackedObjectExtraRefCounts per-thread. + +2008-05-02 Alexey Proskuryakov + + Reviewed by Darin. + + Move call stack depth counter to global object. + + * kjs/ExecState.h: (KJS::ExecState::functionCallDepth): Added a recursion depth counter to + per-thread data. + * kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::init): Initialize PerThreadData.functionCallDepth. + * kjs/JSGlobalObject.h: (KJS::JSGlobalObject::perThreadData): Made the result non-const. + + * kjs/object.cpp: + (KJS::throwStackSizeExceededError): Moved throwError to a separate function, since it is now + the only thing in JSObject::call that needs a PIC branch. + (KJS::JSObject::call): Use a per-thread variable instead of local static for recursion depth + tracking. + +2008-05-02 Alexey Proskuryakov + + Reviewed by Darin. + + Make JavaScriptGlue and JavaScriptCore API functions implicitly call initializeThreading + for the sake of non-WebKit clients. + + * API/JSBase.cpp: + (JSGarbageCollect): + * API/JSContextRef.cpp: + (JSGlobalContextCreate): + These are the JavaScriptCore API bottlenecks. There are a few other JSStringRef + and JSClassRef functions that can be called earlier, but they do not do anything that + requires initializeThreading. + + * kjs/InitializeThreading.cpp: + (KJS::doInitializeThreading): + (KJS::initializeThreading): + On Darwin, make the initialization happen under pthread_once, since there is no guarantee + that non-WebKit clients won't try to call this function re-entrantly. + + * kjs/InitializeThreading.h: + * wtf/Threading.h: + Spell out initializeThreading contract. + + * wtf/ThreadingPthreads.cpp: (WTF::isMainThread): Make sure that results are correct on + Darwin, even if threading was initialized from a secondary thread. + +2008-05-02 Alexey Proskuryakov + + Reviewed by Geoffrey Garen. + + https://bugs.webkit.org/show_bug.cgi?id=18826 + Make JavaScript heap per-thread + + * wtf/ThreadSpecific.h: Make sure to initialize POD thread-specific varaibles, too + (replaced "new T" with "new T()"). + + * kjs/collector.h: Renamed Collector to Heap, made the heap per-thread. Removed support for + multithreaded access to a heap. + (KJS::CollectorBlock): Removed collectOnMainThreadOnly bitmap, added a reference to owner heap. + (KJS::SmallCellCollectorBlock): Ditto. + (KJS::Heap::markListSet): Moved from a static variable in List.cpp to a per-thread one here. + (KJS::Heap::heap): Added a method to find which heap a JSValue is allocated in. + + * kjs/collector.cpp: Changed "const size_t" constants to #defines, to avoid a PIC branch + (gcc was using one to access a constant used in std::max(), because it takes a reference, + even though std::max() itself was inlined). + (KJS::Heap::threadHeap): JS heap is now per-thread. + (KJS::Heap::Heap): Zero-initialize the heap. + (KJS::allocateBlock): Added NEVER_INLINE, because this function uses a PIC branch, so + inlining it in Heap::heapAllocate() is bad for performance, now that the latter doesn't + use any global data. + (KJS::Heap::heapAllocate): Initialize Block::heap. + (KJS::Heap::markCurrentThreadConservatively): Moved into markStackObjectsConservatively(), + as GC only works with a current thread's heap now. + (KJS::Heap::sweep): Removed collectOnMainThreadOnly checks. + (KJS::Heap::collect): Ditto. + + * kjs/JSLock.cpp: + * kjs/JSLock.h: + (KJS::JSLock::JSLock): + Removed registerThread(), as the heap no longer cares. + + * kjs/InitializeThreading.cpp: (KJS::initializeThreading): Initialize new per-thread + variables in Heap and JSGlobalObject. + + * kjs/ExecState.h: (KJS::ExecState::heap): Added a heap pointer for faster access to + per-thread heap, and an accessor for it. + + * kjs/JSGlobalObject.h: Made JSGlobalObject linked list per-thread. + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::~JSGlobalObject): Fixed a bug in linked list handling. It only worked + right if the removed object was the head one! + (KJS::JSGlobalObject::head): Return a per-thread list head. + (KJS::JSGlobalObject::init): Store a reference to per-thread heap. + (KJS::JSGlobalObject::reset): Pass ExecState to functions that need it. + (KJS::JSGlobalObject::tearOffActivation): Ditto. + (KJS::JSGlobalObject::operator new): JSGlobalObject allocation cannot use an ExecState, + so it needs a custom operator new that directly accesses per-thread heap. + + * kjs/list.h: + (KJS::List::List): Replaced m_isInMarkSet boolean with an actual pointer to the set, since it + is no longer a single static object. + (KJS::List::~List): Ditto. + * kjs/list.cpp: + (KJS::List::markSet): Removed, this is now stored in Heap. + (KJS::List::markProtectedLists): Take a reference to the list. + (KJS::List::expandAndAppend): Ask the current thread heap for a mark set reference. + + * kjs/protect.h: + (KJS::gcProtect): + (KJS::gcUnprotect): + Use the newly added Heap::heap() method to find out which heap the value to be (un)protected + belongs to. + + * kjs/property_map.h: Removed unused SavedProperty class. + + * JavaScriptCore.exp: + * API/JSBase.cpp: + (JSGarbageCollect): + * API/JSCallbackObjectFunctions.h: + (KJS::::staticFunctionGetter): + * API/JSClassRef.cpp: + (OpaqueJSClass::prototype): + * API/JSObjectRef.cpp: + (JSObjectMake): + (JSObjectMakeFunctionWithCallback): + (JSObjectMakeConstructor): + (JSObjectMakeFunction): + * API/JSValueRef.cpp: + (JSValueMakeNumber): + (JSValueMakeString): + * kjs/array_instance.cpp: + (KJS::ArrayInstance::ArrayInstance): + (KJS::ArrayInstance::lengthGetter): + * kjs/array_object.cpp: + (KJS::arrayProtoFuncToString): + (KJS::arrayProtoFuncToLocaleString): + (KJS::arrayProtoFuncJoin): + (KJS::arrayProtoFuncConcat): + (KJS::arrayProtoFuncPop): + (KJS::arrayProtoFuncPush): + (KJS::arrayProtoFuncShift): + (KJS::arrayProtoFuncSlice): + (KJS::arrayProtoFuncSplice): + (KJS::arrayProtoFuncUnShift): + (KJS::arrayProtoFuncFilter): + (KJS::arrayProtoFuncMap): + (KJS::arrayProtoFuncEvery): + (KJS::arrayProtoFuncForEach): + (KJS::arrayProtoFuncSome): + (KJS::arrayProtoFuncIndexOf): + (KJS::arrayProtoFuncLastIndexOf): + (KJS::ArrayObjectImp::ArrayObjectImp): + (KJS::ArrayObjectImp::construct): + * kjs/bool_object.cpp: + (KJS::BooleanPrototype::BooleanPrototype): + (KJS::booleanProtoFuncToString): + (KJS::BooleanObjectImp::BooleanObjectImp): + (KJS::BooleanObjectImp::construct): + * kjs/date_object.cpp: + (KJS::formatLocaleDate): + (KJS::DatePrototype::DatePrototype): + (KJS::DateObjectImp::DateObjectImp): + (KJS::DateObjectImp::construct): + (KJS::DateObjectImp::callAsFunction): + (KJS::DateObjectFuncImp::DateObjectFuncImp): + (KJS::DateObjectFuncImp::callAsFunction): + (KJS::dateProtoFuncToString): + (KJS::dateProtoFuncToUTCString): + (KJS::dateProtoFuncToDateString): + (KJS::dateProtoFuncToTimeString): + (KJS::dateProtoFuncToLocaleString): + (KJS::dateProtoFuncToLocaleDateString): + (KJS::dateProtoFuncToLocaleTimeString): + (KJS::dateProtoFuncValueOf): + (KJS::dateProtoFuncGetTime): + (KJS::dateProtoFuncGetFullYear): + (KJS::dateProtoFuncGetUTCFullYear): + (KJS::dateProtoFuncToGMTString): + (KJS::dateProtoFuncGetMonth): + (KJS::dateProtoFuncGetUTCMonth): + (KJS::dateProtoFuncGetDate): + (KJS::dateProtoFuncGetUTCDate): + (KJS::dateProtoFuncGetDay): + (KJS::dateProtoFuncGetUTCDay): + (KJS::dateProtoFuncGetHours): + (KJS::dateProtoFuncGetUTCHours): + (KJS::dateProtoFuncGetMinutes): + (KJS::dateProtoFuncGetUTCMinutes): + (KJS::dateProtoFuncGetSeconds): + (KJS::dateProtoFuncGetUTCSeconds): + (KJS::dateProtoFuncGetMilliSeconds): + (KJS::dateProtoFuncGetUTCMilliseconds): + (KJS::dateProtoFuncGetTimezoneOffset): + (KJS::dateProtoFuncSetTime): + (KJS::setNewValueFromTimeArgs): + (KJS::setNewValueFromDateArgs): + (KJS::dateProtoFuncSetYear): + (KJS::dateProtoFuncGetYear): + * kjs/error_object.cpp: + (KJS::ErrorPrototype::ErrorPrototype): + (KJS::errorProtoFuncToString): + (KJS::ErrorObjectImp::ErrorObjectImp): + (KJS::ErrorObjectImp::construct): + (KJS::NativeErrorPrototype::NativeErrorPrototype): + (KJS::NativeErrorImp::NativeErrorImp): + (KJS::NativeErrorImp::construct): + * kjs/function.cpp: + (KJS::FunctionImp::lengthGetter): + (KJS::FunctionImp::construct): + (KJS::Arguments::Arguments): + (KJS::ActivationImp::createArgumentsObject): + (KJS::encode): + (KJS::decode): + (KJS::globalFuncParseInt): + (KJS::globalFuncParseFloat): + (KJS::globalFuncEscape): + (KJS::globalFuncUnescape): + (KJS::PrototypeFunction::PrototypeFunction): + (KJS::PrototypeReflexiveFunction::PrototypeReflexiveFunction): + * kjs/function_object.cpp: + (KJS::FunctionPrototype::FunctionPrototype): + (KJS::functionProtoFuncToString): + (KJS::FunctionObjectImp::FunctionObjectImp): + (KJS::FunctionObjectImp::construct): + * kjs/internal.cpp: + (KJS::StringImp::toObject): + * kjs/internal.h: + (KJS::StringImp::StringImp): + (KJS::NumberImp::operator new): + * kjs/lookup.h: + (KJS::staticFunctionGetter): + (KJS::cacheGlobalObject): + * kjs/math_object.cpp: + (KJS::MathObjectImp::getValueProperty): + (KJS::mathProtoFuncAbs): + (KJS::mathProtoFuncACos): + (KJS::mathProtoFuncASin): + (KJS::mathProtoFuncATan): + (KJS::mathProtoFuncATan2): + (KJS::mathProtoFuncCeil): + (KJS::mathProtoFuncCos): + (KJS::mathProtoFuncExp): + (KJS::mathProtoFuncFloor): + (KJS::mathProtoFuncLog): + (KJS::mathProtoFuncMax): + (KJS::mathProtoFuncMin): + (KJS::mathProtoFuncPow): + (KJS::mathProtoFuncRandom): + (KJS::mathProtoFuncRound): + (KJS::mathProtoFuncSin): + (KJS::mathProtoFuncSqrt): + (KJS::mathProtoFuncTan): + * kjs/nodes.cpp: + (KJS::Node::handleException): + (KJS::NumberNode::evaluate): + (KJS::StringNode::evaluate): + (KJS::ArrayNode::evaluate): + (KJS::PostIncResolveNode::evaluate): + (KJS::PostIncLocalVarNode::evaluate): + (KJS::PostDecResolveNode::evaluate): + (KJS::PostDecLocalVarNode::evaluate): + (KJS::PostDecLocalVarNode::inlineEvaluateToNumber): + (KJS::PostIncBracketNode::evaluate): + (KJS::PostDecBracketNode::evaluate): + (KJS::PostIncDotNode::evaluate): + (KJS::PostDecDotNode::evaluate): + (KJS::typeStringForValue): + (KJS::LocalVarTypeOfNode::evaluate): + (KJS::TypeOfResolveNode::evaluate): + (KJS::TypeOfValueNode::evaluate): + (KJS::PreIncLocalVarNode::evaluate): + (KJS::PreIncResolveNode::evaluate): + (KJS::PreDecLocalVarNode::evaluate): + (KJS::PreDecResolveNode::evaluate): + (KJS::PreIncConstNode::evaluate): + (KJS::PreDecConstNode::evaluate): + (KJS::PostIncConstNode::evaluate): + (KJS::PostDecConstNode::evaluate): + (KJS::PreIncBracketNode::evaluate): + (KJS::PreDecBracketNode::evaluate): + (KJS::PreIncDotNode::evaluate): + (KJS::PreDecDotNode::evaluate): + (KJS::NegateNode::evaluate): + (KJS::BitwiseNotNode::evaluate): + (KJS::MultNode::evaluate): + (KJS::DivNode::evaluate): + (KJS::ModNode::evaluate): + (KJS::addSlowCase): + (KJS::add): + (KJS::AddNumbersNode::evaluate): + (KJS::AddStringsNode::evaluate): + (KJS::AddStringLeftNode::evaluate): + (KJS::AddStringRightNode::evaluate): + (KJS::SubNode::evaluate): + (KJS::LeftShiftNode::evaluate): + (KJS::RightShiftNode::evaluate): + (KJS::UnsignedRightShiftNode::evaluate): + (KJS::BitXOrNode::evaluate): + (KJS::BitOrNode::evaluate): + (KJS::valueForReadModifyAssignment): + (KJS::ForInNode::execute): + (KJS::TryNode::execute): + (KJS::FuncDeclNode::makeFunction): + (KJS::FuncExprNode::evaluate): + * kjs/number_object.cpp: + (KJS::NumberPrototype::NumberPrototype): + (KJS::numberProtoFuncToString): + (KJS::numberProtoFuncToLocaleString): + (KJS::numberProtoFuncToFixed): + (KJS::numberProtoFuncToExponential): + (KJS::numberProtoFuncToPrecision): + (KJS::NumberObjectImp::NumberObjectImp): + (KJS::NumberObjectImp::getValueProperty): + (KJS::NumberObjectImp::construct): + (KJS::NumberObjectImp::callAsFunction): + * kjs/object.cpp: + (KJS::JSObject::defineGetter): + (KJS::JSObject::defineSetter): + (KJS::JSObject::putDirect): + (KJS::Error::create): + * kjs/object.h: + * kjs/object_object.cpp: + (KJS::ObjectPrototype::ObjectPrototype): + (KJS::objectProtoFuncToLocaleString): + (KJS::objectProtoFuncToString): + (KJS::ObjectObjectImp::ObjectObjectImp): + (KJS::ObjectObjectImp::construct): + * kjs/regexp_object.cpp: + (KJS::RegExpPrototype::RegExpPrototype): + (KJS::regExpProtoFuncToString): + (KJS::RegExpImp::getValueProperty): + (KJS::RegExpObjectImp::RegExpObjectImp): + (KJS::RegExpObjectImp::arrayOfMatches): + (KJS::RegExpObjectImp::getBackref): + (KJS::RegExpObjectImp::getLastParen): + (KJS::RegExpObjectImp::getLeftContext): + (KJS::RegExpObjectImp::getRightContext): + (KJS::RegExpObjectImp::getValueProperty): + (KJS::RegExpObjectImp::createRegExpImp): + * kjs/regexp_object.h: + * kjs/string_object.cpp: + (KJS::StringInstance::StringInstance): + (KJS::StringInstance::lengthGetter): + (KJS::StringInstance::indexGetter): + (KJS::stringInstanceNumericPropertyGetter): + (KJS::StringPrototype::StringPrototype): + (KJS::replace): + (KJS::stringProtoFuncCharAt): + (KJS::stringProtoFuncCharCodeAt): + (KJS::stringProtoFuncConcat): + (KJS::stringProtoFuncIndexOf): + (KJS::stringProtoFuncLastIndexOf): + (KJS::stringProtoFuncMatch): + (KJS::stringProtoFuncSearch): + (KJS::stringProtoFuncReplace): + (KJS::stringProtoFuncSlice): + (KJS::stringProtoFuncSplit): + (KJS::stringProtoFuncSubstr): + (KJS::stringProtoFuncSubstring): + (KJS::stringProtoFuncToLowerCase): + (KJS::stringProtoFuncToUpperCase): + (KJS::stringProtoFuncToLocaleLowerCase): + (KJS::stringProtoFuncToLocaleUpperCase): + (KJS::stringProtoFuncLocaleCompare): + (KJS::stringProtoFuncBig): + (KJS::stringProtoFuncSmall): + (KJS::stringProtoFuncBlink): + (KJS::stringProtoFuncBold): + (KJS::stringProtoFuncFixed): + (KJS::stringProtoFuncItalics): + (KJS::stringProtoFuncStrike): + (KJS::stringProtoFuncSub): + (KJS::stringProtoFuncSup): + (KJS::stringProtoFuncFontcolor): + (KJS::stringProtoFuncFontsize): + (KJS::stringProtoFuncAnchor): + (KJS::stringProtoFuncLink): + (KJS::StringObjectImp::StringObjectImp): + (KJS::StringObjectImp::construct): + (KJS::StringObjectImp::callAsFunction): + (KJS::StringObjectFuncImp::StringObjectFuncImp): + (KJS::StringObjectFuncImp::callAsFunction): + * kjs/string_object.h: + (KJS::StringInstanceThatMasqueradesAsUndefined::StringInstanceThatMasqueradesAsUndefined): + * kjs/testkjs.cpp: + (GlobalObject::GlobalObject): + (functionGC): + (functionRun): + (functionReadline): + (kjsmain): + * kjs/ustring.h: + * kjs/value.cpp: + (KJS::JSCell::operator new): + (KJS::jsString): + (KJS::jsOwnedString): + (KJS::jsNumberCell): + * kjs/value.h: + (KJS::jsNaN): + (KJS::jsNumber): + (KJS::jsNumberFromAnd): + (KJS::JSCell::marked): + (KJS::JSCell::mark): + (KJS::JSValue::toJSNumber): + Removed collectOnMainThreadOnly, as this is the only way to collect now. Replaced calls to + static Collector methods with calls to per-thread Heap ones. + +2008-05-02 Dan Bernstein + + Reviewed by Maciej Stachowiak. + + - Mac build fix + + * wtf/StrHash.h: Added header guards and removed #include "config.h". + +2008-05-01 Ada Chan + + #include in identifier.cpp. + + Reviewed by Maciej. + + * kjs/identifier.cpp: + +2008-05-01 Steve Falkenburg + + Build fix. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2008-05-01 Sam Weinig + + Fix build. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-05-01 Kevin McCullough + + Reviewed by Darin. + + JavaScript profiler (10928) + - Fix "sample" output so that it can be imported into Instruments + - Also keep track of number of times a function is profiled. + + * JavaScriptCore.xcodeproj/project.pbxproj: Add StrHash.h which needed + to be pulled out of identifier.cpp so that it could be used by the + profiler and identifiers. + * kjs/identifier.cpp: Ditto. + * profiler/FunctionCallProfile.cpp: + (KJS::FunctionCallProfile::printDataInspectorStyle): Inspector style + printing should show microseconds. + (KJS::FunctionCallProfile::printDataSampleStyle): Sample style printing + now counts the number of times a function is in the stack tree and does + not print microseconds since that does not make sense for a sampler. + * profiler/FunctionCallProfile.h: Keep track of number of times a + function is profiled. + (KJS::FunctionCallProfile::numberOfCalls): + * profiler/Profiler.cpp: + (KJS::functionNameCountPairComparator): Comparator for sort function in + printDataSampleStyle. + (KJS::Profiler::printDataSampleStyle): Print the number of times that a + function is listed in the stack tree in order of most times listed. + * wtf/HashCountedSet.h: Added copyToVector since it didn't exist and is + a more standard way to copy a HashSet to a Vector. I added on variant + that takes a pair as the Vector's type and so the HashCountedSet simply + fills in that pair with its internal pair, and another variant that + takes a Vector of the type of the HashCountedSet and only fills in the + Vector with the first element of the pair. + (WTF::copyToVector): + * wtf/StrHash.h: Added. + (WTF::): + +2008-04-29 David Kilzer + + BUILD FIX for ENABLE(DASHBOARD_SUPPORT) + + * wtf/Platform.h: Defined ENABLE(DASHBOARD_SUPPORT) to 1 only for + PLATFORM(MAC) and PLATFORM(WIN). Changed default to 0 for other + ports. + +2008-04-29 Greg Bolsinga + + Reviewed by Darin. + + Wrapped Dashboard code with ENABLE(DASHBOARD_SUPPORT) + + * wtf/Platform.h: + +2008-04-29 Kevin McCullough + + Reviewed by Geoff. + + - JavaScript profiler (10928) + -Keep call count. + + * profiler/FunctionCallProfile.cpp: + (KJS::FunctionCallProfile::FunctionCallProfile): + (KJS::FunctionCallProfile::didExecute): Implements call count and fixed a bug where a stackIndex + of 0 was causing the assert to be hit. + (KJS::FunctionCallProfile::stopProfiling): + (KJS::FunctionCallProfile::endAndRecordCall): + * profiler/FunctionCallProfile.h: + +2008-04-29 Simon Hausmann + + Qt/Windows build fix. The externally declared hash tables are actually + declared const and the const is mangled in the symbol name, so when + importing they also need to be marked const. + + When compiling without MULTIPLE_THREADS use a const HashTable& + instead of a HashTable& in ThreadClassInfoHashTables to avoid + initializing the latter with a const reference. + + * kjs/JSGlobalObject.cpp: + +2008-04-28 Alexey Proskuryakov + + Windows build fix. + + * kjs/ExecState.h: For whatever reason, MSVC couldn't generate a default constructor for + a struct that had a "const List" member. Removing the const qulifier makes the problem go away. + +2008-04-28 Alexey Proskuryakov + + Reviewed by Darin. + + Fix run-webkit-tests --threading + and provisionally fix + Proxy server issue in Sunday's Nightly + + Changed ClassInfo objects for built-in objects to hold a getter function returning + a per-thread instance. This makes it safe to share these ClassInfo objects between threads - + and these are the only ones that need to be shared. + + * kjs/lexer.cpp: + (KJS::Lexer::Lexer): + (KJS::Lexer::~Lexer): + * kjs/lexer.h: + Made mainTable a member of Lexer, so that it no longer needs to be shared between threads. + + * kjs/object.cpp: + (KJS::JSObject::deleteProperty): + (KJS::JSObject::findPropertyHashEntry): + (KJS::JSObject::propertyIsEnumerable): + (KJS::JSObject::getPropertyAttributes): + (KJS::JSObject::getPropertyNames): + * kjs/object.h: + (KJS::ClassInfo::propHashTable): + Added a new classPropHashTableGetterFunction field to ClassInfo. If it is non-zero, the + static table is not used. + + * kjs/JSGlobalObject.cpp: + (KJS::ThreadClassInfoHashTables::ThreadClassInfoHashTables): This new class holds per-thread + HashTables for built-in classes. The old static structs are copied to create per-thread + instances. + (KJS::JSGlobalObject::threadClassInfoHashTables): An accessor/initializer for the above. + (KJS::JSGlobalObject::init): Copy per-thread data into a single structure for faster access. + Also, construct globalExec. + (KJS::JSGlobalObject::reset): Adapted for globalExec now being an OwnPtr. + (KJS::JSGlobalObject::mark): Ditto. + (KJS::JSGlobalObject::globalExec): Ditto. + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): Made JSGlobalObject::JSGlobalObjectData::globalExec an OwnPtr, so that it can + be initialized from JSGlobalObject::init() after them. Otherwise, ExecState constructor was + trying to access half-initialized JSGlobalObject to make its own copy of these table + references, and failed. + (KJS::JSGlobalObject::JSGlobalObject): Pass "this" value to init() to create globalExec. + (KJS::JSGlobalObject::perThreadData): An accessor for per-thread data. + + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + * kjs/ExecState.h: + (KJS::ExecState::propertyNames): + (KJS::ExecState::emptyList): + (KJS::ExecState::arrayTable): + (KJS::ExecState::dateTable): + (KJS::ExecState::mathTable): + (KJS::ExecState::numberTable): + (KJS::ExecState::RegExpImpTable): + (KJS::ExecState::RegExpObjectImpTable): + (KJS::ExecState::stringTable): + * kjs/ExecStateInlines.h: + (KJS::ExecState::ExecState): + Each ExecState holds its own reference to per-thread data, for even faster access. Moved + m_emptyList and m_propertyNames to the same structure, making ExecState faster to construct + and take less space on the stack. + + * kjs/InitializeThreading.cpp: (KJS::initializeThreading): Initialize thread-static data + added to JSGlobalObject. + + * API/JSCallbackConstructor.cpp: + * API/JSCallbackFunction.cpp: + * API/JSCallbackObject.cpp: + * JavaScriptCore.exp: + * kjs/JSVariableObject.cpp: + (KJS::JSVariableObject::getPropertyAttributes): + * kjs/JSVariableObject.h: + * kjs/array_instance.cpp: + * kjs/array_object.cpp: + (KJS::ArrayPrototype::getOwnPropertySlot): + * kjs/bool_object.cpp: + * kjs/create_hash_table: + * kjs/date_object.cpp: + (KJS::DatePrototype::getOwnPropertySlot): + (KJS::DateObjectImp::DateObjectImp): + * kjs/error_object.cpp: + * kjs/function.cpp: + * kjs/function_object.cpp: + (KJS::FunctionPrototype::FunctionPrototype): + * kjs/internal.cpp: + * kjs/lookup.h: + * kjs/math_object.cpp: + (KJS::MathObjectImp::getOwnPropertySlot): + * kjs/number_object.cpp: + (KJS::NumberObjectImp::getOwnPropertySlot): + * kjs/object_object.cpp: + (KJS::ObjectPrototype::ObjectPrototype): + * kjs/regexp_object.cpp: + (KJS::RegExpPrototype::RegExpPrototype): + (KJS::RegExpImp::getOwnPropertySlot): + (KJS::RegExpImp::put): + (KJS::RegExpObjectImp::getOwnPropertySlot): + (KJS::RegExpObjectImp::put): + * kjs/string_object.cpp: + (KJS::StringPrototype::getOwnPropertySlot): + Adjust for the above changes. + +2008-04-28 Darin Adler + + Reviewed by Adam. + + - make sure RefPtr's default hash doesn't ref/deref when computing the hash + - remove remnants of the hash table storage type optimization + + * wtf/HashFunctions.h: Used "using" to get the hash and equal functions + from PtrHash into PtrHash>. + + * wtf/HashMap.h: Replaced uses of PairBaseHashTraits with PairHashTraits. + Eliminated storage-related typedefs. Removed constructor, destructor, + copy constructor, and destructor since the compiler-generated ones are + fine. Removed refAll and derefAll. Took out unnnecessary typecasts. + Removed use of RefCounter. + + * wtf/HashSet.h: Eliminated storage-related typedefs. Removed constructor, + destructor, copy constructor, and destructor since the compiler-generated + ones are fine. Removed refAll and derefAll. Removed unneeded template + arguents from HashSetTranslatorAdapter. Eliminated unneeded HashSetTranslator + template. + + * wtf/HashTable.h: Tweaked formatting. Removed NeedsRef, RefCounterBase, + RefCounter, HashTableRefCounterBase, HashTableRefCounter, and Assigner + class templates. + + * wtf/HashTraits.h: Removed StorageTraits, needsRef, PairBaseHashTraits, + and HashKeyStorageTraits. + + * wtf/RefPtrHashMap.h: Made all the same fixes as in HashMap. Also made + the corresponding changes to RefPtrHashMapRawKeyTranslator. + +2008-04-28 Darin Adler + + Reviewed by Mitz. + + - fix assertion hit every time you view www.apple.com + + * kjs/PropertyNameArray.cpp: + (KJS::PropertyNameArray::add): Changed assertion to allow null and empty strings. + Now to find out why we have a property named "" and if that's a bug! + +2008-04-27 Mark Rowe + + Reviewed by Maciej Stachowiak. + + Fix crash inside PtrHash::hash when loading a page. + + * wtf/HashFunctions.h: Explicitly use the superclass implementation of hash to avoid infinite recursion. + +2008-04-27 Darin Adler + + Reviewed by Maciej. + + - fix REGRESSION: JavaScriptCore no longer builds with + GCC 4.2 due to pointer aliasing warnings + + Fix this by removing the HashTable optimizations that allowed us to share a back end + implementation between hash tables with integers, pointers, RefPtr, and String objects + as keys. The way it worked was incompatible with strict aliasing. + + This increases code size. On Mac OS X we'll have to regenerate .order files to avoid + slowing down Safari startup times. + + This creates a slight slowdown in SunSpider, mitigated by the following four speedups: + + - speed up array put slightly by moving a branch (was already done for get) + + - speed up symbol table access by adding a function named inlineGet to HashMap + and using that in symbolTableGet/Put + + - speed up PropertyNameArray creation by reducing the amount of reference count + churn and uniqueness checking when adding names and not doing any allocation at + all when building small arrays + + - speed up conversion of strings to floating point numbers by eliminating the + malloc/free of the buffer for the ASCII copy of the string; a way to make + things even faster would be to change strtod to take a UTF-16 string + + Note that there is considerable unused complexity now in HashSet/Map/Table to support + "storage types", which is no longer used. Will do in a separate patch. + + * API/JSCallbackObjectFunctions.h: + (KJS::JSCallbackObject::getPropertyNames): Removed explicit cast to Identifier to + take advantage of the new PropertyNameArray::add overload and avoid reference count churn. + * API/JSObjectRef.cpp: + (JSPropertyNameAccumulatorAddName): Ditto. + * JavaScriptCore.exp: Updated PropertyNameArray::add entry point name. + + * kjs/JSVariableObject.cpp: Removed now-unneeded IdentifierRepHashTraits::nullRepPtr + definition (see below). + (KJS::JSVariableObject::getPropertyNames): Removed explicit cast to Identifier. + + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTableGet): Use inlineGet for speed. Also changed to do + early exit instead of nesting the body inside an if. + (KJS::JSVariableObject::symbolTablePut): Ditto. + + * kjs/PropertyNameArray.cpp: + (KJS::PropertyNameArray::add): Changed implementation to take a raw pointer instead of + a reference to an identifier. Do uniqueness checking by searching the vector when the + vector is short, only building the set once the vector is large enough. + + * kjs/PropertyNameArray.h: Added an overload of add for a raw pointer, and made the old + add function call that one. Added an addKnownUnique function for use when the new + name is known to be different from any other in the array. Changed the vector to have + an inline capacity of 20. + + * kjs/SymbolTable.h: Changed IdentifierRepHash to inherit from the default hash for + a RefPtr so we don't have to define so much. Added an overload of the hash function for + a raw pointer as required by the new RefPtrHashMap. Got rid of the now-unneeded + IdentifierRepHashTraits -- the default traits now work fine. Added a definition of + empthValueIsZero to SymbolTableIndexHashTraits; not having it was incorrect, but harmless. + + * kjs/array_instance.cpp: + (KJS::ArrayInstance::put): Move the maxArrayIndex check inside the branch that checks + the index against the length, as done in the get function. + + * kjs/function.cpp: + (KJS::globalFuncKJSPrint): Changed to use the new getCString instead of cstring. + + * kjs/internal.cpp: Removed printInfo debugging function, a client of cstring. + If we need a debugging function we can easily make a better one and we haven't + used this one in a long time. + * kjs/internal.h: Ditto. + + * kjs/object.cpp: + (KJS::JSObject::getPropertyNames): Removed explicit cast to Identifier. + * kjs/property_map.cpp: + (KJS::PropertyMap::getEnumerablePropertyNames): Ditto. Also added a special case for + the case where the propertyNames array is empty -- in that case we know we're adding + a set of names that are non-overlapping so we can use addKnownUnique. + * kjs/ustring.cpp: + (KJS::UString::getCString): Replaces cstring. Puts the C string into a CStringBuffer, + which is a char Vector with an inline capacity. Also returns a boolean to indicate if + the converion was lossy, which eliminates the need for a separate is8Bit call. + (KJS::UString::toDouble): Changed to call getCString instead of cstring. + * kjs/ustring.h: Ditto. + + * wtf/HashFunctions.h: Overload the hash and equal functions for RefPtr's default + hash to take raw pointers. This works with the changes to RefPtrHashMap to avoid + introducing refcount churn. + + * wtf/HashMap.h: Removed special code to convert the deleted value to the empty value + when writing a new value into the map. This is now handled elsewhere. + (WTF::HashMap::get): Removed code that checks for an empty hash table before calling + HashTable::lookup; it's slightly more efficient to do this check inside lookup. + + * wtf/HashTable.h: + (WTF::HashTable::isDeletedBucket): Changed to use isDeletedValue instead of using + deletedValue and the equality operator. + (WTF::HashTable::deleteBucket): Changed to use constructDeletedValue instead of + using deletedValue and the assignment operator. + (WTF::HashTable::checkKey): Added. Factors out the check for values that are empty + or deleted keys that's used in various functions below. + (WTF::HashTable::lookup): Changed to use checkKey, check for a 0 table, and also + made public for use by RefPtrHashMap. + (WTF::HashTable::lookupForWriting): Changed to use checkKey. + (WTF::HashTable::fullLookupForWriting): Changed to use checkKey. + (WTF::HashTable::add): Changed to use checkKey, and call initializeBucket on a + deleted bucket before putting a new entry into it. + (WTF::HashTable::addPassingHashCode): Ditto. + (WTF::HashTable::deallocateTable): Check isDeletedBucket before calling ~ValueType. + + * wtf/HashTraits.h: Got ridd of all the HashTraits specialization for the integer + types, since GeneicHashTraitsBase already deals with integers separately. Put the + deleted value support into GenericHashTraitsBase. Changed FloatHashTraits to + inherit from GenericHashTraits, and define construct/isDeletedValue rather than + deletedValue. Removed the ref and deref functions from RefPtr's HashTraits, and + defined construct/isDeletedValue. Eliminated DeletedValueAssigner. Changed + PairHashTraits to define construct/isDeletedValue, and also merged + PairBaseHashTraits in with PairHashTraits. Got rid of all specialization of + HashKeyStorageTraits. We'll remove that, and the needsRef data member, later. + + * wtf/RefPtr.h: Added HashTableDeletedValueType, an enum type with a single value, + HashTableDeletedValue. Used that type to make a new constructor to construct + deleted values and also added an isHashTableDeletedValue function. + + * wtf/RefPtrHashMap.h: Added RefPtrHashMapRawKeyTranslator and used it to implement + the raw pointer functions. This is a way to continue to avoid refcount thrash. We + can't use the old way because it depended on the underlying map using a non-RefPtr + type. + (WTF::HashMap::find): Use find with RefPtrHashMapRawKeyTranslator. + (WTF::HashMap::contains): Use contains with RefPtrHashMapRawKeyTranslator. + (WTF::HashMap::inlineAdd): Use add with RefPtrHashMapRawKeyTranslator. + (WTF::HashMap::get): Removed code that checks for an empty hash table before calling + HashTable::lookup; it's slightly more efficient to do this check inside lookup. + (WTF::HashMap::inlineGet): Added. Just like get, but marked inline for use in the + symbol table code. + +2008-04-25 Sam Weinig + + Rubber-stamped by Mark Rowe. + + Remove SavedBuiltins and SavedProperties classes and the methods used to + save data to them. The CachedPage now stores a the JSGlobalObject in full. + + * JavaScriptCore.exp: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/JSGlobalObject.cpp: + * kjs/JSGlobalObject.h: + * kjs/JSVariableObject.cpp: + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::localStorage): + * kjs/SavedBuiltins.h: Removed. + * kjs/object.h: + * kjs/property_map.cpp: + * kjs/property_map.h: + +2008-04-25 Mark Rowe + + Rubber-stamped by Sam Weinig. + + Add some content to an empty ICU header file to prevent verification errors. + + * icu/unicode/utf_old.h: + +2008-04-25 David Kilzer + + REGRESSION: Wrong line number passed to -willLeaveCallFrame + + Patch by George Dicker and Michael Kahl. Reviewed by Darin. + + When -[NSObject(WebScriptDebugDelegate) webView:willLeaveCallFrame:sourceId:line:forWebFrame:] + is invoked, the first line number of the function is returned instead of the last + line number. This regressed in r28458. + + * kjs/nodes.cpp: + (KJS::FunctionBodyNodeWithDebuggerHooks::execute): Pass lastLine() instead of lineNo() + when calling Debugger::returnEvent(). + +2008-04-25 Darin Adler + + Done with Stephanie Lewis. + + * JavaScriptCore.xcodeproj/project.pbxproj: Prepare for compilation with gcc 4.2 by + adding -fno-strict-aliasing to CollatorICU.cpp. + +2008-04-24 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add a #define to easily enable collecting on every allocation to aid + debugging GC bugs. + + * kjs/collector.cpp: + (KJS::Collector::heapAllocate): + +2008-04-24 Kevin McCullough + + Reviewed by Adam and Sam. + + - JavaScript profiler (10928) + -Only profile the page group that starts profiling to avoid profiling + tools that shouldn't be profiled unless explicitly requested to. + + * JavaScriptCore.exp: Export new signature. + * kjs/JSGlobalObject.cpp: Add unique identifiers to the JSGlobalObject. + (KJS::JSGlobalObject::init): + * kjs/JSGlobalObject.h: Ditto. + (KJS::JSGlobalObject::setPageGroupIdentifier): + (KJS::JSGlobalObject::pageGroupIdentifier): + * profiler/Profiler.cpp: Check the identifier of the page group of the + lexical global exec state and only profile if it matches the given page + group identifier. + (KJS::Profiler::startProfiling): + (KJS::Profiler::willExecute): + (KJS::Profiler::didExecute): + * profiler/Profiler.h: Ditto. + (KJS::Profiler::Profiler): + +2008-04-24 Julien Chaffraix + + Reviewed by Simon. + + Bug 15940: Implement threading API for Qt + https://bugs.webkit.org/show_bug.cgi?id=15940 + + Original patch by Justin Haygood, tweaked by me. + + * JavaScriptCore.pri: + * wtf/ThreadingQt.cpp: Added. + (WTF::threadMapMutex): + (WTF::threadMap): + (WTF::establishIdentifierForThread): + (WTF::clearThreadForIdentifier): + (WTF::threadForIdentifier): + (WTF::initializeThreading): + (WTF::ThreadPrivate::getReturnValue): + (WTF::ThreadPrivate::ThreadPrivate): + (WTF::ThreadPrivate::run): + (WTF::createThread): + (WTF::waitForThreadCompletion): return !res to return + 0 on success (to match the pthreads implementation). + (WTF::detachThread): + (WTF::identifierByQthreadHandle): + (WTF::currentThread): + (WTF::Mutex::Mutex): + (WTF::Mutex::~Mutex): + (WTF::Mutex::lock): + (WTF::Mutex::tryLock): + (WTF::Mutex::unlock): + (WTF::ThreadCondition::ThreadCondition): + (WTF::ThreadCondition::~ThreadCondition): + (WTF::ThreadCondition::wait): + (WTF::ThreadCondition::timedWait): + (WTF::ThreadCondition::signal): + +2008-04-22 Darin Adler + + Reviewed by Anders. + + - simplify use of HashTraits to prepare for some upcoming hash table changes + + * kjs/SymbolTable.h: Made SymbolTableIndexHashTraits derive from HashTraits + and specialize only the empty value. + +2008-04-23 Holger Hans Peter Freyther + + Reviewed by Simon. + + Removed the #define for USE_SYSTEM_MALLOC that we set in WebKit.pri + already. + + * wtf/Platform.h: + +2008-04-21 Kevin McCullough + + Reviewed by Adam. + + JavaScript profiler (10928) + - When stop profiling is called we need to stop the timers on all the + functions that are still running. + + * profiler/FunctionCallProfile.cpp: + (KJS::FunctionCallProfile::didExecute): + (KJS::FunctionCallProfile::stopProfiling): + * profiler/FunctionCallProfile.h: + * profiler/Profiler.cpp: + (KJS::Profiler::stopProfiling): + +2008-04-21 Alexey Proskuryakov + + Reviewed by Darin. + + Move collector main thread initialization from WebKit/win to KJS::initializeThreading. + + * kjs/InitializeThreading.cpp: + (KJS::initializeThreading): + +2008-04-21 Adam Roben + + MSVC build fix + + Reviewed by Alexey Proskuryakov. + + * kjs/ustring.h: + (KJS::UString::cost): Disable a warning about assigning a 32-bit + size_t into a 31-bit size_t. + +2008-04-21 Simon Hausmann + + Reviewed by Lars. + + Made convertValueToQVariant accessible from within WebKit/qt/Api + + * bindings/qt/qt_runtime.h: + +2008-04-21 Holger Hans Peter Freyther + + Reviewed by Simon. + + Build fix for Qt 4.3 + + * When building WebCore/internal make sure the QT_[BEGIN,END]_NAMESPACE is + always defined. Do this by adding defines to the compiler line + * For users of our API this is not feasible. Every public header file should + include qwebkitglobal.h. Define the QT_BEGIN_NAMESPACE and QT_END_NAMESPACE + when we are building everything < 4.4.0 and don't have them defined. + + * kjs/testkjs.pro: + +2008-04-19 Matt Lilek + + Not reviewed, Windows build fix - copy the profiler headers in all + configurations, not just Debug_Internal. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2008-04-19 Mike Hommey + + Reviewed by Alp Toker. + + Don't build testkjs with rpath. + + * GNUmakefile.am: + +2008-04-18 Kevin Ollivier + + wx build fixes. Rename LocalStorage.h to LocalStorageEntry.h + to avoid header detection issues between WebCore/storage/LocalStorage.h + and it, and add $(PROFILER_SOURCES) to the wx JSCore build. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * jscore.bkl: + * kjs/ExecState.h: + * kjs/JSVariableObject.h: + * kjs/LocalStorage.h: Removed. + * kjs/LocalStorageEntry.h: Copied from JavaScriptCore/kjs/LocalStorage.h. + * kjs/function.h: + +2008-04-18 Jan Michael Alonzo + + Reviewed by Alp Toker. + + http://bugs.webkit.org/show_bug.cgi?id=16620 + [GTK] Autotools make dist and make check support + + Cleanups. + + * GNUmakefile.am: + +2008-04-18 Jon Honeycutt + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Windows + build fix. + +2008-04-11 Mark Rowe + + Rubber-stamped by Antti Koivisto. + + Silence GCC 4.3 warnings by removing extraneous consts. + + * kjs/ustring.cpp: + * kjs/ustring.h: + +2008-04-18 Kevin McCullough + + Reviewed by Sam. + + - JavaScript profiler (10928) + - Use Deque instead of Vector since the profiler uses prepend a lot + and deque is faster at that. + + * profiler/FunctionCallProfile.h: + (KJS::FunctionCallProfile::milliSecs): Corrected the name to match + its output. + * wtf/Deque.h: + (WTF::deleteAllValues): + +2008-04-18 Kevin McCullough + + Reviewed by Sam and Adam. + + - JavaScript profiler (10928) + - Cleaned up the header file and made some functions static, added + a new, sane, printing function, and fixed a few minor bugs. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * profiler/FunctionCallProfile.cpp: + (KJS::FunctionCallProfile::didExecute): Removed assertion that time is + > 0 because at ms resolution that may not be true and only cross- + platform way to get time differences is in ms. + (KJS::FunctionCallProfile::printDataInspectorStyle): Added a new + printing function for dumping data in a sane style. + (KJS::FunctionCallProfile::printDataSampleStyle): Fixed a bug where we + displayed too much precision when printing our floats. Also added logic + to make sure we don't display 0 because that doesn't make sense for a + sampling profile. + * profiler/FunctionCallProfile.h: + * profiler/Profiler.cpp: Moved functions that could be static into the + implementation, and chaned the ASSERTs to early returns. I did this + because console.profile() is a JS function and so was being profiled + but asserting because the profiler had not been started! In the future + I would like to put the ASSERTs back and not profile the calls to + console.profile() and console.profileEnd(). + (KJS::Profiler::willExecute): + (KJS::Profiler::didExecute): + (KJS::getStackNames): Fixed a bug where the wrong ExecState was being + used. + (KJS::getFunctionName): + (KJS::Profiler::printDataInspectorStyle): + * profiler/Profiler.h: + +2008-04-18 Alexey Proskuryakov + + Reviewed by Darin. + + Fix leaks during plugin tests (which actually excercise background JS), and potential + PAC brokenness that was not reported, but very likely. + + The leaks shadowed a bigger problem with Identifier destruction. Identifier::remove involves + an IdentifierTable lookup, which is now a per-thread instance. Since garbage collection can + currently happen on a different thread than allocation, a wrong table was used. + + No measurable change on SunSpider total, ~1% variation on individual tests. + + * kjs/ustring.cpp: + (KJS::UString::Rep::create): + (KJS::UString::Rep::destroy): + * kjs/ustring.h: + Replaced isIdentifier with a pointer to IdentifierTable, so that destruction can be done + correctly. Took one bit from reportedCost, to avoid making UString::Rep larger (performance + effect was measurable on SunSpider). + + * kjs/identifier.cpp: + (KJS::IdentifierTable::IdentifierTable): + (KJS::IdentifierTable::~IdentifierTable): + (KJS::IdentifierTable::add): + (KJS::IdentifierTable::remove): + Make IdentifierTable a real class. Its destructor needs to zero out outstanding references, + because some identifiers may briefly outlive it during thread destruction, and we don't want + them to use their stale pointers. + + (KJS::LiteralIdentifierTable): + (KJS::Identifier::add): + Now that LiteralIdentifierTable is per-thread and can be destroyed not just during application + shutdown, it is not appropriate to simply bump refcount for strings that get there; changed + the table to hold RefPtrs. + + (KJS::CStringTranslator::translate): + (KJS::UCharBufferTranslator::translate): + (KJS::Identifier::addSlowCase): + (KJS::Identifier::remove): + * kjs/identifier.h: + (KJS::Identifier::add): + Use and update UString::Rep::identifierTable as appropriate. Updating it is now done in + IdentifierTable::add, not in translators. + +2008-04-18 Alexey Proskuryakov + + Reviewed by Darin. + + Get rid of static compareWithCompareFunctionArguments in array_instance.cpp. + + No change on SunSpider, CelticKane or iBench JavaScript. It is probable that in some cases, + merge sort is still faster, but more investigation is needed to determine a new cutoff. + Or possibly, it would be better to do what FIXME says (change to tree sort). + + Also, made arguments a local variable - not sure why it was a member of + CompareWithCompareFunctionArguments. + + * kjs/array_instance.cpp: + (KJS::CompareWithCompareFunctionArguments::CompareWithCompareFunctionArguments): + (KJS::CompareWithCompareFunctionArguments::operator()): + (KJS::ArrayInstance::sort): + +2008-04-18 Simon Hausmann + + Build fix for gcc 4.3. Include stdio.h for printf. + + * profiler/FunctionCallProfile.cpp: + * profiler/Profiler.cpp: + +2008-04-17 Jon Honeycutt + + Reviewed by mrowe. + + * wtf/Platform.h: Add HAVE_ACCESSIBILITY to Platform.h. + +2008-04-17 Alexey Proskuryakov + + Reviewed by Maciej. + + Thread static data destructors are not guaranteed to be called in any particular order; + turn ThreadSpecific into a phoenix-style singleton to avoid accessing freed memory when + deleted objects are interdependent (e.g. CommonIdentifiers and internal identifier tables). + + No change on SunSpider. + + * wtf/ThreadSpecific.h: + (WTF::ThreadSpecific::Data::Data): + (WTF::::get): + (WTF::::set): + (WTF::::destroy): + +2008-04-15 Srinivas Rao. M Hamse + + Reviewed by Maciej Stachowiak. + + - gcc 3.x build fix + + * kjs/nodes.h: CallerType definition made public for gcc 3.x compilation + +2008-04-16 Brady Eidson + + Reviewed by Sam Weinig + + Change ThreadSafeShared to act like RefCounted by starting out with a single ref by default + + * wtf/Threading.h: + (WTF::ThreadSafeShared::ThreadSafeShared): + +2008-04-16 Sam Weinig + + Reviewed by Geoffrey Garen. + + - To keep the behavior of the WebKit and JavaScriptCore API's the same, + we need to hide the fact that the global object and the window object + are no longer the same thing, and the the global object now changes on + navigations. To do this, only the wrapper should ever be exposed. This + fixes the two remaining spots where the internal global object is exposed, + the windowScriptObject returned from [WebFrame windowObject] and the object + return by calling JSContextGetGlobalObject on [WebFrame globalContext]. + + * API/JSContextRef.cpp: + (JSContextGetGlobalObject): + This is a bit of a hack, this returns the "this" representation of the globalObject + which will be the WrapperWindow for WebCore and the globalObject for non-WebCore. + + * API/JSObjectRef.cpp: + (JSObjectSetProperty): + Call the new putWithAttributes method instead of relying on lower-level calls. + This is needed so that the window wrapper can forward the calls. + + * JavaScriptCore.exp: + * kjs/Activation.h: + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::putWithAttributes): + * kjs/JSGlobalObject.h: + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTablePutWithAttributes): + * kjs/function.cpp: + (KJS::ActivationImp::putWithAttributes): + * kjs/nodes.cpp: + (KJS::ConstDeclNode::handleSlowCase): + (KJS::ConstDeclNode::evaluateSingle): + (KJS::EvalNode::processDeclarations): + * kjs/object.cpp: + (KJS::JSObject::putWithAttributes): + * kjs/object.h: + Rename initializeVariable to putWithAttributes and move it down to JSObject so it + can be used for JSObjectSetProperty. + +2008-04-16 Kevin McCullough + + Reviewed by Sam and Geoff. + + - JavaScript profiler (10928) + Inital profiler prototype + + * GNUmakefile.am: Added new files to project + * JavaScriptCore.pri: Ditto + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Ditto + * JavaScriptCore.xcodeproj/project.pbxproj: Ditto + * JavaScriptCoreSources.bkl: Ditto + * kjs/config.h: Put compiling flag in here. + * kjs/function.cpp: Instrument calling the function eval(). + (KJS::eval): + * kjs/interpreter.cpp: Instrument evaluating global scopes. + (KJS::Interpreter::evaluate): + * kjs/object.cpp: Instrument JS function calls. + (KJS::JSObject::call): + * profiler: Added. + * profiler/FunctionCallProfile.cpp: Added. + (KJS::FunctionCallProfile::FunctionCallProfile): + (KJS::FunctionCallProfile::~FunctionCallProfile): + (KJS::FunctionCallProfile::willExecute): Call right before the JS function or executing context is executed to start the profiler's timer. + (KJS::FunctionCallProfile::didExecute): Call right after the JS function or executing context is executed to stop the profiler's timer. + (KJS::FunctionCallProfile::addChild): Add a child to the current FunctionCallProfile if it isn't already a child of the current FunctionalCallProfile. + (KJS::FunctionCallProfile::findChild): Return the child that matches the given name if there is one. + (KJS::FunctionCallProfile::printDataSampleStyle): Print the current profiled information in a format that matches sample's output. + * profiler/FunctionCallProfile.h: Added. + (KJS::FunctionCallProfile::FunctionCallProfile): + (KJS::FunctionCallProfile::~FunctionCallProfile): + (KJS::FunctionCallProfile::functionName): + (KJS::FunctionCallProfile::microSecs): + * profiler/Profiler.cpp: Added. + (KJS::Profiler::profiler): + (KJS::Profiler::sharedProfiler): Return global singleton (may change due to multi-threading concerns) + (KJS::Profiler::startProfiling): Don't start collecting profiling information until the user starts the profiler. Also don't clear old prfiled data until the profiler is restarted. + (KJS::Profiler::stopProfiling): Stop collecting profile information. + (KJS::Profiler::willExecute): Same as above. + (KJS::Profiler::didExecute): Same as above. + (KJS::Profiler::insertStackNamesInTree): Follow the stack of the given names and if a sub-stack is not in the current tree, add it. + (KJS::Profiler::getStackNames): Get the names from the different passed in parameters and order them as a stack. + (KJS::Profiler::getFunctionName): Get the function name from the given parameter. + (KJS::Profiler::printDataSampleStyle): Print the current profiled information in a format that matches sample's output. + (KJS::Profiler::debugLog): + * profiler/Profiler.h: Added. + (KJS::Profiler::Profiler): + +2008-04-16 Sam Weinig + + Reviewed by Darin Adler. + + - Remove kjs_ prefix from strtod, dtoa, and freedtoa and put it + in the KJS namespace. + - Make strtod, dtoa, and freedtoa c++ functions instead of extern "C". + - Remove mode switching from dtoa. ~2% improvement on test 26. + - Removes all unnecessary #defines from dtoa code. + + * JavaScriptCore.exp: + * kjs/dtoa.cpp: + (KJS::ulp): + (KJS::b2d): + (KJS::d2b): + (KJS::ratio): + (KJS::strtod): + (KJS::freedtoa): + (KJS::dtoa): + * kjs/dtoa.h: + * kjs/function.cpp: + (KJS::parseInt): + * kjs/lexer.cpp: + (KJS::Lexer::lex): + * kjs/number_object.cpp: + (KJS::integer_part_noexp): + (KJS::numberProtoFuncToExponential): + * kjs/ustring.cpp: + (KJS::UString::from): + (KJS::UString::toDouble): + +2008-04-16 Alexey Proskuryakov + + Reviewed by Darin. + + Get rid of static execForCompareByStringForQSort in array_instance.cpp. + + No change on SunSpider, CelticKane or iBench JavaScript. + + * kjs/array_instance.cpp: + (KJS::ArraySortComparator::ArraySortComparator): + (KJS::ArraySortComparator::operator()): + (KJS::ArrayInstance::sort): + Switch slow case to std::sort, so that ExecState can be passed in a comparator. + +2008-04-16 Alexey Proskuryakov + + Reviewed by Adam Roben. + + MSVC build fix. + + * kjs/CommonIdentifiers.cpp: + * kjs/CommonIdentifiers.h: + * kjs/Parser.cpp: + * kjs/Parser.h: + * kjs/identifier.cpp: + * kjs/lexer.h: + * wtf/ThreadSpecific.h: + +2008-04-16 Alexey Proskuryakov + + Build fix. + + * kjs/date_object.cpp: + * kjs/date_object.h: + Don't include DateMath.h from date_object.h, as the latter is used from WebCore, while + where the former is not available. + +2008-04-16 Holger Hans Peter Freyther + + Unreviewed build fix for MSVC. It does not want to have + WTF in the KJS namespace. + + * kjs/CommonIdentifiers.h: + +2008-04-16 Holger Hans Peter Freyther + + Unreviewed build fix for gcc. + + ::msToGregorianDateTime is not known to it. + + * kjs/date_object.cpp: + (KJS::DateInstance::msToGregorianDateTime): + +2008-04-16 Alexey Proskuryakov + + Reviewed by Oliver Hunt. + + Initialize threadMapMutex safely (as already done in ThreadingWin). + + * wtf/ThreadingGtk.cpp: + (WTF::threadMapMutex): + (WTF::initializeThreading): + * wtf/ThreadingPthreads.cpp: + (WTF::threadMapMutex): + (WTF::initializeThreading): + +2008-04-16 Alexey Proskuryakov + + Reviewed by Adam Roben. + + Cache Gregorian date/time structure on DateInstance objects for 1.027x SunSpider speedup + (1.65x on date-format-xparb, 1.13x on date-format-tofte). + + * kjs/DateMath.h: + (KJS::GregorianDateTime::copyFrom): Added. It presumably makes sense to keep GregorianDateTime + Noncopyable, so it's not just operator=. + + * kjs/date_object.h: Added a per-object cache. + + * kjs/date_object.cpp: + (KJS::DateInstance::DateInstance): + (KJS::DateInstance::msToGregorianDateTime): + (KJS::dateProtoFuncToString): + (KJS::dateProtoFuncToUTCString): + (KJS::dateProtoFuncToDateString): + (KJS::dateProtoFuncToTimeString): + (KJS::dateProtoFuncToLocaleString): + (KJS::dateProtoFuncToLocaleDateString): + (KJS::dateProtoFuncToLocaleTimeString): + (KJS::dateProtoFuncGetFullYear): + (KJS::dateProtoFuncGetUTCFullYear): + (KJS::dateProtoFuncToGMTString): + (KJS::dateProtoFuncGetMonth): + (KJS::dateProtoFuncGetUTCMonth): + (KJS::dateProtoFuncGetDate): + (KJS::dateProtoFuncGetUTCDate): + (KJS::dateProtoFuncGetDay): + (KJS::dateProtoFuncGetUTCDay): + (KJS::dateProtoFuncGetHours): + (KJS::dateProtoFuncGetUTCHours): + (KJS::dateProtoFuncGetMinutes): + (KJS::dateProtoFuncGetUTCMinutes): + (KJS::dateProtoFuncGetSeconds): + (KJS::dateProtoFuncGetUTCSeconds): + (KJS::dateProtoFuncGetTimezoneOffset): + (KJS::setNewValueFromTimeArgs): + (KJS::setNewValueFromDateArgs): + (KJS::dateProtoFuncSetYear): + (KJS::dateProtoFuncGetYear): + Use the cache when converting. + +2008-04-16 Alexey Proskuryakov + + Reviewed by Darin. + + Implement an abstraction for thread-specific storage, use it to get rid of some static objects. + + SunSpider results were not conclusive, possibly up to 0.2% slowdown. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + Added ThreadSpecific.h + + * wtf/ThreadSpecific.h: Added. + (WTF::::ThreadSpecific): + (WTF::::~ThreadSpecific): + (WTF::::get): + (WTF::::set): + (WTF::::destroy): + (WTF::T): + (WTF::::operator): + Only implemented for platforms that use pthreads. + + * kjs/CommonIdentifiers.cpp: + (KJS::CommonIdentifiers::shared): + * kjs/CommonIdentifiers.h: + * kjs/InitializeThreading.cpp: + (KJS::initializeThreading): + * kjs/Parser.cpp: + (KJS::parser): + * kjs/Parser.h: + * kjs/identifier.cpp: + (KJS::identifierTable): + (KJS::literalIdentifierTable): + (KJS::Identifier::initializeIdentifierThreading): + * kjs/identifier.h: + * kjs/lexer.cpp: + (KJS::lexer): + * kjs/lexer.h: + Make static instances per-thread. + +2008-04-15 Anders Carlsson + + Reviewed by Adam. + + Add ENABLE_OFFLINE_WEB_APPLICATIONS to FEATURE_DEFINES. + + * Configurations/JavaScriptCore.xcconfig: + +2008-04-15 Andre Poenitz + + Reviewed by Simon. + + Fix compilation with Qt namespaces + + Qt can be configured to have all of its classes inside a specified namespaces. + This is for example used in plugin/component environments like Eclipse. + + This change makes it possible to let the Qt port compile against a namespaced + Qt by the use of macros Qt provides to properly forward declare Qt classes in + the namespace. + + * wtf/unicode/qt4/UnicodeQt4.h: + +2008-04-14 Anders Carlsson + + Reviewed by Adam. + + Don't leak the prototype class. + + * API/JSClassRef.cpp: + (OpaqueJSClass::create): + +2008-04-14 Steve Falkenburg + + Fix build. + + * wtf/ThreadingWin.cpp: + +2008-04-14 Alexey Proskuryakov + + Reviewed by Adam Roben. + + https://bugs.webkit.org/show_bug.cgi?id=18488 + FastMalloc doesn't release thread-specific data on Windows + + * wtf/ThreadingWin.cpp: + (WTF::threadMapMutex): (WTF::initializeThreading): Call threadMapMutex once to initialize the static safely. + (WTF::ThreadFunctionInvocation::ThreadFunctionInvocation): Added a structure to wrap thread entry point and arguments. + (WTF::wtfThreadEntryPoint): Make sure to end all WTF threads with pthread_exit(), to give pthreads-win32 a chance to call + destructors of thread-specific data. + (WTF::createThread): Use _beginthreadex instead of CreateThread, because MSDN says so. Also removed a call to CreateEvent, + for which I could see no reason at all. + +2008-04-14 Alexey Proskuryakov + + Touched a file to make JavaScriptCore.vcproj rebuild. + + * wtf/MathExtras.h: + +2008-04-14 Adam Roben + + Windows build fix + + Rubberstamped by Alexey Proskuryakov. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Disable + the "potentially uninitialized variable" warning for grammar.cpp, as + it seems to be incorrect. yylval gets initialized by the lexer, but + MSVC doesn't seem to understand this. + +2008-04-11 Antti Koivisto + + Reviewed by Maciej. + + Add default hash for pairs of hashable types. + + * wtf/HashFunctions.h: + (WTF::PairHash::hash): + (WTF::PairHash::equal): + (WTF::): + +2008-04-11 Alexey Proskuryakov + + Reviewed by Geoff. + + Make DateMath.cpp thread safe. + + No measurable change on SunSpider (should be a very small speedup). + + * kjs/DateMath.cpp: + (KJS::mimimumYearForDST): (KJS::equivalentYearForDST): Got rid of double caching of the + same precomputed value. + (KJS::calculateUTCOffset): (KJS::getUTCOffset): Factored actual UTC offset calculation code + out of getUTCOffset(), and notification setup into initDateMath(). + + (KJS::initDateMath): Added. + + * kjs/DateMath.h: + * kjs/InitializeThreading.cpp: + (KJS::initializeThreading): + Added initDateMath(). + +2008-04-11 Alexey Proskuryakov + + Windows build fix. + + * kjs/grammar.y: + +2008-04-11 Alexey Proskuryakov + + Tiger build fix. Forward declaring a union didn't work for whatever reason, make the + parameters void*. + + * kjs/grammar.y: + * kjs/lexer.cpp: + (kjsyylex): + (KJS::Lexer::lex): + * kjs/lexer.h: + +2008-04-11 Alexey Proskuryakov + + Reviewed by Geoff. + + Generate a pure (re-entrant) parser with Bison. + + No change on SunSpider. + + * kjs/Parser.cpp: + (KJS::Parser::parse): + * kjs/grammar.y: + * kjs/lexer.cpp: + (kjsyylex): + (KJS::Lexer::lex): + * kjs/lexer.h: + Pass state as function arguments, instead of global data. Don't call lexer() as often as + before, as this function is about to become slower due to thread-specific storage. + + * kjs/function.cpp: + (KJS::isStrWhiteSpace): Don't call isSeparatorSpace() for 8-bit characters, as these are + already taken care of. This is a small speedup, compensating for a small slowdown caused + by switching Bison mode. + +2008-04-10 Alexey Proskuryakov + + Reviewed by Geoff. + + https://bugs.webkit.org/show_bug.cgi?id=18402 + REGRESSION: visited element handling is incorrect in nested join/toString calls + + No change on SunSpider total, possibly a tiny improvement (about 0.1%). + + Test: fast/js/array-tostring-and-join.html + + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::visitedElements): Store visited elements HashSet here, making it + common to toString/toLocalizedString/join again. + + * kjs/array_object.cpp: + (KJS::arrayProtoFuncToString): + (KJS::arrayProtoFuncToLocaleString): + (KJS::arrayProtoFuncJoin): + Got rid of static variables. Replaced UString with Vector to avoid O(n^2) behavior and + regain performance. + + * wtf/Vector.h: + (WTF::::resize): + (WTF::::grow): + (WTF::::reserveCapacity): + (WTF::::append): + (WTF::::insert): + Added null checks, so that Vector methods don't crash when out of memory. The caller should + check that data pointer is not null before proceeding. + +2008-04-10 Mark Rowe + + Reviewed by Maciej Stachowiak. + + Fix https://bugs.webkit.org/show_bug.cgi?id=18367 and the many dupes. + Bug 18367: Crash during celtic kane js speed 2007 test + + GCC 4.2 on x86_64 Linux decided to reorder the local variables in markCurrentThreadConservatively's + stack frame. This lead to the range of addresses the collector treated as stack to exclude the + contents of volatile registers that markCurrentThreadConservatively forces onto the stack. This was + leading to objects being prematurely collected if the only reference to them was via a register at + the time a collection occurred. + + The fix for this is to move the calculation of the top of the stack into a NEVER_INLINE function + that is called from markCurrentThreadConservatively. This forces the dummy variable we use for + determining the top of stack to be in a different stack frame which prevents the compiler from + reordering it relative to the registers that markCurrentThreadConservatively forces onto the stack. + + * kjs/collector.cpp: + (KJS::Collector::markCurrentThreadConservativelyInternal): + (KJS::Collector::markCurrentThreadConservatively): + * kjs/collector.h: + +2008-04-10 Adam Roben + + VC++ Express build fix + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: Link against user32.lib so + that anyone who links against WTF.lib will get user32.lib + automatically. + +2008-04-09 Adam Roben + + VC++ Express build fix + + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: Link against + user32.lib. + +2008-04-09 Adam Roben + + Build fix + + * JavaScriptCore.exp: Export isMainThread. + +2008-04-09 Adam Roben + + Build fix + + * wtf/AlwaysInline.h: Make sure to #include Platform.h before using + the macros it defines. + +2008-04-08 Mark Rowe + + Export WTF::initializeThreading() from JavaScriptCore. + + * JavaScriptCore.exp: + +2008-04-04 Sam Weinig + + Reviewed by Geoffrey Garen. + + First step in implementing the "split window" + + - Add a GlobalThisValue to ExecState which should be used + in places that used to implement the "use the global object + as this if null" rule. + - Factor out lookupGetter/lookupSetter into virtual methods + on JSObject so that they can be forwarded. + - Make defineGetter/defineSetter virtual methods for the same + reason. + - Have PrototypeReflexiveFunction store the globalObject used + to create it so that it can be used to get the correct thisObject + for eval. + + * API/JSObjectRef.cpp: + (JSObjectCallAsFunction): + * JavaScriptCore.exp: + * kjs/Activation.h: + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + (KJS::GlobalExecState::GlobalExecState): + * kjs/ExecState.h: + (KJS::ExecState::globalThisValue): + * kjs/ExecStateInlines.h: + (KJS::ExecState::ExecState): + (KJS::FunctionExecState::FunctionExecState): + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): + (KJS::JSGlobalObject::toGlobalObject): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): + (KJS::JSGlobalObject::JSGlobalObject): + * kjs/array_instance.cpp: + (KJS::CompareWithCompareFunctionArguments::CompareWithCompareFunctionArguments): + (KJS::compareWithCompareFunctionForQSort): + * kjs/array_object.cpp: + (KJS::arrayProtoFuncSort): + (KJS::arrayProtoFuncFilter): + (KJS::arrayProtoFuncMap): + (KJS::arrayProtoFuncEvery): + (KJS::arrayProtoFuncForEach): + (KJS::arrayProtoFuncSome): + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + (KJS::ActivationImp::toThisObject): + (KJS::globalFuncEval): + (KJS::PrototypeReflexiveFunction::PrototypeReflexiveFunction): + (KJS::PrototypeReflexiveFunction::mark): + * kjs/function.h: + (KJS::PrototypeReflexiveFunction::cachedGlobalObject): + * kjs/function_object.cpp: + (KJS::functionProtoFuncApply): + (KJS::functionProtoFuncCall): + * kjs/nodes.cpp: + (KJS::ExpressionNode::resolveAndCall): + (KJS::FunctionCallValueNode::evaluate): + (KJS::LocalVarFunctionCallNode::inlineEvaluate): + (KJS::ScopedVarFunctionCallNode::inlineEvaluate): + (KJS::FunctionCallBracketNode::evaluate): + (KJS::FunctionCallDotNode::inlineEvaluate): + * kjs/object.cpp: + (KJS::JSObject::call): + (KJS::JSObject::put): + (KJS::tryGetAndCallProperty): + (KJS::JSObject::lookupGetter): + (KJS::JSObject::lookupSetter): + (KJS::JSObject::toThisObject): + (KJS::JSObject::toGlobalObject): + (KJS::JSObject::fillGetterPropertySlot): + * kjs/object.h: + * kjs/object_object.cpp: + (KJS::objectProtoFuncLookupGetter): + (KJS::objectProtoFuncLookupSetter): + * kjs/string_object.cpp: + (KJS::replace): + +2008-04-08 Brady Eidson + + Encourage Windows to rebuild - AGAIN... + + * kjs/DateMath.cpp: + +2008-04-08 Adam Roben + + Mac build fix + + * JavaScriptCore.exp: Add callOnMainThread, and sorted the list. + +2008-04-08 Brady Eidson + + Rubberstamped by Adam Roben + + Touch some files to *strongly* encourage Windows to rebuilt with DOM_STORAGE enabled + + * kjs/DateMath.cpp: + +2008-04-08 Adam Roben + + Move callOnMainThread to WTF + + Reviewed by Alexey Proskuryakov. + + * GNUmakefile.am: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + Added new files. + + * wtf/MainThread.cpp: + * wtf/MainThread.h: + * wtf/gtk/MainThreadGtk.cpp: + * wtf/mac/MainThreadMac.mm: + * wtf/qt/MainThreadQt.cpp: + * wtf/win/MainThreadWin.cpp: + * wtf/wx/MainThreadWx.cpp: + Moved here from WebCore/platform. Replaced all instances of "WebCore" + with "WTF". + + * kjs/bool_object.cpp: Touched to force JavaScriptCore.vcproj to + build. + to the WTF namespace. + * wtf/ThreadingWin.cpp: + (WTF::initializeThreading): Call initializeMainThread. + +2008-04-07 Brady Eidson + + Add "ENABLE_DOM_STORAGE" to keep in sync with the rest of the project + + * Configurations/JavaScriptCore.xcconfig: + +2008-04-07 Adam Roben + + Windows build fix + + * wtf/ThreadingWin.cpp: Back out some changes I didn't mean to land. + +2008-04-07 Adam Roben + + Add WTF::isMainThread + + Reviewed by Alexey Proskuryakov. + + * wtf/Threading.h: Declare the new function. + * wtf/ThreadingGtk.cpp: + (WTF::initializeThreading): Initialize the main thread identifier. + (WTF::isMainThread): Added. + * wtf/ThreadingNone.cpp: Ditto ThreadingGtk.cpp. + (WTF::initializeThreading): + (WTF::isMainThread): + * wtf/ThreadingPthreads.cpp: Ditto. + (WTF::initializeThreading): + (WTF::isMainThread): + * wtf/ThreadingWin.cpp: Ditto. + (WTF::initializeThreading): + (WTF::isMainThread): + +2008-04-06 Alexey Proskuryakov + + Reviewed by Darin. + + Make UString thread-safe. + + No change on SunSpider total, although individual tests have changed a lot, up to 3%. + + * kjs/InitializeThreading.cpp: (KJS::initializeThreading): Call UString::null() to initialize + a static. + + * kjs/identifier.cpp: + (KJS::CStringTranslator::translate): + (KJS::UCharBufferTranslator::translate): + Use "true" for a boolean value instead of 1, because it's C++. + + * kjs/ustring.h: + (KJS::CString::adopt): Added a method to create from a char* buffer without copying. + (KJS::UString::Rep::ref): Removed an assertion for JSLock::lockCount, as it's no longer + necessary to hold JSLock when working with strings. + (KJS::UString::Rep::deref): Ditto. + (KJS::UString::Rep::isStatic): Added a field to quickly determine that this is an empty + or null static string. + + * kjs/ustring.cpp: + (KJS::): Removed normalStatBufferSize and statBufferSize, as there is no reason to have such + an advanced implementation of a debug-only ascii() method. Removed a long-obsolete comment + about UChar. + (KJS::UString::Rep::createCopying): Removed an assertion for JSLock::lockCount. + (KJS::UString::Rep::create): Ditto. + (KJS::UString::Rep::destroy): Ditto. Do not do anything for static null and empty strings, + as refcounting is not reliable for those. Reordered branches for a noticeable speed gain - + apparently this functiton is hot enough for SunSpider to see an effect from this! + (KJS::UString::null): Moved a star, added a comment. + (KJS::UString::cstring): Reimplemented to not call ascii(), which is not thread-safe. + (KJS::UString::ascii): Simplified statBuffer handling logic. + (KJS::UString::toDouble): Use cstring() instead of ascii(). + +2008-04-02 Mark Rowe + + Reviewed by Oliver Hunt. + + Ensure that debug symbols are generated for x86_64 and ppc64 builds. + + * Configurations/Base.xcconfig: + +2008-04-01 Christian Dywan + + Build fix for GCC 4.3. + + * wtf/unicode/icu/CollatorICU.cpp: include string.h + +2008-04-01 Alexey Proskuryakov + + Rubber-stamped by Darin. + + Turn off using 64-bit arithmetic on 32-bit hardware, as dtoa own code is faster than + compiler-provided emulation. + + 1% speedup on Acid3 test 26. + + * kjs/dtoa.cpp: + +2008-04-01 Alexey Proskuryakov + + Reviewed by Darin. + + Make MathExtras.h thread safe. + + * kjs/math_object.cpp: + (KJS::mathProtoFuncRandom): If threading is enabled, rely on initializeThreading to call + wtf_random_init(). + + * wtf/Threading.h: + * wtf/ThreadingGtk.cpp: + (WTF::initializeThreading): + * wtf/ThreadingNone.cpp: + (WTF::initializeThreading): + * wtf/ThreadingPthreads.cpp: + (WTF::initializeThreading): + * wtf/ThreadingWin.cpp: + (WTF::initializeThreading): + Call wtf_random_init(); made the function non-inline to avoid having to include too many + headers in Threading.h. + +2008-03-31 Eric Seidel + + Reviewed by darin. + + Make matching of regexps using ^ much faster + http://bugs.webkit.org/show_bug.cgi?id=18086 + + * pcre/pcre_compile.cpp: + (compileBranch): + (branchNeedsLineStart): + * pcre/pcre_exec.cpp: + (match): + (jsRegExpExecute): + * pcre/pcre_internal.h: + +2008-03-29 Alexey Proskuryakov + + Reviewed by Oliver Hunt. + + REGRESSION: Leak in KJS::initializeThreading() + + * kjs/InitializeThreading.cpp: (KJS::initializeThreading): There is no guarantee that + initializeThreading() is called only once; check that the mutex hasn't been already allocated. + +2008-03-29 Oliver Hunt + + Reviewed by Geoff. + + Bug 17924: Crash in KJS::ConstDeclNode::evaluate with |with| and |const| + + + + It turns out this is trivially avoidable if we just match firefox's + semantics and ensure that an assignment in a const declaration always + writes to the variable object. + + * kjs/nodes.cpp: + (KJS::ConstDeclNode::handleSlowCase): + +2008-03-28 Alexey Proskuryakov + + Reviewed by Sam Weinig. + + Fix a dtoa thread safety issue. + + WebCore can call kjs_strtod without holding JS lock, but we didn't have thread safety + compiled in for dtoa. + + This is a 0.5% regression on SunSpider, which Sam Weinig has volunteered to cover with + his recent improvement. + + * kjs/dtoa.cpp: + (Bigint::Balloc): + (Bigint::Bfree): + Changed to use fastMalloc/fastDelete - they are much faster than the dtoa custom version was + in the presence of locking (but somewhat slower in single-threaded case). + (Bigint::pow5mult): Got rid of the dreaded double-checked locking anti-pattern (had to + restructure the code to avoid significant performance implications). + (Bigint::lshift): Rewrote to avoid an allocation, if possible. + + (Bigint::rv_alloc): + (Bigint::kjs_freedtoa): + (Bigint::kjs_dtoa): + Check for USE(MULTIPLE_THREADS), not dtoa legacy MULTIPLE_THREADS. + + * kjs/InitializeThreading.cpp: Added. + (KJS::initializeThreading): + * kjs/InitializeThreading.h: Added. + Initialize threading at KJS level, if enabled. + + * kjs/dtoa.h: Expose dtoa mutex for KJS::initializeThreading. + + * kjs/testkjs.cpp: (kjsmain): Call initializeThreading. + + * JavaScriptCore.exp: Export KJS::initializeThreading. + + * GNUmakefile.am: + * JavaScriptCore.exp: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCoreSources.bkl: + * JavaScriptCore.xcodeproj/project.pbxproj: + Added InitializeThreading.{h,cpp}. + + * wtf/Threading.h: Removed a using directive for WTF::initializeThreading - it is only + to be called from KJS::initializeThreading, and having it in the global namespace is useless. + +2008-03-28 Brady Eidson + + Reviewed by Darin + + Export Unicode/UTF8.h and convertUTF16ToUTF8() for more flexible conversion in WebCore + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-03-27 Darin Adler + + Reviewed by Mark Rowe. + + Regular expressions with large nested repetition counts can have their + compiled length calculated incorrectly. + + * pcre/pcre_compile.cpp: + (multiplyWithOverflowCheck): + (calculateCompiledPatternLength): Check for overflow when dealing with nested repetition counts + and bail with an error rather than returning incorrect results. + +2008-03-26 Mark Rowe + + Rubber-stamped by Brady Eidson. + + Update FEATURE_DEFINES to be consistent with the other locations in which it is defined. + + * Configurations/JavaScriptCore.xcconfig: + +2008-03-26 Adam Roben + + Fix Bug 18060: Assertion failure (JSLock not held) beneath + JSCallbackObject::toString + + + + Reviewed by Geoff Garen. + + Bug fix: + + * API/JSCallbackObjectFunctions.h: + (KJS::JSCallbackObject::toString): Make the DropAllLocks + instance only be in scope while calling convertToType. + + Test: + + * API/testapi.c: + (MyObject_convertToType): Implement type conversion to string. + * API/testapi.js: Add a test for type conversion to string. + +2008-03-26 Adam Roben + + Windows build fix + + * kjs/array_instance.cpp: Touched this. + * wtf/HashFunctions.h: + (WTF::intHash): Added 8- and 16-bit versions of intHash. + +2008-03-26 Adam Roben + + Force JSC headers to be copied by touching a file + + * kjs/array_instance.cpp: + (KJS::ArrayInstance::getPropertyNames): + +2008-03-26 Adam Roben + + Windows build fix after r31324 + + Written with Darin. + + Added HashTable plumbing to support using wchar_t as a key type. + + * wtf/HashFunctions.h: + * wtf/HashTraits.h: + (WTF::): + +2008-03-26 Maciej Stachowiak + + Reviewed by Darin. + + - JSC part of fix for "SVG multichar glyph matching matches longest instead of first (affects Acid3 test 79)" + http://bugs.webkit.org/show_bug.cgi?id=18118 + + * wtf/HashFunctions.h: + (WTF::): + * wtf/HashTraits.h: + (WTF::): + +2008-03-26 Alexey Proskuryakov + + Reviewed by Darin. + + Cache C string identifiers by address, not value, assuming that C strings can only + be literals. + + 1% speedup on Acid3 test 26. + + * kjs/identifier.cpp: + (KJS::literalIdentifierTable): + (KJS::Identifier::add): + Added a new table to cache UString::Reps created from C strings by address. Elements are + never removed from this cache, as only predefined identifiers can get there. + + * kjs/identifier.h: + (KJS::Identifier::Identifier): Added a warning. + +2008-03-26 Alexey Proskuryakov + + Rubber-stamped by Maciej. + + An assertion was failing in function-toString-object-literals.html when parsing 1e-500. + The condition existed before, and got uncovered by turning compiled-out dtoa checks into + ASSERTs. + + The assertion was verifying that the caller wasn't constructing a Bigint from 0. + This might have had some reason behind it originally, but I couldn't find any, + and this doesn't look like a reasonable requirement. + + * kjs/dtoa.cpp: (d2b): Removed the assertion (two copies in different code paths). + +2008-03-25 Adam Roben + + Fix Bug 18077: Integrate testapi.c into the Windows build + + + + Reviewed by Steve Falkenburg. + + * JavaScriptCore.vcproj/testapi/testapi.vcproj: Added. + +2008-03-25 Adam Roben + + Make testapi.c compile under MSVC + + Currently you must compile testapi.c as C++ code since MSVC does not + support many C features that GCC does. + + Reviewed by Steve Falkenburg. + + * API/testapi.c: + (nan): Added an implementation of this for MSVC. + (assertEqualsAsUTF8String): Use malloc instead of dynamically-sized + stack arrays. + (assertEqualsAsCharactersPtr): Ditto. + (print_callAsFunction): Ditto. + (main): Ditto, and explicitly cast from UniChar* to JSChar*. + +2008-03-25 Adam Roben + + Stop using JavaScriptCore's custom stdbool.h and stdint.h on Windows + + We can't remove the os-win32 directory yet because other ports (at + least wx) are still relying on it. + + Reviewed by Steve Falkenburg. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + - Made all the include paths match the one for the Debug + configuration (these got out of sync in r30797) + - Removed os-win32 from the include path + - Removed os-win32 from the directories we copy to $WebKitOutputDir. + - Removed stdint.h from the project + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make: + Delete the files that we may have previously copied from the os-win32 + directory. + +2008-03-25 Alexey Proskuryakov + + Windows build fix. + + * kjs/dtoa.cpp: Include stdint.h. + +2008-03-25 Alexey Proskuryakov + + Rubber-stamped by Darin. + + Cleanup dtoa.cpp style. + + * kjs/dtoa.cpp: + (Bigint::Balloc): + (Bigint::Bfree): + (Bigint::multadd): + (Bigint::s2b): + (Bigint::hi0bits): + (Bigint::lo0bits): + (Bigint::i2b): + (Bigint::mult): + (Bigint::pow5mult): + (Bigint::lshift): + (Bigint::cmp): + (Bigint::diff): + (Bigint::ulp): + (Bigint::b2d): + (Bigint::d2b): + (Bigint::ratio): + (Bigint::): + (Bigint::match): + (Bigint::hexnan): + (Bigint::kjs_strtod): + (Bigint::quorem): + (Bigint::rv_alloc): + (Bigint::nrv_alloc): + (Bigint::kjs_freedtoa): + (Bigint::kjs_dtoa): + * kjs/dtoa.h: + +2008-03-24 Darin Adler + + Reviewed by Sam. + + - convert a JavaScript immediate number to a string more efficiently + + 2% speedup of Acid3 test 26 + + * kjs/JSImmediate.cpp: + (KJS::JSImmediate::toString): Take advantage of the fact that all immediate + numbers are integers, and use the faster UString function for formatting integers + instead of the slower one that works for floating point. I think this is a leftover + from when immediate numbers were floating point. + +2008-03-23 Sam Weinig + + Reviewed by Darin Adler. + + Fix http://bugs.webkit.org/show_bug.cgi?id=18048 + The "thisObject" parameter to JSEvaluateScript is not used properly + + Making passing a thisObject to JSEvaluateScript actually set the thisObject of the created + ExecState. + + * API/testapi.c: + (main): Add tests for setting the thisObject when calling JSEvaluateScript. + + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): Assign the thisObject to m_thisValue and remove the comment. + +2008-03-22 Jesse Ruderman + + Reviewed by Sam Weinig. Landed by eseidel. + + Make testkjs flush stdout after printing. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/testkjs.cpp: + (functionPrint): + +2008-03-21 Oliver Hunt + + Reviewed by Maciej. + + Optimise lookup of Math, undefined, NaN and Infinity + + Added a method to JSVariableObject to allow us to inject DontDelete properties + into the symbol table and localStorage. This results in a 0.4% progression in + SunSpider, with a 8% gain in math-partial-sums. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTableInsert): + +2008-03-21 Oliver Hunt + + Reviewed by Geoff Garen. + + Global properties that use LocalStorage are not correctly listed as enumerable. + + The problem was caused by JSObject::getPropertyAttributes not being aware + of the JSVariableObject SymbolTable. The fix is to make getPropertyAttributes + virtual and override in JSVariableObject. This does not produce any performance + regression. + + * JavaScriptCore.exp: + * kjs/JSVariableObject.cpp: + (KJS::JSVariableObject::getPropertyNames): + (KJS::JSVariableObject::getPropertyAttributes): + * kjs/JSVariableObject.h: + * kjs/object.h: + +2008-03-21 Arkadiusz Miskiewicz + + Webkit does not build on linux powerpc + + + + Reviewed by David Kilzer. + + * wtf/TCSpinLock.h: + (TCMalloc_SpinLock::Unlock): + +2008-03-21 Rodney Dawes + + Reviewed by Holger. + + http://bugs.webkit.org/show_bug.cgi?id=17981 + + Add javascriptcore_cppflags to Programs_minidom_CPPFLAGS. + + * GNUmakefile.am: + +2008-03-21 Alexey Proskuryakov + + Reviewed by Oliver Hunt. + + Consolidate static identifier initializers within CommonIdentifiers. + + No reliably measurable change on SunSpider; maybe a tiny improvement (within 0.2%). + + * kjs/CommonIdentifiers.h: Added static identifiers that were lazily initialized + throughout the code. + + * kjs/date_object.cpp: + (KJS::DateObjectImp::DateObjectImp): + * kjs/function_object.cpp: + (KJS::FunctionPrototype::FunctionPrototype): + * kjs/object_object.cpp: + (KJS::ObjectPrototype::ObjectPrototype): + * kjs/regexp_object.cpp: + (KJS::RegExpPrototype::RegExpPrototype): + Use the values from CommonIdentifiers. + + * kjs/lookup.h: Caching the identifier in a static wasn't a win on SunSpider, removed it. + + * kjs/value.h: + (KJS::jsNaN): We already have a shared NaN value, no need for a duplicate here. + + * wtf/MathExtras.h: + (wtf_atan2): Having local variables for numeric_limits constants is good for readability, + but there is no reason to keep them static. + + * JavaScriptCore.exp: Don't needlessly export JSGlobalObject::s_head. + +2008-03-20 Oliver Hunt + + Reviewed by Maciej. + + Fix for leak introduced by inline ScopeChainNode use + + To avoid any extra branches when managing an inline ScopeChainNode + in the ScopeChain the inline node gets inserted with a refcount of + 2. This meant than when the ScopeChain was destroyed the ScopeChainNodes + above the inline node would be leaked. + + We resolve this by manually popping the inline node in the + FunctionExecState destructor. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/ExecStateInlines.h: + (KJS::FunctionExecState::~FunctionExecState): + * kjs/scope_chain.h: + (KJS::ScopeChain::popInlineScopeNode): + +2008-03-20 Mark Rowe + + Reviewed by Sam Weinig. + + Ensure that the defines in FEATURE_DEFINES are sorted so that they will match the default settings of build-webkit. + This will prevent the world from being rebuilt if you happen to switch between building in Xcode and with build-webkit on the + command-line. + + * Configurations/JavaScriptCore.xcconfig: + +2008-03-20 David Krause + + Reviewed by David Kilzer. + + Fix http://bugs.webkit.org/show_bug.cgi?id=17923 + Bug 17923: ARM platform endian defines inaccurate + + * wtf/Platform.h: + Replaced !defined(__ARMEL__) check with !defined(__VFP_FP__) + for PLATFORM(MIDDLE_ENDIAN) + +2008-03-20 Maciej Stachowiak + + - fix build + + * JavaScriptCore.xcodeproj/project.pbxproj: install Activation.h as private + +2008-03-20 Maciej Stachowiak + + Reviewed by Oliver. + + - reduce function call overhead for 1.014x speedup on SunSpider + + I moved some functions from ExecState.cpp to ExecStateInline.h and + from JSGlobalObject.cpp to JSGlobalObject.h, and declared them + inline; machine function call overhead for these was hurting JS + funcion call overhead. + + * kjs/ExecState.cpp: + * kjs/ExecStateInlines.h: Added. + (KJS::ExecState::ExecState): + (KJS::ExecState::~ExecState): + (KJS::FunctionExecState::FunctionExecState): + (KJS::FunctionExecState::~FunctionExecState): + * kjs/JSGlobalObject.cpp: + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::pushActivation): + (KJS::JSGlobalObject::checkActivationCount): + (KJS::JSGlobalObject::popActivation): + * kjs/function.cpp: + +2008-03-19 Oliver Hunt + + Reviewed by Maciej. + + Avoid heap allocating the root scope chain node for eval and closure free functions + + Maciej suggested using an inline ScopeChainNode for functions that don't use eval + or closures as they are unable to ever capture the scope chain. This gives us a 2.4% + win in sunspider, a 15% win in controlflow-recursive, and big (>5%) wins in a number + of other tests. + + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + * kjs/ExecState.h: + * kjs/scope_chain.h: + (KJS::ScopeChain::push): + +2008-03-19 Mark Rowe + + Reviewed by Sam Weinig. + + Fix release build. + + * kjs/JSGlobalObject.cpp: Add missing #include. + +2008-03-19 Sam Weinig + + Reviewed by Anders Carlsson. + + Fix for + Crash occurs at KJS::Collector::collect() when loading web clip widgets with a PAC file + + Make the activeExecStates stack per JSGlobalObject instead of static to ensure + thread safety. + + * JavaScriptCore.exp: + * kjs/ExecState.cpp: + (KJS::InterpreterExecState::InterpreterExecState): + (KJS::InterpreterExecState::~InterpreterExecState): + (KJS::EvalExecState::EvalExecState): + (KJS::EvalExecState::~EvalExecState): + (KJS::FunctionExecState::FunctionExecState): + (KJS::FunctionExecState::~FunctionExecState): + * kjs/ExecState.h: + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::mark): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::activeExecStates): + * kjs/collector.cpp: + (KJS::Collector::collect): + (KJS::Collector::reportOutOfMemoryToAllExecStates): Iterate all JSGlobalObjects and report + the OutOfMemory condition to all the ExecStates in each. + +2008-03-19 Jasper Bryant-Greene + + Reviewed by Maciej Stachowiak. + + Fix http://bugs.webkit.org/show_bug.cgi?id=17941 + Bug 17941: C++-style comments in JavaScriptCore API + + * API/JSBase.h: + Remove C++-style comments from public JavaScriptCore API, replacing + with standard C90 block comments. + +2008-03-19 Mark Rowe + + Reviewed by Oliver Hunt. + + Fix http://bugs.webkit.org/show_bug.cgi?id=17939 + Bug 17939: Crash decompiling "const a = 1, b;" + + * kjs/nodes2string.cpp: + (KJS::ConstDeclNode::streamTo): Null-check the correct variable. + +2008-03-18 Oliver Hunt + + Reviewed by Mark Rowe. + + Bug 17929: Incorrect decompilation with |const|, comma + http://bugs.webkit.org/show_bug.cgi?id=17929 + + There were actually two bugs here. First we weren't correctly handling const + nodes with multiple declarations. The second issue was caused by us not + giving the correct precedence to the initialisers. + + * kjs/nodes2string.cpp: + (KJS::ConstDeclNode::streamTo): + +2008-03-18 Darin Adler + + Reviewed by Maciej. + + - Speed up JavaScript built-in properties by changing the + hash table to take advantage of the identifier objects + + 5% speedup for Acid3 test 26 + + * JavaScriptCore.exp: Updated. + * kjs/create_hash_table: Compute size of hash table large enough so that there + are no collisions, but don't generate the hash table. + * kjs/identifier.h: Made the add function that returns a PassRefPtr public. + * kjs/lexer.cpp: + (KJS::Lexer::lex): Updated for change to HashTable interface. + * kjs/lookup.cpp: + (KJS::HashTable::changeKeysToIdentifiers): Added. Finds the identifier for + each property so the equality comparision can be done with pointer comparision. + * kjs/lookup.h: Made the key be a union of char* with UString::Rep* so it can + hold identifiers. Added a keysAreIdentifiers flag to the HashTable. Changed + the Lookup functions to be member functions of HashTable instead. + * kjs/object.cpp: + (KJS::JSObject::deleteProperty): Update for change to HashTable. + (KJS::JSObject::findPropertyHashEntry): Ditto. + (KJS::JSObject::getPropertyAttributes): Ditto. + (KJS::JSObject::getPropertyNames): Ditto. + +2008-03-18 Mark Rowe + + Reviewed by Oliver Hunt. + + Fix http://bugs.webkit.org/show_bug.cgi?id=17925 and http://bugs.webkit.org/show_bug.cgi?id=17927. + - Bug 17925: Crash in KJS::JSObject::put after setting this.__proto__ + - Bug 17927: Hang after attempting to create circular __proto__ + + * kjs/object.cpp: + (KJS::JSObject::put): Silently ignore attempts to set __proto__ to a non-object, non-null value. + Return after setting the exception when an attempt to set a cyclic __proto__ is detected so that + the cyclic value is not set. + +2008-03-18 Maciej Stachowiak + + Reviewed by Oliver. + + - inline ActivationImp::init for 0.8% SunSpider speedup + + * kjs/Activation.h: + (KJS::ActivationImp::init): Moved here from function.cpp + * kjs/function.cpp: + +2008-03-18 Simon Hausmann + + Fix the Qt build. + + Including config.h like in the other .cpp files gets the #ifdeffery + correct for rand_s. + + * kjs/JSWrapperObject.cpp: + +2008-03-17 Darin Adler + + Reviewed by Maciej. + + JavaScriptCore changes to support a WebCore speedup. + + * JavaScriptCore.exp: Export the UString::Rep::computeHash function. + * wtf/HashSet.h: Added a find and contains function that take a translator, + like the add function. + +2008-03-18 Maciej Stachowiak + + Reviewed by Oliver. + + - a few micro-optimizations for 1.2% SunSpider speedup + + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): check for Return completion before Throw, + it is more likely. + * kjs/object.cpp: + (KJS::JSObject::put): When walking prototype chain, instead of + checking isObject (a virtual call), compare to jsNull (compare to + a constant) since null is the only non-object that can be in a + prototype chain. + +2008-03-17 Oliver Hunt + + Reviewed by Geoff. + + Optimise multi-scope function call resolution + + Refactor multiscope variable resolution and use to add + optimised FunctionCallResolveNode subclasses. + + 2.6% gain in sunspider performance, *25%* gain in controlflow-recursive + + * kjs/nodes.cpp: + (KJS::getSymbolTableEntry): + (KJS::ResolveNode::optimizeVariableAccess): + (KJS::getNonLocalSymbol): + (KJS::ExpressionNode::resolveAndCall): + (KJS::FunctionCallResolveNode::optimizeVariableAccess): + (KJS::FunctionCallResolveNode::inlineEvaluate): + (KJS::ScopedVarFunctionCallNode::inlineEvaluate): + (KJS::ScopedVarFunctionCallNode::evaluate): + (KJS::ScopedVarFunctionCallNode::evaluateToNumber): + (KJS::ScopedVarFunctionCallNode::evaluateToBoolean): + (KJS::ScopedVarFunctionCallNode::evaluateToInt32): + (KJS::ScopedVarFunctionCallNode::evaluateToUInt32): + (KJS::NonLocalVarFunctionCallNode::inlineEvaluate): + (KJS::NonLocalVarFunctionCallNode::evaluate): + (KJS::NonLocalVarFunctionCallNode::evaluateToNumber): + (KJS::NonLocalVarFunctionCallNode::evaluateToBoolean): + (KJS::NonLocalVarFunctionCallNode::evaluateToInt32): + (KJS::NonLocalVarFunctionCallNode::evaluateToUInt32): + * kjs/nodes.h: + (KJS::ScopedVarFunctionCallNode::): + (KJS::NonLocalVarFunctionCallNode::): + +2008-03-17 David Kilzer + + Don't define PLATFORM(MIDDLE_ENDIAN) on little endian ARM. + + Reviewed by Darin. + + See . + + * wtf/Platform.h: Added check for !defined(__ARMEL__) when defining + PLATFORM(MIDDLE_ENDIAN). + +2008-03-17 Oliver Hunt + + Reviewed by Geoff, Darin and Weinig. + + Add fast multi-level scope lookup + + Add logic and AST nodes to provide rapid variable resolution across + static scope boundaries. This also adds logic that allows us to skip + any static scopes that do not contain the variable to be resolved. + + This results in a ~2.5% speedup in SunSpider, and gives a 25-30% speedup + in some simple and ad hoc closure and global variable access tests. + + * JavaScriptCore.exp: + * kjs/Activation.h: + * kjs/JSGlobalObject.cpp: + * kjs/JSGlobalObject.h: + * kjs/JSVariableObject.cpp: + * kjs/JSVariableObject.h: + * kjs/function.cpp: + (KJS::ActivationImp::isDynamicScope): + * kjs/nodes.cpp: + (KJS::ResolveNode::optimizeVariableAccess): + (KJS::ScopedVarAccessNode::inlineEvaluate): + (KJS::ScopedVarAccessNode::evaluate): + (KJS::ScopedVarAccessNode::evaluateToNumber): + (KJS::ScopedVarAccessNode::evaluateToBoolean): + (KJS::ScopedVarAccessNode::evaluateToInt32): + (KJS::ScopedVarAccessNode::evaluateToUInt32): + (KJS::NonLocalVarAccessNode::inlineEvaluate): + (KJS::NonLocalVarAccessNode::evaluate): + (KJS::NonLocalVarAccessNode::evaluateToNumber): + (KJS::NonLocalVarAccessNode::evaluateToBoolean): + (KJS::NonLocalVarAccessNode::evaluateToInt32): + (KJS::NonLocalVarAccessNode::evaluateToUInt32): + (KJS::IfElseNode::optimizeVariableAccess): + (KJS::ScopeNode::optimizeVariableAccess): + * kjs/nodes.h: + (KJS::ScopedVarAccessNode::): + (KJS::NonLocalVarAccessNode::): + * kjs/object.h: + + 2008-03-16 weihongzeng + + Reviewed by Darin Adler. + + http://bugs.webkit.org/show_bug.cgi?id=15416 + Add support for mixed-endian processors + + * kjs/dtoa.cpp: Add IEEE_ARM, triggered by PLATFORM(MIDDLE_ENDIAN). + +2008-03-16 Kevin Ollivier + + Rubber stamped by Darin. + + Add set-webkit-configuration support for wx port, and centralize + build dir location setting. + + http://bugs.webkit.org/show_bug.cgi?id=17790 + + * jscore.bkl: + +2008-03-14 Steve Falkenburg + + PGO build fixes. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2008-03-14 Oliver Hunt + + Reviewed by Maciej. + + Add logic to track whether a function uses a locally scoped eval or requires a closure + + Now that we limit eval we can track those uses of eval that operate + in the local scope and functions that require a closure. We track + this information during initial parsing to avoid yet another tree + walk. + + * JavaScriptCore.exp: + * kjs/NodeInfo.h: + * kjs/Parser.cpp: + (KJS::Parser::didFinishParsing): + * kjs/Parser.h: + (KJS::Parser::parse): + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::ScopeNode::ScopeNode): + (KJS::ProgramNode::ProgramNode): + (KJS::ProgramNode::create): + (KJS::EvalNode::EvalNode): + (KJS::EvalNode::create): + (KJS::FunctionBodyNode::FunctionBodyNode): + (KJS::FunctionBodyNode::create): + * kjs/nodes.h: + (KJS::ScopeNode::): + (KJS::ScopeNode::usesEval): + (KJS::ScopeNode::needsClosure): + +2008-03-14 Geoffrey Garen + + Reviewed by Beth Dakin. + + Fixed another problem with Vector::shrinkCapacity. + + moveOverlapping isn't good enough for the case where the buffer hasn't + changed, because it still destroys the contents of the buffer. + + * wtf/Vector.h: + (WTF::::shrinkCapacity): Changed to explicitly check whether the call + to allocateBuffer produced a new buffer. If it didn't, there's no need + to move. + +2008-03-14 Geoffrey Garen + + Reviewed by Beth Dakin. + + Fixed a few problems with Vector::shrinkCapacity that I noticed in testing. + + * wtf/Vector.h: + (WTF::VectorBufferBase::deallocateBuffer): Clear our m_buffer pointer + when we deallocate m_buffer, in case we're not asked to reallocate a new + buffer. (Otherwise, we would use a stale m_buffer if we were asked to + perform any operations after shrinkCapacity was called.) + + (WTF::VectorBuffer::allocateBuffer): Made VectorBuffer with inline + capacity aware that calls to allocateBuffer might be shrinks, rather + than grows, so we shouldn't allocate a new buffer on the heap unless + our inline buffer is too small. + + (WTF::::shrinkCapacity): Call resize() instead of just setting m_size, + so destructors run. Call resize before reallocating the buffer to make + sure that we still have access to the objects we need to destroy. Call + moveOverlapping instead of move, since a call to allocateBuffer on an + inline buffer may produce identical storage. + +2008-03-14 Alexey Proskuryakov + + Reviewed by Darin. + + Get rid of a localime() call on platforms that have better alternatives. + + * kjs/DateMath.h: Added getLocalTime(); + + * kjs/DateMath.cpp: + (KJS::getLocalTime): + (KJS::getDSTOffsetSimple): + Implementation moved from getDSTOffsetSimple(). + + * kjs/date_object.cpp: + (KJS::DateObjectImp::callAsFunction): Switched to getLocalTime(). + +2008-03-14 David D. Kilzer + + Unify concept of enabling the Mac Java bridge. + + Reviewed by Darin and Anders. + + * wtf/Platform.h: Define ENABLE_MAC_JAVA_BRIDGE here. + +2008-03-13 Mark Mentovai + + Reviewed by eseidel. Landed by eseidel. + + * wtf/FastMalloc.cpp: #include outside of any + namespaces. + +2008-03-13 Mark Mentovai + + Reviewed by eseidel. Landed by eseidel. + + * pcre/pcre_exec.cpp: Fix misnamed variable, allowing -DDEBUG build + to succeed. + * wtf/ThreadingPthreads.cpp: #include for gettimeofday + in non-pch build. + +2008-03-13 Steve Falkenburg + + PGO build fixes. + + Disable PGO for normal release builds. + Added work-in-progress Release_PGOInstrument/Release_PGOOptimize targets. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2008-03-13 Beth Dakin + + Reviewed by Geoff. + + Adding new functionality to Vector. Currently all of the shrink and + resize functions on Vector only shrink the size of the Vector, not + the capacity. For the Vector to take up as little memory as + possible, though, it is necessary to be able to shrink the capacity + as well. So this patch adds that functionality. + + I need this for a speed up I am working on, and Geoff wants to use + it in a speed up he is working on also, so he asked me to commit it + now. + + * wtf/Vector.h: + (WTF::VectorBufferBase::allocateBuffer): + (WTF::::shrinkCapacity): + +2008-03-13 Simon Hausmann + + Reviewed by Adam Roben. + + Attempt at fixing the Qt/Windows build bot. Quote using double-quotes + instead of single quotes. + + * pcre/dftables: + +2008-03-12 Steve Falkenburg + + Build fix. + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + +2008-03-12 Alp Toker + + Another autotools testkjs build fix attempt. + + * GNUmakefile.am: + +2008-03-12 Alp Toker + + Attempt to fix the autotools testkjs build on systems with + non-standard include paths. + + * GNUmakefile.am: + +2008-03-11 Alexey Proskuryakov + + Reviewed by Darin. + + REGRESSION: Crash at WTF::Collator::CreateCollator() running fast/js/kde/StringObject.html on Windows + + * wtf/unicode/icu/CollatorICU.cpp: + (WTF::Collator::createCollator): Check for null (== user default) m_locale before calling strcmp. + +2008-03-11 Steve Falkenburg + + Disable LTCG/PGO for grammar.cpp and nodes.cpp. + PGO on these files causes us to hang. + + Copy newer vsprops files from relative WebKitLibraries path to environment variable based path. + + Reviewed by Oliver. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make: + +2008-03-10 Darin Adler + + - Windows build fix + + * kjs/function.cpp: (KJS::decode): Initialize variable. + +2008-03-10 Brent Fulgham + + Windows build fix + + Reviewed by Adam. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make: + Set the PATH to include Cygwin before running touch. + +2008-03-10 Eric Seidel + + Build fix for JSC on windows. + + * API/JSStringRefCF.cpp: + (JSStringCreateWithCFString): + * kjs/function.cpp: + (KJS::decode): + * kjs/nodes2string.cpp: + (KJS::escapeStringForPrettyPrinting): + +2008-03-10 Eric Seidel + + No review, build fix only. + + Attempt to fix the windows build? + + * kjs/ustring.h: change unsigned short to UChar + +2008-03-10 Eric Seidel + + Reviewed by Darin. + + Remove KJS::UChar, use ::UChar instead + http://bugs.webkit.org/show_bug.cgi?id=17017 + + * API/JSStringRef.cpp: + (JSStringCreateWithCharacters): + (JSStringCreateWithUTF8CString): + * API/JSStringRefCF.cpp: + (JSStringCreateWithCFString): + * JavaScriptCore.exp: + * kjs/Parser.h: + * kjs/function.cpp: + (KJS::decode): + (KJS::parseInt): + (KJS::parseFloat): + (KJS::globalFuncEscape): + (KJS::globalFuncUnescape): + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::construct): + * kjs/identifier.cpp: + (KJS::Identifier::equal): + (KJS::CStringTranslator::translate): + * kjs/interpreter.h: + * kjs/lexer.cpp: + (KJS::Lexer::setCode): + (KJS::Lexer::shift): + (KJS::Lexer::lex): + (KJS::Lexer::convertUnicode): + (KJS::Lexer::makeIdentifier): + * kjs/lookup.cpp: + (KJS::keysMatch): + * kjs/nodes2string.cpp: + (KJS::escapeStringForPrettyPrinting): + (KJS::SourceStream::operator<<): + * kjs/regexp.cpp: + (KJS::RegExp::RegExp): + (KJS::RegExp::match): + * kjs/string_object.cpp: + (KJS::substituteBackreferences): + (KJS::stringProtoFuncCharCodeAt): + (KJS::stringProtoFuncToLowerCase): + (KJS::stringProtoFuncToUpperCase): + (KJS::stringProtoFuncToLocaleLowerCase): + (KJS::stringProtoFuncToLocaleUpperCase): + * kjs/ustring.cpp: + (KJS::UString::Rep::computeHash): + (KJS::UString::UString): + (KJS::UString::append): + (KJS::UString::ascii): + (KJS::UString::operator=): + (KJS::UString::is8Bit): + (KJS::UString::toStrictUInt32): + (KJS::UString::find): + (KJS::operator==): + (KJS::operator<): + (KJS::compare): + (KJS::UString::UTF8String): + * kjs/ustring.h: + * pcre/pcre.h: + +2008-03-09 Steve Falkenburg + + Stop Windows build if an error occurs in a prior project. + + Rubber stamped by Darin. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make: + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: + +2008-03-09 J¸rg Billeter + + Reviewed by Alp Toker. + + Conditionalise ICU for Unicode in the GTK+ port. + + * wtf/Platform.h: + +2008-03-07 David D. Kilzer + + Unify concept of enabling Netscape Plug-in API (NPAPI). + + Reviewed by Darin. + + * wtf/Platform.h: Define ENABLE_NETSCAPE_PLUGIN_API here. + +2008-03-07 Geoffrey Garen + + Reviewed by Darin Adler. + + Fixed Stricter (ES4) eval semantics + + The basic rule is: + + - "eval(s)" is treated as an operator that gives the ES3 eval behavior. + ... but only if there is no overriding declaration of "eval" in scope. + - All other invocations treat eval as a function that evaluates a + script in the context of its "this" object. + ... but if its "this" object is not the global object it was + originally associated with, eval throws an exception. + + Because only expressions of the form "eval(s)" have access to local + scope, the compiler can now statically determine whether a function + needs local scope to be dynamic. + + * kjs/nodes.h: Added FunctionCallEvalNode. It works just like + FuncationCallResolveNode, except it statically indicates that the node + may execute eval in the ES3 way. + * kjs/nodes.cpp: + * kjs/nodes2string.cpp: + + * tests/mozilla/expected.html: This patch happens to fix a Mozilla JS + test, but it's a bit of a pyrrhic victory. The test intends to test + Mozilla's generic API for calling eval on any object, but, in reality, + we only support calling eval on the global object. + +2008-03-06 Steve Falkenburg + + Build fix. + + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: + +2008-03-06 Steve Falkenburg + + Build fix. + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + +2008-03-06 Alp Toker + + Fix the build fix in r30845 to support out-of-tree builds. + + * GNUmakefile.am: + +2008-03-06 Steve Falkenburg + + Build fix. + + * wtf/ThreadingWin.cpp: + (WTF::ThreadCondition::timedWait): + +2008-03-06 Darin Adler + + - another small step towards fixing the Qt build + + * JavaScriptCore.pri: Remove more references to the now-obsolete bindings directory. + +2008-03-06 Darin Adler + + - a small step towards fixing the Qt build + + * JavaScriptCore.pri: Remove references to files no longer present in JavaScriptCore/bindings. + +2008-03-06 Brady Eidson + + Gtk Build fix + + * wtf/ThreadingGtk.cpp: + (WTF::ThreadCondition::timedWait): + +2008-03-06 Alexey Proskuryakov + + Wx build fix. + + * wtf/unicode/icu/CollatorICU.cpp: + (WTF::Collator::userDefault): Put ICU workaround under both PLATFORM(DARWIN) and + PLATFORM(CF) checks, so that each port can decide if it wants to use CF on Mac for it. + +2008-03-06 Brady Eidson + + Reviewed by Darin + + Add a timedWait() method to ThreadCondition + + * JavaScriptCore.exp: + + * wtf/Threading.h: + + * wtf/ThreadingGtk.cpp: + (WTF::ThreadCondition::timedWait): + + * wtf/ThreadingNone.cpp: + (WTF::ThreadCondition::timedWait): + + * wtf/ThreadingPthreads.cpp: + (WTF::ThreadCondition::timedWait): + + * wtf/ThreadingWin.cpp: + (WTF::ThreadCondition::timedWait): Needs implementation + +2008-03-06 Alexey Proskuryakov + + More build fixes. + + * jscore.bkl: Add the wtf/unicode directory. + * wtf/unicode/CollatorDefault.cpp: + (WTF::Collator::userDefault): Use a constructor that does exist. + * wtf/unicode/icu/CollatorICU.cpp: Mac build fix for case-sensitive file systems. + +2008-03-06 Darin Adler + + - try to fix the Qt build + + * JavaScriptCore.pri: Add the wtf/unicode directory. + +2008-03-06 Darin Adler + + - try to fix the GTK build + + * GNUmakefile.am: Add a -I for the wtf/unicode directory. + +2008-03-06 Darin Adler + + - try to fix the Mac build + + * icu/unicode/parseerr.h: Copied from ../WebCore/icu/unicode/parseerr.h. + * icu/unicode/ucol.h: Copied from ../WebCore/icu/unicode/ucol.h. + * icu/unicode/uloc.h: Copied from ../WebCore/icu/unicode/uloc.h. + * icu/unicode/unorm.h: Copied from ../WebCore/icu/unicode/unorm.h. + * icu/unicode/uset.h: Copied from ../WebCore/icu/unicode/uset.h. + +2008-03-06 Alexey Proskuryakov + + Reviewed by Darin. + + Need to create a Collator abstraction for WebCore and JavaScriptCore + + * wtf/Threading.h: + (WTF::initializeThreading): + * wtf/ThreadingGtk.cpp: + (WTF::initializeThreading): + * wtf/ThreadingNone.cpp: + * wtf/ThreadingPthreads.cpp: + * wtf/ThreadingWin.cpp: + Added AtomicallyInitializedStatic. + + * kjs/string_object.cpp: (KJS::localeCompare): Changed to use Collator. + + * GNUmakefile.am: + * JavaScriptCore.exp: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + Added new fiiles to projects. + + * wtf/unicode/Collator.h: Added. + (WTF::Collator::): + * wtf/unicode/CollatorDefault.cpp: Added. + (WTF::Collator::Collator): + (WTF::Collator::~Collator): + (WTF::Collator::setOrderLowerFirst): + (WTF::Collator::collate): + * wtf/unicode/icu/CollatorICU.cpp: Added. + (WTF::cachedCollatorMutex): + (WTF::Collator::Collator): + (WTF::Collator::~Collator): + (WTF::Collator::setOrderLowerFirst): + (WTF::Collator::collate): + (WTF::Collator::createCollator): + (WTF::Collator::releaseCollator): + +2008-03-05 Kevin Ollivier + + Fix the wx build after the bindings move. + + * JavaScriptCoreSources.bkl: + * jscore.bkl: + +2008-03-05 Alp Toker + + GTK+ build fix for breakage introduced in r30800. + + Track moved bridge sources from JavaScriptCore to WebCore. + + * GNUmakefile.am: + +2008-03-05 Brent Fulgham + + Reviewed by Adam Roben. + + Remove definition of WTF_USE_SAFARI_THEME from wtf/Platform.h + because the PLATFORM(CG) flag is not set until config.h has + already included this file. + + * wtf/Platform.h: Remove useless definition of WTF_USE_SAFARI_THEME + +2008-03-05 Brady Eidson + + Reviewed by Alexey and Mark Rowe + + Fix for - Reproducible crash on storage/execute-sql-args.html + + DatabaseThread::unscheduleDatabaseTasks() manually filters through a MessageQueue, + removing particular items for Databases that were shutting down. + + This filtering operation is not atomic, and therefore causes a race condition with the + MessageQueue waking up and reading from the message queue. + + The end result was an attempt to dereference a null DatabaseTask. Timing-wise, this never + seemed to happen in a debug build, otherwise an assertion would've caught it. Replacing that + assertion with a crash in a release build is what revealed this bug. + + * wtf/MessageQueue.h: + (WTF::::waitForMessage): Tweak the waiting logic to check the queue's empty state then go back + to sleep if the queue was empty - checking m_killed each time it wakes up. + +2008-03-05 David D. Kilzer + + Remove unused header includes from interpreter.cpp. + + Reviewed by Darin. + + * kjs/interpreter.cpp: Remove unused header includes. + +2008-03-05 Anders Carlsson + + Reviewed by Sam. + + Remove bindings/. + + * bindings: Removed. + +2008-03-05 Anders Carlsson + + Don't build bindings/ anymore. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2008-03-05 Anders Carlsson + + Reviewed by Geoff. + + Don't build JavaScriptCore/bindings. + + * JavaScriptCore.exp: + Export a couple of new functions. + + * JavaScriptCore.xcodeproj/project.pbxproj: + Remove bindings/ + + * kjs/config.h: + No need to define HAVE_JNI anymore. + + * kjs/interpreter.cpp: + Remove unnecessary include. + +2008-03-05 David D. Kilzer + + Allow override of default script file name using command-line argument. + + Reviewed by Adele. + + * API/minidom.c: + (main): Allow first command-line argument to override the default script + file name of "minidom.js". + * API/testapi.c: + (main): Allow first command-line argument to override the default script + file name of "testapi.js". + +2008-03-04 Mark Rowe + + Mac build fix. + + * JavaScriptCore.exp: Add new symbol to exports file. + +2008-03-03 Oliver Hunt + + Reviewed by Anders. + + Make ForInNode check for the timeout interrupt + + * kjs/nodes.cpp: + (KJS::ForInNode::execute): + +2008-03-02 Brent Fulgham + + Reviewed by Alp Toker. + + http://bugs.webkit.org/show_bug.cgi?id=17415 + GTK Build (using autotools) on Mac OS (DarwinPorts) Fails + + Add -lstdc++ to link flags for minidom program. This corrects + a build error for the GTK+ on Mac OS. + + * GNUmakefile.am: + +2008-03-01 Mark Rowe + + Reviewed by Tim Hatcher. + + Update Xcode configuration to support building debug and release from the mysterious future. + + * Configurations/Base.xcconfig: + * Configurations/DebugRelease.xcconfig: + +2008-02-29 Brent Fulgham + + http://bugs.webkit.org/show_bug.cgi?id=17483 + Implement scrollbars on Windows (Cairo) + + Reviewed by Adam Roben. + + * wtf/Platform.h: + +2008-02-29 Adam Roben + + Remove unused DebuggerImp::abort and DebuggerImp::aborted + + Reviewed by Tim and Sam. + + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::construct): + * kjs/internal.h: + (KJS::DebuggerImp::DebuggerImp): + * kjs/nodes.cpp: + (KJS::Node::handleException): + (KJS::FunctionBodyNodeWithDebuggerHooks::execute): + +2008-02-28 Eric Christopher + + Reviewed by Geoffrey Garen. + + ** TOTAL **: 1.005x as fast 2867.6ms +/- 0.4% 2853.2ms +/- 0.3% significant + + * kjs/nodes.cpp: Tell the compiler that exceptions are unexpected (for + the sake of branch prediction and code organization). + +2008-02-27 Alexey Proskuryakov + + Reviewed by Sam Weinig. + + http://bugs.webkit.org/show_bug.cgi?id=17030 + Small buffer overflow within initialization + + * kjs/date_object.cpp: + (KJS::DateObjectFuncImp::callAsFunction): + (KJS::parseDate): + Remove unnecessary and incorrect memset() calls - GregorianDateTime can initialize itself. + +2008-02-25 Sam Weinig + + Reviewed by Dan Bernstein. + + - Add a variant of remove that takes a position and a length. + + * wtf/Vector.h: + (WTF::Vector::remove): + +2008-02-25 Mark Mentovai + + Reviewed by Mark Rowe. + + Enable CollectorHeapIntrospector to build by itself, as well as in an AllInOneFile build. + http://bugs.webkit.org/show_bug.cgi?id=17538 + + * kjs/CollectorHeapIntrospector.cpp: Provide "using" declaration for + WTF::RemoteMemoryReader. + * kjs/collector.h: Move CollectorHeap declaration here... + * kjs/collector.cpp: ... from here. + +2008-02-25 Darin Adler + + Reviewed by Adam. + + * JavaScriptCore.exp: Sort the contents of this file. + +2008-02-25 Adam Roben + + MSVC build fix + + * kjs/testkjs.cpp: + (functionQuit): Don't add a return statement after exit(0) for MSVC. + +2008-02-24 Sam Weinig + + Reviewed by Mark Rowe. + + http://bugs.webkit.org/show_bug.cgi?id=17529 + Add support for reading from stdin from testkjs + + * kjs/testkjs.cpp: + (GlobalObject::GlobalObject): Add readline function to global object. + (functionReadline): Added. Reads characters from stdin until a '\n' or + EOF is encountered. The input is returned as a String to the caller. + +2008-02-24 Sam Weinig + + Reviewed by Mark Rowe. + + http://bugs.webkit.org/show_bug.cgi?id=17528 + Give testkjs a bath + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: Make the testkjs.cpp use 4 space indentation. + * kjs/testkjs.cpp: + (StopWatch::getElapsedMS): + (GlobalObject::className): + (GlobalObject::GlobalObject): + Rename GlobalImp to GlobalObject and setup the global functions + in the GlobalObject's constructor. Also, use static functions for + the implementation so we can use the standard PrototypeFunction + class and remove TestFunctionImp. + (functionPrint): Move print() functionality here. + (functionDebug): Move debug() functionality here. + (functionGC): Move gc() functionality here. + (functionVersion): Move version() functionality here. + (functionRun): Move run() functionality here. + (functionLoad): Move load() functionality here. + (functionQuit): Move quit() functionality here. + (prettyPrintScript): Fix indentation. + (runWithScripts): Since all the functionality of createGlobalObject is + now in the GlobalObject constructor, just call new here. + (parseArguments): Fix indentation. + (kjsmain): Ditto + (fillBufferWithContentsOfFile): Ditto. + +2008-02-24 Sam Weinig + + Reviewed by Oliver Hunt and Mark Rowe. + + http://bugs.webkit.org/show_bug.cgi?id=17505 + Add support for getting command line arguments in testkjs + + - This slightly changes the behavior of parsing arguments by requiring + a '-f' before all files. + + * kjs/testkjs.cpp: + (createGlobalObject): Add a global property called 'arguments' which + contains an array with the parsed arguments as strings. + (runWithScripts): Pass in the arguments vector so that it can be passed + to the global object. + (parseArguments): Change parsing rules to require a '-f' before any script + file. After all '-f' and '-p' arguments have been parsed, the remaining + are added to the arguments vector and exposed to the script. If there is a + chance of ambiguity (the user wants to pass the string '-f' to the script), + the string '--' can be used separate the options from the pass through + arguments. + (kjsmain): + +2008-02-24 Dan Bernstein + + Reviewed by Darin Adler. + + - fix http://bugs.webkit.org/show_bug.cgi?id=17511 + REGRESSION: Reproducible crash in SegmentedSubstring::SegmentedSubstring(SegmentedSubstring const&) + + * wtf/Deque.h: + (WTF::::expandCapacityIfNeeded): Fixed the case where m_start and m_end + are both zero but the buffer capacity is non-zero. + (WTF::::prepend): Added validity checks. + +2008-02-23 Jan Michael Alonzo + + Rubber stamped by Darin. + + Add separator '\' after libJavaScriptCore_la_LIBADD and cleanup + whitespaces introduced in the previous commit. + + * GNUmakefile.am: + +2008-02-23 Jan Michael Alonzo + + * GNUmakefile.am: Add GLOBALDEPS for testkjs and minidom. + +2008-02-23 Darin Adler + + Reviewed by Anders. + + - http://bugs.webkit.org/show_bug.cgi?id=17496 + make Deque use a circular array; add iterators + + * wtf/Deque.h: Wrote an all-new version of this class that uses a circular + buffer. Growth policy is identical to vector. Added iterators. + + * wtf/Vector.h: Made two small refinements while using this to implement + Deque: Made VectorBufferBase derive from Noncopyable, which would have + saved me some debugging time if it had been there. Renamed Impl and + m_impl to Buffer and m_buffer. + +2008-02-23 Darin Adler + + Reviewed by Anders. + + - http://bugs.webkit.org/show_bug.cgi?id=17067 + eliminate attributes parameter from JSObject::put for speed/clarity + + * API/JSCallbackObject.h: Removed attribute arguments. + * API/JSCallbackObjectFunctions.h: + (KJS::JSCallbackObject::put): Ditto. + * API/JSObjectRef.cpp: + (JSObjectSetProperty): Use initializeVariable or putDirect when necessary + to set attribute values. + * JavaScriptCore.exp: Updated. + * bindings/objc/objc_runtime.h: Removed attribute arguments. + * bindings/objc/objc_runtime.mm: + (ObjcFallbackObjectImp::put): Ditto. + * bindings/runtime_array.cpp: + (RuntimeArray::put): Ditto. + * bindings/runtime_array.h: Ditto. + * bindings/runtime_object.cpp: + (RuntimeObjectImp::put): Ditto. + * bindings/runtime_object.h: Ditto. Also removed canPut which was only + called from one place in WebCore that can use hasProperty instead. + + * kjs/Activation.h: Removed attribute argument from put and added the new + initializeVariable function that's used to put variables in variable objects. + Also made isActivationObject a const member. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::put): Removed attribute argument. + (KJS::JSGlobalObject::initializeVariable): Added. Used to give variables + their initial values, which can include the read-only property. + (KJS::JSGlobalObject::reset): Removed obsolete comments about flags. + Removed Internal flag, which is no longer needed. + * kjs/JSGlobalObject.h: More of the same. + + * kjs/JSVariableObject.h: Added pure virtual initializeVariable function. + (KJS::JSVariableObject::symbolTablePut): Removed checkReadOnly flag; we always + check read-only. + (KJS::JSVariableObject::symbolTableInitializeVariable): Added. + + * kjs/array_instance.cpp: + (KJS::ArrayInstance::put): Removed attribute argument. + * kjs/array_instance.h: Ditto. + + * kjs/function.cpp: + (KJS::FunctionImp::put): Ditto. + (KJS::Arguments::put): Ditto. + (KJS::ActivationImp::put): Ditto. + (KJS::ActivationImp::initializeVariable): Added. + * kjs/function.h: Removed attribute arguments. + + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::construct): Removed Internal flag. + + * kjs/lookup.h: + (KJS::lookupPut): Removed attributes argument. Also changed to use putDirect + instead of calling JSObject::put. + (KJS::cacheGlobalObject): Ditto. + + * kjs/nodes.cpp: + (KJS::ConstDeclNode::handleSlowCase): Call initializeVariable to initialize + the constant. + (KJS::ConstDeclNode::evaluateSingle): Ditto. + (KJS::TryNode::execute): Use putDirect to set up the new object. + (KJS::FunctionBodyNode::processDeclarations): Removed Internal. + (KJS::ProgramNode::processDeclarations): Ditto. + (KJS::EvalNode::processDeclarations): Call initializeVariable to initialize + the variables and functions. + (KJS::FuncDeclNode::makeFunction): Removed Internal. + (KJS::FuncExprNode::evaluate): Ditto. + + * kjs/object.cpp: Removed canPut, which was only being used in one code path, + not the normal high speed one. + (KJS::JSObject::put): Removed attribute argument. Moved the logic from + canPut here, in the one code ath that was still using it. + * kjs/object.h: Removed Internal attribute, ad canPut function. Removed the + attributes argument to the put function. Made isActivationObject const. + + * kjs/regexp_object.cpp: + (KJS::RegExpImp::put): Removed attributes argument. + (KJS::RegExpImp::putValueProperty): Ditto. + (KJS::RegExpObjectImp::put): Ditto. + (KJS::RegExpObjectImp::putValueProperty): Ditto. + * kjs/regexp_object.h: Ditto. + + * kjs/string_object.cpp: + (KJS::StringInstance::put): Removed attributes argument. + * kjs/string_object.h: Ditto. + +2008-02-23 Jan Michael Alonzo + + Not reviewed, Gtk build fix. + + * kjs/testkjs.pro: + +2008-02-23 Alexey Proskuryakov + + Windows build fix - move ThreadCondition implementation from WebCore to WTF. + + * wtf/ThreadingWin.cpp: + (WTF::ThreadCondition::ThreadCondition): + (WTF::ThreadCondition::~ThreadCondition): + (WTF::ThreadCondition::wait): + (WTF::ThreadCondition::signal): + (WTF::ThreadCondition::broadcast): + +2008-02-23 Alexey Proskuryakov + + Touch some files, hoping that Windows build bot will create JSC headers. + + * kjs/AllInOneFile.cpp: + * kjs/array_instance.cpp: + * wtf/HashTable.cpp: + +2008-02-23 Alexey Proskuryakov + + Qt/Wx build fix - this file was still in a wrong namespace, too. + + * wtf/ThreadingNone.cpp: + +2008-02-23 Alexey Proskuryakov + + More build fixing - fix mismatched braces. + + * JavaScriptCore.pri: + +2008-02-23 Alexey Proskuryakov + + Wx and Gtk build fixes. + + * JavaScriptCore.pri: Don't try to compile ThreadingPthreads. + * wtf/ThreadingGtk.cpp: Use a correct namespace. + +2008-02-23 Alexey Proskuryakov + + Reviewed by Darin. + + Move basic threading support from WebCore to WTF. + + Added mutex protection to MessageQueue::killed() for paranoia sake. + + * GNUmakefile.am: + * JavaScriptCore.exp: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * wtf/Locker.h: Copied from WebCore/platform/Locker.h. + * wtf/MessageQueue.h: Copied from WebCore/platform/MessageQueue.h. + (WTF::::killed): + * wtf/Threading.h: Copied from WebCore/platform/Threading.h. + * wtf/ThreadingGtk.cpp: Copied from WebCore/platform/gtk/ThreadingGtk.cpp. + (WebCore::createThread): + * wtf/ThreadingNone.cpp: Copied from WebCore/platform/ThreadingNone.cpp. + * wtf/ThreadingPthreads.cpp: Copied from WebCore/platform/pthreads/ThreadingPthreads.cpp. + (WTF::createThread): + * wtf/ThreadingWin.cpp: Copied from WebCore/platform/win/ThreadingWin.cpp. + (WTF::createThread): + (WTF::Mutex::Mutex): + (WTF::Mutex::~Mutex): + (WTF::Mutex::lock): + (WTF::Mutex::tryLock): + (WTF::Mutex::unlock): + +2008-02-22 Geoffrey Garen + + Reviewed by Sam Weinig. + + Partial fix for Gmail out of memory (17455) + + I'm removing KJS_MEM_LIMIT for the following reasons: + + - We have a few reports of KJS_MEM_LIMIT breaking important web + applications, like GMail and Google Reader. (For example, if you + simply open 12 GMail tabs, tab #12 will hit the limit.) + + - Firefox has no discernable JS object count limit, so any limit, even + a large one, is a potential compatibility problem. + + - KJS_MEM_LIMIT does not protect against malicious memory allocation, + since there are many ways to maliciously allocate memory without + increasing the JS object count. + + - KJS_MEM_LIMIT is already mostly broken, since it only aborts the + script that breaches the limit, not any subsequent scripts. + + - We've never gotten bug reports about websites that would have + benefited from an unbroken KJS_MEM_LIMIT. The initial check-in of + KJS_MEM_LIMIT (KJS revision 80061) doesn't mention a website that + needed it. + + - Any website that brings you anywhere close to crashing due to the + number of live JS objects will almost certainly put up the "slow + script" dialog at least 20 times beforehand. + + * kjs/collector.cpp: + (KJS::Collector::collect): + * kjs/collector.h: + * kjs/nodes.cpp: + (KJS::TryNode::execute): + +2008-02-22 Oliver Hunt + + Reviewed by Alexey P. + + REGRESSION: while(NaN) acts like while(true) + + Fix yet another case where we incorrectly relied on implicit double + to bool coercion. + + * kjs/nodes.cpp: + (KJS::PostDecLocalVarNode::evaluateToBoolean): + +2008-02-20 Michael Knaup + + Reviewed by Darin. + + Fix for Bug 16753: date set methods with no args should result in NaN (Acid3 bug) + The set values result in NaN now when called with no args, NaN or +/- inf values. + The setYear, setFullYear and setUTCFullYear methods used on NaN dates work as + descripted in the standard. + + * kjs/date_object.cpp: + (KJS::fillStructuresUsingTimeArgs): + (KJS::fillStructuresUsingDateArgs): + (KJS::setNewValueFromTimeArgs): + (KJS::setNewValueFromDateArgs): + (KJS::dateProtoFuncSetYear): + +2008-02-19 Anders Carlsson + + Reviewed by Darin. + + Change OpaqueJSClass and RootObject to start with a ref count of 1. + + * API/JSClassRef.cpp: + (OpaqueJSClass::OpaqueJSClass): + (OpaqueJSClass::createNoAutomaticPrototype): + (OpaqueJSClass::create): + * API/JSClassRef.h: + * API/JSObjectRef.cpp: + (JSClassCreate): + * bindings/runtime_root.cpp: + (KJS::Bindings::RootObject::create): + (KJS::Bindings::RootObject::RootObject): + +2008-02-19 Darin Adler + + Rubber stamped by Anders. + + - removed explicit initialization to 1 for RefCounted; that's now the default + + * kjs/regexp.cpp: + (KJS::RegExp::RegExp): Removed RefCounted initializer. + +2008-02-19 Darin Adler + + Reviewed by Anders. + + - next step for http://bugs.webkit.org/show_bug.cgi?id=17257 + start ref counts at 1 instead of 0 for speed + + * wtf/RefCounted.h: + (WTF::RefCounted::RefCounted): Have refcounts default to 1. This allows us to start + removing the explicit initialization of RefCounted from classes and eventually we + can remove the ability to have the initial count of 0 entirely. + +2008-02-18 Samuel Weinig + + Reviewed by Geoff Garen. + + Fix for http://bugs.webkit.org/show_bug.cgi?id=17419 + Remove CompatMode from JavaScriptCore as it is never set to anything other than NativeMode + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::init): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::setDebugger): + * kjs/date_object.cpp: + (KJS::dateProtoFuncGetYear): + +2008-02-18 Darin Adler + + Reviewed by Sam. + + * wtf/ASCIICType.h: + (WTF::toASCIIHexValue): Added. + +2008-02-17 Darin Adler + + * wtf/ListHashSet.h: (WTF::swap): Removed stray return statement. + +2008-02-15 Adam Roben + + Make JavaScriptCore's FEATURE_DEFINES match WebCore's + + Reviewed by Mark. + + * Configurations/JavaScriptCore.xcconfig: + +2008-02-14 Stephanie Lewis + + Reviewed by Geoff. + + Update order files. + + * JavaScriptCore.order: + +2008-02-14 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed nee http://bugs.webkit.org/show_bug.cgi?id=17329 + Crash in JSGlobalObject::popActivation when inserting hyperlink in Wordpress (17329) + + Don't reset the "activations" stack in JSGlobalObject::reset, since we + might be executing a script during the call to reset, and the script + needs to safely run to completion. + + Instead, initialize the "activations" stack when the global object is + created, and subsequently rely on pushing and popping during normal + execution to maintain the stack's state. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::init): + (KJS::JSGlobalObject::reset): + +2008-02-13 Bernhard Rosenkraenzer + + Reviewed by Darin. + + - http://bugs.webkit.org/show_bug.cgi?id=17339 + JavaScriptCore does not build with gcc 4.3 + + * kjs/interpreter.cpp: Add include of , since that's where + getpid() comes from. + +2008-02-13 Oliver Hunt + + Reviewed by Alexey P. + + REGRESSION (r27747): can't browse pictures on fastcupid.com + + When converting numeric values to booleans we need to account for NaN + + * kjs/nodes.cpp: + (KJS::MultNode::evaluateToBoolean): + (KJS::ModNode::evaluateToBoolean): + +2008-02-08 Samuel Weinig + + Reviewed by Brady Eidson. + + REGRESSION: PLT 0.3% slower due to r28868 (caching ClassNodeList and NamedNodeList) + + - Tweak the statements in isASCIISpace to account for the statistical distribution of + usage in the PLT. + + .4% speedup on my machine. Stephanie's machine shows this as .3% speedup. + + * wtf/ASCIICType.h: + (WTF::isASCIISpace): + +2008-02-11 Sam Weinig + + Reviewed by Anders Carlsson. + + Fixes for: + Match Firefox's cross-domain model more accurately by return the built-in version of functions even if they have been overridden + Crash when setting the Window objects prototype to a custom Object and then calling a method on it + + - Expose the native Object.prototype.toString implementation so that it can be used for cross-domain + toString calling. + + * JavaScriptCore.exp: + * kjs/object_object.cpp: + * kjs/object_object.h: + +2008-02-10 Darin Adler + + Rubber stamped by Eric. + + * kjs/ExecState.h: + (KJS::ExecState::takeException): Added. + +2008-02-10 Darin Adler + + Reviewed by Eric. + + - http://bugs.webkit.org/show_bug.cgi?id=17256 + eliminate default ref. count of 0 in RefCounted class + + * wtf/RefCounted.h: + (WTF::RefCounted::RefCounted): Remove default of 0. + +2008-02-10 Darin Adler + + Reviewed by Eric. + + - http://bugs.webkit.org/show_bug.cgi?id=17256 + Make clients of RefCounted explicitly set the count to 0. + + * API/JSClassRef.cpp: + (OpaqueJSClass::OpaqueJSClass): + * bindings/runtime_root.cpp: + (KJS::Bindings::RootObject::RootObject): + +2008-02-09 Darin Adler + + Reviewed by Mitz. + + - http://bugs.webkit.org/show_bug.cgi?id=17256 + Change RegExp to start its ref count at 1, not 0 + + We'll want to do this to every RefCounted class, one at a time. + + * kjs/nodes.h: + (KJS::RegExpNode::RegExpNode): Use RegExp::create instead of new RegExp. + * kjs/regexp.cpp: + (KJS::RegExp::RegExp): Marked inline, set initial ref count to 1. + (KJS::RegExp::create): Added. Calls new RegExp then adopts the initial ref. + * kjs/regexp.h: Reformatted. Made the constructors private. Added static + create functions that return objects already wrapped in PassRefPtr. + * kjs/regexp_object.cpp: + (KJS::regExpProtoFuncCompile): Use RegExp::create instead of new RegExp. + (KJS::RegExpObjectImp::construct): Ditto. + * kjs/string_object.cpp: + (KJS::stringProtoFuncMatch): Ditto. + (KJS::stringProtoFuncSearch): Ditto. + +2008-02-08 Oliver Hunt + + Reviewed by Maciej. + + REGRESSION (r28973): Extraneous parentheses in function.toString() + https://bugs.webkit.org/show_bug.cgi?id=17214 + + Make a subclass of CommaNode to provide the correct precedence for each expression in + a variable declaration list. + + * kjs/grammar.y: + * kjs/nodes.h: + (KJS::VarDeclCommaNode::): + +2008-02-08 Darin Adler + + Reviewed by Oliver. + + - fix http://bugs.webkit.org/show_bug.cgi?id=17247 + Labelled continue/break can fail in some cases + + Test: fast/js/continue-break-multiple-labels.html + + * kjs/nodes.h: + (KJS::StatementNode::pushLabel): Made this virtual. + (KJS::LabelNode::pushLabel): Forward pushLabel calls to the statement inside. + +2008-02-08 Darin Adler + + Reviewed by Eric. + + - fix http://bugs.webkit.org/show_bug.cgi?id=15003 + Function.prototype.constructor should not be DontDelete/ReadOnly (Acid3 bug) + + Test: fast/js/constructor-attributes.html + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): Remove unwanted attributes from "constructor". + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::construct): Ditto. + * kjs/nodes.cpp: + (KJS::FuncDeclNode::makeFunction): Ditto. + (KJS::FuncExprNode::evaluate): Ditto. + +2008-02-06 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Added an ASSERT to catch refCount underflow, since it caused a leak in + my last check-in. + + * wtf/RefCounted.h: + (WTF::RefCounted::deref): + +2008-02-06 Geoffrey Garen + + Reviewed by Darin Adler. + + PLT speedup related to REGRESSION: PLT .4% + slower due to r28884 (global variable symbol table optimization) + + Tweaked RefCounted::deref() to be a little more efficient. + + 1% - 1.5% speedup on my machine. .7% speedup on Stephanie's machine. + + * wtf/RefCounted.h: + (WTF::RefCounted::deref): Don't modify m_refCount if we're just going + to delete the object anyway. Also, use a simple == test, which might be + faster than <= on some hardware. + +2008-02-06 Darin Adler + + Reviewed by Sam. + + - fix http://bugs.webkit.org/show_bug.cgi?id=17094 + Array.prototype functions create length properties with DontEnum/DontDelete + + Test results match Gecko with very few obscure exceptions that seem to be + bugs in Gecko. + + Test: fast/js/array-functions-non-arrays.html + + * kjs/array_object.cpp: + (KJS::arrayProtoFuncConcat): Removed DontEnum and DontDelete from the call + to set length. + (KJS::arrayProtoFuncPop): Ditto. Also added missing call to deleteProperty, + which is not needed for real arrays, but is needed for non-arrays. + (KJS::arrayProtoFuncPush): Ditto. + (KJS::arrayProtoFuncShift): Ditto. + (KJS::arrayProtoFuncSlice): Ditto. + (KJS::arrayProtoFuncSort): Removed incorrect call to set length when + the array has no elements. + (KJS::arrayProtoFuncSplice): Removed DontEnum and DontDelete from the call + to set length. + (KJS::arrayProtoFuncUnShift): Ditto. Also added a check for 0 arguments to + make behavior match the specification in that case. + * kjs/nodes.cpp: + (KJS::ArrayNode::evaluate): Removed DontEnum and DontDelete from the call + to set length. + +2008-02-06 Darin Adler + + Reviewed by Sam. + + - replace calls to put to set up properties with calls to putDirect, to + prepare for a future change where put won't take attributes any more, + and for a slight performance boost + + * API/JSObjectRef.cpp: + (JSObjectMakeConstructor): Use putDirect instead of put. + * kjs/CommonIdentifiers.h: Removed lastIndex. + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): Use putDirect instead of put. + * kjs/array_object.cpp: + (KJS::arrayProtoFuncConcat): Took out extra call to get length (unused). + (KJS::ArrayObjectImp::ArrayObjectImp): Use putDirect instead of put. + * kjs/error_object.cpp: + (KJS::ErrorPrototype::ErrorPrototype): Use putDirect instead of put. + * kjs/function.cpp: + (KJS::Arguments::Arguments): Use putDirect instead of put. + (KJS::PrototypeFunction::PrototypeFunction): Use putDirect instead of put. + * kjs/function_object.cpp: + (KJS::FunctionObjectImp::construct): Use putDirect instead of put. + * kjs/nodes.cpp: + (KJS::FuncDeclNode::makeFunction): Use putDirect instead of put. + (KJS::FuncExprNode::evaluate): Use putDirect instead of put. + * kjs/regexp_object.cpp: + (KJS::regExpProtoFuncCompile): Use setLastIndex instead of put(lastIndex). + (KJS::RegExpImp::match): Get and set lastIndex by using m_lastIndex instead of + calling get and put. + * kjs/regexp_object.h: + (KJS::RegExpImp::setLastIndex): Added. + * kjs/string_object.cpp: + (KJS::stringProtoFuncMatch): Use setLastIndex instead of put(lastIndex). + +2008-02-05 Sam Weinig + + Reviewed by Anders Carlsson. + + Fix for http://bugs.webkit.org/show_bug.cgi?id=8080 + NodeList (and other DOM lists) items are not enumeratable using for..in + + * JavaScriptCore.exp: + +2008-02-05 Mark Rowe + + Reviewed by Oliver Hunt. + + Update versioning to support the mysterious future. + + * Configurations/Version.xcconfig: Add SYSTEM_VERSION_PREFIX_1060. + +2008-02-04 Cameron Zwarich + + Reviewed by Oliver Hunt. + + Fixes Bug 16889: REGRESSION (r29425): Canvas-based graphing calculator fails to run + Bug 17015: REGRESSION (r29414-29428): www.fox.com "shows" menu fails to render + Bug 17164: REGRESSION: JavaScript pop-up menu appears at wrong location when hovering image at http://news.chinatimes.com/ + + + + + + + + + + The ActivationImp tear-off (r29425) introduced a problem with ReadModify + nodes that first resolve a slot, call valueForReadModifyNode(), and then + store a value in the previously resolved slot. Since valueForReadModifyNode() + may cause a tear-off, the slot needs to be resolved again, but this was + not happening with the existing code. + + * kjs/nodes.cpp: + (KJS::ReadModifyLocalVarNode::evaluate): + (KJS::ReadModifyResolveNode::evaluate): + +2008-02-04 Cameron McCormack + + Reviewed by Geoff Garen. + + Remove some unneccesary UNUSED_PARAMs. Clarify ownership rule of return value of JSObjectCopyPropertyNames. + + * API/JSNode.c: + (JSNode_appendChild): + (JSNode_removeChild): + (JSNode_replaceChild): + (JSNode_getNodeType): + (JSNode_getFirstChild): + * API/JSNodeList.c: + (JSNodeList_length): + * API/JSObjectRef.h: + +2008-02-04 Rodney Dawes + + Reviewed by Alp Toker and Mark Rowe. + + Fix http://bugs.webkit.org/show_bug.cgi?id=17175. + Bug 17175: Use of C++ compiler flags in CFLAGS + + * GNUmakefile.am: Use global_cxxflags as well as global_cflags in CXXFLAGS. + +2008-02-04 Alp Toker + + Rubber-stamped by Mark Rowe. + + Remove all trailing whitespace in the GTK+ port and related + components. + + * GNUmakefile.am: + +2008-02-02 Darin Adler + + Reviewed by Geoff Garen. + + PLT speedup related to REGRESSION: PLT .4% + slower due to r28884 (global variable symbol table optimization) + + Geoff's theory is that the slowdown was due to copying hash tables when + putting things into the back/forward cache. If that's true, then this + should fix the problem. + + (According to Geoff's measurements, in a PLT that exaggerates the + importance of symbol table saving during cached page creation, this + patch is a ~3X speedup in cached page creation, and a 9% speedup overall.) + + * JavaScriptCore.exp: Updated. + + * kjs/JSVariableObject.cpp: + (KJS::JSVariableObject::saveLocalStorage): Updated for changes to SavedProperty, + which has been revised to avoid initializing each SavedProperty twice when building + the array. Store the property names too, so we don't have to store the symbol table + separately. Do this by iterating the symbol table instead of the local storage vector. + (KJS::JSVariableObject::restoreLocalStorage): Ditto. Restore the symbol table as + well as the local storage vector. + + * kjs/JSVariableObject.h: Removed save/restoreSymbolTable and do that work inside + save/restoreLocalStorage instead. Made restoreLocalStorage a non-const member function + that takes a const reference to a SavedProperties object. + + * kjs/LocalStorage.h: Changed attributes to be unsigned instead of int to match + other declarations of attributes elsewhere. + + * kjs/property_map.cpp: + (KJS::SavedProperties::SavedProperties): Updated for data member name change. + (KJS::PropertyMap::save): Updated for data member name change and to use the new + inline init function instead of setting the fields directly. This allows us to + skip initializing the SavedProperty objects when first allocating the array, and + just do it when we're actually setting up the individual elements. + (KJS::PropertyMap::restore): Updated for SavedProperty changes. + + * kjs/property_map.h: Changed SavedProperty from a struct to a class. Set it up so + it does not get initialized at construction time to avoid initializing twice when + creating an array of SavedProperty. Removed the m_ prefixes from the members of + the SavedProperties struct. Generally we use m_ for class members and not struct. + +2008-02-02 Tony Chang + + Reviewed by darin. Landed by eseidel. + + Add #define guards for WIN32_LEAN_AND_MEAN and _CRT_RAND_S. + + * kjs/config.h: + * wtf/FastMalloc.cpp: + * wtf/TCSpinLock.h: + +2008-01-28 Sam Weinig + + Rubber-stamped by Darin Adler. + + - Fix whitespace in nodes.h/cpp and nodes2string.cpp. + + (NOTE: Specific changed functions elided for space and clarity) + * kjs/nodes.cpp: + * kjs/nodes.h: + * kjs/nodes2string.cpp: + +2008-01-27 Sam Weinig + + Reviewed by Oliver Hunt. + + Patch for http://bugs.webkit.org/show_bug.cgi?id=17025 + nodes.h/cpp has been rolling around in the mud - lets hose it down + + - Rename member variables to use the m_ prefix. + + (NOTE: Specific changed functions elided for space and clarity) + * kjs/grammar.y: + * kjs/nodes.cpp: + * kjs/nodes.h: + * kjs/nodes2string.cpp: + +2008-01-27 Darin Adler + + Reviewed by Oliver. + + - fix REGRESSION: const is broken + + Test: fast/js/const.html + + SunSpider said this was 0.3% slower. And I saw some Shark samples in + JSGlobalObject::put -- not a lot but a few. We may be able to regain the + speed, but for now we will take that small hit for correctness sake. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::put): Pass the checkReadOnly flag in to symbolTablePut + instead of passing attributes. + + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTablePut): Removed the code to set attributes + here, since we only set attributes when creating a property. Added the code + to check read-only here, since we need that to implement const! + + * kjs/function.cpp: + (KJS::ActivationImp::put): Pass the checkReadOnly flag in to symbolTablePut + instead of passing attributes. + + * kjs/nodes.cpp: + (KJS::isConstant): Added. + (KJS::PostIncResolveNode::optimizeVariableAccess): Create a PostIncConstNode + if optimizing for a local variable and the variable is constant. + (KJS::PostDecResolveNode::optimizeVariableAccess): Ditto. But PostDecConstNode. + (KJS::PreIncResolveNode::optimizeVariableAccess): Ditto. But PreIncConstNode. + (KJS::PreDecResolveNode::optimizeVariableAccess): Ditto. But PreDecConstNode. + (KJS::PreIncConstNode::evaluate): Return the value + 1. + (KJS::PreDecConstNode::evaluate): Return the value - 1. + (KJS::PostIncConstNode::evaluate): Return the value converted to a number. + (KJS::PostDecConstNode::evaluate): Ditto. + (KJS::ReadModifyResolveNode::optimizeVariableAccess): Create a ReadModifyConstNode + if optimizing for a local variable and the variable is constant. + (KJS::AssignResolveNode::optimizeVariableAccess): Ditto. But AssignConstNode. + (KJS::ScopeNode::optimizeVariableAccess): Pass the local storage to the + node optimizeVariableAccess functions, since that's where we need to look to + figure out if a variable is constant. + (KJS::FunctionBodyNode::processDeclarations): Moved the call to + optimizeVariableAccess until after localStorage is set up. + (KJS::ProgramNode::processDeclarations): Ditto. + + * kjs/nodes.h: Fixed the IsConstant and HasInitializer values. They are used + as flag masks, so a value of 0 will not work for IsConstant. Changed the + first parameter to optimizeVariableAccess to be a const reference to a symbol + table and added a const reference to local storage. Added classes for const + versions of local variable access: PostIncConstNode, PostDecConstNode, + PreIncConstNode, PreDecConstNode, ReadModifyConstNode, and AssignConstNode. + + * kjs/object.cpp: + (KJS::JSObject::put): Tweaked comments a bit, and changed the checkReadOnly + expression to match the form used at the two other call sites. + +2008-01-27 Darin Adler + + Reviewed by Oliver. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16498 + ''.constructor.toString() gives [function] + + Test: fast/js/function-names.html + + * kjs/array_object.cpp: + (KJS::ArrayObjectImp::ArrayObjectImp): Use the class name as the constructor's function name. + * kjs/bool_object.cpp: + (KJS::BooleanObjectImp::BooleanObjectImp): Ditto. + * kjs/date_object.cpp: + (KJS::DateObjectImp::DateObjectImp): Ditto. + * kjs/error_object.cpp: + (KJS::ErrorPrototype::ErrorPrototype): Make the error object be an Error. + (KJS::ErrorObjectImp::ErrorObjectImp): Use the class name as the constructor's function name. + (KJS::NativeErrorPrototype::NativeErrorPrototype): Take const UString&. + (KJS::NativeErrorImp::NativeErrorImp): Use the prototype's name as the constructor's function + name. + * kjs/error_object.h: Change ErrorPrototype to inherit from ErrorInstance. Change the + NativeErrorImp constructor to take a NativeErrorPrototype pointer for its prototype. + * kjs/function.h: Removed unneeded constructor for internal functions without names. + We want to avoid those! + * kjs/function_object.cpp: + (KJS::functionProtoFuncToString): Removed code that writes out just [function] for functions + that have no names. There's no reason to do that. + (KJS::FunctionObjectImp::FunctionObjectImp): Use the class name as the constructor's + function name. + * kjs/internal.cpp: Removed the unused constructor. + * kjs/number_object.cpp: + (KJS::fractionalPartToString): Marked static for internal linkage. + (KJS::exponentialPartToString): Ditto. + (KJS::numberProtoFuncToPrecision): Removed an unneeded else. + (KJS::NumberObjectImp::NumberObjectImp): Use the class name as the constructor's + function name. + (KJS::NumberObjectImp::getValueProperty): Tweaked formatting. + * kjs/object_object.cpp: + (KJS::ObjectObjectImp::ObjectObjectImp): Use "Object" for the function name. + * kjs/regexp_object.cpp: + (KJS::RegExpObjectImp::RegExpObjectImp): Use "RegExp" for the function name. + * kjs/string_object.cpp: + (KJS::StringObjectImp::StringObjectImp): Use the class name as the constructor's + function name. + +2008-01-26 Darin Adler + + Reviewed by Oliver. + + - fix http://bugs.webkit.org/show_bug.cgi?id=17027 + Incorrect Function.toString behaviour with read/modify/write operators performed on negative numbers + + Test: fast/js/function-toString-parentheses.html + + The problem here was that a NumberNode with a negative number in it had the wrong + precedence. It's not a primary expression, it's a unary operator with a primary + expression after it. + + Once the precedence of NumberNode was fixed, the cases from bug 17020 were also + fixed without trying to treat bracket nodes like dot nodes. That wasn't needed. + The reason we handle numbers before dot nodes specially is that the dot is a + legal character in a number. The same is not true of a bracket. Eventually we + could get smarter, and only add the parentheses when there is actual ambiguity. + There is none if the string form of the number already has a dot in it, or if + it's a number with a alphabetic name like infinity or NAN. + + * kjs/nodes.h: Renamed back from ObjectAccess to DotExpr. + (KJS::NumberNode::precedence): Return PrecUnary for negative numbers, since + they serialize as a unary operator, not a primary expression. + * kjs/nodes2string.cpp: + (KJS::SourceStream::operator<<): Clear m_numberNeedsParens if this adds + parens; one set is enough. + (KJS::bracketNodeStreamTo): Remove unneeded special flag here. Normal + operator precedence suffices. + (KJS::NewExprNode::streamTo): Ditto. + +2008-01-26 Oliver Hunt + + Reviewed by Maciej and Darin. + + Fix for http://bugs.webkit.org/show_bug.cgi?id=17020 + Function.toString does not parenthesise numbers for the bracket accessor + + It turns out that logic was there for all of the dot accessor nodes to make numbers be + parenthesised properly, so it was a trivial extension to extend that to the bracket nodes. + I renamed the enum type to reflect the fact that it is now used for both dot and bracket + accessors. + + * kjs/nodes2string.cpp: + (KJS::bracketNodeStreamTo): + (KJS::BracketAccessorNode::streamTo): + +2008-01-26 Oliver Hunt + + Reviewed by Darin. + + Fix Bug 17018: Incorrect code generated from Function.toString for get/setters in object literals + + Don't quote getter and setter names during output, as that is simply wrong. + + * kjs/nodes2string.cpp: + (KJS::PropertyNode::streamTo): + +2008-01-26 Darin Adler + + Reviewed by Eric Seidel. + + - http://bugs.webkit.org/show_bug.cgi?id=16860 + a bit of cleanup after the Activation optimization + + * JavaScriptCore.exp: Export the GlobalExecState constructor instead of + the global flavor of the ExecState constructor. It'd probably be cleaner + to not export either one, but JSGlobalObject inlines the code that + constructs the ExecState. If we changed that, we could remove this export. + + * JavaScriptCore.xcodeproj/project.pbxproj: Re-sorted a few things and + put the new source files into the kjs group rather than at the top level. + + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): Marked inline and updated for data member + name changes. This is now only for use for the derived classes. Also removed + code that sets the unused m_savedExec data member for the global case. That + data member is only used for the other two types. + (KJS::ExecState::~ExecState): Marked inline and removed all the code. + The derived class destructors now inclde the appropriate code. + (KJS::ExecState::lexicalGlobalObject): Removed unneeded special case for + an empty scope chain. The bottom function already returns 0 for that case, + so the general case code handles it fine. Also changed to use data members + directly rather than calling functions. + (KJS::GlobalExecState::GlobalExecState): Added. Calls through to the base + class constructor. + (KJS::GlobalExecState::~GlobalExecState): Added. + (KJS::InterpreterExecState::InterpreterExecState): Added. Moved code to + manipulate activeExecStates here since we don't want to have to check for the + special case of globalExec. + (KJS::InterpreterExecState::~InterpreterExecState): Added. + (KJS::EvalExecState::EvalExecState): Added. + (KJS::EvalExecState::~EvalExecState): Added. + (KJS::FunctionExecState::FunctionExecState): Added. + (KJS::FunctionExecState::~FunctionExecState): Added. + + * kjs/ExecState.h: Tweaked the header, includes, and declarations a bit. + Made ExecState inherit from Noncopyable. Reformatted some comments and + made them a bit more brief. Rearranged declarations a little bit and removed + unused savedExec function. Changed seenLabels function to return a reference + rather than a pointer. Made constructors and destructor protected, and also + did the same with all data members. Renamed m_thisVal to m_thisValue and + ls to m_labelStack. Added three new derived classes for each of the + types of ExecState. The primary goal here was to remove a branch from the + code in the destructor, but it's also clearer than overloading the arguments + to the ExecState constructor. + + * kjs/JSGlobalObject.cpp: + (KJS::getCurrentTime): Fixed formatting. + (KJS::JSGlobalObject::pushActivation): Removed parentheses that don't make + the expression clearer -- other similar sites didn't have these parentheses, + even the one a couple lines earlier that sets stackEntry. + (KJS::JSGlobalObject::tearOffActivation): Got rid of unneeded static_cast + (I think I mentioned this during patch review) and used an early exit so that + the entire contents of the function aren't nested inside an if statement. + Also removed the check of codeType, instead checking Activation for 0. + For now, I kept the codeType check, but inside an assertion. + + * kjs/JSGlobalObject.h: Changed type of globalExec to GlobalExecState. + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): Changed type to FunctionExecState. + (KJS::GlobalFuncImp::callAsFunction): Changed type to EvalExecState. + * kjs/interpreter.cpp: + (KJS::Interpreter::evaluate): Changed type to GlobalExecState. + + * kjs/nodes.cpp: + (KJS::ContinueNode::execute): Changed code since seenLabels() returns a + reference now instead of a pointer. + (KJS::BreakNode::execute): Ditto. + (KJS::LabelNode::execute): Ditto. + +2008-01-26 Sam Weinig + + Reviewed by Mark Rowe. + + Cleanup node2string a little. + - Remove some unnecessary branching. + - Factor out bracket and dot streaming into static inline functions. + + * kjs/nodes.h: + * kjs/nodes2string.cpp: + (KJS::bracketNodeStreamTo): + (KJS::dotNodeStreamTo): + (KJS::FunctionCallBracketNode::streamTo): + (KJS::FunctionCallDotNode::streamTo): + (KJS::PostIncBracketNode::streamTo): + (KJS::PostDecBracketNode::streamTo): + (KJS::PostIncDotNode::streamTo): + (KJS::PostDecDotNode::streamTo): + (KJS::DeleteBracketNode::streamTo): + (KJS::DeleteDotNode::streamTo): + (KJS::PreIncBracketNode::streamTo): + (KJS::PreDecBracketNode::streamTo): + (KJS::PreIncDotNode::streamTo): + (KJS::PreDecDotNode::streamTo): + (KJS::ReadModifyBracketNode::streamTo): + (KJS::AssignBracketNode::streamTo): + (KJS::ReadModifyDotNode::streamTo): + (KJS::AssignDotNode::streamTo): + (KJS::WhileNode::streamTo): + +2008-01-26 Mark Rowe + + Reviewed by Darin Adler. + + Fix http://bugs.webkit.org/show_bug.cgi?id=17001 + Bug 17001: Build error with Gtk port on Mac OS X + + If both XP_MACOSX and XP_UNIX are defined then X11.h and Carbon.h will both be included. + These provide conflicting definitions for a type named 'Cursor'. As XP_UNIX is set by + the build system when targeting X11, it doesn't make sense for XP_MACOSX to also be set + in this instance. + + * bindings/npapi.h: Don't define XP_MACOSX if XP_UNIX is defined. + +2008-01-26 Darin Adler + + Reviewed by Oliver. + + - fix http://bugs.webkit.org/show_bug.cgi?id=17013 + JSC can't round trip certain for-loops + + Test: fast/js/toString-for-var-decl.html + + * kjs/nodes.h: Added PlaceholderTrueNode so we can put nodes into + for loops without injecting the word "true" into them (nice, but not + the bug fix). Fixed ForNode constructor so expr1WasVarDecl is set + only when there is an expression, since it's common for the actual + variable declaration to be moved by the parser. + + * kjs/nodes2string.cpp: + (KJS::PlaceholderTrueNode::streamTo): Added. Empty. + +2008-01-25 Oliver Hunt + + Reviewed by Maciej. + + Fix for bug 17012: REGRESSION: JSC can't round trip an object literal + + Add logic to ensure that object literals and function expressions get + parentheses when necessary. + + * kjs/nodes.h: + * kjs/nodes2string.cpp: + (KJS::SourceStream::operator<<): + +2008-01-24 Steve Falkenburg + + Build fix. + + * JavaScriptCore.vcproj/JavaScriptCore.sln: + +2008-01-24 Steve Falkenburg + + Build fix. + + * JavaScriptCore.vcproj/JavaScriptCoreSubmit.sln: + +2008-01-24 Michael Goddard + + Reviewed by Simon. + + Fix QDateTime to JS Date conversion. + Several conversion errors (some UTC related, some month + offset related) and the conversion distance for Date + to DateTime conversion weights were fixed (it should never + be better to convert a JS Number into a Date rather than + an int). + + * bindings/qt/qt_runtime.cpp: + (KJS::Bindings::convertValueToQVariant): + (KJS::Bindings::convertQVariantToValue): + +2008-01-24 Michael Goddard + + Reviewed by Simon. + + Add support for calling QObjects. + Add support for invokeDefaultMethod (via a call to + a specific slot), and also allow using it as a + constructor, like QtScript. + + + * bindings/qt/qt_class.cpp: + (KJS::Bindings::QtClass::fallbackObject): + * bindings/qt/qt_instance.cpp: + (KJS::Bindings::QtRuntimeObjectImp::construct): + (KJS::Bindings::QtInstance::QtInstance): + (KJS::Bindings::QtInstance::~QtInstance): + (KJS::Bindings::QtInstance::implementsCall): + (KJS::Bindings::QtInstance::invokeDefaultMethod): + * bindings/qt/qt_instance.h: + * bindings/qt/qt_runtime.cpp: + (KJS::Bindings::findMethodIndex): + (KJS::Bindings::QtRuntimeMetaMethod::QtRuntimeMetaMethod): + (KJS::Bindings::QtRuntimeMetaMethod::callAsFunction): + * bindings/qt/qt_runtime.h: + +2008-01-24 Michael Goddard + + Reviewed by Simon. + + Code style cleanups. + Add spaces before/after braces in inline function. + + * bindings/qt/qt_instance.h: + +2008-01-24 Michael Goddard + + Reviewed by Simon. + + Code style cleanups. + Remove spaces and unneeded declared parameter names. + + * bindings/qt/qt_instance.cpp: + (KJS::Bindings::QtRuntimeObjectImp::removeFromCache): + +2008-01-24 Michael Goddard + + Reviewed by Simon. + + Clear stale RuntimeObjectImps. + Since other objects can have refs to the QtInstance, + we can't rely on the QtInstance being deleted when the + RuntimeObjectImp is invalidate or deleted. This + could result in a stale JSObject being returned for + a valid Instance. + + * bindings/qt/qt_instance.cpp: + (KJS::Bindings::QtRuntimeObjectImp::QtRuntimeObjectImp): + (KJS::Bindings::QtRuntimeObjectImp::~QtRuntimeObjectImp): + (KJS::Bindings::QtRuntimeObjectImp::invalidate): + (KJS::Bindings::QtRuntimeObjectImp::removeFromCache): + (KJS::Bindings::QtInstance::getRuntimeObject): + * bindings/runtime.cpp: + (KJS::Bindings::Instance::createRuntimeObject): + * bindings/runtime.h: + +2008-01-23 Alp Toker + + Rubber-stamped by Mark Rowe. + + Remove whitespace after -I in automake include lists. + + * GNUmakefile.am: + +2008-01-23 Michael Goddard + + Reviewed by Lars Knoll . + + Reworked the JavaScriptCore Qt bindings: + + * Add initial support for string and variant arrays, as well + as sub QObjects in the JS bindings. + + * Don't expose fields marked as not scriptable by moc. + + * Add support for dynamic properties and accessing named + QObject children of an object (like QtScript and older + IE DOM style JS). + * Add support for custom toString methods. + + * Fine tune some bindings to be closer to QtScript. + Make void functions return undefined, and empty/ + null QStrings return a zero length string. + + * Create framework for allowing more direct method calls. + Since RuntimeMethod doesn't allow us to add additional + methods/properties to a function, add these classes. + Start prototyping object.signal.connect(...). + + * Add signal support to the Qt bindings. + Allow connecting to signals (object.signal.connect(slot)), + disconnecting, and emitting signals. Currently chooses + the first signal that matches the name, so this will need + improvement. + + * Add property names, and resolve signals closer to use. + Enumerating properties now returns some of the Qt properties + and signals. Slots and methods aren't quite present. Also, + resolve signal connections etc. closer to the time of use, so + we can do more dynamic resolution based on argument type etc. + Still picks the first one with the same name, at the moment. + + * Make signature comparison code consistent. + Use the same code for checking meta signatures in + the method and fallback getters, and avoid a + QByteArray construction when we can. + + * Fix minor memory leak, and handle pointers better. + Delete the private object in the dtors, and use RefPtrs + for holding Instances etc. + + * Handle method lookup better. + Allow invocation time method lookup based on the arguments, + which is closer to QtScript behaviour. Also, cache the + method lists and delete them in the QtClass dtor (stops + a memory leak). + + * Improve JS to Qt data type conversions. + Add some support for Date & RegExp JS objects, + and provide some metrics on the quality of the + conversion. + + * A couple of fixes for autotest failures. + Better support for converting lists, read/write only + QMetaProperty support, modified slot search order...) + + * bindings/qt/qt_class.cpp: + (KJS::Bindings::QtClass::QtClass): + (KJS::Bindings::QtClass::~QtClass): + (KJS::Bindings::QtClass::name): + (KJS::Bindings::QtClass::fallbackObject): + (KJS::Bindings::QtClass::methodsNamed): + (KJS::Bindings::QtClass::fieldNamed): + * bindings/qt/qt_class.h: + * bindings/qt/qt_instance.cpp: + (KJS::Bindings::QtInstance::QtInstance): + (KJS::Bindings::QtInstance::~QtInstance): + (KJS::Bindings::QtInstance::getRuntimeObject): + (KJS::Bindings::QtInstance::getClass): + (KJS::Bindings::QtInstance::implementsCall): + (KJS::Bindings::QtInstance::getPropertyNames): + (KJS::Bindings::QtInstance::invokeMethod): + (KJS::Bindings::QtInstance::invokeDefaultMethod): + (KJS::Bindings::QtInstance::stringValue): + (KJS::Bindings::QtInstance::booleanValue): + (KJS::Bindings::QtInstance::valueOf): + (KJS::Bindings::QtField::name): + (KJS::Bindings::QtField::valueFromInstance): + (KJS::Bindings::QtField::setValueToInstance): + * bindings/qt/qt_instance.h: + (KJS::Bindings::QtInstance::getBindingLanguage): + (KJS::Bindings::QtInstance::getObject): + * bindings/qt/qt_runtime.cpp: + (KJS::Bindings::QWKNoDebug::QWKNoDebug): + (KJS::Bindings::QWKNoDebug::~QWKNoDebug): + (KJS::Bindings::QWKNoDebug::operator<<): + (KJS::Bindings::): + (KJS::Bindings::valueRealType): + (KJS::Bindings::convertValueToQVariant): + (KJS::Bindings::convertQVariantToValue): + (KJS::Bindings::QtRuntimeMethod::QtRuntimeMethod): + (KJS::Bindings::QtRuntimeMethod::~QtRuntimeMethod): + (KJS::Bindings::QtRuntimeMethod::codeType): + (KJS::Bindings::QtRuntimeMethod::execute): + (KJS::Bindings::QtRuntimeMethodData::~QtRuntimeMethodData): + (KJS::Bindings::QtRuntimeMetaMethodData::~QtRuntimeMetaMethodData): + (KJS::Bindings::QtRuntimeConnectionMethodData::~QtRuntimeConnectionMethodData): + (KJS::Bindings::QtMethodMatchType::): + (KJS::Bindings::QtMethodMatchType::QtMethodMatchType): + (KJS::Bindings::QtMethodMatchType::kind): + (KJS::Bindings::QtMethodMatchType::isValid): + (KJS::Bindings::QtMethodMatchType::isVariant): + (KJS::Bindings::QtMethodMatchType::isMetaType): + (KJS::Bindings::QtMethodMatchType::isUnresolved): + (KJS::Bindings::QtMethodMatchType::isMetaEnum): + (KJS::Bindings::QtMethodMatchType::enumeratorIndex): + (KJS::Bindings::QtMethodMatchType::variant): + (KJS::Bindings::QtMethodMatchType::metaType): + (KJS::Bindings::QtMethodMatchType::metaEnum): + (KJS::Bindings::QtMethodMatchType::unresolved): + (KJS::Bindings::QtMethodMatchType::typeId): + (KJS::Bindings::QtMethodMatchType::name): + (KJS::Bindings::QtMethodMatchData::QtMethodMatchData): + (KJS::Bindings::QtMethodMatchData::isValid): + (KJS::Bindings::QtMethodMatchData::firstUnresolvedIndex): + (KJS::Bindings::indexOfMetaEnum): + (KJS::Bindings::findMethodIndex): + (KJS::Bindings::findSignalIndex): + (KJS::Bindings::QtRuntimeMetaMethod::QtRuntimeMetaMethod): + (KJS::Bindings::QtRuntimeMetaMethod::mark): + (KJS::Bindings::QtRuntimeMetaMethod::callAsFunction): + (KJS::Bindings::QtRuntimeMetaMethod::getOwnPropertySlot): + (KJS::Bindings::QtRuntimeMetaMethod::lengthGetter): + (KJS::Bindings::QtRuntimeMetaMethod::connectGetter): + (KJS::Bindings::QtRuntimeMetaMethod::disconnectGetter): + (KJS::Bindings::QtRuntimeConnectionMethod::QtRuntimeConnectionMethod): + (KJS::Bindings::QtRuntimeConnectionMethod::callAsFunction): + (KJS::Bindings::QtRuntimeConnectionMethod::getOwnPropertySlot): + (KJS::Bindings::QtRuntimeConnectionMethod::lengthGetter): + (KJS::Bindings::QtConnectionObject::QtConnectionObject): + (KJS::Bindings::QtConnectionObject::~QtConnectionObject): + (KJS::Bindings::QtConnectionObject::metaObject): + (KJS::Bindings::QtConnectionObject::qt_metacast): + (KJS::Bindings::QtConnectionObject::qt_metacall): + (KJS::Bindings::QtConnectionObject::execute): + (KJS::Bindings::QtConnectionObject::match): + (KJS::Bindings::::QtArray): + (KJS::Bindings::::~QtArray): + (KJS::Bindings::::rootObject): + (KJS::Bindings::::setValueAt): + (KJS::Bindings::::valueAt): + * bindings/qt/qt_runtime.h: + (KJS::Bindings::QtField::): + (KJS::Bindings::QtField::QtField): + (KJS::Bindings::QtField::fieldType): + (KJS::Bindings::QtMethod::QtMethod): + (KJS::Bindings::QtMethod::name): + (KJS::Bindings::QtMethod::numParameters): + (KJS::Bindings::QtArray::getLength): + (KJS::Bindings::QtRuntimeMethod::d_func): + (KJS::Bindings::QtRuntimeMetaMethod::d_func): + (KJS::Bindings::QtRuntimeConnectionMethod::d_func): + (KJS::Bindings::): + * bindings/runtime.cpp: + (KJS::Bindings::Instance::createBindingForLanguageInstance): + (KJS::Bindings::Instance::createRuntimeObject): + (KJS::Bindings::Instance::reallyCreateRuntimeObject): + * bindings/runtime.h: + +2008-01-22 Anders Carlsson + + Reviewed by Darin and Adam. + + + div element on microsoft site has wrong left offset. + + Return true even if NPN_GetProperty returns null or undefined. This matches Firefox + (and is what the Silverlight plug-in expects). + + * bindings/NP_jsobject.cpp: + (_NPN_GetProperty): + +2008-01-21 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed http://bugs.webkit.org/show_bug.cgi?id=16909 + REGRESSION: Amazon.com crash (ActivationImp) + + (and a bunch of other crashes) + + Plus, a .7% SunSpider speedup to boot. + + Replaced the buggy currentExec and savedExec mechanisms with an + explicit ExecState stack. + + * kjs/collector.cpp: + (KJS::Collector::collect): Explicitly mark the ExecState stack. + + (KJS::Collector::reportOutOfMemoryToAllExecStates): Slight change in + behavior: We no longer throw an exception in any global ExecStates, + since global ExecStates are more like pseudo-ExecStates, and aren't + used for script execution. (It's unclear what would happen if you left + an exception waiting around in a global ExecState, but it probably + wouldn't be good.) + +2008-01-21 Jan Michael Alonzo + + Reviewed by Alp Toker. + + http://bugs.webkit.org/show_bug.cgi?id=16955 + Get errors when cross-compile webkit-gtk + + * GNUmakefile.am: removed ICU_CFLAGS + +2008-01-18 Kevin McCullough + + - Build fix. + + * kjs/ustring.h: + +2008-01-18 Kevin McCullough + + - Build fix. + + * kjs/ustring.cpp: + * kjs/ustring.h: + (KJS::UString::cost): + +2008-01-18 Kevin McCullough + + Reviewed by Geoff. + + - Correctly report cost of appended strings to trigger GC. + + * kjs/ustring.cpp: + (KJS::UString::Rep::create): + (KJS::UString::UString): Don't create unnecssary objects. + (KJS::UString::cost): Report cost if necessary but also keep track of + reported cost. + * kjs/ustring.h: + +2008-01-18 Simon Hausmann + + Reviewed by Holger. + + Fix return type conversions from Qt slots to JS values. + + This also fixes fast/dom/open-and-close-by-DOM.html, which called + layoutTestController.windowCount(). + + When constructing the QVariant that holds the return type we cannot + use the QVarian(Type) constuctor as that will create a null variant. + We have to use the QVariant(Type, void *) constructor instead, just + like in QMetaObject::read() for example. + + + * bindings/qt/qt_instance.cpp: + (KJS::Bindings::QtInstance::getRuntimeObject): + +2008-01-18 Prasanth Ullattil + + Reviewed by Simon Hausmann . + + Fix compilation on Win64(2): Implemented currentThreadStackBase on X86-64 on Windows + + + * kjs/collector.cpp: + (KJS::Collector::heapAllocate): + +2008-01-18 Prasanth Ullattil + + Reviewed by Simon Hausmann . + + Fix compilation on Win64(1): Define WTF_PLATFORM_X86_64 correctly on Win64. + + + * wtf/Platform.h: + +2008-01-17 Antti Koivisto + + Fix Windows build. + + * kjs/regexp_object.cpp: + (KJS::regExpProtoFuncToString): + +2008-01-16 Sam Weinig + + Reviewed by Darin. + + Fix for http://bugs.webkit.org/show_bug.cgi?id=16901 + Convert remaining JS function objects to use the new PrototypeFunction class + + - Moves Boolean, Function, RegExp, Number, Object and Global functions to their + own static function implementations so that they can be used with the + PrototypeFunction class. SunSpider says this is 1.003x as fast. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): + * kjs/array_object.h: + * kjs/bool_object.cpp: + (KJS::BooleanInstance::BooleanInstance): + (KJS::BooleanPrototype::BooleanPrototype): + (KJS::booleanProtoFuncToString): + (KJS::booleanProtoFuncValueOf): + (KJS::BooleanObjectImp::BooleanObjectImp): + (KJS::BooleanObjectImp::implementsConstruct): + (KJS::BooleanObjectImp::construct): + (KJS::BooleanObjectImp::callAsFunction): + * kjs/bool_object.h: + (KJS::BooleanInstance::classInfo): + * kjs/error_object.cpp: + (KJS::ErrorPrototype::ErrorPrototype): + (KJS::errorProtoFuncToString): + * kjs/error_object.h: + * kjs/function.cpp: + (KJS::globalFuncEval): + (KJS::globalFuncParseInt): + (KJS::globalFuncParseFloat): + (KJS::globalFuncIsNaN): + (KJS::globalFuncIsFinite): + (KJS::globalFuncDecodeURI): + (KJS::globalFuncDecodeURIComponent): + (KJS::globalFuncEncodeURI): + (KJS::globalFuncEncodeURIComponent): + (KJS::globalFuncEscape): + (KJS::globalFuncUnEscape): + (KJS::globalFuncKJSPrint): + (KJS::PrototypeFunction::PrototypeFunction): + * kjs/function.h: + * kjs/function_object.cpp: + (KJS::FunctionPrototype::FunctionPrototype): + (KJS::functionProtoFuncToString): + (KJS::functionProtoFuncApply): + (KJS::functionProtoFuncCall): + * kjs/function_object.h: + * kjs/number_object.cpp: + (KJS::NumberPrototype::NumberPrototype): + (KJS::numberProtoFuncToString): + (KJS::numberProtoFuncToLocaleString): + (KJS::numberProtoFuncValueOf): + (KJS::numberProtoFuncToFixed): + (KJS::numberProtoFuncToExponential): + (KJS::numberProtoFuncToPrecision): + * kjs/number_object.h: + (KJS::NumberInstance::classInfo): + (KJS::NumberObjectImp::classInfo): + (KJS::NumberObjectImp::): + * kjs/object_object.cpp: + (KJS::ObjectPrototype::ObjectPrototype): + (KJS::objectProtoFuncValueOf): + (KJS::objectProtoFuncHasOwnProperty): + (KJS::objectProtoFuncIsPrototypeOf): + (KJS::objectProtoFuncDefineGetter): + (KJS::objectProtoFuncDefineSetter): + (KJS::objectProtoFuncLookupGetter): + (KJS::objectProtoFuncLookupSetter): + (KJS::objectProtoFuncPropertyIsEnumerable): + (KJS::objectProtoFuncToLocaleString): + (KJS::objectProtoFuncToString): + * kjs/object_object.h: + * kjs/regexp_object.cpp: + (KJS::RegExpPrototype::RegExpPrototype): + (KJS::regExpProtoFuncTest): + (KJS::regExpProtoFuncExec): + (KJS::regExpProtoFuncCompile): + (KJS::regExpProtoFuncToString): + * kjs/regexp_object.h: + +2008-01-16 Cameron Zwarich + + Reviewed by Maciej & Darin. + + Fixes Bug 16868: Gmail crash + and Bug 16871: Crash when loading apple.com/startpage + + + + + + + + Adds ActivationImp tear-off for cross-window eval() and fixes an + existing garbage collection issue exposed by the ActivationImp tear-off + patch (r29425) that can occur when an ExecState's m_callingExec is + different than its m_savedExec. + + * kjs/ExecState.cpp: + (KJS::ExecState::mark): + * kjs/function.cpp: + (KJS::GlobalFuncImp::callAsFunction): + +2008-01-16 Sam Weinig + + Reviewed by Oliver. + + Clean up MathObjectImp, it needed a little scrubbing. + + * kjs/math_object.cpp: + (KJS::MathObjectImp::MathObjectImp): + (KJS::MathObjectImp::getOwnPropertySlot): + (KJS::MathObjectImp::getValueProperty): + (KJS::mathProtoFuncACos): + (KJS::mathProtoFuncASin): + (KJS::mathProtoFuncATan): + (KJS::mathProtoFuncATan2): + (KJS::mathProtoFuncCos): + (KJS::mathProtoFuncExp): + (KJS::mathProtoFuncLog): + (KJS::mathProtoFuncSin): + (KJS::mathProtoFuncSqrt): + (KJS::mathProtoFuncTan): + * kjs/math_object.h: + (KJS::MathObjectImp::classInfo): + (KJS::MathObjectImp::): + +2008-01-16 Sam Weinig + + Reviewed by Geoffrey Garen. + + Rename Lexer variable bol to atLineStart. + + * kjs/lexer.cpp: + (KJS::Lexer::Lexer): + (KJS::Lexer::setCode): + (KJS::Lexer::nextLine): + (KJS::Lexer::lex): + * kjs/lexer.h: + +2008-01-16 Sam Weinig + + Reviewed by Geoffrey Garen and Anders Carlsson. + + Remove uses of KJS_PURE_ECMA as we don't ever build with it defined, + and we have many features that are not included in the ECMA spec. + + * kjs/lexer.cpp: + (KJS::Lexer::Lexer): + (KJS::Lexer::setCode): + (KJS::Lexer::nextLine): + (KJS::Lexer::lex): + * kjs/lexer.h: + * kjs/string_object.cpp: + * kjs/string_object.h: + +2008-01-15 Sam Weinig + + Reviewed by Geoffrey Garen. + + Fix r27608 introduced a 20% increase in JS binary size, 4% increase in WebCore binary size + + - This changes the way JS functions that use Lookup tables are handled. Instead of using + one class per function, which allowed specialization of the virtual callAsFunction + method, we now use one class, PrototypeFunction, which takes a pointer to a static + function to use as the implementation. This significantly decreases the binary size + of JavaScriptCore (about 145k on an Intel only build) while still keeping some of the + speedup r27608 garnered (SunSpider says this is 1.005x as slow, which should leave some + wiggle room from the original 1% speedup) and keeps the functions implementations in separate + functions to help with optimizations. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/array_object.cpp: + (KJS::arrayProtoFuncToString): + (KJS::arrayProtoFuncToLocaleString): + (KJS::arrayProtoFuncJoin): + (KJS::arrayProtoFuncConcat): + (KJS::arrayProtoFuncPop): + (KJS::arrayProtoFuncPush): + (KJS::arrayProtoFuncReverse): + (KJS::arrayProtoFuncShift): + (KJS::arrayProtoFuncSlice): + (KJS::arrayProtoFuncSort): + (KJS::arrayProtoFuncSplice): + (KJS::arrayProtoFuncUnShift): + (KJS::arrayProtoFuncFilter): + (KJS::arrayProtoFuncMap): + (KJS::arrayProtoFuncEvery): + (KJS::arrayProtoFuncForEach): + (KJS::arrayProtoFuncSome): + (KJS::arrayProtoFuncIndexOf): + (KJS::arrayProtoFuncLastIndexOf): + * kjs/array_object.h: + * kjs/date_object.cpp: + (KJS::DatePrototype::getOwnPropertySlot): + (KJS::dateProtoFuncToString): + (KJS::dateProtoFuncToUTCString): + (KJS::dateProtoFuncToDateString): + (KJS::dateProtoFuncToTimeString): + (KJS::dateProtoFuncToLocaleString): + (KJS::dateProtoFuncToLocaleDateString): + (KJS::dateProtoFuncToLocaleTimeString): + (KJS::dateProtoFuncValueOf): + (KJS::dateProtoFuncGetTime): + (KJS::dateProtoFuncGetFullYear): + (KJS::dateProtoFuncGetUTCFullYear): + (KJS::dateProtoFuncToGMTString): + (KJS::dateProtoFuncGetMonth): + (KJS::dateProtoFuncGetUTCMonth): + (KJS::dateProtoFuncGetDate): + (KJS::dateProtoFuncGetUTCDate): + (KJS::dateProtoFuncGetDay): + (KJS::dateProtoFuncGetUTCDay): + (KJS::dateProtoFuncGetHours): + (KJS::dateProtoFuncGetUTCHours): + (KJS::dateProtoFuncGetMinutes): + (KJS::dateProtoFuncGetUTCMinutes): + (KJS::dateProtoFuncGetSeconds): + (KJS::dateProtoFuncGetUTCSeconds): + (KJS::dateProtoFuncGetMilliSeconds): + (KJS::dateProtoFuncGetUTCMilliseconds): + (KJS::dateProtoFuncGetTimezoneOffset): + (KJS::dateProtoFuncSetTime): + (KJS::dateProtoFuncSetMilliSeconds): + (KJS::dateProtoFuncSetUTCMilliseconds): + (KJS::dateProtoFuncSetSeconds): + (KJS::dateProtoFuncSetUTCSeconds): + (KJS::dateProtoFuncSetMinutes): + (KJS::dateProtoFuncSetUTCMinutes): + (KJS::dateProtoFuncSetHours): + (KJS::dateProtoFuncSetUTCHours): + (KJS::dateProtoFuncSetDate): + (KJS::dateProtoFuncSetUTCDate): + (KJS::dateProtoFuncSetMonth): + (KJS::dateProtoFuncSetUTCMonth): + (KJS::dateProtoFuncSetFullYear): + (KJS::dateProtoFuncSetUTCFullYear): + (KJS::dateProtoFuncSetYear): + (KJS::dateProtoFuncGetYear): + * kjs/date_object.h: + * kjs/function.cpp: + (KJS::PrototypeFunction::PrototypeFunction): + (KJS::PrototypeFunction::callAsFunction): + * kjs/function.h: + * kjs/lookup.h: + (KJS::HashEntry::): + (KJS::staticFunctionGetter): + * kjs/math_object.cpp: + (KJS::mathProtoFuncAbs): + (KJS::mathProtoFuncACos): + (KJS::mathProtoFuncASin): + (KJS::mathProtoFuncATan): + (KJS::mathProtoFuncATan2): + (KJS::mathProtoFuncCeil): + (KJS::mathProtoFuncCos): + (KJS::mathProtoFuncExp): + (KJS::mathProtoFuncFloor): + (KJS::mathProtoFuncLog): + (KJS::mathProtoFuncMax): + (KJS::mathProtoFuncMin): + (KJS::mathProtoFuncPow): + (KJS::mathProtoFuncRandom): + (KJS::mathProtoFuncRound): + (KJS::mathProtoFuncSin): + (KJS::mathProtoFuncSqrt): + (KJS::mathProtoFuncTan): + * kjs/math_object.h: + * kjs/string_object.cpp: + (KJS::stringProtoFuncToString): + (KJS::stringProtoFuncValueOf): + (KJS::stringProtoFuncCharAt): + (KJS::stringProtoFuncCharCodeAt): + (KJS::stringProtoFuncConcat): + (KJS::stringProtoFuncIndexOf): + (KJS::stringProtoFuncLastIndexOf): + (KJS::stringProtoFuncMatch): + (KJS::stringProtoFuncSearch): + (KJS::stringProtoFuncReplace): + (KJS::stringProtoFuncSlice): + (KJS::stringProtoFuncSplit): + (KJS::stringProtoFuncSubstr): + (KJS::stringProtoFuncSubstring): + (KJS::stringProtoFuncToLowerCase): + (KJS::stringProtoFuncToUpperCase): + (KJS::stringProtoFuncToLocaleLowerCase): + (KJS::stringProtoFuncToLocaleUpperCase): + (KJS::stringProtoFuncLocaleCompare): + (KJS::stringProtoFuncBig): + (KJS::stringProtoFuncSmall): + (KJS::stringProtoFuncBlink): + (KJS::stringProtoFuncBold): + (KJS::stringProtoFuncFixed): + (KJS::stringProtoFuncItalics): + (KJS::stringProtoFuncStrike): + (KJS::stringProtoFuncSub): + (KJS::stringProtoFuncSup): + (KJS::stringProtoFuncFontcolor): + (KJS::stringProtoFuncFontsize): + (KJS::stringProtoFuncAnchor): + (KJS::stringProtoFuncLink): + * kjs/string_object.h: + +2008-01-15 Geoffrey Garen + + Reviewed by Adam Roben. + + Some tweaks to our headerdoc, suggested by David Gatwood on the docs + team. + + * API/JSBase.h: + * API/JSObjectRef.h: + * API/JSStringRef.h: + * API/JSValueRef.h: + +2008-01-15 Alp Toker + + Rubber-stamped by Anders. + + Make the HTTP backend configurable in the GTK+ port. curl is currently + the only option. + + * wtf/Platform.h: Don't hard-code WTF_USE_CURL for GTK + +2008-01-15 Sam Weinig + + Reviewed by Beth Dakin. + + Remove unneeded variable. + + * kjs/string_object.cpp: + (KJS::StringProtoFuncSubstr::callAsFunction): + +2008-01-14 Steve Falkenburg + + Use shared vsprops for most vcproj properties. + + Reviewed by Darin. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Add missing Debug_Internal config. + * JavaScriptCore.vcproj/WTF/WTF.vcproj: Add missing Debug_Internal config. + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: + +2008-01-14 Adam Roben + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Added + some headers that were missing from the vcproj so their contents will + be included in Find in Files. + +2008-01-14 Adam Roben + + Fix Bug 16871: Crash when loading apple.com/startpage + + + + + Patch written by Darin, reviewed by me. + + * kjs/ExecState.cpp: + (KJS::ExecState::mark): Call ActivationImp::markChildren if our + m_activation is on the stack. This is what ScopeChain::mark also does, + but apparently in some cases it's possible for an ExecState's + ActivationImp to not be in any ScopeChain. + +2008-01-14 Kevin McCullough + + Reviewed by Oliver. + + - REGRESSION (Leopard-ToT): Endless loading loop + trying to view techreport.com comments + - We need to set values in the map, because if they are already in the + map they will not be reset when we use add(). + + * kjs/array_instance.cpp: + (KJS::ArrayInstance::put): + +2008-01-14 Darin Adler + + Reviewed by Adam. + + - re-speed-up the page load test (my StringImpl change slowed it down) + + * wtf/RefCounted.h: + (WTF::RefCounted::RefCounted): Allow derived classes to start with a reference + count other than 0. Eventually everyone will want to start with a 1. This is a + staged change. For now, there's a default of 0, and you can specify 1. Later, + there will be no default and everyone will have to specify. And then later, there + will be a default of 1. Eventually, we can take away even the option of starting + with 0! + + * wtf/Vector.h: + (WTF::Vector::Vector): Sped up creation of non-empty vectors by removing the + overhead of first constructing something empty and then calling resize. + (WTF::Vector::clear): Sped up the common case of calling clear on an empty + vector by adding a check for that case. + (WTF::Vector::releaseBuffer): Marked this function inline and removed a branch + in the case of vectors with no inline capacity (normal vectors) by leaving out + the code to copy the inline buffer in that case. + +2008-01-14 Alexey Proskuryakov + + Reviewed by David Kilzer. + + http://bugs.webkit.org/show_bug.cgi?id=16787 + array.splice() with 1 element not working + + Test: fast/js/array-splice.html + + * kjs/array_object.cpp: + (KJS::ArrayProtoFuncSplice::callAsFunction): Implement this Mozilla extension, and fix + some other edge cases. + +2008-01-13 Steve Falkenburg + + Share common files across projects. + + Unify vsprops files + Debug: common.vsprops, debug.vsprops + Debug_Internal: common.vsprops, debug.vsprops, debug_internal.vsprops + Release: common.vsprops, release.vsprops + + Shared properties can go into common.vsprops, shared debug settings can go into debug.vsprops. + debug_internal.vsprops will be mostly empty except for file path prefix modifiers. + + Reviewed by Adam Roben. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * JavaScriptCore.vcproj/debug.vsprops: Removed. + * JavaScriptCore.vcproj/debug_internal.vsprops: Removed. + * JavaScriptCore.vcproj/release.vsprops: Removed. + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: + +2008-01-13 Marius Bugge Monsen + + Contributions and review by Adriaan de Groot, + Simon Hausmann, Eric Seidel, and Darin Adler. + + - http://bugs.webkit.org/show_bug.cgi?id=16590 + Compilation fixes for Solaris. + + * kjs/DateMath.h: + (KJS::GregorianDateTime::GregorianDateTime): Use the WIN_OS code path + for SOLARIS too, presumably because Solaris also lacks the tm_gtoff and tm_zone + fields. + (KJS::GregorianDateTime::operator tm): Ditto. + + * kjs/collector.cpp: + (KJS::currentThreadStackBase): Use thr_stksegment on Solaris. + + * wtf/MathExtras.h: + (isfinite): Implement for Solaris. + (isinf): Ditto. + (signbit): Ditto. But this one is wrong, so I added a FIXME. + + * wtf/Platform.h: Define PLATFORM(SOLARIS) when "sun" or "__sun" is defined. + +2008-01-13 Michael Goddard + + Reviewed by Anders Carlsson. + + Add binding language type to Instance. + Allows runtime determination of the type of an + Instance, to allow safe casting. Doesn't actually + add any safe casting yet, though. + + Add a helper function to get an Instance from a JSObject*. + Given an object and the expected binding language, see if + the JSObject actually wraps an Instance of the given type + and return it. Otherwise return 0. + + Move RuntimeObjectImp creations into Instance. + Make the ctor protected, and Instance a friend class, so + that all creation of RuntimeObjectImps goes through + one place. + + Remove copy ctor/assignment operator for QtInstance. + Instance itself is Noncopyable, so QtInstance doesn't + need to have these. + + Add caching for QtInstance and associated RuntimeObjectImps. + Push any dealings with QtLanguage bindings into QtInstance, + and cache them there, rather than in the Instance layer. Add + a QtRuntimeObjectImp to help with caching. + + * JavaScriptCore.exp: + * bindings/c/c_instance.h: + * bindings/jni/jni_instance.h: + * bindings/objc/objc_instance.h: + * bindings/qt/qt_instance.cpp: + (KJS::Bindings::QtRuntimeObjectImp::QtRuntimeObjectImp): + (KJS::Bindings::QtRuntimeObjectImp::~QtRuntimeObjectImp): + (KJS::Bindings::QtRuntimeObjectImp::invalidate): + (KJS::Bindings::QtRuntimeObjectImp::removeFromCache): + (KJS::Bindings::QtInstance::QtInstance): + (KJS::Bindings::QtInstance::~QtInstance): + (KJS::Bindings::QtInstance::getQtInstance): + (KJS::Bindings::QtInstance::getRuntimeObject): + * bindings/qt/qt_instance.h: + (KJS::Bindings::QtInstance::getBindingLanguage): + * bindings/runtime.cpp: + (KJS::Bindings::Instance::createBindingForLanguageInstance): + (KJS::Bindings::Instance::createRuntimeObject): + (KJS::Bindings::Instance::getInstance): + * bindings/runtime.h: + * bindings/runtime_object.h: + (KJS::RuntimeObjectImp::getInternalInstance): + +2008-01-12 Alp Toker + + Reviewed by Mark Rowe. + + Hide non-public symbols in GTK+/autotools release builds. + + * GNUmakefile.am: + +2008-01-12 Cameron Zwarich + + Reviewed by Mark Rowe. + + Fix http://bugs.webkit.org/show_bug.cgi?id=16852 + Fixes leaking of ActivationStackNode objects. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::deleteActivationStack): + (KJS::JSGlobalObject::~JSGlobalObject): + (KJS::JSGlobalObject::init): + (KJS::JSGlobalObject::reset): + * kjs/JSGlobalObject.h: + +2008-01-12 Darin Adler + + - try to fix Qt Windows build + + * pcre/dftables: Remove reliance on the list form of Perl pipes. + +2008-01-12 Darin Adler + + - try to fix Qt build + + * kjs/function.cpp: Added include of scope_chain_mark.h. + * kjs/scope_chain_mark.h: Added multiple-include guards. + +2008-01-12 Mark Rowe + + Another Windows build fix. + + * kjs/Activation.h: + +2008-01-12 Mark Rowe + + Attempted Windows build fix. Use struct consistently when forward-declaring + ActivationStackNode and StackActivation. + + * kjs/Activation.h: + * kjs/JSGlobalObject.h: + +2008-01-12 Cameron Zwarich + + Reviewed by Maciej. + + Fixes a problem with the ActivationImp tear-off patch (r29425) where + some of the calls to JSGlobalObject::tearOffActivation() were using + the wrong test to determine whether it should leave a relic behind. + + * kjs/function.cpp: + (KJS::FunctionImp::argumentsGetter): + (KJS::ActivationImp::getOwnPropertySlot): + +2008-01-11 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed REGRESSION (r28880-r28886): Global + variable access (16644) + + This bug was caused by var declarations shadowing built-in properties of + the global object. + + To match Firefox, we've decided that var declarations will never shadow + built-in properties of the global object or its prototypes. We used to + behave more like IE, which allows shadowing, but walking that line got + us into trouble with websites that sent us down the Firefox codepath. + + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTableGet): New code to support calling + hasProperty before the variable object is fully initialized (so you + can call it during initialization). + + * kjs/nodes.cpp:. + (KJS::ProgramNode::initializeSymbolTable): Always do a full hasProperty + check when looking for duplicates, not getDirect, since it only checks + the property map, and not hasOwnProperty, since it doesn't check + prototypes. + (KJS::EvalNode::processDeclarations): ditto + + * kjs/property_slot.h: + (KJS::PropertySlot::ungettableGetter): Best function name evar. + +2008-01-11 Cameron Zwarich + + Reviewed by Maciej. + + Optimized ActivationImp allocation, so that activation records are now + first allocated on an explicitly managed stack and only heap allocated + when necessary. Roughly a 5% improvement on SunSpider, and a larger + improvement on benchmarks that use more function calls. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/Activation.h: Added. + (KJS::ActivationImp::ActivationData::ActivationData): + (KJS::ActivationImp::ActivationImp): + (KJS::ActivationImp::classInfo): + (KJS::ActivationImp::isActivationObject): + (KJS::ActivationImp::isOnStack): + (KJS::ActivationImp::d): + (KJS::StackActivation::StackActivation): + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + (KJS::ExecState::~ExecState): + * kjs/ExecState.h: + (KJS::ExecState::replaceScopeChainTop): + (KJS::ExecState::setActivationObject): + (KJS::ExecState::setLocalStorage): + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): + (KJS::JSGlobalObject::pushActivation): + (KJS::JSGlobalObject::checkActivationCount): + (KJS::JSGlobalObject::popActivationHelper): + (KJS::JSGlobalObject::popActivation): + (KJS::JSGlobalObject::tearOffActivation): + * kjs/JSGlobalObject.h: + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::JSVariableObjectData::JSVariableObjectData): + (KJS::JSVariableObject::JSVariableObject): + * kjs/function.cpp: + (KJS::FunctionImp::argumentsGetter): + (KJS::ActivationImp::ActivationImp): + (KJS::ActivationImp::~ActivationImp): + (KJS::ActivationImp::init): + (KJS::ActivationImp::getOwnPropertySlot): + (KJS::ActivationImp::markHelper): + (KJS::ActivationImp::mark): + (KJS::ActivationImp::ActivationData::ActivationData): + (KJS::GlobalFuncImp::callAsFunction): + * kjs/function.h: + * kjs/nodes.cpp: + (KJS::PostIncResolveNode::evaluate): + (KJS::PostDecResolveNode::evaluate): + (KJS::PreIncResolveNode::evaluate): + (KJS::PreDecResolveNode::evaluate): + (KJS::ReadModifyResolveNode::evaluate): + (KJS::AssignResolveNode::evaluate): + (KJS::WithNode::execute): + (KJS::TryNode::execute): + (KJS::FunctionBodyNode::processDeclarations): + (KJS::FuncExprNode::evaluate): + * kjs/object.h: + * kjs/scope_chain.h: + (KJS::ScopeChain::replace): + * kjs/scope_chain_mark.h: Added. + (KJS::ScopeChain::mark): + +2008-01-11 Simon Hausmann + + Reviewed by Mark Rowe. + + Fix the (clean) qmake build. For generating chartables.c we don't + depend on a separate input source file anymore, the dftables perl + script is enough. So use that instead as value for the .input + variable, to ensure that qmake also generates a rule to call dftables. + + * pcre/pcre.pri: + +2008-01-10 Geoffrey Garen + + Reviewed by John Sullivan. + + Fixed some world leak reports: + * PLT complains about world leak of 1 JavaScript + Interpreter after running cvs-base suite + + * PLT complains about world leak if browser + window is open when PLT starts + + * kjs/collector.h: Added the ability to distinguish between global + objects and GC-protected global objects, since we only consider the + latter to be world leaks. + * kjs/collector.cpp: + +2008-01-11 Mark Rowe + + Silence qmake warning about ctgen lacking input. + + Rubber-stamped by Alp Toker. + + * pcre/pcre.pri: + +2008-01-10 David Kilzer + + dftables should be rewritten as a script + + + + + Reviewed by Darin. + + Rewrote the dftables utility in Perl. Attempted to switch all + build systems to call the script directly instead of building + a binary first. Only the Xcode build was able to be tested. + + * DerivedSources.make: Added pcre directory to VPATH and changed + to invoke dftables directly. + * GNUmakefile.am: Removed build information and changed to invoke + dftables directly. + * JavaScriptCore.vcproj/JavaScriptCore.sln: Removed reference to + dftables project. + * JavaScriptCore.vcproj/JavaScriptCoreSubmit.sln: Ditto. + * JavaScriptCore.vcproj/dftables: Removed. + * JavaScriptCore.vcproj/dftables/dftables.vcproj: Removed. + * JavaScriptCore.xcodeproj/project.pbxproj: Removed dftables target. + * jscore.bkl: Removed dftables executable definition. + * pcre/dftables: Copied from JavaScriptCore/pcre/dftables.cpp. + * pcre/dftables.cpp: Removed. + * pcre/dftables.pro: Removed. + * pcre/pcre.pri: Removed references to dftables.cpp and changed to + invoke dftables directly. + +2008-01-10 Dan Bernstein + + Reviewed by Darin Adler. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16782 + REGRESSION(r29266): Reproducible crash in fast/replaced/image-map.html + + The crash resulted from a native object (DumpRenderTree's + EventSender) causing its wrapper to be invalidated (by clicking a + link that replaced the document in the window) and consequently + deallocated. The fix is to use RefPtrs to protect the native object + from deletion by self-invalidation. + + * bindings/runtime_method.cpp: + (RuntimeMethod::callAsFunction): + * bindings/runtime_object.cpp: + (RuntimeObjectImp::fallbackObjectGetter): + (RuntimeObjectImp::fieldGetter): + (RuntimeObjectImp::methodGetter): + (RuntimeObjectImp::put): + (RuntimeObjectImp::defaultValue): + (RuntimeObjectImp::callAsFunction): + +2008-01-07 Mark Rowe + + Reviewed by Maciej Stachowiak. + + Turn testIsInteger assertions into compile-time asserts and move them into HashTraits.h + where possible. + + * kjs/testkjs.cpp: + * wtf/HashTraits.h: + +2008-01-07 Nikolas Zimmermann + + Reviewed by Mark. + + Enable SVG_FONTS by default. + + * Configurations/JavaScriptCore.xcconfig: + +2008-01-07 Darin Adler + + Rubber stamped by David Kilzer. + + - get rid of empty fpconst.cpp + + * GNUmakefile.am: Remove fpconst.cpp. + * JavaScriptCore.pri: Ditto. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Ditto. + * JavaScriptCore.xcodeproj/project.pbxproj: Ditto. + * JavaScriptCoreSources.bkl: Ditto. + + * kjs/fpconst.cpp: Removed. + +2008-01-07 Darin Adler + + Reviewed by David Kilzer. + + - fix alignment problem with NaN and Inf globals + + * kjs/fpconst.cpp: Move the contents of this file from here back to + value.cpp. The reason this was in a separate file is that the DARWIN + version of this used a declaration of the globals with a different + type to avoid creating "init routines". That's no longer necessary for + DARWIN and was never necessary for the non-DARWIN code path. + To make this patch easy to merge, I didn't actually delete this file + yet. We'll do that in a separate changeset. + + * kjs/value.cpp: If C99's NAN and INFINITY are present, then use them, + othrewise use the union trick from fpconst.cpp. I think it would be + better to eliminate KJS::NaN and KJS::Inf and just use NAN and INFINITY + directly or std::numeric_limits::quiet_nan() and + std::numeric_limits::infinity(). But when I tried that, it + slowed down SunSpider. Someone else could do that cleanup if they + could do it without slowing down the engine. + +2008-01-07 Adam Roben + + Windows build fix + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Added + JavaScript.h to the project. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make: + Copy JavaScript.h to WEBKITOUTPUTDIR. + +2008-01-07 Timothy Hatcher + + Reviewed by Darin. + + Fix Mac build. + + * API/JSNode.c: + * API/JSNode.h: + * API/JSNodeList.c: + * API/JSNodeList.h: + * API/JavaScript.h: + * API/JavaScriptCore.h: + * API/minidom.c: + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-01-07 Alp Toker + + Reviewed by Darin. + + http://bugs.webkit.org/show_bug.cgi?id=16029 + JavaScriptCore.h is not suitable for platforms other than Mac OS X + + Introduce a new JavaScriptCore/JavaScript.h public API header. This + should be used by all new portable code using the JavaScriptCore API. + + JavaScriptCore/JavaScriptCore.h will remain for compatibility with + existing applications that depend on it including JSStringRefCF.h + which isn't portable. + + Also add minidom to the GTK+/autotools build since we can now support + it on all platforms. + + * API/JSNode.h: + * API/JSNodeList.h: + * API/JavaScript.h: Added. + * API/JavaScriptCore.h: + * ForwardingHeaders/JavaScriptCore/JavaScript.h: Added. + * GNUmakefile.am: + * JavaScriptCore.xcodeproj/project.pbxproj: + +2008-01-06 Eric Seidel + + Reviewed by Sam. + + Abstract all DateObject.set* functions in preparation for fixing: + http://bugs.webkit.org/show_bug.cgi?id=16753 + + SunSpider had random changes here and there but was overall a wash. + + * kjs/date_object.cpp: + (KJS::fillStructuresUsingTimeArgs): + (KJS::setNewValueFromTimeArgs): + (KJS::setNewValueFromDateArgs): + (KJS::DateProtoFuncSetMilliSeconds::callAsFunction): + (KJS::DateProtoFuncSetUTCMilliseconds::callAsFunction): + (KJS::DateProtoFuncSetSeconds::callAsFunction): + (KJS::DateProtoFuncSetUTCSeconds::callAsFunction): + (KJS::DateProtoFuncSetMinutes::callAsFunction): + (KJS::DateProtoFuncSetUTCMinutes::callAsFunction): + (KJS::DateProtoFuncSetHours::callAsFunction): + (KJS::DateProtoFuncSetUTCHours::callAsFunction): + (KJS::DateProtoFuncSetDate::callAsFunction): + (KJS::DateProtoFuncSetUTCDate::callAsFunction): + (KJS::DateProtoFuncSetMonth::callAsFunction): + (KJS::DateProtoFuncSetUTCMonth::callAsFunction): + (KJS::DateProtoFuncSetFullYear::callAsFunction): + (KJS::DateProtoFuncSetUTCFullYear::callAsFunction): + +2008-01-06 Nikolas Zimmermann + + Reviewed by Dan. + + Add new helper function isArabicChar - SVG Fonts support needs it. + + * wtf/unicode/icu/UnicodeIcu.h: + (WTF::Unicode::isArabicChar): + * wtf/unicode/qt4/UnicodeQt4.h: + (WTF::Unicode::isArabicChar): + +2008-01-06 Alp Toker + + Reviewed by Mark Rowe. + + Use $(EXEEXT) to account for the .exe extension in the GTK+ Windows + build. (This is already done correctly in DerivedSources.make.) Issue + noticed by Mikkel when building in Cygwin. + + Add a missing slash. This was a hack from the qmake build system that + isn't necessary with autotools. + + * GNUmakefile.am: + +2008-01-05 Darin Adler + + * API/JSRetainPtr.h: One more file that needed the change below. + +2008-01-05 Darin Adler + + * wtf/OwnPtr.h: OwnPtr needs the same fix as RefPtr below. + +2008-01-05 Adam Roben + + Build fix. + + Reviewed by Maciej. + + * wtf/RetainPtr.h: Use PtrType instead of T* because of the + RemovePointer magic. + +2008-01-05 Darin Adler + + Rubber stamped by Maciej Stachowiak. + + - cut down own PIC branches by using a pointer-to-member-data instead of a + pointer-to-member-function in WTF smart pointers + + * wtf/OwnArrayPtr.h: + * wtf/OwnPtr.h: + * wtf/PassRefPtr.h: + * wtf/RefPtr.h: + * wtf/RetainPtr.h: + Use a pointer to the m_ptr member instead of the get member. + The GCC compiler generates better code for this idiom. + +2008-01-05 Henry Mason + + Reviewed by Maciej Stachowiak. + + http://bugs.webkit.org/show_bug.cgi?id=16738 + Bug 16738: Collector block offset could be stored as an cell offset instead of a byte offset + + Gives a 0.4% SunSpider boost and prettier code. + + * kjs/collector.cpp: Switched to cell offsets from byte offsets + (KJS::Collector::heapAllocate): + (KJS::Collector::sweep): + +2008-01-04 Mark Rowe + + Reviewed by Maciej Stachowiak. + + Have the two malloc zones print useful diagnostics if their free method are unexpectedly invoked. + Due to this can happen if an application attempts to free a pointer that + was not allocated by any registered malloc zone on the system. + + * kjs/CollectorHeapIntrospector.h: + * wtf/FastMalloc.cpp: + +2008-01-04 Alp Toker + + GTK+ autotools build fix. Terminate empty rules. + + * GNUmakefile.am: + +2008-01-03 Simon Hausmann + + Reviewed by Mark Rowe. + + Fix compilation with gcc 4.3: limits.h is needed for INT_MAX. + + * pcre/pcre_exec.cpp: + +2008-01-03 Darin Adler + + * tests/mozilla/expected.html: The fix for bug 16696 also fixed a test + case, ecma_3/RegExp/perlstress-002.js, so updated results to expect + that test to succeed. + +2008-01-02 Darin Adler + + Reviewed by Geoff. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16696 + JSCRE fails fails to match Acid3 regexp + + Test: fast/regex/early-acid3-86.html + + The problem was with the cutoff point between backreferences and octal + escape sequences. We need to determine the cutoff point by counting the + total number of capturing brackets, which requires an extra pass through + the expression when compiling it. + + * pcre/pcre_compile.cpp: + (CompileData::CompileData): Added numCapturingBrackets. Removed some + unused fields. + (compileBranch): Use numCapturingBrackets when calling checkEscape. + (calculateCompiledPatternLength): Use numCapturingBrackets when calling + checkEscape, and also store the bracket count at the end of the compile. + (jsRegExpCompile): Call calculateCompiledPatternLength twice -- once to + count the number of brackets and then a second time to calculate the length. + +2008-01-02 Darin Adler + + Reviewed by Geoff. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16696 + JSCRE fails fails to match Acid3 regexp + + Test: fast/regex/early-acid3-86.html + + The problem was with the cutoff point between backreferences and octal + escape sequences. We need to determine the cutoff point by counting the + total number of capturing brackets, which requires an extra pass through + the expression when compiling it. + + * pcre/pcre_compile.cpp: + (CompileData::CompileData): Added numCapturingBrackets. Removed some + unused fields. + (compileBranch): Use numCapturingBrackets when calling checkEscape. + (calculateCompiledPatternLength): Use numCapturingBrackets when calling + checkEscape, and also store the bracket count at the end of the compile. + (jsRegExpCompile): Call calculateCompiledPatternLength twice -- once to + count the number of brackets and then a second time to calculate the length. + +2008-01-02 David Kilzer + + Reviewed and landed by Darin. + + * kjs/nodes.cpp: + (KJS::DoWhileNode::execute): Added a missing return. + +2008-01-02 Darin Adler + + - try to fix Qt build + + * wtf/unicode/qt4/UnicodeQt4.h: + (WTF::Unicode::foldCase): Add some missing const. + +2008-01-02 Alice Liu + + Reviewed by Sam Weinig. + + need to export ASCIICType.h for use in DRT + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * wtf/ASCIICType.h: + (WTF::isASCIIUpper): + +2008-01-02 Sam Weinig + + Reviewed by Beth Dakin. + + Cleanup error_object.h/cpp. + + * kjs/JSGlobalObject.cpp: + (KJS::JSGlobalObject::reset): + * kjs/error_object.cpp: + (KJS::ErrorInstance::ErrorInstance): + (KJS::ErrorPrototype::ErrorPrototype): + (KJS::ErrorProtoFuncToString::ErrorProtoFuncToString): + (KJS::ErrorProtoFuncToString::callAsFunction): + (KJS::ErrorObjectImp::ErrorObjectImp): + (KJS::ErrorObjectImp::implementsConstruct): + (KJS::ErrorObjectImp::construct): + (KJS::ErrorObjectImp::callAsFunction): + (KJS::NativeErrorPrototype::NativeErrorPrototype): + (KJS::NativeErrorImp::NativeErrorImp): + (KJS::NativeErrorImp::implementsConstruct): + (KJS::NativeErrorImp::construct): + (KJS::NativeErrorImp::callAsFunction): + (KJS::NativeErrorImp::mark): + * kjs/error_object.h: + (KJS::ErrorInstance::classInfo): + (KJS::NativeErrorImp::classInfo): + +2008-01-02 Mark Rowe + + Rubber-stamped by Alp Toker. + + * GNUmakefile.am: Add missing dependency on grammar.y. + +2008-01-01 Darin Adler + + Reviewed by Eric. + + - fix for http://bugs.webkit.org/show_bug.cgi?id=16695 + JSC allows non-identifier codepoints in identifiers (affects Acid3) + + Test: fast/js/kde/parse.html + + * kjs/lexer.cpp: + (KJS::Lexer::lex): Added additional states to distinguish Unicode escapes at the + start of identifiers from ones inside identifiers. Rejected characters that don't pass + the isIdentStart and isIdentPart tests. + (KJS::Lexer::convertUnicode): Removed incorrect FIXME comment. + + * kjs/lexer.h: Added new states to distinguish \u escapes at the start of identifiers + from \u escapes inside identifiers. + +2008-01-01 Darin Adler + + - rolled scope chain optimization out; it was breaking the world + +2008-01-01 Darin Adler + + Reviewed by Geoff. + + - http://bugs.webkit.org/show_bug.cgi?id=16685 + eliminate List::empty() to cut down on PIC branches + + Also included one other speed-up -- remove the call to reserveCapacity from + FunctionBodyNode::processDeclarations in all but the most unusual cases. + + Together these make SunSpider 1.016x as fast. + + * JavaScriptCore.exp: Updated. + * kjs/ExecState.cpp: + (KJS::globalEmptyList): Added. Called only when creating global ExecState + instances. + (KJS::ExecState::ExecState): Broke constructor up into three separate functions, + for the three separate node types. Also went through each of the three and + streamlined as much as possible, removing dead code. This prevents us from having + to access the global in the function body version of the constructor. + + * kjs/ExecState.h: Added emptyList(). Replaced the constructor with a set of + three that are specific to the different node types that can create new execution + state objects. + + * kjs/array_object.cpp: + (KJS::ArrayProtoFuncToLocaleString::callAsFunction): Use exec->emptyList() instead + of List::empty(). + (KJS::ArrayProtoFuncConcat::callAsFunction): Ditto. + (KJS::ArrayProtoFuncSlice::callAsFunction): Ditto. + (KJS::ArrayProtoFuncSplice::callAsFunction): Ditto. + (KJS::ArrayProtoFuncFilter::callAsFunction): Ditto. + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): Updated to call new ExecState constructor. + (KJS::GlobalFuncImp::callAsFunction): Ditto (for eval). + * kjs/function_object.cpp: + (FunctionObjectImp::construct): Use exec->emptyList() instead of List::empty(). + + * kjs/list.cpp: Removed List::empty. + * kjs/list.h: Ditto. + + * kjs/nodes.cpp: + (KJS::ElementNode::evaluate): Use exec->emptyList() instead of List::empty(). + (KJS::ArrayNode::evaluate): Ditto. + (KJS::ObjectLiteralNode::evaluate): Ditto. + (KJS::PropertyListNode::evaluate): Ditto. + (KJS::FunctionBodyNode::processDeclarations): Another speed-up. Check the capacity + before calling reserveCapacity, because it doesn't get inlined the local storage + vector is almost always big enough -- saving the function call overhead is a big + deal. + (KJS::FuncDeclNode::makeFunction): Use exec->emptyList() instead of List::empty(). + (KJS::FuncExprNode::evaluate): Ditto. + * kjs/object.cpp: + (KJS::tryGetAndCallProperty): Ditto. + * kjs/property_slot.cpp: + (KJS::PropertySlot::functionGetter): Ditto. + * kjs/string_object.cpp: + (KJS::StringProtoFuncSplit::callAsFunction): Ditto. + +2008-01-01 Darin Adler + + Reviewed by Geoff. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16648 + REGRESSION (r28165): Yuku.com navigation prints "jsRegExpExecute failed with result -2" + REGRESSION (r28165): Layout test fast/regex/test1 fails intermittently + + Fixes 34 failing test cases in the fast/regex/test1.html test. + + Restored the stack which prevents infinite loops for brackets that match the empty + string; it had been removed as an optimization. + + Unfortunately, restoring this stack causes the regular expression test in SunSpider + to be 1.095x as slow and the overall test to be 1.004x as slow. Maybe we can find + a correct optimization to restore the speed! + + It's possible the original change was on the right track but just off by one. + + * pcre/pcre_exec.cpp: Add back eptrblock, but name it BracketChainNode. + (MatchStack::pushNewFrame): Add back the logic needed here. + (startNewGroup): Ditto. + (match): Ditto. + +2008-01-01 Darin Adler + + Reviewed by Geoff. + + - http://bugs.webkit.org/show_bug.cgi?id=16683 + speed up function calls by making ScopeChain::push cheaper + + This gives a 1.019x speedup on SunSpider. + + After doing this, I realized this probably will be obsolete when the optimization + to avoid creating an activation object is done. When we do that one we should check + if rolling this out will speed things up, since this does add overhead at the time + you copy the scope chain. + + * kjs/object.h: Removed the ScopeChain::release function. It was + marked inline, and called in exactly one place, so moved it there. + No idea why it was in this header file! + + * kjs/scope_chain.cpp: Removed the overload of the ScopeChain::push + function that takes another ScopeChain. It was unused. I think we used + it over in WebCore at one point, but not any more. + + * kjs/scope_chain.h: Changed ScopeChainNode into a struct rather than + a class, got rid of its constructor so we can have one that's uninitialized, + and moved the refCount into a derived struct, ScopeChainHeapNode. Made _node + mutable so it can be changed in the moveToHeap function. Changed the copy + constructor and assignment operator to call moveToHeap, since the top node + can't be shared when it's embedded in another ScopeChain object. Updated + functions as needed to handle the case where the first object isn't on the + heap or to add casts for cases where it's guaranteed to be. Changed the push + function to always put the new node into the ScopeChain object; it will get + put onto the heap when needed later. + +2008-01-01 Geoffrey Garen + + Reviewed by Darin Adler. + + Fixed slight logic error in reserveCapacity, where we would reallocate + the storage buffer unnecessarily. + + * wtf/Vector.h: + (WTF::::reserveCapacity): No need to grow the buffer if newCapacity is + equal to capacity(). + +2008-01-01 Darin Adler + + Reviewed by Oliver. + + - http://bugs.webkit.org/show_bug.cgi?id=16684 + eliminate debugger overhead from function body execution + + Speeds SunSpider up 1.003x. That's a small amount, but measurable. + + * JavaScriptCore.exp: Updated. + * kjs/Parser.h: + (KJS::Parser::parse): Create the node with a static member function named create() instead + of using new explicitly. + + * kjs/grammar.y: Changed calls to new FunctionBodyNode to use FunctionBodyNode::create(). + + * kjs/nodes.cpp: + (KJS::ProgramNode::create): Added. Calls new. + (KJS::EvalNode::create): Ditto. + (KJS::FunctionBodyNode::create): Ditto, but creates FunctionBodyNodeWithDebuggerHooks + when a debugger is present. + (KJS::FunctionBodyNode::execute): Removed debugger hooks. + (KJS::FunctionBodyNodeWithDebuggerHooks::FunctionBodyNodeWithDebuggerHooks): Added. + (KJS::FunctionBodyNodeWithDebuggerHooks::execute): Calls the debugger, then the code, + then the debugger again. + + * kjs/nodes.h: Added create functions, made the constructors private and protected. + +2007-12-30 Eric Seidel + + Reviewed by Sam. + + More small cleanup to array_object.cpp + + * kjs/array_object.cpp: + (KJS::ArrayProtoFuncToString::callAsFunction): + (KJS::ArrayProtoFuncToLocaleString::callAsFunction): + (KJS::ArrayProtoFuncJoin::callAsFunction): + (KJS::ArrayProtoFuncConcat::callAsFunction): + (KJS::ArrayProtoFuncReverse::callAsFunction): + (KJS::ArrayProtoFuncShift::callAsFunction): + (KJS::ArrayProtoFuncSlice::callAsFunction): + (KJS::ArrayProtoFuncSort::callAsFunction): + (KJS::ArrayProtoFuncSplice::callAsFunction): + (KJS::ArrayProtoFuncUnShift::callAsFunction): + (KJS::ArrayProtoFuncFilter::callAsFunction): + (KJS::ArrayProtoFuncMap::callAsFunction): + (KJS::ArrayProtoFuncEvery::callAsFunction): + +2007-12-30 Eric Seidel + + Reviewed by Sam. + + Apply wkstyle to array_object.cpp + + * kjs/array_object.cpp: + (KJS::ArrayPrototype::ArrayPrototype): + (KJS::ArrayPrototype::getOwnPropertySlot): + (KJS::ArrayProtoFuncConcat::callAsFunction): + (KJS::ArrayProtoFuncPop::callAsFunction): + (KJS::ArrayProtoFuncReverse::callAsFunction): + (KJS::ArrayProtoFuncShift::callAsFunction): + (KJS::ArrayProtoFuncSlice::callAsFunction): + (KJS::ArrayProtoFuncSort::callAsFunction): + (KJS::ArrayProtoFuncSplice::callAsFunction): + (KJS::ArrayProtoFuncUnShift::callAsFunction): + (KJS::ArrayProtoFuncFilter::callAsFunction): + (KJS::ArrayProtoFuncMap::callAsFunction): + (KJS::ArrayProtoFuncEvery::callAsFunction): + (KJS::ArrayProtoFuncLastIndexOf::callAsFunction): + (KJS::ArrayObjectImp::ArrayObjectImp): + (KJS::ArrayObjectImp::implementsConstruct): + (KJS::ArrayObjectImp::construct): + (KJS::ArrayObjectImp::callAsFunction): + +2007-12-30 Eric Seidel + + Reviewed by Sam. + + Remove maxInt/minInt, replacing with std:max/min() + + * kjs/array_object.cpp: + (KJS::ArrayProtoFuncSplice::callAsFunction): + * kjs/operations.cpp: + * kjs/operations.h: + +2007-12-30 Eric Seidel + + Reviewed by Sam. + + Update Number.toString to properly throw exceptions. + Cleanup code in Number.toString implementation. + + * kjs/number_object.cpp: + (KJS::numberToString): + * kjs/object.cpp: + (KJS::Error::create): Remove bogus debug lines. + +2007-12-28 Eric Seidel + + Reviewed by Oliver. + + ASSERT when debugging via Drosera due to missed var lookup optimization. + http://bugs.webkit.org/show_bug.cgi?id=16634 + + No test case possible. + + * kjs/nodes.cpp: + (KJS::BreakpointCheckStatement::optimizeVariableAccess): + * kjs/nodes.h: + +2007-12-28 Eric Seidel + + Reviewed by Oliver. + + Fix (-0).toFixed() and re-factor a little + Fix (-0).toExponential() and printing of trailing 0s in toExponential + Fix toPrecision(nan) handling + http://bugs.webkit.org/show_bug.cgi?id=16640 + + * kjs/number_object.cpp: + (KJS::numberToFixed): + (KJS::fractionalPartToString): + (KJS::numberToExponential): + (KJS::numberToPrecision): + +2007-12-28 Eric Seidel + + Reviewed by Sam. + + More changes to make number code readable + + * kjs/number_object.cpp: + (KJS::integer_part_noexp): + (KJS::numberToFixed): + (KJS::numberToExponential): + +2007-12-28 Eric Seidel + + Reviewed by Sam. + + More small cleanups to toPrecision + + * kjs/number_object.cpp: + (KJS::numberToPrecision): + +2007-12-28 Eric Seidel + + Reviewed by Sam. + + More small attempts to make number code readable + + * kjs/number_object.cpp: + (KJS::exponentialPartToString): + (KJS::numberToExponential): + (KJS::numberToPrecision): + +2007-12-28 Eric Seidel + + Reviewed by Sam. + + Break out callAsFunction implementations into static functions + + * kjs/number_object.cpp: + (KJS::numberToString): + (KJS::numberToFixed): + (KJS::numberToExponential): + (KJS::numberToPrecision): + (KJS::NumberProtoFunc::callAsFunction): + +2007-12-28 Eric Seidel + + Reviewed by Sam. + + Apply wkstyle/astyle and fix placement of * + + * kjs/number_object.cpp: + (KJS::NumberInstance::NumberInstance): + (KJS::NumberPrototype::NumberPrototype): + (KJS::NumberProtoFunc::NumberProtoFunc): + (KJS::integer_part_noexp): + (KJS::intPow10): + (KJS::NumberProtoFunc::callAsFunction): + (KJS::NumberObjectImp::NumberObjectImp): + (KJS::NumberObjectImp::getOwnPropertySlot): + (KJS::NumberObjectImp::getValueProperty): + (KJS::NumberObjectImp::implementsConstruct): + (KJS::NumberObjectImp::construct): + (KJS::NumberObjectImp::callAsFunction): + * kjs/object.cpp: + (KJS::JSObject::put): + +2007-12-27 Eric Seidel + + Reviewed by Sam. + + ASSERT in JavaScriptCore while viewing WICD test case + http://bugs.webkit.org/show_bug.cgi?id=16626 + + * kjs/nodes.cpp: + (KJS::ForInNode::execute): move KJS_CHECK_EXCEPTION to proper place + +2007-12-26 Jan Michael Alonzo + + Reviewed by Alp Toker. + + http://bugs.webkit.org/show_bug.cgi?id=16390 + Use autotools or GNU make as the build system for the GTK port + + * GNUmakefile.am: Added. + +2007-12-25 Maciej Stachowiak + + Reviewed by Oliver. + + - Remove unnecessary redundant check from property setting + http://bugs.webkit.org/show_bug.cgi?id=16602 + + 1.3% speedup on SunSpider. + + * kjs/object.cpp: + (KJS::JSObject::put): Don't do canPut check when not needed; let + the PropertyMap handle it. + (KJS::JSObject::canPut): Don't check the static property + table. lookupPut does that already. + +2007-12-24 Alp Toker + + Fix builds that don't use AllInOneFile.cpp following breakage + introduced in r28973. + + * kjs/grammar.y: + +2007-12-24 Maciej Stachowiak + + Reviewed by Eric. + + - Optimize variable declarations + http://bugs.webkit.org/show_bug.cgi?id=16585 + + 3.5% speedup on SunSpider. + + var statements now result in either assignments or empty statements. + + This allows a couple of optimization opportunities: + - No need to branch at runtime to check if there is an initializer + - EmptyStatementNodes can be removed entirely (also done in this patch) + - Assignment expressions get properly optimized for local variables + + This patch also includes some code cleanup: + - Most of the old VarStatement/VarDecl logic is now only used for const declarations, + thus it is renamed appropriately + - AssignExprNode is gone + + * JavaScriptCore.exp: + * kjs/NodeInfo.h: + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::SourceElements::append): + (KJS::ConstDeclNode::ConstDeclNode): + (KJS::ConstDeclNode::optimizeVariableAccess): + (KJS::ConstDeclNode::handleSlowCase): + (KJS::ConstDeclNode::evaluateSingle): + (KJS::ConstDeclNode::evaluate): + (KJS::ConstStatementNode::optimizeVariableAccess): + (KJS::ConstStatementNode::execute): + (KJS::VarStatementNode::optimizeVariableAccess): + (KJS::VarStatementNode::execute): + (KJS::ForInNode::ForInNode): + (KJS::ForInNode::optimizeVariableAccess): + (KJS::ForInNode::execute): + (KJS::FunctionBodyNode::initializeSymbolTable): + (KJS::ProgramNode::initializeSymbolTable): + (KJS::FunctionBodyNode::processDeclarations): + (KJS::ProgramNode::processDeclarations): + (KJS::EvalNode::processDeclarations): + * kjs/nodes.h: + (KJS::DeclarationStacks::): + (KJS::StatementNode::): + (KJS::ConstDeclNode::): + (KJS::ConstStatementNode::): + (KJS::EmptyStatementNode::): + (KJS::VarStatementNode::): + (KJS::ForNode::): + * kjs/nodes2string.cpp: + (KJS::ConstDeclNode::streamTo): + (KJS::ConstStatementNode::streamTo): + (KJS::ScopeNode::streamTo): + (KJS::VarStatementNode::streamTo): + (KJS::ForNode::streamTo): + (KJS::ForInNode::streamTo): + +2007-12-21 Mark Rowe + + Reviewed by Oliver Hunt. + + * JavaScriptCore.exp: Remove unused symbol to prevent a weak external symbol + being generated in JavaScriptCore.framework. + +2007-12-21 Darin Adler + + Requested by Maciej. + + * kjs/nodes.h: Use the new NEVER_INLINE here and eliminate the old + KJS_NO_INLINE. We don't want to have two, and we figured it was better + to keep the one that's in WTF. + +2007-12-21 Darin Adler + + Reviewed by Eric. + + - http://bugs.webkit.org/show_bug.cgi?id=16561 + remove debugger overhead from non-debugged JavaScript execution + + 1.022x as fast on SunSpider. + + * JavaScriptCore.exp: Updated. + + * kjs/NodeInfo.h: Renamed SourceElementsStub to SourceElements, + since that more accurately describes the role of this object, which + is a reference-counted wrapper for a Vector. + + * kjs/Parser.cpp: + (KJS::Parser::didFinishParsing): Changed parameter type to SourceElements, + and use plain assignment instead of set. + * kjs/Parser.h: Changed parameter type of didFinishParsing to a + SourceElements. Also changed m_sourceElements; we now use a RefPtr instead + of an OwnPtr as well. + + * kjs/grammar.y: Got rid of all the calls to release() on SourceElements. + That's now handed inside the constructors for various node types, since we now + use vector swapping instead. + + * kjs/nodes.cpp: + (KJS::Node::rethrowException): Added NEVER_INLINE, because this was getting inlined + and we want exception handling out of the normal code flow. + (KJS::SourceElements::append): Moved here from the header. This now handles + creating a BreakpointCheckStatement for each statement in the debugger case. + That way we can get breakpoint handling without having it in every execute function. + (KJS::BreakpointCheckStatement::BreakpointCheckStatement): Added. + (KJS::BreakpointCheckStatement::execute): Added. Contains the code that was formerly + in the StatementNode::hitStatement function and the KJS_BREAKPOINT macro. + (KJS::BreakpointCheckStatement::streamTo): Added. + (KJS::ArgumentListNode::evaluateList): Use KJS_CHECKEXCEPTIONVOID since the return + type is void. + (KJS::VarStatementNode::execute): Removed KJS_BREAKPOINT. + (KJS::BlockNode::BlockNode): Changed parameter type to SourceElements. + Changed code to use release since the class now contains a vector rather than + a vector point. + (KJS::BlockNode::optimizeVariableAccess): Updated since member is now a vector + rather than a vector pointer. + (KJS::BlockNode::execute): Ditto. + (KJS::ExprStatementNode::execute): Removed KJS_BREAKPOINT. + (KJS::IfNode::execute): Ditto. + (KJS::IfElseNode::execute): Ditto. + (KJS::DoWhileNode::execute): Ditto. + (KJS::WhileNode::execute): Ditto. + (KJS::ContinueNode::execute): Ditto. + (KJS::BreakNode::execute): Ditto. + (KJS::ReturnNode::execute): Ditto. + (KJS::WithNode::execute): Ditto. + (KJS::CaseClauseNode::optimizeVariableAccess): Updated since member is now a vector + rather than a vector pointer. + (KJS::CaseClauseNode::executeStatements): Ditto. + (KJS::SwitchNode::execute): Removed KJS_BREAKPOINT. + (KJS::ThrowNode::execute): Ditto. + (KJS::TryNode::execute): Ditto. + (KJS::ScopeNode::ScopeNode): Changed parameter type to SourceElements. + (KJS::ProgramNode::ProgramNode): Ditto. + (KJS::EvalNode::EvalNode): Ditto. + (KJS::FunctionBodyNode::FunctionBodyNode): Ditto. + (KJS::ScopeNode::optimizeVariableAccess): Updated since member is now a vector + rather than a vector pointer. + + * kjs/nodes.h: Removed hitStatement. Renamed SourceElements to StatementVector. + Renamed SourceElementsStub to SourceElements and made it derive from + ParserRefCounted rather than from Node, hold a vector rather than a pointer to + a vector, and changed the release function to swap with another vector rather + than the pointer idiom. Updated BlockNode and CaseClauseNode to hold actual + vectors instead of pointers to vectors. Added BreakpointCheckStatement. + + * kjs/nodes2string.cpp: + (KJS::statementListStreamTo): Changed to work on a vector instead of a pointer + to a vector. + (KJS::BlockNode::streamTo): Ditto. + (KJS::CaseClauseNode::streamTo): Ditto. + + * wtf/AlwaysInline.h: Added NEVER_INLINE. + * wtf/PassRefPtr.h: Tweaked formatting. Added clear() function that matches the + ones in OwnPtr and auto_ptr. + * wtf/RefPtr.h: Ditto. + +2007-12-21 Darin Adler + + - fix broken regression tests + + The broken tests were fast/js/do-while-expression-value.html and + fast/js/while-expression-value.html. + + * kjs/nodes.cpp: Check in the correct version of this file. I had accidentally landed + an old version of my patch for bug 16471. + (KJS::statementListExecute): The logic here was backwards. Have to set the value + even for non-normal execution results. + +2007-12-20 Alexey Proskuryakov + + Windows build fix + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Copy npruntime_internal.h + to WebKitBuild. + +2007-12-20 Eric Seidel + + Reviewed by mjs. + + Split IfNode into IfNode and IfElseNode for speedup. + http://bugs.webkit.org/show_bug.cgi?id=16470 + + SunSpider claims this is 1.003x as fast as before. + (This required running with --runs 15 to get consistent enough results to tell!) + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::IfNode::optimizeVariableAccess): + (KJS::IfNode::execute): + (KJS::IfNode::getDeclarations): + (KJS::IfElseNode::optimizeVariableAccess): + (KJS::IfElseNode::execute): + (KJS::IfElseNode::getDeclarations): + * kjs/nodes.h: + (KJS::IfNode::): + (KJS::IfElseNode::): + * kjs/nodes2string.cpp: + (KJS::IfNode::streamTo): + (KJS::IfElseNode::streamTo): + +2007-12-20 Darin Adler + + Reviewed by Sam. + + * wtf/OwnPtr.h: + (WTF::operator==): Added. + (WTF::operator!=): Added. + +2007-12-20 Geoffrey Garen + + Reviewed by Oliver Hunt. + + AST optimization: Avoid NULL-checking ForNode's child nodes. + + 0.6% speedup on SunSpider. + + This is a proof of concept patch that demonstrates how to optimize + grammar productions with optional components, like + + for (optional; optional; optional) { + ... + } + + The parser emits NULL for an optional component that is not present. + + Instead of checking for a NULL child at execution time, a node that + expects an optional component to be present more often than not checks + for a NULL child at construction time, and substitutes a viable + alternative node in its place. + + (We'd like the parser to start emitting NULL a lot more once we teach + it to emit NULL for certain no-op productions like EmptyStatement and + VariableStatement, so, as a foundation, it's important for nodes with + NULL optional components to be fast.) + + * kjs/Parser.cpp: + (KJS::Parser::didFinishParsing): Check for NULL SourceElements. Also, + moved didFinishParsing into the .cpp file because adding a branch while + it was in the header file caused a substantial and inexplicable + performance regression. (Did I mention that GCC is crazy?) + + * kjs/grammar.y: + + * kjs/nodes.cpp: + (KJS::BlockNode::BlockNode): Check for NULL SourceElements. + (KJS::ForNode::optimizeVariableAccess): No need to check for NULL here. + (KJS::ForNode::execute): No need to check for NULL here. + * kjs/nodes.h: + (KJS::ForNode::): Check for NULL SourceElements. Substitute a TrueNode + because it's semantically harmless, and it evaluates to boolean in an + efficient manner. + +2007-12-20 Oliver Hunt + + Reviewed by Geoff. + + Slight logic reordering in JSImmediate::from(double) + + This gives a 0.6% improvement in SunSpider. + + * kjs/JSImmediate.h: + (KJS::JSImmediate::from): + +2007-12-20 Eric Seidel + + Reviewed by mjs. + + Fix major Array regression introduced by 28899. + + SunSpider claims this is at least 1.37x as fast as pre-regression. :) + + * kjs/array_instance.cpp: make Arrays fast again! + +2007-12-20 Eric Seidel + + Reviewed by Geoff, then re-rubber-stamped by Geoff after final search/replace and testing. + + Small reworking of Date code for 4% speedup on Date tests (0.2% overall) + http://bugs.webkit.org/show_bug.cgi?id=16537 + + Make msToYear human-readable + Make msToDayInMonth slightly more readable and avoid recalculating msToYear + Remove use of isInLeapYear to avoid calling msToYear + Remove dayInYear call by changing msToDayInMonth to dayInMonthFromDayInYear + Remove more duplicate calls to dayInYear and getUTCOffset for further speedup + + * kjs/DateMath.cpp: + (KJS::daysFrom1970ToYear): + (KJS::msToYear): + (KJS::monthFromDayInYear): + (KJS::checkMonth): + (KJS::dayInMonthFromDayInYear): + (KJS::dateToDayInYear): + (KJS::getDSTOffsetSimple): + (KJS::getDSTOffset): + (KJS::gregorianDateTimeToMS): + (KJS::msToGregorianDateTime): + +2007-12-20 Rodney Dawes + + Reviewed by Darin Adler. + + Proxy includes of npruntime.h or npapi.h through npruntime_internal.h + Include stdio.h in npapi.h for the use of FILE with XP_UNIX defined + This is for building with X11, as some type and enum names conflict + with #define names in X11 headers. + http://bugs.webkit.org/show_bug.cgi?id=15669 + + * JavaScriptCore.xcodeproj/project.pbxproj: + * bindings/NP_jsobject.h: + * bindings/npapi.h: + * bindings/npruntime.cpp: + * bindings/npruntime_impl.h: + * bindings/npruntime_priv.h: + * bindings/npruntime_internal.h: + * bindings/testbindings.cpp: + * bindings/c/c_class.h: + * bindings/c/c_runtime.h: + * bindings/c/c_utility.h: + +2007-12-20 Darin Adler + + - re-fix http://bugs.webkit.org/show_bug.cgi?id=16471 + Completions need to be smaller (or not exist at all) + + Same patch as last time with the test failures problem fixed. + + * kjs/function.cpp: + (KJS::GlobalFuncImp::callAsFunction): Make sure to check the completion + type from newExec to see if the execute raised an exception. + +2007-12-20 Darin Adler + + - roll out that last change -- it was causing test failures; + I'll check it back in after fixing them + +2007-12-20 Darin Adler + + Reviewed by Eric. + + - http://bugs.webkit.org/show_bug.cgi?id=16471 + Completions need to be smaller (or not exist at all) + + SuSpider shows 2.4% speedup. + + Stop using completions in the execution engine. + Instead, the completion type and label target are both + stored in the ExecState. + + * API/JSContextRef.cpp: Removed unneeded include of "completion.h". + * bindings/runtime_method.cpp: Removed unused execute function. + * bindings/runtime_method.h: Ditto. + + * kjs/ExecState.h: Added completionType, breakOrContinueTarget, + setCompletionType, setNormalCompletion, setBreakCompletion, + setContinueCompletion, setReturnValueCompletion, setThrowCompletion, + setInterruptedCompletion, m_completionType, and m_breakOrContinueTarget. + + * kjs/completion.h: Removed constructor and getter for target + for break and continue from Completion. This class is now only + used for the public API to Interpreter and such. + + * kjs/date_object.h: Removed unused execute function. + + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): Removed some unneeded + exception processing. Updated to call the new execute function + and to get the completion type from the ExecState. Merged in + the execute function, which repeated some of the same logic and + was called only from here. + (KJS::GlobalFuncImp::callAsFunction): More of the same for eval. + * kjs/function.h: Removed execute. + + * kjs/interpreter.cpp: + (KJS::Interpreter::evaluate): Added code to convert the result of + execut into a Completion. + + * kjs/nodes.cpp: + (KJS::Node::setErrorCompletion): Renamed from createErrorCompletion. + Now sets the completion type in the ExecState. + (KJS::Node::rethrowException): Now sets the completion type in the + ExecState. + (KJS::StatementNode::hitStatement): Now sets the completion type in + the ExecState. + (KJS::VarStatementNode::execute): Updated to put completion type in + the ExecState instead of a Completion object. + (KJS::statementListExecute): Ditto. Also changed the for loop to use + indices instead of iterators. + (KJS::BlockNode::execute): Updated return type. + (KJS::EmptyStatementNode::execute): Updated to put completion type in + the ExecState instead of a Completion object. + (KJS::ExprStatementNode::execute): Ditto. + (KJS::IfNode::execute): Ditto. + (KJS::DoWhileNode::execute): Ditto. Also streamlined the logic a little + to make the normal case a little faster and moved the end outside the + loop so that "break" can do a break. + (KJS::WhileNode::execute): Ditto. + (KJS::ForNode::execute): Ditto. + (KJS::ForInNode::execute): Ditto. + (KJS::ContinueNode::execute): Updated to put completion type in + the ExecState instead of a Completion object. + (KJS::BreakNode::execute): Ditto. + (KJS::ReturnNode::execute): Ditto. + (KJS::WithNode::execute): Ditto. + (KJS::CaseClauseNode::executeStatements): Ditto. Also renamed to have + execute in its name to reflect the fact that it's a member of the same + family of functions. + (KJS::CaseBlockNode::executeBlock): Ditto. + (KJS::SwitchNode::execute): Ditto. + (KJS::LabelNode::execute): Ditto. + (KJS::ThrowNode::execute): Ditto. + (KJS::TryNode::execute): Ditto. + (KJS::ProgramNode::execute): Ditto. + (KJS::EvalNode::execute): Ditto. + (KJS::FunctionBodyNode::execute): Ditto. + (KJS::FuncDeclNode::execute): Ditto. + + * kjs/nodes.h: Renamed setErrorCompletion to createErrorCompletion, made + hitStatement protected, changed return value of execute to a JSValue, + renamed evalStatements to executeStatements, and evalBlock to executeBlock. + + * kjs/number_object.h: Removed unused execute function. + +2007-12-20 Geoffrey Garen + + Added Radar number. + + * kjs/nodes.cpp: + (KJS::ProgramNode::processDeclarations): + +2007-12-20 Geoffrey Garen + + Linux build fix: config.h has to come first. + + * kjs/error_object.cpp: + +2007-12-19 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Optimized global access to global variables, using a symbol table. + + SunSpider reports a 1.5% overall speedup, a 6.2% speedup on 3d-morph, + and a whopping 33.1% speedup on bitops-bitwise-and. + + * API/JSCallbackObjectFunctions.h: Replaced calls to JSObject:: with + calls to Base::, since JSObject is not always our base class. This + was always a bug, but the bug is even more apparent after some of my + changes. + + (KJS::::staticFunctionGetter): Replaced use of getDirect with call to + getOwnPropertySlot. Global declarations are no longer stored in the + property map, so a call to getDirect is insufficient for finding + override properties. + + * API/testapi.c: + * API/testapi.js: Added test for the getDirect change mentioned above. + + * kjs/ExecState.cpp: + * kjs/ExecState.h: Dialed back the optimization to store a direct + pointer to the localStorage buffer. One ExecState can grow the global + object's localStorage without another ExecState's knowledge, so + ExecState can't store a direct pointer to the localStorage buffer + unless/until we invent a way to update all the relevant ExecStates. + + * kjs/JSGlobalObject.cpp: Inserted the symbol table into get and put + operations. + (KJS::JSGlobalObject::reset): Reset the symbol table and local storage, + too. Also, clear the property map here, removing the need for a + separate call. + + * kjs/JSVariableObject.cpp: + * kjs/JSVariableObject.h: Added support for saving localStorage and the + symbol table to the back/forward cache, and restoring them. + + * kjs/function.cpp: + (KJS::GlobalFuncImp::callAsFunction): Renamed progNode to evalNode + because it's an EvalNode, not a ProgramNode. + + * kjs/lookup.h: + (KJS::cacheGlobalObject): Replaced put with faster putDirect, since + that's how the rest of lookup.h works. putDirect is safe here because + cacheGlobalObject is only used for objects whose names are not valid + identifiers. + + * kjs/nodes.cpp: The good stuff! + + (KJS::EvalNode::processDeclarations): Replaced hasProperty with + the new hasOwnProperty, which is slightly faster. + + * kjs/object.h: Nixed clearProperties because clear() does this job now. + + * kjs/property_map.cpp: + * kjs/property_map.h: More back/forward cache support. + + * wtf/Vector.h: + (WTF::::grow): Added fast non-branching grow function. I used it in + an earlier version of this patch, even though it's not used anymore. + +2007-12-09 Mark Rowe + + Reviewed by Oliver Hunt. + + Build fix for non-Mac platforms. Move NodeInfo into its own header so that the YYTYPE + declaration in grammar.h is able to declare members of that type. + + * kjs/NodeInfo.h: Added. + (KJS::createNodeInfo): + (KJS::mergeDeclarationLists): + (KJS::appendToVarDeclarationList): + * kjs/grammar.y: + * kjs/lexer.cpp: + +2007-12-19 Oliver Hunt + + Make appendToVarDeclarationList static + + RS=Weinig. + + * kjs/grammar.y: + +2007-12-18 Oliver Hunt + + Remove dead code due to removal of post-parse declaration discovery. + + RS=Geoff. + + Due to the removal of the declaration discovery pass after parsing we + no longer need any of the logic used for that discovery. + + * kjs/nodes.cpp: + (KJS::Node::Node): + (KJS::VarDeclNode::VarDeclNode): + (KJS::BlockNode::BlockNode): + (KJS::ForInNode::ForInNode): + (KJS::CaseBlockNode::CaseBlockNode): + * kjs/nodes.h: + (KJS::VarStatementNode::): + (KJS::IfNode::): + (KJS::DoWhileNode::): + (KJS::WhileNode::): + (KJS::WithNode::): + (KJS::LabelNode::): + (KJS::TryNode::): + (KJS::FuncDeclNode::): + (KJS::CaseClauseNode::): + (KJS::ClauseListNode::): + (KJS::SwitchNode::): + +2007-12-18 Oliver Hunt + + Replace post-parse pass to find declarations with logic in the parser itself + + Reviewed by Geoff. + + Instead of finding declarations in a pass following the initial parsing of + a program, we incorporate the logic directly into the parser. This lays + the groundwork for further optimisations (such as improving performance in + declaration expressions -- var x = y; -- to match that of standard assignment) + in addition to providing a 0.4% performance improvement in SunSpider. + + * JavaScriptCore.exp: + * kjs/Parser.cpp: + (KJS::Parser::parse): + * kjs/Parser.h: + (KJS::Parser::didFinishParsing): + (KJS::Parser::parse): + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::ParserTracked::ParserTracked): + (KJS::ParserTracked::~ParserTracked): + (KJS::ParserTracked::ref): + (KJS::ParserTracked::deref): + (KJS::ParserTracked::refcount): + (KJS::ParserTracked::clearNewTrackedObjects): + (KJS::Node::Node): + (KJS::ScopeNode::ScopeNode): + (KJS::ProgramNode::ProgramNode): + (KJS::EvalNode::EvalNode): + (KJS::FunctionBodyNode::FunctionBodyNode): + (KJS::FunctionBodyNode::initializeSymbolTable): + (KJS::FunctionBodyNode::processDeclarations): + * kjs/nodes.h: + (KJS::ParserTracked::): + (KJS::Node::): + (KJS::ScopeNode::): + +2007-12-18 Xan Lopez + + Reviewed by Geoff. + + Fix http://bugs.webkit.org/show_bug.cgi?id=14521 + Bug 14521: JavaScriptCore fails to build on Linux/PPC gcc 4.1.2 + + * wtf/TCSpinLock.h: + (TCMalloc_SpinLock::Unlock): + + Use less strict memory operand constraint on inline asm generation. + PLATFORM(DARWIN) left unpatched due to Apple's GCC bug. + + Patch by David Kilzer + +2007-12-18 Mark Rowe + + Rubber-stamped by Maciej Stachowiak. + + Remove outdated and non-functioning project files for the Apollo port. + + * JavaScriptCore.apolloproj: Removed. + +2007-12-18 Darin Adler + + - fix Windows build + + * pcre/pcre_exec.cpp: + (jsRegExpExecute): Change back from false/true to 0/1 -- I probably should not have + deleted MATCH_MATCH and MATCH_NOMATCH, but I'm going to leave them out. + +2007-12-18 Darin Adler + + Reviewed by Geoff. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16458 + REGRESSION (r28164): regular expressions can now hang due to lack of a match limit + + + Test: fast/regex/slow.html + + Slows down SunSpider a bit (about 1.01x); filed a bug to follow up on that: + http://bugs.webkit.org/show_bug.cgi?id=16503 + + * pcre/pcre.h: Changed name of error code to not specifically mention "recursion". + * pcre/pcre_exec.cpp: + (match): Replaced the depth limit, MATCH_RECURSION_LIMIT, with a total match looping + limit, matchLimit. Also eliminated the constants for MATCH_MATCH and MATCH_NOMATCH, + since they are just true and false (1 and 0). + (jsRegExpExecute): More of the MATCH_MATCH change. + +2007-12-17 Darin Adler + + - speculative build fix for non-gcc platforms + + * pcre/pcre_exec.cpp: (match): Remove unused cases from return switch. + +2007-12-16 Mark Rowe + + Speculative build fix for non-Mac platforms. + + * pcre/pcre_compile.cpp: Include string.h for memset, memmove, etc. + +2007-12-16 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=16438 + - removed some more unused code + - changed quite a few more names to WebKit-style + - moved more things out of pcre_internal.h + - changed some indentation to WebKit-style + - improved design of the functions for reading and writing + 2-byte values from the opcode stream (in pcre_internal.h) + + * pcre/dftables.cpp: + (main): Added the kjs prefix a normal way in lieu of using macros. + + * pcre/pcre_compile.cpp: Moved some definitions here from pcre_internal.h. + (errorText): Name changes, fewer typedefs. + (checkEscape): Ditto. Changed uppercase conversion to use toASCIIUpper. + (isCountedRepeat): Name change. + (readRepeatCounts): Name change. + (firstSignificantOpcode): Got rid of the use of OP_lengths, which is + very lightly used here. Hard-coded the length of OP_BRANUMBER. + (firstSignificantOpcodeSkippingAssertions): Ditto. Also changed to + use the advanceToEndOfBracket function. + (getOthercaseRange): Name changes. + (encodeUTF8): Ditto. + (compileBranch): Name changes. Removed unused after_manual_callout and + the code to handle it. Removed code to handle OP_ONCE since we never + emit this opcode. Changed to use advanceToEndOfBracket in more places. + (compileBracket): Name changes. + (branchIsAnchored): Removed code to handle OP_ONCE since we never emit + this opcode. + (bracketIsAnchored): Name changes. + (branchNeedsLineStart): More fo the same. + (bracketNeedsLineStart): Ditto. + (branchFindFirstAssertedCharacter): Removed OP_ONCE code. + (bracketFindFirstAssertedCharacter): More of the same. + (calculateCompiledPatternLengthAndFlags): Ditto. + (returnError): Name changes. + (jsRegExpCompile): Ditto. + + * pcre/pcre_exec.cpp: Moved some definitions here from pcre_internal.h. + (matchRef): Updated names. + Improved macros to use the do { } while(0) idiom so they expand to single + statements rather than to blocks or multiple statements. And refeactored + the recursive match macros. + (MatchStack::pushNewFrame): Name changes. + (getUTF8CharAndIncrementLength): Name changes. + (match): Name changes. Removed the ONCE opcode. + (jsRegExpExecute): Name changes. + + * pcre/pcre_internal.h: Removed quite a few unneeded includes. Rewrote + quite a few comments. Removed the macros that add kjs prefixes to the + functions with external linkage; instead renamed the functions. Removed + the unneeded typedefs pcre_uint16, pcre_uint32, and uschar. Removed the + dead and not-all-working code for LINK_SIZE values other than 2, although + we aim to keep the abstraction working. Removed the OP_LENGTHS macro. + (put2ByteValue): Replaces put2ByteOpcodeValueAtOffset. + (get2ByteValue): Replaces get2ByteOpcodeValueAtOffset. + (put2ByteValueAndAdvance): Replaces put2ByteOpcodeValueAtOffsetAndAdvance. + (putLinkValueAllowZero): Replaces putOpcodeValueAtOffset; doesn't do the + addition, since a comma is really no better than a plus sign. Added an + assertion to catch out of range values and changed the parameter type to + int rather than unsigned. + (getLinkValueAllowZero): Replaces getOpcodeValueAtOffset. + (putLinkValue): New function that most former callers of the + putOpcodeValueAtOffset function can use; asserts the value that is + being stored is non-zero and then calls putLinkValueAllowZero. + (getLinkValue): Ditto. + (putLinkValueAndAdvance): Replaces putOpcodeValueAtOffsetAndAdvance. No + caller was using an offset, which makes sense given the advancing behavior. + (putLinkValueAllowZeroAndAdvance): Ditto. + (isBracketOpcode): Added. For use in an assertion. + (advanceToEndOfBracket): Renamed from moveOpcodePtrPastAnyAlternateBranches, + and removed comments about how it's not well designed. This function takes + a pointer to the beginning of a bracket and advances to the end of the + bracket. + + * pcre/pcre_tables.cpp: Updated names. + * pcre/pcre_ucp_searchfuncs.cpp: + (kjs_pcre_ucp_othercase): Ditto. + * pcre/pcre_xclass.cpp: + (getUTF8CharAndAdvancePointer): Ditto. + (kjs_pcre_xclass): Ditto. + * pcre/ucpinternal.h: Ditto. + + * wtf/ASCIICType.h: + (WTF::isASCIIAlpha): Added an int overload, like the one we already have for + isASCIIDigit. + (WTF::isASCIIAlphanumeric): Ditto. + (WTF::isASCIIHexDigit): Ditto. + (WTF::isASCIILower): Ditto. + (WTF::isASCIISpace): Ditto. + (WTF::toASCIILower): Ditto. + (WTF::toASCIIUpper): Ditto. + +2007-12-16 Darin Adler + + Reviewed by Maciej. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16459 + REGRESSION: assertion failure with regexp with \B in a case-ignoring character range + + + The problem was that \B was not handled properly in character classes. + + Test: fast/js/regexp-overflow.html + + * pcre/pcre_compile.cpp: + (check_escape): Added handling of ESC_b and ESC_B in character classes here. + Allows us to get rid of the handling of \b in character classes from all the + call sites that handle it separately and to handle \B properly as well. + (compileBranch): Remove the ESC_b handling, since it's not needed any more. + (calculateCompiledPatternLengthAndFlags): Ditto. + +2007-12-16 Mark Rowe + + Reviewed by Maciej Stachowiak. + + Fix http://bugs.webkit.org/show_bug.cgi?id=16448 + Bug 16448: [GTK] Celtic Kane JavaScript performance on Array test is slow relative to Mac + + * kjs/array_instance.cpp: + (KJS::compareByStringPairForQSort): + (KJS::ArrayInstance::sort): Convert JSValue's to strings once up front and then sort the + results. This avoids calling toString twice per comparison, but requires a temporary buffer + so we only use this approach in cases where the array being sorted is not too large. + +2007-12-16 Geoffrey Garen + + Reviewed by Darin Adler and Maciej Stachowiak. + + More refactoring to support global variable optimization. + + Changed SymbolTable to use RefPtr as its key instead of + UString::Rep*. With globals, the symbol table can outlast the + declaration node for any given symbol, so the symbol table needs to ref + its symbol names. + + In support, specialized HashMaps with RefPtr keys to allow lookup + via raw pointer, avoiding refcount churn. + + SunSpider reports a .6% speedup (prolly just noise). + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: Added new file: wtf/RefPtrHashMap.h + * JavaScriptCore.xcodeproj/project.pbxproj: ditto + + * kjs/JSVariableObject.cpp: + (KJS::JSVariableObject::getPropertyNames): Symbol table keys are RefPtrs now. + + * kjs/SymbolTable.h: Modified key traits to match RefPtr. Added a + static Rep* for null, which helps compute the deletedValue() trait. + + * wtf/HashMap.h: #include the RefPtr specialization so everyone can use it. + + * wtf/RefPtrHashMap.h: Copied from wtf/HashMap.h. Added overloaded versions + of find(), contains(), get(), set(), add(), remove(), and take() that take + raw pointers as keys. + +2007-12-16 Alexey Proskuryakov + + Reviewed by Darin. + + http://bugs.webkit.org/show_bug.cgi?id=16162 + Problems with float parsing on Linux (locale-dependent parsing was used). + + * kjs/dtoa.cpp: Removed USE_LOCALE to reduce future confusion. + * kjs/lexer.cpp: (KJS::Lexer::lex): Parse with kjs_strtod, not the system one. + +2007-12-14 Alp Toker + + Reviewed by Mark Rowe. + + Enable the AllInOneFile.cpp optimization for the GTK+ port. + + * JavaScriptCore.pri: + +2007-12-14 Mark Rowe + + Unreviewed. Remove commented out fprintf's that were for debugging purposes only. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::IncrementalScavenge): + +2007-12-14 Mark Rowe + + Reviewed by Maciej Stachowiak. + + Don't use the MADV_DONTNEED code path for now as it has no effect on Mac OS X and is + currently untested on other platforms. + + * wtf/TCSystemAlloc.cpp: + (TCMalloc_SystemRelease): Return after releasing memory rather than potentially falling + through into another mechanism if multiple are supported. + +2007-12-14 Alp Toker + + Build fix for GTK+/Qt and ports that don't use AllInOneFile.cpp. + + Include UnusedParam.h. + + * wtf/TCSystemAlloc.cpp: + +2007-12-14 Oliver Hunt + + Reviewed by Stephanie. + + Fix build on windows + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::IncrementalScavenge): + +2007-12-14 Dan Bernstein + + - try again to fix the Windows build + + * wtf/TCSystemAlloc.cpp: + (TCMalloc_SystemRelease): + +2007-12-14 Dan Bernstein + + - try to fix the Windows build + + * wtf/TCSystemAlloc.cpp: + (TCMalloc_SystemRelease): + +2007-12-14 Mark Rowe + + Reviewed by Maciej and Oliver. + + Add final changes to make TCMalloc release memory to the system. + This results in a 0.4% regression against ToT, but this is offset + against the gains made by the original TCMalloc r38 merge - in fact + we retain around 0.3-0.4% progression overall. + + * wtf/FastMalloc.cpp: + (WTF::InitSizeClasses): + (WTF::TCMalloc_PageHeap::IncrementalScavenge): + * wtf/TCSystemAlloc.cpp: + (TCMalloc_SystemRelease): + +2007-12-14 Darin Adler + + Reviewed by Sam. + + - removed unnecessary includes of "Vector.h" + + * wtf/HashMap.h: + (WTF::copyKeysToVector): Make the type of the vector be a template parameter. + This allows copying keys into a vector of a base class or one with an inline capacity. + (WTF::copyValuesToVector): Ditto. + * wtf/HashSet.h: + (WTF::copyToVector): Ditto. + +2007-12-14 Anders Carlsson + + Reviewed by Darin and Geoff. + + + REGRESSION: 303-304: Embedded YouTube video fails to render- JS errors (16150) (Flash 9) + + Get rid of unnecessary and incorrect security checks for plug-ins accessing JavaScript objects. + + The way this used to work was that each NPObject that wrapped a JSObject would have a root object + corresponding to the frame object (used for managing the lifecycle) and an origin root object (used for + doing security checks). + + This would prevent a plug-in from accessing a frame's window object if it's security origin was different + (some parts of the window, such as the location object, can be accessed from frames with different security + origins, and those checks are being done in WebCore). + + Also, if a plug-in were to access a window object of a frame that later went away, it could lead to that + Window JSObject being garbage collected and the NPObject pointing to freed memory. + + How this works now is that there is no origin root object anymore, and all NPObject wrappers that are created + for a plug-in will have the root object of the containing frame of that plug-in. + + * bindings/NP_jsobject.cpp: + (jsDeallocate): + Don't free the origin root object. + + (_NPN_CreateScriptObject): + Remove the origin root object parameter. + + (_NPN_InvokeDefault): + (_NPN_Invoke): + (_NPN_Evaluate): + (_NPN_GetProperty): + (_NPN_SetProperty): + (_NPN_RemoveProperty): + (_NPN_HasProperty): + (_NPN_HasMethod): + (_NPN_Enumerate): + Get rid of all security checks. + + * bindings/NP_jsobject.h: + Remove originRootObject from the JavaScriptObject struct. + + * bindings/c/c_utility.cpp: + (KJS::Bindings::convertValueToNPVariant): + Always use the root object from the ExecState. + +2007-12-13 Steve Falkenburg + + Move source file generation into its own vcproj to fix build dependencies. + + Reviewed by Adam. + + * JavaScriptCore.vcproj/JavaScriptCore.sln: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make: Added. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.vcproj: Added. + * JavaScriptCore.vcproj/JavaScriptCoreSubmit.sln: + +2007-12-13 Alp Toker + + http://bugs.webkit.org/show_bug.cgi?id=16406 + [Gtk] JavaScriptCore needs -lpthread + + Build fix for Debian and any other platforms that don't implicitly + link to pthread. + + Link to pthread on non-Windows platforms until this dependency is + removed from JSC. + +2007-12-11 Geoffrey Garen + + Reviewed by Sam Weinig. + + Build fix: Note some variables that are used only for ASSERTs. + + * API/testapi.c: + (Base_finalize): + (globalObject_initialize): + (testInitializeFinalize): + +2007-12-11 Geoffrey Garen + + Reviewed by Darin Adler. + + Fixed: All JS tests crash on Windows. + + NDEBUG wasn't defined when compiling testkjs in release builds, so the + HashTable definition in HashTable.h included an extra data member. + + The solution was to add NDEBUG to the release testkjs configuration on + Windows and Mac. + + For giggles, I also added other missing #defines to testkjs on Windows. + + * Configurations/Base.xcconfig: + * Configurations/JavaScriptCore.xcconfig: + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/testkjs.cpp: + (main): + +2007-12-11 Geoffrey Garen + + Reviewed by Darin Adler. + + Removed bogus ASSERT. + + ASSERT should only be used when we know that a code path will not be + taken. This code path is taken often during the jsFunFuzz test. + + * pcre/pcre_exec.cpp: + (jsRegExpExecute): + +2007-12-11 Darin Adler + + * wtf/unicode/qt4/UnicodeQt4.h: Try to fix Qt build by adding U16_IS_SINGLE. + +2007-12-10 Darin Adler + + Reviewed by Sam Weinig. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16379 + REGRESSION(r28525): Failures in http/tests/xmlhttprequest/response-encoding.html and + fast/dom/xmlhttprequest-html-response-encoding.html + and REGRESSION (306A4-ToT): Access violation in PCRE function + find_firstassertedchar + + Test: fast/js/regexp-find-first-asserted.html + + * pcre/pcre_compile.cpp: + (compileBracket): Take out unnecessary initialization of out parameters. + (branchFindFirstAssertedCharacter): Added. Broke out the half of the function that handles + a branch. + (bracketFindFirstAssertedCharacter): Renamed from find_firstassertedchar. Also removed the + options parameter -- the caller can handle the options. + (jsRegExpCompile): Changed call site to call the appropriate bracket or branch version of + the find_firstassertedchar function. Also put the REQ_IGNORE_CASE code here instead of + passing in the options. + +2007-12-10 Geoffrey Garen + + Reviewed by Sam Weinig. + + Split this: + + FunctionBodyNode + ^ + | + ProgramNode + + into this: + + ScopeNode + ^ ^ ^ + | | | + FunctionBodyNode ProgramNode EvalNode + + in preparation for specializing each class more while optimizing global + variable access. + + Also removed some cruft from the FunctionBodyNode interface to simplify + things. + + SunSpider says this patch is a .8% speedup, which seems reasonable, + since it eliminates a few branches and adds KJS_FAST_CALL in a few + places. + + Layout tests and JS tests pass. Also, this baby builds on Windows! (Qt + mileage may vary...) + +2007-12-10 Geoffrey Garen + + RS by Mark Rowe. + + Mac build fix: added some exported symbols, now that Parser::parse is + defined in the header. + + * JavaScriptCore.exp: + +2007-12-10 Sam Weinig + + Build fix. + + Template methods need to be in the header. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * kjs/Parser.cpp: + * kjs/Parser.h: + (KJS::Parser::parse): + +2007-12-10 Geoffrey Garen + + Reviewed by Sam Weinig. + + Merged different implementations of Parser::parse into a single, + templatized implementation, in preparation for adding yet another + implementation for "eval" code. + + JS and layout tests pass. + +2007-12-10 Timothy Hatcher + + Reviewed by Mark Rowe + + Bundle versions on Tiger should be 4523.x not 523.x + + * Configurations/Version.xcconfig: Some Tiger versions of Xcode don't set MAC_OS_X_VERSION_MAJOR, + so assume Tiger and use a 4 for the SYSTEM_VERSION_PREFIX. + +2007-12-10 Mark Rowe + + Tiger build fix. + + * kjs/grammar.y: Use @1 and @0 in place of @$ where Tiger's bison chokes. + +2007-12-10 Darin Adler + + Reviewed by Mark Rowe. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16375 + REGRESSION: Safari crashes on quit + + Probably a debug-only issue. + + * kjs/Parser.cpp: + (KJS::parser): Create the parser and never destroy it by using a pointer instead + of a global object. + +2007-12-09 Darin Adler + + Reviewed by Sam Weinig. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16369 + REGRESSION (r28525): regular expression tests failing due to bad firstByte optimization + + * pcre/pcre_compile.cpp: Changed some names to use interCaps intead of under_scores. + (branchIsAnchored): Broke is_anchored into two separate functions; this one works on a + branch and the other on an anchor. The old function would only work on a bracket. + Also removed unneeded parameters; the anchored check does not require the bracket + map or the options any more because we have a reduced set of features. + (bracketIsAnchored): Ditto. + (branchNeedsLineStart): Broke canApplyFirstCharOptimization into two functions and gave + both a better name. This is the function that was returning the wrong value. The failure + was beacuse the old function would only work on a bracket. + (bracketNeedsLineStart): Ditto. + (jsRegExpCompile): Changed to call the appropriate branch or bracket flavor of the + functions based on whether we compiled an outer bracket. Also removed inaccurate comments + and unneeded parameters. + + - other small changes + + * pcre/pcre.h: Renumbered error codes, in a logical order. First, normal failure, then + the recursion limit, then running out of memory, and finally an unexpected internal error. + + * pcre/pcre_exec.cpp: Fixed indentation. + (jsRegExpExecute): Corrected an inaccurate comment. + +2007-12-09 Darin Adler + + Reviewed by Maciej. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16370 + REGRESSION (r28540): source URL and line number no longer set for outer function/programs + + Test: fast/js/exception-linenums-in-html-1.html + Test: fast/js/exception-linenums-in-html-2.html + Test: fast/js/exception-linenums.html + + By the time the ProgramNode was constructed, the source URL was empty. + + * kjs/Parser.cpp: + (KJS::Parser::parseProgram): Added code to set and clear m_sourceURL, which is now + handled here instead of in the lexer; it needs to still be set when we create the + program node. Call setLoc to set the first and last line number. + (KJS::Parser::parseFunctionBody): Ditto, but for the body. + (KJS::Parser::parse): Removed the sourceURL argument. + + * kjs/Parser.h: Added sourceURL(), m_sourceURL, and m_lastLine. Added a lastLine + parameter to didFinishParsing, since the bison grammar knows the last line number + and we otherwise do not know it. Removed the sourceURL parameter from parse, since + that's now handled at a higher level. + + * kjs/grammar.y: Pass the last line number to didFinishParsing. + + * kjs/lexer.cpp: + (KJS::Lexer::setCode): Removed the sourceURL argument and the code to set m_sourceURL. + (KJS::Lexer::clear): Ditto. + * kjs/lexer.h: More of the same. + + * kjs/nodes.cpp: + (KJS::FunctionBodyNode::FunctionBodyNode): Get the source URL from the parser rather + than from the lexer. Removed unneeded call to setLoc, since the line numbers already + both default to -1. + +2007-12-08 Oliver Hunt + + Reviewed by Sam W. + + Split the ENABLE_SVG_EXPERIMENTAL_FEATURES flag into separate flags. + + Fixes Must disable SVG animation + Disable SVG filters on Mac to match Windows behavior + + Minor config changes. + + * Configurations/JavaScriptCore.xcconfig: + * JavaScriptCore.xcodeproj/project.pbxproj: + +2007-12-07 Sam Weinig + + Reviewed by Darin. + + - Rename isSafeScript to allowsAccessFrom. + + * bindings/NP_jsobject.cpp: + (_isSafeScript): + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::allowsAccessFrom): Reverse caller/argument of allowsAccessFrom to match + the new call. + +2007-12-07 Geoffrey Garen + + Reviewed by Sam Weinig. + + Refactored variable access optimization: Removed the assumption that + the FunctionBodyNode holds the symbol table. + +2007-12-07 Geoffrey Garen + + Build fix: added #include. + + * kjs/nodes.cpp: + +2007-12-07 Geoffrey Garen + + Build fix: added #include. + + * kjs/interpreter.cpp: + +2007-12-07 Geoffrey Garen + + Build fix: added #include. + + * kjs/grammar.y: + +2007-12-07 Geoffrey Garen + + Build fix: added #include. + + * kjs/function_object.cpp: + +2007-12-07 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed crash seen running layout tests. + + Reverted a change I made earlier today. Added a comment to try to + discourage myself from making this mistake a third time. + + * kjs/function.cpp: + (KJS::ActivationImp::mark): + * kjs/function.h: + (KJS::ActivationImp::ActivationImpData::ActivationImpData): + +2007-12-07 Geoffrey Garen + + Reviewed by Sam Weinig. + + Refactored parsing of global code: Removed the assumption that + ProgramNode inherits from FunctionBodyNode from the parser. + + * kjs/Parser.cpp: + (KJS::Parser::parseProgram): + (KJS::Parser::parseFunctionBody): + (KJS::Parser::parse): + * kjs/Parser.h: + (KJS::Parser::didFinishParsing): + * kjs/function.cpp: + * kjs/grammar.y: + * kjs/nodes.h: + +2007-12-07 Geoffrey Garen + + Build fix: added JSVariableObject.cpp to the .pri file. + + * JavaScriptCore.pri: + +2007-12-07 Geoffrey Garen + + Build fix: added #include. + + * kjs/function.cpp: + +2007-12-07 Steve Falkenburg + + Re-named our B&I flag from BUILDBOT to PRODUCTION. + + Reviewed by Sam Weinig. + + * JavaScriptCore.vcproj/JavaScriptCore.make: + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: + +2007-12-07 Geoffrey Garen + + Build fix: removed stray name qualification. + + * kjs/function.h: + (KJS::ActivationImp::ActivationImp): + +2007-12-07 Geoffrey Garen + + Build fix: moved functions with qualified names outside of class + declaration. + + * kjs/JSVariableObject.h: + (KJS::JSVariableObject::symbolTableGet): + (KJS::JSVariableObject::symbolTablePut): + +2007-12-07 Geoffrey Garen + + Reviewed by Sam Weinig. + + Next step in refactoring JSGlobalObject: Added JSVariableObject class, + and factored symbol-table-related code into it. (JSGlobalObject doesn't + use the symbol table code yet, though.) + + Layout and JS tests, and testapi, pass. SunSpider reports no regression. + +2007-12-07 Darin Adler + + Reviewed by Geoff. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16185 + jsRegExpCompile should not add implicit non-capturing bracket + + While this does not make SunSpider faster, it will make many regular + expressions a bit faster. + + * pcre/pcre_compile.cpp: Moved CompileData struct in here from the + header since it's private to this file. + (compile_branch): Updated for function name change. + (compile_bracket): Renamed from compile_regex, since, for one thing, + this does not compile an entire regular expression. + (calculateCompiledPatternLengthAndFlags): Removed unused item_count + local variable. Renamed CompileData to cd instead of compile_block + to be consistent with other functions. Added code to set the + needOuterBracket flag if there's at least one "|" at the outer level. + (jsRegExpCompile): Renamed CompileData to cd instead of compile_block + to be consistent with other functions. Removed unneeded "size" field + from the compiled regular expression. If no outer bracket is needed, + then use compile_branch to compile the regular expression. + + * pcre/pcre_internal.h: Removed the CompileData struct, which is now + private to pcre_compile.cpp. Removed the size member from JSRegExp. + +2007-12-06 Kevin Ollivier + + MSVC7 build fix due to a compiler bug with placement new and/or + templates and casting. + + Reviewed by Darin Adler. + + * wtf/Vector.h: + (WTF::::append): + +2007-12-06 Darin Adler + + Reviewed by Eric Seidel. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16321 + new RegExp("[\u0097]{4,6}", "gmy") crashes in DEBUG builds + + + Test: fast/js/regexp-oveflow.html + + * pcre/pcre_compile.cpp: + (calculateCompiledPatternLengthAndFlags): In the case where a single character + character class is optimized to not use a character class at all, the preflight + code was not setting the lastitemlength variable. + +2007-12-05 Mark Rowe + + Qt Windows build fix. Include the time-related headers in the correct place. + + * kjs/JSGlobalObject.cpp: + * kjs/interpreter.cpp: + +2007-12-05 Darin Adler + + Not reviewed; just undoing a previous commit. + + - remove earlier incorrect fix for http://bugs.webkit.org/show_bug.cgi?id=16220 + Crash opening www.news.com (CNet) + + The real bug was the backwards ?: in the compile function, which Geoff just + fixed. Rolling out the incorrect earlier fix. + + * pcre/pcre_compile.cpp: (calculateCompiledPatternLengthAndFlags): Take out + the unneeded preflight change. The regression test proves this is still working + fine, so the bug remains fixed. + +2007-12-01 Mark Rowe + + Build fix. Include headers before trying to use the things that they declare. + + * kjs/JSImmediate.cpp: + * kjs/nodes.cpp: + * kjs/object.cpp: + * kjs/object_object.cpp: + * kjs/regexp_object.cpp: + * kjs/string_object.cpp: + +2007-12-05 Geoffrey Garen + + Build fix: added some #includes. + + * kjs/JSImmediate.cpp: + +2007-12-05 Geoffrey Garen + + Build fix: added some #includes. + + * kjs/JSGlobalObject.cpp: + * kjs/JSImmediate.cpp: + +2007-12-05 Geoffrey Garen + + Build fix: Fixed #include spelling. + + * kjs/debugger.cpp: + +2007-12-05 Geoffrey Garen + + Build fix: added #include. + + * kjs/debugger.cpp: + +2007-12-05 Geoffrey Garen + + Build fix: added a forward declaration. + + * kjs/debugger.h: + +2007-12-05 Geoffrey Garen + + Build fix: added an #include. + + * kjs/error_object.cpp: + +2007-12-05 Geoffrey Garen + + Build fix: added an #include. + + * kjs/bool_object.cpp: + +2007-12-05 Geoffrey Garen + + Reviewed by Darin Adler. + + Third step in refactoring JSGlobalObject: Moved data members and + functions accessing data members from Interpreter to JSGlobalObject. + Changed Interpreter member functions to static functions. + + This resolves a bug in global object bootstrapping, where the global + ExecState could be used when uninitialized. + + This is a big change, but it's mostly code motion and renaming. + + Layout and JS tests, and testjsglue and testapi, pass. SunSpider reports + a .7% regression, but Shark sees no difference related to this patch, + and SunSpider reported a .7% speedup from an earlier step in this + refactoring, so I think it's fair to call that a wash. + +2007-12-05 Geoffrey Garen + + Reviewed by Darin Adler. (Or vice versa.) + + Fixed ASSERT during run-javascriptcore-tests. (Darin just added the + ASSERT, but the bug wasn't new.) + + * pcre/pcre_compile.cpp: + (compile_branch): The ?: operator here was backwards, causing us to + execute the loop too many times, adding stray KET opcodes to the + compiled regular expression. + +2007-12-05 Kevin McCullough + + Reviewed by Geoff. + + - Wait until local variable data is fully constructed before notifying the debugger of entering + or leaving a call frame. + + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + * kjs/nodes.cpp: + (KJS::FunctionBodyNode::execute): + +2007-12-05 Mark Rowe + + Reviewed by Oliver. + + Build fix for GCC 4.2. Cast via a union to avoid strict-aliasing issues. + + * wtf/FastMalloc.cpp: + (WTF::): + (WTF::getPageHeap): + +2007-12-05 Mark Rowe + + Reviewed by Darin. + + Fix testkjs in 64-bit. + + When built for 64-bit the TCMalloc spin lock uses pthread mutexes rather than a custom spin lock + implemented in assembly. If we fail to initialize the pthread mutex, attempts to lock or unlock + it will fail and trigger a call to abort. + + * wtf/FastMalloc.cpp: Initialize the spin lock so that we can later lock and unlock it. + * wtf/TCSpinLock.h: Add an Init method to the optimised spin lock. + +2007-12-04 Oliver Hunt + + Fix gtk build. + + * wtf/TCSystemAlloc.cpp: + +2007-12-03 Oliver Hunt + + Reviewed by Mark Rowe and Geoff Garen. + + Merge TCMalloc r38 + + It also result in a performance progression between 0.5% and + 0.9% depending on the test, however most if not all of this + gain will be consumed by the overhead involved in the later + change to release memory to the system. + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * wtf/FastMalloc.cpp: + (WTF::KernelSupportsTLS): + (WTF::CheckIfKernelSupportsTLS): + (WTF::): + (WTF::ClassIndex): + (WTF::SLL_Next): + (WTF::SLL_SetNext): + (WTF::SLL_Push): + (WTF::SLL_Pop): + (WTF::SLL_PopRange): + (WTF::SLL_PushRange): + (WTF::SLL_Size): + (WTF::SizeClass): + (WTF::ByteSizeForClass): + (WTF::NumMoveSize): + (WTF::InitSizeClasses): + (WTF::AllocationSize): + (WTF::TCMalloc_PageHeap::GetSizeClassIfCached): + (WTF::TCMalloc_PageHeap::CacheSizeClass): + (WTF::TCMalloc_PageHeap::init): + (WTF::TCMalloc_PageHeap::New): + (WTF::TCMalloc_PageHeap::AllocLarge): + (WTF::TCMalloc_PageHeap::Carve): + (WTF::TCMalloc_PageHeap::Delete): + (WTF::TCMalloc_PageHeap::IncrementalScavenge): + (WTF::PagesToMB): + (WTF::TCMalloc_PageHeap::Dump): + (WTF::TCMalloc_PageHeap::GrowHeap): + (WTF::TCMalloc_PageHeap::Check): + (WTF::ReleaseFreeList): + (WTF::TCMalloc_PageHeap::ReleaseFreePages): + (WTF::TCMalloc_ThreadCache_FreeList::Push): + (WTF::TCMalloc_ThreadCache_FreeList::PushRange): + (WTF::TCMalloc_ThreadCache_FreeList::PopRange): + (WTF::TCMalloc_ThreadCache_FreeList::Pop): + (WTF::TCMalloc_Central_FreeList::length): + (WTF::TCMalloc_Central_FreeList::tc_length): + (WTF::TCMalloc_Central_FreeList::Init): + (WTF::TCMalloc_Central_FreeList::ReleaseListToSpans): + (WTF::TCMalloc_Central_FreeList::EvictRandomSizeClass): + (WTF::TCMalloc_Central_FreeList::MakeCacheSpace): + (WTF::TCMalloc_Central_FreeList::ShrinkCache): + (WTF::TCMalloc_Central_FreeList::InsertRange): + (WTF::TCMalloc_Central_FreeList::RemoveRange): + (WTF::TCMalloc_Central_FreeList::FetchFromSpansSafe): + (WTF::TCMalloc_Central_FreeList::Populate): + (WTF::TCMalloc_ThreadCache::Init): + (WTF::TCMalloc_ThreadCache::Cleanup): + (WTF::TCMalloc_ThreadCache::Allocate): + (WTF::TCMalloc_ThreadCache::Deallocate): + (WTF::TCMalloc_ThreadCache::FetchFromCentralCache): + (WTF::TCMalloc_ThreadCache::ReleaseToCentralCache): + (WTF::TCMalloc_ThreadCache::Scavenge): + (WTF::TCMalloc_ThreadCache::PickNextSample): + (WTF::TCMalloc_ThreadCache::NewHeap): + (WTF::TCMalloc_ThreadCache::GetThreadHeap): + (WTF::TCMalloc_ThreadCache::GetCache): + (WTF::TCMalloc_ThreadCache::GetCacheIfPresent): + (WTF::TCMalloc_ThreadCache::InitTSD): + (WTF::TCMalloc_ThreadCache::CreateCacheIfNecessary): + (WTF::TCMallocStats::ExtractStats): + (WTF::TCMallocStats::DumpStats): + (WTF::TCMallocStats::DumpStackTraces): + (WTF::TCMallocStats::TCMallocImplementation::MarkThreadIdle): + (WTF::TCMallocStats::TCMallocImplementation::ReleaseFreeMemory): + (WTF::TCMallocStats::TCMallocGuard::TCMallocGuard): + (WTF::TCMallocStats::TCMallocGuard::~TCMallocGuard): + (WTF::TCMallocStats::DoSampledAllocation): + (WTF::TCMallocStats::CheckCachedSizeClass): + (WTF::TCMallocStats::CheckedMallocResult): + (WTF::TCMallocStats::SpanToMallocResult): + (WTF::TCMallocStats::do_malloc): + (WTF::TCMallocStats::do_free): + (WTF::TCMallocStats::do_memalign): + (WTF::TCMallocStats::do_malloc_stats): + (WTF::TCMallocStats::do_mallopt): + (WTF::TCMallocStats::do_mallinfo): + (WTF::TCMallocStats::realloc): + (WTF::TCMallocStats::cpp_alloc): + (WTF::TCMallocStats::operator new): + (WTF::TCMallocStats::): + (WTF::TCMallocStats::operator new[]): + (WTF::TCMallocStats::malloc_stats): + (WTF::TCMallocStats::mallopt): + (WTF::TCMallocStats::mallinfo): + * wtf/TCPackedCache.h: Added. + (PackedCache::PackedCache): + (PackedCache::Put): + (PackedCache::Has): + (PackedCache::GetOrDefault): + (PackedCache::Clear): + (PackedCache::EntryToValue): + (PackedCache::EntryToUpper): + (PackedCache::KeyToUpper): + (PackedCache::UpperToPartialKey): + (PackedCache::Hash): + (PackedCache::KeyMatch): + * wtf/TCPageMap.h: + (TCMalloc_PageMap2::PreallocateMoreMemory): + * wtf/TCSystemAlloc.cpp: + (TCMalloc_SystemRelease): + * wtf/TCSystemAlloc.h: + +2007-12-04 Anders Carlsson + + Reviewed by Sam. + + Make isSafeScript const. + + * kjs/JSGlobalObject.h: + (KJS::JSGlobalObject::isSafeScript): + +2007-12-04 Darin Adler + + Reviewed by Geoff. + + - fix first part of http://bugs.webkit.org/show_bug.cgi?id=16220 + Crash opening www.news.com (CNet) + + Test: fast/js/regexp-overflow.html + + * pcre/pcre_compile.cpp: + (calculateCompiledPatternLengthAndFlags): Add room for the additional BRA/KET that + was generated in the compile code but not taken into account here. + +2007-12-03 Darin Adler + + Reviewed by Geoff. + + - fix http://bugs.webkit.org/show_bug.cgi?id=15618 + REGRESSION: Stack overflow/crash in KJS::equal (15618) + + Test: fast/js/recursion-limit-equal.html + + * kjs/operations.cpp: (KJS::equal): Check the exception from toPrimitive. + +2007-12-03 Dan Bernstein + + - fix a copy-and-paste-o + + * bindings/npruntime.cpp: + (_NPN_GetIntIdentifier): + +2007-12-03 Dan Bernstein + + Reviewed by Darin Adler. + + - fix an ASSERT when getIntIdentifier is called with 0 or -1 + + * bindings/npruntime.cpp: + (_NPN_GetIntIdentifier): We cannot use the hashmap for 0 and -1 since + they are the empty value and the deleted value. Instead, keep the + identifiers for those two integers in a static array. + +2007-12-02 Darin Adler + + Reviewed by Mitz. + + - fix http://bugs.webkit.org/show_bug.cgi?id=15848 + REGRESSION: Assertion failure viewing comments page on digg.com + + Test: fast/js/sparse-array.html + + * kjs/array_instance.cpp: + (KJS::ArrayInstance::inlineGetOwnPropertySlot): Check sparse array cutoff before looking + in hash map. Can't avoid the branch because we can't look for 0 in the hash. + (KJS::ArrayInstance::deleteProperty): Ditto. + +2007-12-02 Geoffrey Garen + + Build fix: added an #include. + + * kjs/collector.cpp: + +2007-12-02 Geoffrey Garen + + Reviewed by Eric Seidel. + + Second step in refactoring JSGlobalObject: moved virtual functions from + Interpreter to JSGlobalObject. + + Layout and JS tests pass. SunSpider reports a .7% speedup -- don't + believe his lies. + +2007-12-01 Alp Toker + + Reviewed by Adam Roben. + + http://bugs.webkit.org/show_bug.cgi?id=16228 + kJSClassDefinitionEmpty is not exported with JS_EXPORT + + Add JS_EXPORT to kJSClassDefinitionEmpty. + + Make the gcc compiler check take precedence over the WIN32||_WIN32 + check to ensure that symbols are exported on Windows when using gcc. + + Add a TODO referencing the bug about JS_EXPORT in the Win build + (http://bugs.webkit.org/show_bug.cgi?id=16227) + + Don't define JS_EXPORT as 'extern' when the compiler is unknown since + it would result in the incorrect expansion: + + extern extern const JSClassDefinition kJSClassDefinitionEmpty; + + (This was something we inherited from CFBase.h that doesn't make sense + for JSBase.h) + + * API/JSBase.h: + * API/JSObjectRef.h: + +2007-11-30 Geoffrey Garen + + Reviewed by Beth Dakin. + + Reversed the ownership relationship between Interpreter and JSGlobalObject. + Now, the JSGlobalObject owns the Interpreter, and top-level objects + that need the two to persist just protect the JSGlobalObject from GC. + + Global object bootstrapping looks a little odd right now, but it will + make much more sense soon, after further rounds of refactoring. + + * bindings/runtime_root.h: Made this class inherit from RefCounted, + to avoid code duplication. + + * kjs/collector.cpp: + (KJS::Collector::collect): No need to give special GC treatment to + Interpreters, since we mark their global objects, which mark them. + + * kjs/interpreter.cpp: + (KJS::Interpreter::mark): No need to mark our global object, since it + marks us. + * kjs/interpreter.h: Don't inherit from RefCounted -- JSGlobalObject + owns us directly. + + * kjs/testkjs.cpp: Modified to follow the new rules. + (createGlobalObject): + (runWithScripts): + +2007-11-30 Brent Fulgham + + Reviewed by Eric. + + * ChangeLog: + * pcre/pcre_compile.cpp: + (compile_branch): + +2007-11-30 Eric Seidel + + No review, build fix only. + + Fix uninitialized var warnings in release build. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * pcre/pcre_compile.cpp: + (compile_regex): + +2007-11-30 Darin Adler + + Reviewed by Adam Roben. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16207 + JavaScript regular expressions should match UTF-16 code units rather than characters + + SunSpider says this is 5.5% faster on the regexp test, 0.4% faste overall. + + Test: fast/js/regexp-non-bmp.html + + Renamed ANY_CHAR to NOT_NEWLINE to more-accurately reflect its meaning. + + * pcre/pcre_compile.cpp: + (compile_branch): Removed calls to the UTF-16 character accessor functions, replacing + them with simple pointer dereferences in some cases, and no code at all in others. + (calculateCompiledPatternLengthAndFlags): Ditto. + + * pcre/pcre_exec.cpp: + (match): Fixed indentation of some case labels (including all the BEGIN_OPCODE). + Removed calls to the UTF-16 character accessor functions, replacing them with simple + pointer dereferences in some cases, and no code at all in others. Also removed some + explicit UTF-16 support code in a few cases. Removed the unneeded "UTF-8" code path + in the ANY_CHAR repeat code, and in another case, eliminated the code to check against + end_subject in because it is already done outside the loop. + (jsRegExpExecute): + + * pcre/pcre_internal.h: Removed all the UTF-16 helper functions. + +2007-11-30 Eric Seidel + + Reviewed by darin. + + PCRE crashes under GuardMalloc + http://bugs.webkit.org/show_bug.cgi?id=16127 + check against patternEnd to make sure we don't walk off the end of the string + + * pcre/pcre_compile.cpp: + (compile_branch): + (calculateCompiledPatternLengthAndFlags): + +2007-11-30 Eric Seidel + + Reviewed by Maciej. + + Fix layout test regressions caused by r28186 + http://bugs.webkit.org/show_bug.cgi?id=16195 + change first_byte and req_byte back to shorts instead of chars + (I think PCRE stuffs information in the high bits) + + * pcre/pcre_internal.h: + +2007-11-29 Oliver Hunt + + Reviewed by Maciej and Darin. + + Make the JS collector work with multiple threads + + Under heavy contention it was possible the GC to suspend other + threads inside the pthread spinlock, which could lead to the GC + thread blocking on the pthread spinlock itself. + + We now determine and store each thread's stack base when it is + registered, thus removing the need for any calls to pthread_get_stackaddr_np + that needed the pthread spinlock. + + * kjs/collector.cpp: + (KJS::Collector::Thread::Thread): + (KJS::Collector::registerThread): + (KJS::Collector::markOtherThreadConservatively): + +2007-11-29 Adam Roben + + Windows build fix + + Removed some unreachable code (ironically, the code was some + ASSERT_NOT_REACHED()s). + + * pcre/pcre_compile.cpp: + (compile_branch): + * pcre/pcre_exec.cpp: + (match): + +2007-11-29 Eric Seidel + + Reviewed by Mark Rowe. + + Fix for --guard crash of fast/js/regexp-charclass-crash introduced by r28151. + + * pcre/pcre_compile.cpp: + (is_anchored): + +2007-11-28 Mark Rowe + + Gtk build fix. Rubber-stamped by Eric. + + * pcre/pcre_exec.cpp: + (match): Add braces around the body of the case statement to prevent + wanings about jumps across the initialization of a variable. + +2007-11-29 Eric Seidel + + Reviewed by Mark Rowe. + + Attempt to fix non-mac builds after PCRE cleanup. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCoreSources.bkl: + * pcre/pcre.pri: + +2007-11-28 Eric Seidel + + Reviewed by Maciej. + + Centralize code for subjectPtr adjustments using inlines, only ever check for a single + trailing surrogate (as UTF16 only allows one), possibly fix PCRE bugs involving char + classes and garbled UTF16 strings. + + * pcre/pcre_exec.cpp: + (match): + (jsRegExpExecute): + * pcre/pcre_internal.h: + (getPreviousChar): + (movePtrToPreviousChar): + (movePtrToNextChar): + (movePtrToStartOfCurrentChar): + +2007-11-28 Eric Seidel + + Reviewed by Maciej. + + change getChar* functions to return result and push 'c' into local scopes for clarity + + * pcre/pcre_compile.cpp: + (compile_branch): + (calculateCompiledPatternLengthAndFlags): + * pcre/pcre_exec.cpp: + (match): + * pcre/pcre_internal.h: + (getChar): + (getCharAndAdvance): + (getCharAndLength): + (getCharAndAdvanceIfSurrogate): + +2007-11-28 Eric Seidel + + Reviewed by Sam. + + Comment cleanup + + * pcre/pcre_exec.cpp: + (match): + +2007-11-26 Eric Seidel + + Reviewed by Sam. + + Further cleanups to calculateCompiledPatternLengthAndFlags + + * pcre/pcre_compile.cpp: + (calculateCompiledPatternLengthAndFlags): + * pcre/pcre_internal.h: + +2007-11-26 Eric Seidel + + Reviewed by Sam. + + Give consistent naming to the RegExp options/compile flags + + * pcre/pcre_compile.cpp: + (compile_branch): + (is_anchored): + (find_firstassertedchar): + (printCompiledRegExp): + (jsRegExpCompile): + * pcre/pcre_exec.cpp: + (jsRegExpExecute): + * pcre/pcre_internal.h: + +2007-11-26 Eric Seidel + + Reviewed by Sam. + + Pull first_byte and req_byte optimizations out into separate static funtions, SunSpider reported this as a win. + + * pcre/pcre_exec.cpp: + (tryFirstByteOptimization): + (tryRequiredByteOptimization): + (jsRegExpExecute): + * pcre/pcre_internal.h: + +2007-11-26 Eric Seidel + + Reviewed by Maciej. + + give PCRE_MULTILINE a better name: OptionMatchAcrossMultipleLines + + * pcre/pcre_compile.cpp: + (compile_branch): + (is_anchored): + (printCompiledRegExp): + (jsRegExpCompile): + * pcre/pcre_exec.cpp: + (jsRegExpExecute): + * pcre/pcre_internal.h: + +2007-11-26 Eric Seidel + + Reviewed by Oliver. + + Deprecate jsRegExpExecute's offset-vector fallback code + + * pcre/pcre_exec.cpp: + (jsRegExpExecute): + +2007-11-26 Eric Seidel + + Reviewed by Maciej. + + Make cur_is_word and prev_is_word locals, and change OP_ANY to OP_ANY_CHAR for clarity + + * pcre/pcre_compile.cpp: + (find_fixedlength): + (compile_branch): + (canApplyFirstCharOptimization): + * pcre/pcre_exec.cpp: + (match): + * pcre/pcre_internal.h: + +2007-11-26 Eric Seidel + + Reviewed by Mitz & Maciej. + + Change _NC operators to use _IGNORING_CASE for clarity + + * pcre/pcre_compile.cpp: + (find_fixedlength): + (compile_branch): + (find_firstassertedchar): + * pcre/pcre_exec.cpp: + (match): + * pcre/pcre_internal.h: + +2007-11-26 Eric Seidel + + Reviewed by Mitz. + + Remove branch from return + + * pcre/pcre_compile.cpp: + (compile_branch): + * pcre/pcre_exec.cpp: + (match): + +2007-11-26 Eric Seidel + + Reviewed by Maciej. + + Add repeatInformationFromInstructionOffset inline + + * pcre/pcre_exec.cpp: + (repeatInformationFromInstructionOffset): + (match): + +2007-11-26 Eric Seidel + + Reviewed by Maciej. + + Remove no longer used error code JSRegExpErrorMatchLimit + + * kjs/regexp.cpp: + (KJS::RegExp::match): + * pcre/pcre.h: + * pcre/pcre_internal.h: + +2007-11-26 Eric Seidel + + Reviewed by Sam. + + Make i locally scoped for better code clarity + + * pcre/pcre_exec.cpp: + (match): + +2007-11-26 Eric Seidel + + Reviewed by Maciej. + + Give subjectPtr and instructionPtr sane names, reduce size of MatchFrame for a 0.2% speedup. + + * pcre/pcre_compile.cpp: + (compile_branch): + (calculateCompiledPatternLengthAndFlags): + * pcre/pcre_exec.cpp: + (match_ref): + (MatchStack::pushNewFrame): + (getUTF8CharAndIncrementLength): + (match): + * pcre/pcre_internal.h: + (getChar): + (getCharAndAdvance): + (getCharAndLength): + (getCharAndAdvanceIfSurrogate): + * pcre/pcre_xclass.cpp: + (getUTF8CharAndAdvancePointer): + +2007-11-26 Eric Seidel + + Reviewed by Sam. + + Small speedup (0.7%) by simplifying canUseStackBufferForNextFrame() check + + * pcre/pcre_exec.cpp: + (MatchStack::MatchStack): + (MatchStack::popCurrentFrame): + +2007-11-25 Eric Seidel + + Reviewed by Sam. + + Lower MATCH_LIMIT_RECURSION to more sane levels to prevent hangs on run-javascriptcore-tests + + * pcre/pcre_internal.h: + +2007-11-25 Eric Seidel + + Reviewed by Maciej. + + Remove match_is_group variable for another 5% speedup + + * pcre/pcre_compile.cpp: + * pcre/pcre_exec.cpp: + (startNewGroup): + (match): + +2007-11-28 Eric Seidel + + Reviewed by Sam. + + Abstract frame variables into locals and args + + * pcre/pcre_compile.cpp: + (compile_branch): + * pcre/pcre_exec.cpp: + (match): + * pcre/pcre_internal.h: + +2007-11-28 Eric Seidel + + Reviewed by Sam. + + Section off MatchData arguments into args struct + + * pcre/pcre_exec.cpp: + (MatchStack::pushNewFrame): + (match): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Remove redundant eptrblock struct + + * pcre/pcre_exec.cpp: + (MatchStack::pushNewFrame): + (match): + +2007-11-24 Eric Seidel + + Reviewed by Maciej. + + Remove redundant match_call_count and move recursion check out of super-hot code path + SunSpider says this is at least an 8% speedup for regexp. + + * pcre/pcre_exec.cpp: + (MatchStack::MatchStack): + (MatchStack::pushNewFrame): + (MatchStack::popCurrentFrame): + (MatchStack::popAllFrames): + (match): + (jsRegExpExecute): + * pcre/pcre_internal.h: + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Get rid of GETCHAR* macros, replacing them with better named inlines + + * pcre/pcre_compile.cpp: + (compile_branch): + (calculateCompiledPatternLengthAndFlags): + * pcre/pcre_exec.cpp: + (match): + * pcre/pcre_internal.h: + (getCharAndAdvance): + (getCharAndLength): + (getCharAndAdvanceIfSurrogate): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Further cleanup GET/PUT inlines + + * pcre/pcre_internal.h: + (putOpcodeValueAtOffset): + (getOpcodeValueAtOffset): + (putOpcodeValueAtOffsetAndAdvance): + (put2ByteOpcodeValueAtOffset): + (get2ByteOpcodeValueAtOffset): + (put2ByteOpcodeValueAtOffsetAndAdvance): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Give GET, PUT better names, and add (poor) moveOpcodePtrPastAnyAlternateBranches + + * pcre/pcre_compile.cpp: + (firstSignificantOpCodeSkippingAssertions): + (find_fixedlength): + (complete_callout): + (compile_branch): + (compile_regex): + (is_anchored): + (canApplyFirstCharOptimization): + (find_firstassertedchar): + * pcre/pcre_exec.cpp: + (match): + * pcre/pcre_internal.h: + (putOpcodeValueAtOffset): + (getOpcodeValueAtOffset): + (putOpcodeValueAtOffsetAndAdvance): + (put2ByteOpcodeValueAtOffset): + (get2ByteOpcodeValueAtOffset): + (moveOpcodePtrPastAnyAlternateBranches): + * pcre/pcre_ucp_searchfuncs.cpp: + (_pcre_ucp_othercase): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Add inlines for toLowerCase, isWordChar, isSpaceChar for further regexp speedup + + * pcre/pcre_compile.cpp: + (compile_branch): + (jsRegExpCompile): + * pcre/pcre_exec.cpp: + (match): + (jsRegExpExecute): + * pcre/pcre_internal.h: + (toLowerCase): + (flipCase): + (classBitmapForChar): + (charTypeForChar): + (isWordChar): + (isSpaceChar): + (CompileData::CompileData): + * pcre/pcre_xclass.cpp: + (_pcre_xclass): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + cleanup _pcre_ucp_othercase + + * pcre/pcre_ucp_searchfuncs.cpp: + (_pcre_ucp_othercase): + +2007-11-24 Eric Seidel + + Reviewed by Maciej. + + Use better variable names for case ignoring options + + * pcre/pcre_compile.cpp: + (compile_branch): + (find_firstassertedchar): + (printCompiledRegExp): + (jsRegExpCompile): + * pcre/pcre_exec.cpp: + (match_ref): + (match): + (jsRegExpExecute): + * pcre/pcre_internal.h: + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + split first_significant_code into two simpler functions + + * pcre/pcre_compile.cpp: + (firstSignificantOpCode): + (firstSignificantOpCodeSkippingAssertions): + (is_anchored): + (canApplyFirstCharOptimization): + (find_firstassertedchar): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + clean up is_counted_repeat + + * pcre/pcre_compile.cpp: + (is_counted_repeat): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + clean up check_escape + + * pcre/pcre_compile.cpp: + (check_escape): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Reformat find_fixedlength + + * pcre/pcre_compile.cpp: + (find_fixedlength): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + reformat is_anchored + + * pcre/pcre_compile.cpp: + (is_anchored): + +2007-11-24 Eric Seidel + + Reviewed by Maciej. + + Remove unused function could_be_empty_branch + + * pcre/pcre_compile.cpp: + (first_significant_code): + (find_fixedlength): + (compile_branch): + (canApplyFirstCharOptimization): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Pass around MatchData objects by reference + + * pcre/pcre_exec.cpp: + (pchars): + (match_ref): + (match): + (jsRegExpExecute): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + give PCRE_STARTLINE a better name and rename match_data to MatchData + + * pcre/pcre_compile.cpp: + (compile_branch): + (canApplyFirstCharOptimization): + (find_firstassertedchar): + (printCompiledRegExp): + (jsRegExpCompile): + * pcre/pcre_exec.cpp: + (pchars): + (jsRegExpExecute): + * pcre/pcre_internal.h: + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Clean up find_firstassertedchar + + * pcre/pcre_compile.cpp: + (get_othercase_range): + (find_firstassertedchar): + (calculateCompiledPatternLengthAndFlags): + +2007-11-24 Eric Seidel + + Reviewed by Tim Hatcher. + + Pass around CompileData& instead of CompileData* + + * pcre/pcre_compile.cpp: + (compile_branch): + (jsRegExpCompile): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Clean up compile_branch, move _pcre_ord2utf8, and rename CompileData + + * JavaScriptCore.xcodeproj/project.pbxproj: + * pcre/pcre_compile.cpp: + (_pcre_ord2utf8): + (calculateCompiledPatternLengthAndFlags): + (jsRegExpCompile): + * pcre/pcre_internal.h: + * pcre/pcre_ord2utf8.cpp: Removed. + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + removing more macros + + * pcre/pcre_compile.cpp: + (could_be_empty_branch): + (compile_branch): + (calculateCompiledPatternLengthAndFlags): + * pcre/pcre_exec.cpp: + (match): + (jsRegExpExecute): + * pcre/pcre_internal.h: + * pcre/pcre_xclass.cpp: + +2007-11-24 Eric Seidel + + Reviewed by Maciej. + + clean up formating in compile_branch + + * pcre/pcre_compile.cpp: + (compile_branch): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Fix spacing for read_repeat_counts + + * pcre/pcre_compile.cpp: + (read_repeat_counts): + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + Get rid of PCRE custom char types + + * pcre/pcre_compile.cpp: + (check_escape): + (complete_callout): + (compile_branch): + (compile_regex): + (calculateCompiledPatternLengthAndFlags): + (jsRegExpCompile): + * pcre/pcre_exec.cpp: + (match_ref): + (match): + (jsRegExpExecute): + * pcre/pcre_internal.h: + +2007-11-24 Eric Seidel + + Reviewed by Sam. + + reformat get_othercase_range + + * pcre/pcre_compile.cpp: + (get_othercase_range): + +2007-11-24 Eric Seidel + + Reviewed by Maciej. + + Remove register keyword and more cleanup + + * pcre/pcre_compile.cpp: + (find_fixedlength): + (compile_branch): + (is_anchored): + (is_startline): + (find_firstassertedchar): + (calculateCompiledPatternLengthAndFlags): + (jsRegExpCompile): + * pcre/pcre_exec.cpp: + (MatchStack::canUseStackBufferForNextFrame): + (MatchStack::allocateNextFrame): + (MatchStack::pushNewFrame): + (MatchStack::frameIsStackAllocated): + (MatchStack::popCurrentFrame): + (MatchStack::unrollAnyHeapAllocatedFrames): + (getUTF8CharAndIncrementLength): + (match): + (jsRegExpExecute): + * pcre/pcre_internal.h: + (PUT2INC): + (isLeadingSurrogate): + (isTrailingSurrogate): + (decodeSurrogatePair): + (getChar): + * pcre/pcre_ord2utf8.cpp: + (_pcre_ord2utf8): + * pcre/pcre_xclass.cpp: + (getUTF8CharAndAdvancePointer): + (_pcre_xclass): + +2007-11-24 Eric Seidel + + Reviewed by Maciej. + + Clean up jsRegExpExecute + + * pcre/pcre_compile.cpp: + (returnError): + (jsRegExpCompile): + * pcre/pcre_exec.cpp: + (jsRegExpExecute): + * pcre/pcre_internal.h: + +2007-11-29 Oliver Hunt + + Reviewed by Geoff. + + Merging updated system alloc and spinlock code from r38 of TCMalloc. + + This is needed as a precursor to the merge of TCMalloc proper. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::GrowHeap): + * wtf/TCSpinLock.h: + (TCMalloc_SpinLock::TCMalloc_SpinLock): + (TCMalloc_SpinLock::): + (TCMalloc_SpinLock::Lock): + (TCMalloc_SpinLock::Unlock): + (TCMalloc_SpinLock::IsHeld): + * wtf/TCSystemAlloc.cpp: + (TrySbrk): + (TryMmap): + (TryVirtualAlloc): + (TryDevMem): + (TCMalloc_SystemAlloc): + * wtf/TCSystemAlloc.h: + +2007-11-28 Brady Eidson + + Reviewed by Geoff + + Add copyKeysToVector utility, mirroring copyValuesToVector + Also change the copyValuesToVector implementation to be a little more attractive + + * wtf/HashMap.h: + (WTF::copyKeysToVector): + (WTF::copyValuesToVector): + +2007-11-27 Alp Toker + + Reviewed by Mark Rowe. + + Add a list of public JavaScriptCore headers for installation. + + This follows the convention used for the Qt and GTK+ header lists. + + * headers.pri: Added. + +2007-11-27 Alp Toker + + Prospective MSVC build fix. + + Roll back dllexport/dllimport support for now. + + * API/JSBase.h: + +2007-11-27 Alp Toker + + Reviewed by Maciej. + + http://bugs.webkit.org/show_bug.cgi?id=15569 + [gtk] GTK JavaScriptCore needs to export symbols for JSC API and WTF + + Introduce JS_EXPORT to mark symbols to be exported as public API. + + Export all public symbols in the JavaScriptCore C API. + + This matches conventions for exporting symbols set by the CF and CG + frameworks. + + * API/JSBase.h: + * API/JSContextRef.h: + * API/JSObjectRef.h: + * API/JSStringRef.h: + * API/JSStringRefBSTR.h: + * API/JSStringRefCF.h: + * API/JSValueRef.h: + +2007-11-27 Anders Carlsson + + Reviewed by Adam. + + Make PropertyNameArray and ScopeChain COMEnumVariant friendly. + + * kjs/PropertyNameArray.cpp: + (KJS::PropertyNameArray::swap): + Implement PropertyNameArray::swap. + + * kjs/PropertyNameArray.h: + Add ValueType typedef. Replace PropertyNameArrayIterator with + PropertyNameArray::const_iterator. + + * kjs/nodes.cpp: + (KJS::ForInNode::execute): + * kjs/scope_chain.cpp: + (KJS::ScopeChain::print): + Update for changes to PropertyNameArray. + + * kjs/scope_chain.h: + Add const_iterator and ValueType typedef. + +2007-11-27 Anders Carlsson + + Reviewed by Darin. + + Add a ValueType typedef. + + * wtf/Vector.h: + +2007-11-26 Darin Adler + + Reviewed by Mitz. + + - fix http://bugs.webkit.org/show_bug.cgi?id=16096 + REGRESSION (r26653-r26699): Plaxo.com addressbook does not load in webkit nightlies + + Test: fast/js/regexp-overflow.html + + * pcre/pcre_compile.cpp: (calculateCompiledPatternLengthAndFlags): + Removed a stray "ptr++" that I added by accident when merging the + changes between PCRE 6.4 and 6.5. + +2007-11-26 Geoffrey Garen + + Reviewed by Kevin McCullough. + + Fixed REGRESSION (r27126): Drosera does not + show variables (can't enumerate ActivationImp properties) + + Implemented a custom ActivationImp::getPropertyNames, since + ActivationImp now uses a custom property storage mechanism for local + variables. + + * kjs/function.cpp: + (KJS::ActivationImp::getPropertyNames): + * kjs/function.h: + +2007-11-26 Alp Toker + + GTK+/Qt/Wx build fix for breakage introduced in r28039. + + * ForwardingHeaders/JavaScriptCore/JSRetainPtr.h: Added. + +2007-11-24 Laszlo Gombos + + Reviewed by Maciej Stachowiak. + + Fix minor compiler warning (GCC 4.1.3) + + * pcre/pcre_internal.h: + * pcre/pcre_ucp_searchfuncs.cpp: + (_pcre_ucp_othercase): + +2007-11-25 Mark Rowe + + Reviewed by Dan Bernstein. + + Fix http://bugs.webkit.org/show_bug.cgi?id=16129 + Bug 16129: REGRESSION (r27761-r27811): malloc error while visiting http://mysit.es (crashes release build) + + * pcre/pcre_compile.cpp: Change errorcode to be passed by reference so that any error code is propagated + to our caller like they expect. + +2007-11-23 Kevin Ollivier + + MSVC7 build fix. (rand_s doesn't exist there) + + Reviewed by Adam Roben. + + * kjs/config.h: + * wtf/MathExtras.h: + +2007-11-23 Kevin Ollivier + + wx build fix. Move WX_PYTHON logic into project build settings, + add WebKitLibraries dirs on Win, and explicitly include JSCore + headers in testkjs rather than getting them from a template. + (Include dir order of JSCore/WTF and ICU headers is important due + to wtf/unicode/utf8.h.) + + * jscore.bkl: + +2007-11-23 Simon Hausmann + + Reviewed by George Staikos . + + Fix make (dist)clean on Windows. + + OBJECTS_DIR_WTR does not exist anymore, use GENERATED_SOURCES_DIR. + + + * JavaScriptCore.pri: + * pcre/pcre.pri: + +2007-11-22 Simon Hausmann + + Reviewed by George. + + Make the directory of where to put the generated sources configurable through the GENERATED_SOURCE_DIR variable + + * JavaScriptCore.pri: + * pcre/pcre.pri: + +2007-11-22 Simon Hausmann + + Reviewed by George. + + Centralize the setup for all the extra compilers in a addExtraCompiler function. + + This allows adding a "generated_files" target that builds all generated files using "make generated_files". + For the build inside Qt we do not generate actual rules for the extra compilers but instead + do the variable substitution of compiler.output manually and add the generated sources to SOURCES. + + * JavaScriptCore.pri: + * pcre/pcre.pri: + +2007-11-20 Mark Rowe + + Reviewed by Tim Hatcher. + + Need to resolve new GCC 4.2 warnings + + Fix all warnings emitted by GCC 4.2 when building JavaScriptCore. This allows builds with + -Werror to succeed. At present they will crash when executed due to code that is not safe + under strict aliasing (). + + * Configurations/Base.xcconfig: Remove the -Wno-long-double flag. + * kjs/date_object.cpp: + (KJS::formatTime): Test whether the stack-allocated string is empty rather than at a non-null address. + * kjs/dtoa.cpp: + (Bigint::): Tweak formatting to silence warnings. + * pcre/pcre_exec.cpp: + (match): Tweak formatting to silence warnings + * wtf/Assertions.cpp: Add printf format attribute to functions that warrant it. + * wtf/Assertions.h: Ditto. + +2007-11-19 Kevin Ollivier + + wx port build fix (wx headers include ctype functions). + + * kjs/config.h: + +2007-11-19 Kevin Ollivier + + Remove outdated and unused Windows port files. + + Reviewed by Adam Roben. + + * Makefile.vc: Removed. + * README-Win32.txt: Removed. + +2007-11-18 Eric Seidel + + Reviewed by Oliver. + + * tests/mozilla/jsDriver.pl: exit non-0 when user aborts test run + +2007-11-17 Mark Rowe + + Reviewed by Darin Adler. + + Fix: REGRESSION: testapi exits with assertion failure in debug build + JSGlobalContextCreate throws away globalObjectClass's prototype + http://bugs.webkit.org/show_bug.cgi?id=16033 + + Split Interpreter's initialization into two distinct steps: the creation of the global prototypes + and constructors, and storing them on the global object. This allows JSClassRef's passed to + JSGlobalContextCreate to be instantiated with the correct prototype. + + * API/JSCallbackObject.cpp: Assert at compile-time that the custom global object will fit in a collector cell. + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + (KJS::::JSCallbackObject): + (KJS::::init): + * API/JSContextRef.cpp: + (JSGlobalContextCreate): Construct and set the interpreter's global object separately. When globalObjectClass + is passed we need to set the interpreter's global object before doing the JSCallbackObject's initialization to + prevent any JSObjectInitializeCallback's being invoked before a global object is set. + * API/testapi.c: + (globalObject_initialize): Test the object passed in is correct and that it has the expected global properties. + (globalObject_get): + (globalObject_set): + (main): + * API/testapi.js: Test that any static properties exposed by the global object's custom class are found. + * JavaScriptCore.exp: + * bindings/testbindings.cpp: + (main): Update for changes in Interpreter method signatures. + * bindings/testbindings.mm: + (main): Ditto. + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + (KJS::ExecState::mark): + (KJS::ExecState::setGlobalObject): + * kjs/ExecState.h: Rename scope to m_scopeChain. + * kjs/interpreter.cpp: + (KJS::Interpreter::Interpreter): + (KJS::Interpreter::init): + (KJS::Interpreter::globalObject): + (KJS::Interpreter::setGlobalObject): + (KJS::Interpreter::resetGlobalObjectProperties): + (KJS::Interpreter::createObjectsForGlobalObjectProperties): + (KJS::Interpreter::setGlobalObjectProperties): Switch to using putDirect to ensure that the global object's put method + cannot interfere with setting of the global properties. This prevents a user-written JSClassRef from attempting to + call back into JavaScript from the initialization of the global object's members. + * kjs/interpreter.h: + * kjs/testkjs.cpp: + (setupInterpreter): Update for changes in Interpreter method signatures. + +2007-11-17 Mark Rowe + + Reviewed by Sam Weinig. + + Prevent testapi from reporting false leaks. Clear out local variables pointing at + JSObjectRefs to allow their values to be collected. + + * API/testapi.c: + (main): + +2007-11-17 Mark Rowe + + Reviewed by Sam Weinig. + + Prevent testapi from crashing if testapi.js can not be found by nil-checking the result of createStringWithContentsOfFile. + + * API/testapi.c: + (main): + +2007-11-17 Alp Toker + + Reviewed by Eric. + + http://bugs.webkit.org/show_bug.cgi?id=16032 + JS minidom is not portable + + Use a plain UTF-8 string instead of a CFString. + + Print to stdout, not stderr like CFShow() would have done, since that + behaviour seems unintentional. + + * API/minidom.c: + (main): + +2007-11-17 Steve Falkenburg + + Windows build fix. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2007-11-16 Mark Rowe + + Windows build fix. + + * kjs/lexer.cpp: + (KJS::Lexer::record8): + +2007-11-16 Mark Rowe + + Reviewed by Eric. + + Replace strings, identifier, buffer8 and buffer16 members of Lexer with vectors. + SunSpider claims this is a 0.7% speedup. + + * kjs/lexer.cpp: + (KJS::Lexer::Lexer): + (KJS::Lexer::lex): + (KJS::Lexer::record8): + (KJS::Lexer::record16): + (KJS::Lexer::scanRegExp): + (KJS::Lexer::clear): + (KJS::Lexer::makeIdentifier): + (KJS::Lexer::makeUString): + * kjs/lexer.h: + * kjs/ustring.cpp: + (KJS::UString::UString): Add a convenience constructor that takes a const Vector&. + * kjs/ustring.h: + +2007-11-16 Adam Roben + + Windows build fix + + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: Add a new include path + and ignore the int -> bool conversion warning. + +2007-11-16 Alexey Proskuryakov + + Fix Windows debug build. + Rubber-stamped by Eric + + * pcre/pcre_exec.cpp: (match): Removed ASSERT_NOT_REACHED assertions that were making MSVC + complain about unreachable code. + +2007-11-15 Mark Rowe + + Gtk build fix. + + * kjs/Parser.cpp: + +2007-11-15 Mark Rowe + + Mac build and header search path sanity fix. + + Reviewed by Sam Weinig and Tim Hatcher. + + Move base setting for HEADER_SEARCH_PATHS into Base.xcconfig, and extend + it in JavaScriptCore.xcconfig. This removes the need to override it on a + per-target basis inside the .xcodeproj file. + + * Configurations/Base.xcconfig: + * Configurations/JavaScriptCore.xcconfig: + * JavaScriptCore.xcodeproj/project.pbxproj: + +2007-11-15 Mark Rowe + + Qt build fix. + + * kjs/Parser.h: + +2007-11-15 Geoffrey Garen + + Reviewed by Eric Seidel. + + Another round of grammar / parsing cleanup. + + 1. Created distinct parser calls for parsing function bodies vs + programs. This will help later with optimizing global variable access. + + 2. Turned Parser into a singleton. Cleaned up Lexer's singleton + interface. + + 3. Modified Lexer to free a little more memory when done lexing. (Added + FIXMEs for similar issues that I didn't fix.) + + 4. Changed Lexer::makeIdentifier and Lexer::makeUString to start + respecting the arguments passed to them. (No behavior change, but this + problem could have caused serious problems for an unsuspecting user of + these functions.) + + 5. Removed KJS_DEBUG_MEM because it was bit-rotted. + + 6. Removed Parser::prettyPrint because the same work was simpler to do + at the call site. + + 7. Some renames: + + "Parser::accept" => "Parser::didFinishParsing" + "Parser::sid" => "Parser::m_sourceID" + "Lexer::doneParsing" => "Lexer::clear" + "sid" => "sourceId" + "lineno" => "lineNo" + + * JavaScriptCore.exp: + * kjs/Parser.cpp: + (KJS::Parser::Parser): + (KJS::Parser::parseProgram): + (KJS::Parser::parseFunctionBody): + (KJS::Parser::parse): + (KJS::Parser::didFinishParsing): + (KJS::parser): + * kjs/Parser.h: + (KJS::Parser::sourceId): + * kjs/function.cpp: + (KJS::GlobalFuncImp::callAsFunction): + * kjs/function_object.cpp: + (FunctionObjectImp::construct): + * kjs/grammar.y: + * kjs/interpreter.cpp: + (KJS::Interpreter::checkSyntax): + (KJS::Interpreter::evaluate): + * kjs/interpreter.h: + * kjs/lexer.cpp: + (kjsyylex): + (KJS::lexer): + (KJS::Lexer::Lexer): + (KJS::Lexer::~Lexer): + (KJS::Lexer::scanRegExp): + (KJS::Lexer::doneParsing): + (KJS::Lexer::makeIdentifier): + (KJS::Lexer::makeUString): + * kjs/lexer.h: + (KJS::Lexer::pattern): + (KJS::Lexer::flags): + (KJS::Lexer::sawError): + * kjs/nodes.cpp: + (KJS::Node::Node): + (KJS::FunctionBodyNode::FunctionBodyNode): + * kjs/nodes.h: + * kjs/testkjs.cpp: + (prettyPrintScript): + (kjsmain): + * kjs/ustring.cpp: + * kjs/ustring.h: + +2007-11-15 Oliver Hunt + + Reviewed by Darin. + + REGRESSION: All SourceElements and their children leak after a syntax error + + Add a stub node to maintain the Vector of SourceElements until assignment. + + * kjs/grammar.y: + * kjs/nodes.h: + (KJS::SourceElementsStub::SourceElementsStub): + (KJS::SourceElementsStub::append): + (KJS::SourceElementsStub::release): + (KJS::SourceElementsStub::): + (KJS::SourceElementsStub::precedence): + +2007-11-15 Eric Seidel + + Reviewed by Sam. + + Abstract most of RMATCH into MatchStack functions. + + SunSpider claims this, combined with the last 2 patches was a 1% speedup, 10% for dna-regexp. + + * pcre/pcre_exec.cpp: + (MatchStack::canUseStackBufferForNextFrame): + (MatchStack::allocateNextFrame): + (MatchStack::pushNewFrame): + (MatchStack::frameIsStackAllocated): + (MatchStack::popCurrentFrame): + (MatchStack::unrollAnyHeapAllocatedFrames): + (match): + +2007-11-15 Eric Seidel + + Reviewed by Sam. + + Remove RETURN_ERROR, add MatchStack + + * pcre/pcre_exec.cpp: + (MatchStack::MatchStack): + (MatchStack::unrollAnyHeapAllocatedFrames): + (matchError): + (match): + +2007-11-15 Eric Seidel + + Reviewed by Sam. + + Clean up match function to match WebKit style + + * JavaScriptCore.xcodeproj/project.pbxproj: + * pcre/pcre_exec.cpp: + (match): + +2007-11-15 Steve Falkenburg + + Windows build fix. + + * JavaScriptCore.vcproj/JavaScriptCore.make: + +2007-11-14 Alexey Proskuryakov + + Reviewed by Darin. + + http://bugs.webkit.org/show_bug.cgi?id=15982 + Improve JSString UTF-8 decoding + + * API/JSStringRef.cpp: + (JSStringCreateWithUTF8CString): Use strict decoding, return 0 on error. + + * wtf/unicode/UTF8.cpp: + (WTF::Unicode::convertUTF16ToUTF8): + (WTF::Unicode::convertUTF8ToUTF16): + * wtf/unicode/UTF8.h: + Made these function names start with a lower case letter. + + * kjs/ustring.cpp: (KJS::UString::UTF8String): Updated for the above renaming. + + * bindings/c/c_utility.cpp: + (KJS::Bindings::convertUTF8ToUTF16WithLatin1Fallback): Renamed to highlight the difference + from convertUTF8ToUTF16 in wtf/unicode. + (KJS::Bindings::convertNPStringToUTF16): Updated for the above renaming. + (KJS::Bindings::identifierFromNPIdentifier): Ditto. + * bindings/c/c_utility.h: Made convertUTF8ToUTF16WithLatin1Fallback() a file static. + +2007-11-14 Sam Weinig + + Rubber-stamped by Anders. + + Fix the Xcode project file after it was messed up in r27402. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2007-11-14 Eric Seidel + + Reviewed by Oliver. + + More PCRE style cleanup. + + * pcre/pcre_compile.cpp: + (compile_regex): + +2007-11-14 Adam Roben + + Clean up the bison conflict checking script + + Reviewed by Geoff. + + * DerivedSources.make: + +2007-11-14 Eric Seidel + + Reviewed by Geoff. + + Another round of PCRE cleanups: inlines + + SunSpider claims that this, combined with my previous PCRE cleanup were a 0.7% speedup, go figure. + + * pcre/pcre_compile.cpp: + (jsRegExpCompile): + * pcre/pcre_exec.cpp: + (match): + (jsRegExpExecute): + * pcre/pcre_internal.h: + (PUT): + (GET): + (PUT2): + (GET2): + (isNewline): + +2007-11-14 Eric Seidel + + Reviewed by Sam. + + Give PCRE a (small) bath. + Fix some formating and break things off into separate functions + http://bugs.webkit.org/show_bug.cgi?id=15993 + + * pcre/pcre_compile.cpp: + (calculateCompiledPatternLengthAndFlags): + (printCompiledRegExp): + (returnError): + (jsRegExpCompile): + * pcre/pcre_internal.h: + (compile_data::compile_data): + +2007-11-14 Geoffrey Garen + + Reviewed by Eric Seidel. + + Cleaned up the JavaScript grammar a bit. + + 1. Changed BlockNode to always hold a child vector (which may be empty), + eliminating a few NULL-check branches in the common execution case. + + 2. Changed the Block production to correctly report its starting and + ending line numbers to the debugger. (It used to report its ending line + as its starting line.) Also, removed duplicate line-reporting code + inside the BlockNode constructor. + + 3. Moved curly braces up from FunctionBody production into parent + productions. (I had to move the line number reporting code, too, since + it depends on the location of the curly braces.) This matches the ECMA + spec more closely, and makes some future changes I plan easier. + + 4. Fixed statementList* convenience functions to deal appropriately with + empty Vectors. + + SunSpider reports a small and statistically insignificant speedup. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::statementListPushFIFO): + (KJS::statementListGetDeclarations): + (KJS::statementListInitializeDeclarationStack): + (KJS::statementListInitializeVariableAccessStack): + (KJS::BlockNode::BlockNode): + (KJS::BlockNode::optimizeVariableAccess): + (KJS::BlockNode::getDeclarations): + (KJS::BlockNode::execute): + (KJS::FunctionBodyNode::initializeDeclarationStacks): + (KJS::FunctionBodyNode::optimizeVariableAccess): + +2007-11-13 Anders Carlsson + + Add RefCounted.h (And remove Shared.h) + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + +2007-11-13 Geoffrey Garen + + Build fix. + + * kjs/regexp.h: + +2007-11-13 Geoffrey Garen + + Reviewed by Anders Carlsson. + + Renamed Shared to RefCounted. + + * API/JSClassRef.h: + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/interpreter.h: + * kjs/regexp.h: + * wtf/RefCounted.h: Copied from JavaScriptCore/wtf/Shared.h. + (WTF::RefCounted::RefCounted): + * wtf/Shared.h: Removed. + +2007-11-13 Adam Roben + + Build fix + + Reviewed by Geoff. + + * kjs/regexp.h: Added a missing #include. + +2007-11-13 Geoffrey Garen + + Reviewed by Sam Weinig. + + Moved Shared.h into wtf so it could be used in more places. Deployed + Shared in places where JSCore previously had hand-rolled ref-counting + classes. + + * API/JSClassRef.cpp: + (OpaqueJSClass::OpaqueJSClass): + * API/JSClassRef.h: + * API/JSObjectRef.cpp: + (JSClassRetain): + (JSClassRelease): + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/interpreter.cpp: + (KJS::Interpreter::init): + * kjs/interpreter.h: + * kjs/regexp.cpp: + (KJS::RegExp::RegExp): + * kjs/regexp.h: + * wtf/Shared.h: Copied from WebCore/platform/Shared.h. + +2007-11-13 Eric Seidel + + Reviewed by Maciej. + + Add an ASSERT to getTruncatedInt32 to enforce proper usage. + Best part about this patch? It doesn't break the web! + + * kjs/JSImmediate.h: + (KJS::JSImmediate::getTruncatedInt32): + (KJS::JSImmediate::toDouble): + (KJS::JSImmediate::getUInt32): + +2007-11-13 Alexey Proskuryakov + + Windows build fix. + + * bindings/c/c_utility.cpp: + (KJS::Bindings::convertUTF8ToUTF16): + * kjs/ustring.cpp: + (KJS::UString::UTF8String): + * wtf/unicode/UTF8.cpp: + (WTF::Unicode::ConvertUTF8ToUTF16): + +2007-11-13 Darin Adler + + Reviewed by Geoff. + + - fix http://bugs.webkit.org/show_bug.cgi?id=11231 + RegExp bug when handling newline characters + and a number of other differences between PCRE behvior + and JavaScript regular expressions: + + + single-digit sequences like \4 should be treated as octal + character constants, unless there is a sufficient number + of brackets for them to be treated as backreferences + + + \8 turns into the character "8", not a binary zero character + followed by "8" (same for 9) + + + only the first 3 digits should be considered part of an + octal character constant (the old behavior was to decode + an arbitrarily long sequence and then mask with 0xFF) + + + if \x is followed by anything other than two valid hex digits, + then it should simply be treated a the letter "x"; that includes + not supporting the \x{41} syntax + + + if \u is followed by anything less than four valid hex digits, + then it should simply be treated a the letter "u" + + + an extra "+" should be a syntax error, rather than being treated + as the "possessive quantifier" + + + if a "]" character appears immediately after a "[" character that + starts a character class, then that's an empty character class, + rather than being the start of a character class that includes a + "]" character + + + a "$" should not match a terminating newline; we could have gotten + PCRE to handle this the way we wanted by passing an appropriate option + + Test: fast/js/regexp-no-extensions.html + + * pcre/pcre_compile.cpp: + (check_escape): Check backreferences against bracount to catch both + overflows and things that should be treated as octal. Rewrite octal + loop to not go on indefinitely. Rewrite both hex loops to match and + remove \x{} support. + (compile_branch): Restructure loops so that we don't special-case a "]" + at the beginning of a character class. Remove code that treated "+" as + the possessive quantifier. + (jsRegExpCompile): Change the "]" handling here too. + + * pcre/pcre_exec.cpp: (match): Changed CIRC to match the DOLL implementation. + Changed DOLL to remove handling of "terminating newline", a Perl concept + which we don't need. + + * tests/mozilla/expected.html: Two tests are fixed now: + ecma_3/RegExp/regress-100199.js and ecma_3/RegExp/regress-188206.js. + One test fails now: ecma_3/RegExp/perlstress-002.js -- our success before + was due to a bug (we treated all 1-character numeric escapes as backreferences). + The date tests also now both expect success -- whatever was making them fail + before was probably due to the time being close to a DST shift; maybe we need + to get rid of those tests. + +2007-11-13 Darin Adler + + * kjs/JSImmediate.h: (KJS::JSImmediate::getTruncatedInt32): + Remove too-strong assert that was firing constantly and preventing even basic + web browsing from working in a debug build. This function is used in many + cases where the immediate value is not a number; the assertion could perhaps + be added back later with a bit of reorganization. + +2007-11-13 Alp Toker + + Build fix for breakage to non-Mac builds introduced in r27746. + + * kjs/ustring.cpp: + +2007-11-13 Eric Seidel + + Reviewed by Maciej. + + Clean up evaluateToBoolean functions to use inlines instead of copy/paste code + + * kjs/JSImmediate.h: + * kjs/nodes.cpp: + (KJS::GreaterNode::inlineEvaluateToBoolean): + (KJS::GreaterNode::evaluate): + (KJS::LessEqNode::inlineEvaluateToBoolean): + (KJS::LessEqNode::evaluate): + (KJS::GreaterEqNode::inlineEvaluateToBoolean): + (KJS::GreaterEqNode::evaluate): + (KJS::InNode::evaluateToBoolean): + (KJS::EqualNode::inlineEvaluateToBoolean): + (KJS::EqualNode::evaluate): + (KJS::NotEqualNode::inlineEvaluateToBoolean): + (KJS::NotEqualNode::evaluate): + (KJS::StrictEqualNode::inlineEvaluateToBoolean): + (KJS::StrictEqualNode::evaluate): + (KJS::NotStrictEqualNode::inlineEvaluateToBoolean): + (KJS::NotStrictEqualNode::evaluate): + * kjs/nodes.h: + +2007-11-12 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed http://bugs.webkit.org/show_bug.cgi?id=15958 + base64 spends 1.1% of total time checking for special Infinity case + + Use a fast character test instead of calling strncmp. + + 1.1% speedup on string-base64. SunSpider reports a .4% speedup overall; + Sharks reports only .1%. Who are you going to believe? Huh? + + * kjs/ustring.cpp: + (KJS::UString::toDouble): + +2007-11-12 Eric Seidel + + Reviewed by Oliver. + + Add evaluateToInt32 and evaluateUInt32 methods and deploy them. + Fix a few missing evaluateToBoolean methods + Deploy all evaluateTo* functions to more nodes to avoid slowdowns + http://bugs.webkit.org/show_bug.cgi?id=15950 + + SunSpider claims this is at least a 1.4% speedup. + + * kjs/JSImmediate.h: + (KJS::JSImmediate::getTruncatedInt32): + (KJS::JSImmediate::toDouble): + (KJS::JSImmediate::getUInt32): + * kjs/nodes.cpp: + (KJS::ExpressionNode::evaluateToNumber): + (KJS::ExpressionNode::evaluateToInt32): + (KJS::ExpressionNode::evaluateToUInt32): + (KJS::NumberNode::evaluateToInt32): + (KJS::NumberNode::evaluateToUInt32): + (KJS::ImmediateNumberNode::evaluateToInt32): + (KJS::ImmediateNumberNode::evaluateToUInt32): + (KJS::ResolveNode::evaluate): + (KJS::ResolveNode::evaluateToNumber): + (KJS::ResolveNode::evaluateToBoolean): + (KJS::ResolveNode::evaluateToInt32): + (KJS::ResolveNode::evaluateToUInt32): + (KJS::LocalVarAccessNode::evaluateToInt32): + (KJS::LocalVarAccessNode::evaluateToUInt32): + (KJS::BracketAccessorNode::evaluateToNumber): + (KJS::BracketAccessorNode::evaluateToBoolean): + (KJS::BracketAccessorNode::evaluateToInt32): + (KJS::BracketAccessorNode::evaluateToUInt32): + (KJS::DotAccessorNode::inlineEvaluate): + (KJS::DotAccessorNode::evaluate): + (KJS::DotAccessorNode::evaluateToNumber): + (KJS::DotAccessorNode::evaluateToBoolean): + (KJS::DotAccessorNode::evaluateToInt32): + (KJS::DotAccessorNode::evaluateToUInt32): + (KJS::NewExprNode::inlineEvaluate): + (KJS::NewExprNode::evaluate): + (KJS::NewExprNode::evaluateToNumber): + (KJS::NewExprNode::evaluateToBoolean): + (KJS::NewExprNode::evaluateToInt32): + (KJS::NewExprNode::evaluateToUInt32): + (KJS::FunctionCallResolveNode::inlineEvaluate): + (KJS::FunctionCallResolveNode::evaluate): + (KJS::FunctionCallResolveNode::evaluateToNumber): + (KJS::FunctionCallResolveNode::evaluateToBoolean): + (KJS::FunctionCallResolveNode::evaluateToInt32): + (KJS::FunctionCallResolveNode::evaluateToUInt32): + (KJS::LocalVarFunctionCallNode::evaluate): + (KJS::LocalVarFunctionCallNode::evaluateToNumber): + (KJS::LocalVarFunctionCallNode::evaluateToBoolean): + (KJS::LocalVarFunctionCallNode::evaluateToInt32): + (KJS::LocalVarFunctionCallNode::evaluateToUInt32): + (KJS::FunctionCallDotNode::evaluate): + (KJS::FunctionCallDotNode::evaluateToNumber): + (KJS::FunctionCallDotNode::evaluateToBoolean): + (KJS::FunctionCallDotNode::evaluateToInt32): + (KJS::FunctionCallDotNode::evaluateToUInt32): + (KJS::PostDecLocalVarNode::inlineEvaluateToNumber): + (KJS::PostDecLocalVarNode::evaluateToNumber): + (KJS::PostDecLocalVarNode::evaluateToBoolean): + (KJS::PostDecLocalVarNode::evaluateToInt32): + (KJS::PostDecLocalVarNode::evaluateToUInt32): + (KJS::typeStringForValue): + (KJS::UnaryPlusNode::evaluate): + (KJS::UnaryPlusNode::evaluateToBoolean): + (KJS::UnaryPlusNode::evaluateToNumber): + (KJS::UnaryPlusNode::evaluateToInt32): + (KJS::BitwiseNotNode::inlineEvaluateToInt32): + (KJS::BitwiseNotNode::evaluate): + (KJS::BitwiseNotNode::evaluateToNumber): + (KJS::BitwiseNotNode::evaluateToBoolean): + (KJS::BitwiseNotNode::evaluateToInt32): + (KJS::MultNode::evaluateToBoolean): + (KJS::MultNode::evaluateToInt32): + (KJS::MultNode::evaluateToUInt32): + (KJS::DivNode::evaluateToInt32): + (KJS::DivNode::evaluateToUInt32): + (KJS::ModNode::evaluateToBoolean): + (KJS::ModNode::evaluateToInt32): + (KJS::ModNode::evaluateToUInt32): + (KJS::AddNode::evaluateToNumber): + (KJS::AddNode::evaluateToInt32): + (KJS::AddNode::evaluateToUInt32): + (KJS::AddNumbersNode::evaluateToInt32): + (KJS::AddNumbersNode::evaluateToUInt32): + (KJS::SubNode::evaluateToInt32): + (KJS::SubNode::evaluateToUInt32): + (KJS::LeftShiftNode::inlineEvaluateToInt32): + (KJS::LeftShiftNode::evaluate): + (KJS::LeftShiftNode::evaluateToNumber): + (KJS::LeftShiftNode::evaluateToInt32): + (KJS::RightShiftNode::inlineEvaluateToInt32): + (KJS::RightShiftNode::evaluate): + (KJS::RightShiftNode::evaluateToNumber): + (KJS::RightShiftNode::evaluateToInt32): + (KJS::UnsignedRightShiftNode::inlineEvaluateToUInt32): + (KJS::UnsignedRightShiftNode::evaluate): + (KJS::UnsignedRightShiftNode::evaluateToNumber): + (KJS::UnsignedRightShiftNode::evaluateToInt32): + (KJS::LessNode::inlineEvaluateToBoolean): + (KJS::LessNode::evaluate): + (KJS::LessNode::evaluateToBoolean): + (KJS::LessNumbersNode::inlineEvaluateToBoolean): + (KJS::LessNumbersNode::evaluate): + (KJS::LessNumbersNode::evaluateToBoolean): + (KJS::LessStringsNode::inlineEvaluateToBoolean): + (KJS::LessStringsNode::evaluate): + (KJS::BitAndNode::evaluate): + (KJS::BitAndNode::inlineEvaluateToInt32): + (KJS::BitAndNode::evaluateToNumber): + (KJS::BitAndNode::evaluateToBoolean): + (KJS::BitAndNode::evaluateToInt32): + (KJS::BitXOrNode::inlineEvaluateToInt32): + (KJS::BitXOrNode::evaluate): + (KJS::BitXOrNode::evaluateToNumber): + (KJS::BitXOrNode::evaluateToBoolean): + (KJS::BitXOrNode::evaluateToInt32): + (KJS::BitOrNode::inlineEvaluateToInt32): + (KJS::BitOrNode::evaluate): + (KJS::BitOrNode::evaluateToNumber): + (KJS::BitOrNode::evaluateToBoolean): + (KJS::BitOrNode::evaluateToInt32): + (KJS::ConditionalNode::evaluateToNumber): + (KJS::ConditionalNode::evaluateToInt32): + (KJS::ConditionalNode::evaluateToUInt32): + (KJS::valueForReadModifyAssignment): + (KJS::AssignExprNode::evaluate): + (KJS::AssignExprNode::evaluateToBoolean): + (KJS::AssignExprNode::evaluateToNumber): + (KJS::AssignExprNode::evaluateToInt32): + (KJS::VarDeclNode::handleSlowCase): + * kjs/nodes.h: + (KJS::FunctionCallResolveNode::precedence): + (KJS::AddNode::precedence): + (KJS::AddNode::): + (KJS::LessNumbersNode::): + (KJS::LessStringsNode::): + * kjs/value.cpp: + (KJS::JSValue::toInt32SlowCase): + (KJS::JSValue::toUInt32SlowCase): + * kjs/value.h: + (KJS::JSValue::asCell): + (KJS::JSValue::toInt32): + (KJS::JSValue::toUInt32): + +2007-11-12 Alexey Proskuryakov + + Reviewed by Darin. + + http://bugs.webkit.org/show_bug.cgi?id=15953 + Add UTF-8 encoding/decoding to WTF + + * kjs/ustring.h: Moved UTF8SequenceLength() and decodeUTF8Sequence() to wtf/unicode. + * kjs/ustring.cpp: (KJS::UString::UTF8String): Changed this function to take a strict/lenient + parameter. Callers are not interested in getting decoding results in strict mode, so + this allows for bailing out as soon as an error is seen. + + * kjs/function.cpp: + (KJS::encode): Updated for new UString::UTF8String() signature. + + * API/JSStringRef.cpp: + (JSStringCreateWithCharacters): Disambiguate UChar. + (JSStringCreateWithUTF8CString): Actually use UTF-8 when creating the string! + * bindings/c/c_utility.cpp: (KJS::Bindings::convertUTF8ToUTF16): Use ConvertUTF8ToUTF16(). + + * wtf/unicode/UTF8.cpp: Added. + (WTF::Unicode::inlineUTF8SequenceLengthNonASCII): + (WTF::Unicode::inlineUTF8SequenceLength): + (WTF::Unicode::UTF8SequenceLength): + (WTF::Unicode::decodeUTF8Sequence): + (WTF::Unicode::): + (WTF::Unicode::ConvertUTF16ToUTF8): + (WTF::Unicode::isLegalUTF8): + (WTF::Unicode::ConvertUTF8ToUTF16): + * wtf/unicode/UTF8.h: Added. + (WTF::Unicode::): + Some code moved from ustring.h, some adapted from unicode.org sources. + + * JavaScriptCore.exp: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + Added UTF8.{h,cpp} + +2007-11-12 Josh Aas + + Reviewed by Darin. + + - http://bugs.webkit.org/show_bug.cgi?id=15946 + add NPPValue NPPVpluginDrawingModel (Mozilla bug 403418 compat) + + * bindings/npapi.h: + +2007-11-12 Darin Adler + + Reviewed by Sam. + + - http://bugs.webkit.org/show_bug.cgi?id=15951 + REGRESSION: assertion failure in regexp match() when running JS tests + + Test: fast/js/regexp-many-brackets.html + + * pcre/pcre_exec.cpp: (match): Added back accidentally-removed case for + the BRANUMBER opcode. + +2007-11-12 Darin Adler + + Reviewed by Geoff. + + - fix use of prefix and config.h, got rid of a few unneeded things in + the PCRE code; no behavior changes + + * API/JSBase.cpp: Added include of config.h. + * API/JSCallbackConstructor.cpp: Ditto. + * API/JSCallbackFunction.cpp: Ditto. + * API/JSCallbackObject.cpp: Ditto. + * API/JSClassRef.cpp: Ditto. + * API/JSContextRef.cpp: Ditto. + * API/JSObjectRef.cpp: Ditto. + * API/JSStringRef.cpp: Ditto. + * API/JSValueRef.cpp: Ditto. + + * JavaScriptCorePrefix.h: Removed obsolete workaround. + Moved new/delete macros after includes, as they are in WebCore's prefix. + Removed "config.h". + + * pcre/dftables.cpp: (main): Changed back to not use a separate maketables + function. This is needed for PCRE, but not helpful for our use. Also changed + the tables to all be 128 entries long instead of 256, since only the first + 128 are ever used. + + * pcre/pcre_compile.cpp: Added include of config.h. Eliminated digitab, + which was only being used to check hex digits. Changed all uses of TRUE and + FALSE to use the C++ true and false instead. + (check_escape): Just the TRUE/FALSE thing. + (is_counted_repeat): Ditto. + (could_be_empty_branch): Ditto. + (get_othercase_range): Ditto. + (compile_branch): Ditto. + (compile_regex): Ditto. + (is_anchored): Ditto. + (is_startline): Ditto. + (find_firstassertedchar): Ditto. + (jsRegExpCompile): Ditto. + + * pcre/pcre_exec.cpp: Added include of config.h. Changed all uses of TRUE and + FALSE to use the C++ true and false instead. + (match_ref): Just the TRUE/FALSE thing. + (match): Ditto. Removed some unneeded braces. + (jsRegExpExecute): Just the TRUE/FALSE thing. + + * pcre/pcre_internal.h: Moved the constants needed by dftables.cpp to the top + of the file instead of the bottom, so they can be used. Also changed the table + sizes to 128 instead of 256. Removed macro definitions of FALSE and TRUE. + Set array sizes for all the const arrays. Changed _pcre_utf8_table1_size to + be a macro instead of a extern int. + + * pcre/pcre_maketables.cpp: Removed. It's all in dftables.cpp now. + + * pcre/pcre_tables.cpp: Made table sizes explicit. + + * pcre/pcre_xclass.cpp: Just the TRUE/FALSE thing. + +2007-11-12 Adam Roben + + Build fix + + * wtf/FastMalloc.h: Add missing using statement. + +2007-11-11 Oliver Hunt + + Reviewed by Darin. + + Add special fastZeroedMalloc function to replace a + number of fastCalloc calls where one argument was 1. + + This results in a 0.4% progression in SunSpider, more + than making up for the earlier regression caused by + additional overflow checks. + + * JavaScriptCore.exp: + * kjs/array_instance.cpp: + * kjs/property_map.cpp: + * wtf/FastMalloc.cpp: + * wtf/FastMalloc.h: + * wtf/HashTable.h: + +2007-11-11 Adam Roben + + Fix ASSERT in HashTable::checkTableConsistencyExceptSize beneath WebNotificationCenter + + The bug was due to a mismatch between HashMap::remove and + HashTable::checkTableConsistency. HashMap::remove can delete the value + stored in the HashTable (by derefing it), which is not normally + allowed by HashTable. It's OK in this case because the value is about + to be removed from the table, but HashTable wasn't aware of this. + + HashMap::remove now performs the consistency check itself before + derefing the value. + + Darin noticed that the same bug would occur in HashSet, so I've fixed + it there as well. + + Reviewed by Darin. + + * wtf/HashMap.h: + (WTF::HashMap::remove): Perform the HashTable consistency check + manually before calling deref. + * wtf/HashSet.h: + (WTF::HashSet::remove): Ditto. + * wtf/HashTable.h: Made checkTableConsistency public so that HashMap + and HashSet can call it. + (WTF::HashTable::removeAndInvalidateWithoutEntryConsistencyCheck): + Added. + (WTF::HashTable::removeAndInvalidate): Added. + (WTF::HashTable::remove): + (WTF::HashTable::removeWithoutEntryConsistencyCheck): Added. + +2007-11-11 Mark Rowe + + Build fix. Use the correct filename case. + + * kjs/nodes.h: + +2007-11-11 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed http://bugs.webkit.org/show_bug.cgi?id=15902 + 15% of string-validate-input.js is spent compiling the same regular expression + + Store a compiled representation of the regular expression in the AST. + + Only a .2% SunSpider speedup overall, but a 10.6% speedup on + string-validate-input.js. + + * kjs/nodes.cpp: + (KJS::RegExpNode::evaluate): + * kjs/nodes.h: + (KJS::RegExpNode::): + * kjs/nodes2string.cpp: + (KJS::RegExpNode::streamTo): + * kjs/regexp.cpp: + (KJS::RegExp::flags): + * kjs/regexp.h: + (KJS::RegExp::pattern): + * kjs/regexp_object.cpp: + (KJS::RegExpObjectImp::construct): + (KJS::RegExpObjectImp::createRegExpImp): + * kjs/regexp_object.h: + +2007-11-11 Oliver Hunt + + Reviewed by Eric. + + Partial fix for numfuzz: integer overflows opening malformed SVG file in WebCore::ImageBuffer::create + + Unfortunately this is a very slight regression, but is unavoidable. + + * wtf/FastMalloc.cpp: + +2007-11-10 Eric Seidel + + Reviewed by darin. + + Add simple type inferencing to the parser, and create custom + AddNode and LessNode subclasses based on inferred types. + http://bugs.webkit.org/show_bug.cgi?id=15884 + + SunSpider claims this is at least a 0.5% speedup. + + * JavaScriptCore.exp: + * kjs/grammar.y: + * kjs/internal.cpp: + (KJS::NumberImp::getPrimitiveNumber): + (KJS::GetterSetterImp::getPrimitiveNumber): + * kjs/internal.h: + * kjs/lexer.cpp: + (KJS::Lexer::lex): + * kjs/nodes.cpp: + (KJS::Node::Node): + (KJS::StringNode::evaluate): + (KJS::StringNode::evaluateToNumber): + (KJS::StringNode::evaluateToBoolean): + (KJS::RegExpNode::evaluate): + (KJS::UnaryPlusNode::optimizeVariableAccess): + (KJS::AddNode::evaluate): + (KJS::AddNode::evaluateToNumber): + (KJS::AddNumbersNode::inlineEvaluateToNumber): + (KJS::AddNumbersNode::evaluate): + (KJS::AddNumbersNode::evaluateToNumber): + (KJS::AddStringsNode::evaluate): + (KJS::AddStringLeftNode::evaluate): + (KJS::AddStringRightNode::evaluate): + (KJS::lessThan): + (KJS::lessThanEq): + (KJS::LessNumbersNode::evaluate): + (KJS::LessStringsNode::evaluate): + * kjs/nodes.h: + (KJS::ExpressionNode::): + (KJS::RegExpNode::): + (KJS::RegExpNode::precedence): + (KJS::TypeOfResolveNode::): + (KJS::LocalVarTypeOfNode::): + (KJS::UnaryPlusNode::): + (KJS::UnaryPlusNode::precedence): + (KJS::AddNode::): + (KJS::AddNode::precedence): + (KJS::AddNumbersNode::): + (KJS::AddStringLeftNode::): + (KJS::AddStringRightNode::): + (KJS::AddStringsNode::): + (KJS::LessNode::): + (KJS::LessNode::precedence): + (KJS::LessNumbersNode::): + (KJS::LessStringsNode::): + * kjs/nodes2string.cpp: + (KJS::StringNode::streamTo): + * kjs/object.cpp: + * kjs/object.h: + * kjs/value.h: + (KJS::JSValue::getPrimitiveNumber): + +2007-11-11 Darin Adler + + - try another way of fixing dftables builds -- refactor pcre_internal.h a bit + + * pcre/pcre_internal.h: Make most of this header do nothing when DFTABLES is set. + Later we can break it into two files. + + * JavaScriptCore.vcproj/dftables/dftables.vcproj: Take out now-unneeded include paths. + * pcre/dftables.cpp: Set DFTABLES. Use delete instead of free. + * pcre/dftables.pro: Take out now-unneeded include paths. + * pcre/pcre_maketables.cpp: Use new instead of malloc. + +2007-11-11 Darin Adler + + * pcre/dftables.pro: Try fixing Qt builds (I looked at qt-win) by adding + another include path. + +2007-11-11 Darin Adler + + * JavaScriptCore.xcodeproj/project.pbxproj: Try fixing Mac Tiger builds + by adding another include path. + +2007-11-11 Darin Adler + + Reviewed by Sam. + + - http://bugs.webkit.org/show_bug.cgi?id=15924 + next round of changes to JSRegExp (formerly PCRE) + + This is a combination of converting to C++, tweaking the API, and adding + some additional optimizations. + + Future steps will involve getting rid of the use of UTF-8 completely + (we'll use UTF-16 exclusively instead), eliminating more source files, + and some more speed-ups. + + SunSpider says the current round is an 0.9% speed-up overall, and a + 5.3% speed-up for regexp. + + * JavaScriptCore.exp: Updated for new entry points. + + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.vcproj/dftables/dftables.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + * jscore.bkl: + Updated for new source file names and ForwardingHeaders. + + * kjs/regexp.cpp: + (KJS::RegExp::RegExp): Changed to use the error message without calling + strdup on it and to pass the new types and options. + (KJS::RegExp::~RegExp): Removed the now-unneeded free of the error message. + (KJS::RegExp::match): Pass the new types and options. + * kjs/regexp.h: Update type of m_constructionError. + + * pcre/AUTHORS: Update to reflect the status of the project -- we don't include + the Google parts, and this isn't the PCRE library, per se. + * pcre/COPYING: Ditto. + + * pcre/dftables.cpp: Copied from JavaScriptCore/pcre/dftables.c. + (main): Removed unneeded ctype_digit. + + * pcre/pcre.h: Convert to C++, tweak API a bit. Use UChar instead of JSRegExpChar. + + * pcre/pcre_compile.cpp: Copied from JavaScriptCore/pcre/pcre_compile.c. + Moved a lot of private stuff used only within this file here from pcre_internal.h. + Renumbered the error codes. + (error_text): Use a single string with embedded nulls for the error text (I got + this idea from newer versions of PCRE). + (check_escape): Changed return type to be enum instead of int. Replaced ctype_digit + uses with isASCIIDigit. + (is_counted_repeat): Ditto. + (read_repeat_counts): Ditto. + (first_significant_code): Ditto. + (find_fixedlength): Ditto. + (could_be_empty_branch): Ditto. + (compile_branch): Ditto. Also removed some code that handles changing options. + JavaScript doesn't have any of the features that allow options to change. + (compile_regex): Updated for change to options parameter. + (is_anchored): Ditto. + (find_firstassertedchar): Ditto. + (jsRegExpCompile): Changed to take separate flags instead of an options int. + Also changed to call new/delete instead of pcre_malloc/free. + (jsRegExpFree): Ditto. + + * pcre/pcre_exec.cpp: Copied from JavaScriptCore/pcre/pcre_exec.c. + Added a case that uses computed goto for the opcode loop, but did not turn it on. + Changed the RMATCH macro to handle returns more efficiently by putting the where + pointer in the new frame instead of the old one, allowing us to branch to the + return with a single statement. Switched to new/delete from pcre_malloc/free. + Changed many RRETURN callers to not set the return value since it's already + set correctly. Replaced the rrc variable with an is_match variable. Values other + than "match" and "no match" are now handled differently. This allows us to remove + the code to check for those cases in various rules. + (match): All the case statements use a macro BEGIN_OPCODE instead. And all the + continue statements, or break statements that break out of the outer case use + a macro NEXT_OPCODE instead. Replaced a few if statements with assertions. + (jsRegExpExecute): Use new/delete instead of pcre_malloc/free. Removed unused + start_match field from the match block. + + * pcre/pcre_internal.h: Moved the last few configuration macros from pcre-config.h + in here. Removed various unused types. Converted from JSRegExpChar to UChar. + Eliminated pcre_malloc/free. Replaced the opcode enum with a macro that can be + used in multiple places. Unfortunately we lose the comments for each opcode; we + should find a place to put those back. Removed ctype_digit. + + * pcre/pcre_maketables.cpp: Copied from JavaScriptCore/pcre/pcre_maketables.c. + (pcre_maketables): Got rid of the conditional code that allows this to be compiled + in -- it's only used for dftables now (and soon may be obsolete entirely). + Changed code for cbit_digit to not use isdigit, and took the "_" case out of the + loop. Removed ctype_digit. + + * pcre/pcre_ord2utf8.cpp: Copied from JavaScriptCore/pcre/pcre_ord2utf8.c. + + * pcre/pcre_tables.cpp: Copied from JavaScriptCore/pcre/pcre_tables.c. + Moved _pcre_OP_lengths out of here into pcre_exec.cpp. + + * pcre/pcre_ucp_searchfuncs.cpp: Copied from JavaScriptCore/pcre/pcre_ucp_searchfuncs.c. + Updated for other file name changes. + + * pcre/pcre_xclass.cpp: Copied from JavaScriptCore/pcre/pcre_xclass.c. + + * pcre/ucpinternal.h: Updated header. + + * pcre/ucptable.cpp: Copied from JavaScriptCore/pcre/ucptable.c. + + * wtf/ASCIICType.h: (WTF::isASCIIDigit): Removed a branch by changing from && to + & for this operation. Also added an overload that takes an int because that's + useful for PCRE. Later we could optimize for int and overload other functions in + this file; stuck to this simple one for now. + + * wtf/unicode/icu/UnicodeIcu.h: Removed unused isUpper. + * wtf/unicode/qt4/UnicodeQt4.h: Ditto. + + * pcre/LICENCE: Removed. + * pcre/pcre-config.h: Removed. + * wtf/FastMallocPCRE.cpp: Removed. + + * pcre/dftables.c: Renamed to cpp. + * pcre/pcre_compile.c: Ditto. + * pcre/pcre_exec.c: Ditto. + * pcre/pcre_maketables.c: Ditto. + * pcre/pcre_ord2utf8.c: Ditto. + * pcre/pcre_tables.c: Ditto. + * pcre/pcre_ucp_searchfuncs.c: Ditto. + * pcre/pcre_xclass.c: Ditto. + * pcre/ucptable.c: Ditto. + +2007-11-11 Eric Seidel + + Reviewed by Oliver. + + Add KJS_CHECKEXCEPTIONBOOLEAN to match rest of nodes.cpp + + * kjs/nodes.cpp: + (KJS::ExpressionNode::evaluateToBoolean): + (KJS::LessNode::evaluateToBoolean): + (KJS::GreaterNode::evaluateToBoolean): + (KJS::LessEqNode::evaluateToBoolean): + (KJS::GreaterEqNode::evaluateToBoolean): + (KJS::InstanceOfNode::evaluateToBoolean): + (KJS::InNode::evaluateToBoolean): + (KJS::EqualNode::evaluateToBoolean): + (KJS::NotEqualNode::evaluateToBoolean): + (KJS::StrictEqualNode::evaluateToBoolean): + (KJS::NotStrictEqualNode::evaluateToBoolean): + (KJS::LogicalAndNode::evaluateToBoolean): + (KJS::LogicalOrNode::evaluateToBoolean): + (KJS::ConditionalNode::evaluateToBoolean): + +2007-11-10 Darin Adler + + Reviewed by Sam. + + - fix http://bugs.webkit.org/show_bug.cgi?id=15927 + REGRESSION(r27487): delete a.c followed by __defineGetter__("c", ...) incorrectly deletes another property + and REGRESSION (r27487): Can't switch out of Edit HTML Source mode on Leopard Wiki + + Test: fast/js/delete-then-put.html + + * kjs/property_map.cpp: + (KJS::PropertyMap::put): Added a missing "- 1"; code to find an empty slot was not working. + (KJS::PropertyMap::checkConsistency): Added a missing range check that would have caught this + problem before. + + - roll out a last-minute change to my evaluateToBoolean patch that was incorrect. + + * kjs/nodes.h: (KJS::ExprStatementNode::ExprStatementNode): Take out call to + optimizeForUnnecessaryResult, since the result is used in some cases. + +2007-11-10 Adam Roben + + Windows build fix + + Roll out some changes that were (seemingly accidentally) checked in + with r27664. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2007-11-10 Darin Adler + + Reviewed by Sam. + + - http://bugs.webkit.org/show_bug.cgi?id=15915 + add an evaluation path for booleans like the one we have for numbers + + Gives 1.1% on SunSpider. + + * kjs/grammar.y: Create TrueNode and FalseNode instead of BooleanNode. + + * kjs/nodes.h: Changed to use Noncopyable. Moved optimizeForUnnecessaryResult + down from Node to ExpressionNode. Changed some classes to not inherit from + ExpressionNode where not necessary, and removed unnneeded evaluate functions + as well as evaluate functions that need not be virtual. Call the + optimizeForUnnecessaryResult function on the start of a for loop too. + * kjs/nodes.cpp: + (KJS::ExpressionNode::evaluateToBoolean): Added. + (KJS::FalseNode::evaluate): Added. + (KJS::TrueNode::evaluate): Added. + (KJS::NumberNode::evaluateToBoolean): Added. + (KJS::StringNode::evaluateToBoolean): Added. + (KJS::LocalVarAccessNode::evaluateToBoolean): Added. + (KJS::BracketAccessorNode::evaluateToBoolean): Added. + (KJS::LogicalNotNode::evaluate): Changed to call evaluateToBoolean. + (KJS::LogicalNotNode::evaluateToBoolean): Added. + (KJS::lessThan): Changed to return bool. + (KJS::lessThanEq): Ditto. + (KJS::LessNode::evaluate): Changed since lessThan returns bool. + (KJS::LessNode::evaluateToBoolean): Added. + (KJS::GreaterNode::evaluate): Changed since lessThanEq returns bool. + (KJS::GreaterNode::evaluateToBoolean): Added. + (KJS::LessEqNode::evaluate): Changed since lessThanEq returns bool. + (KJS::LessEqNode::evaluateToBoolean): Added. + (KJS::GreaterEqNode::evaluate): Changed since lessThan returns bool. + (KJS::GreaterEqNode::evaluateToBoolean): Added. + (KJS::InstanceOfNode::evaluateToBoolean): Added. + (KJS::InNode::evaluateToBoolean): Added. + (KJS::EqualNode::evaluateToBoolean): Added. + (KJS::NotEqualNode::evaluateToBoolean): Added. + (KJS::StrictEqualNode::evaluateToBoolean): Added. + (KJS::NotStrictEqualNode::evaluateToBoolean): Added. + (KJS::ConditionalNode::evaluate): Changed to call evaluateToBoolean. + (KJS::IfNode::execute): Ditto. + (KJS::DoWhileNode::execute): Ditto. + (KJS::WhileNode::execute): Ditto. + (KJS::ForNode::execute): Ditto. + + * kjs/nodes2string.cpp: + (KJS::FalseNode::streamTo): Added. + (KJS::TrueNode::streamTo): Added. + +2007-11-09 Adam Roben + + Windows build fix + + Reviewed by Darin. + + * kjs/value.h: + (KJS::jsNumber): Add some explicit casts. + +2007-11-08 Darin Adler + + - fix build + + * kjs/grammar.y: + * kjs/nodes.h: + * kjs/property_map.cpp: + +2007-11-08 Darin Adler + + - roll out accidentally-checked in changes + + * kjs/nodes.cpp: Back to previous version. + * kjs/nodes.h: Ditto. + * kjs/grammar.y: Ditto. + +2007-11-08 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15912 + fasta spends a lot of time in qsort + + * kjs/property_map.cpp: + (KJS::PropertyMap::getEnumerablePropertyNames): + Use insertion sort instead of qsort for small sets of property names. + We can probably do some even-better speedups of for/in, but this nets + 0.6% overall and 6.7% on fasta. + +2007-11-08 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15906 + getting characters by indexing into a string is very slow + + This fixes one source of the slowness -- the conversion to an unused + Identifier as we call the get function from the slot -- but doesn't + fix others, such as the fact that we have to allocate a new UString::Rep + for every single character. + + Speeds up string-base64 30%, and at least 0.5% overall. + But does slow down access-fannkuch quite a bit. Might be worth + revisiting in the future to see what we can do about that (although + I did look at a profile for a while). + + * kjs/property_slot.h: Add a new marker for "numeric" property slots; + slots where we don't need to pass the identifier to the get function. + (KJS::PropertySlot::getValue): Added code to call the numeric get function. + (KJS::PropertySlot::setCustomNumeric): Added. + * kjs/string_object.cpp: + (KJS::StringInstance::indexGetter): Changed to use substr() instead + of constructing a wholly new UString each time. + (KJS::stringInstanceNumericPropertyGetter): Added. Like indexGetter, but + takes advantage of setCustomNumeric to avoid creating an Identifier. + (KJS::StringInstance::getOwnPropertySlot): Changed to use setCustomNumeric. + +2007-11-08 Darin Adler + + Reviewed by Oliver. + + - http://bugs.webkit.org/show_bug.cgi?id=15904 + more speed-ups possible by tightening up int version of JSImmediate + + 1% improvement of SunSpider + + * kjs/JSImmediate.h: Eliminate the now-unneeded FPBitValues struct template. + (KJS::JSImmediate::from): Overload for most numeric types; many types can + do fewer branches and checks. + (KJS::JSImmediate::getUInt32): Removed unneeded check for undefined. + (KJS::JSImmediate::getTruncatedInt32): Ditto. + (KJS::JSImmediate::getTruncatedUInt32): Ditto. There's no difference any more + between getUInt32 and getTruncatedUInt32, so that's worth a rename and merge later. + + * kjs/grammar.y: Update since fromDouble is now just from. + * kjs/nodes.h: Ditto. + + * kjs/value.h: (KJS::jsNumber): Overload for most numeric types. + +2007-11-08 Kevin Ollivier + + Bakefiles for building JavaScriptCore, needed by wx port. + + Reviewed by Mark Rowe. + + * JavaScriptCoreSources.bkl: Added. + * jscore.bkl: Added. + +2007-11-08 Oliver Hunt + + Reviewed by Maciej. + + Fix regression caused by earlier bitwise and optimisation. 1 & undefined != 1. + + The implementation of JSImmediate::areBothImmediateNumbers relies on + (JSImmediate::getTag(immediate1) & JSImmediate::getTag(immediate2)) having + a unique result when both immediate values are numbers. + + The regression was due to UndefinedType & NumberType returning NumberType (3 & 1). + By swapping the value of NumberType and UndefinedType this ceases to be a problem. + + * kjs/JSType.h: + +2007-11-08 Darin Adler + + - fix build + + * kjs/nodes.h: Add missing parameter name. + +2007-11-08 Eric Seidel + + Reviewed by darin. + + Add ExpressionNode subclass of Node, use it. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::ForInNode::ForInNode): + * kjs/nodes.h: + (KJS::ExpressionNode::): + (KJS::NullNode::): + (KJS::NullNode::precedence): + (KJS::BooleanNode::): + (KJS::BooleanNode::precedence): + (KJS::RegExpNode::): + (KJS::RegExpNode::precedence): + (KJS::ThisNode::): + (KJS::ThisNode::precedence): + (KJS::ResolveNode::): + (KJS::ElementNode::): + (KJS::ArrayNode::): + (KJS::PropertyNode::): + (KJS::PropertyNode::precedence): + (KJS::PropertyNode::name): + (KJS::PropertyListNode::): + (KJS::ObjectLiteralNode::): + (KJS::ObjectLiteralNode::precedence): + (KJS::BracketAccessorNode::): + (KJS::DotAccessorNode::): + (KJS::DotAccessorNode::precedence): + (KJS::ArgumentListNode::): + (KJS::ArgumentsNode::): + (KJS::NewExprNode::): + (KJS::NewExprNode::precedence): + (KJS::FunctionCallValueNode::): + (KJS::FunctionCallValueNode::precedence): + (KJS::FunctionCallResolveNode::): + (KJS::FunctionCallBracketNode::): + (KJS::FunctionCallBracketNode::precedence): + (KJS::FunctionCallDotNode::): + (KJS::FunctionCallDotNode::precedence): + (KJS::PrePostResolveNode::): + (KJS::PostfixBracketNode::): + (KJS::PostfixBracketNode::precedence): + (KJS::PostIncBracketNode::): + (KJS::PostIncBracketNode::isIncrement): + (KJS::PostDecBracketNode::): + (KJS::PostDecBracketNode::isIncrement): + (KJS::PostfixDotNode::): + (KJS::PostfixDotNode::precedence): + (KJS::PostIncDotNode::): + (KJS::PostIncDotNode::isIncrement): + (KJS::PostDecDotNode::): + (KJS::PostDecDotNode::isIncrement): + (KJS::PostfixErrorNode::): + (KJS::PostfixErrorNode::precedence): + (KJS::DeleteResolveNode::): + (KJS::DeleteBracketNode::): + (KJS::DeleteBracketNode::precedence): + (KJS::DeleteDotNode::): + (KJS::DeleteDotNode::precedence): + (KJS::DeleteValueNode::): + (KJS::DeleteValueNode::precedence): + (KJS::VoidNode::): + (KJS::VoidNode::precedence): + (KJS::TypeOfResolveNode::): + (KJS::TypeOfValueNode::): + (KJS::PrefixBracketNode::): + (KJS::PrefixBracketNode::precedence): + (KJS::PreIncBracketNode::): + (KJS::PreIncBracketNode::isIncrement): + (KJS::PreDecBracketNode::): + (KJS::PreDecBracketNode::isIncrement): + (KJS::PrefixDotNode::): + (KJS::PrefixDotNode::precedence): + (KJS::PreIncDotNode::): + (KJS::PreIncDotNode::isIncrement): + (KJS::PreDecDotNode::): + (KJS::PreDecDotNode::isIncrement): + (KJS::PrefixErrorNode::): + (KJS::PrefixErrorNode::precedence): + (KJS::UnaryPlusNode::): + (KJS::UnaryPlusNode::precedence): + (KJS::NegateNode::): + (KJS::NegateNode::precedence): + (KJS::BitwiseNotNode::): + (KJS::BitwiseNotNode::precedence): + (KJS::LogicalNotNode::): + (KJS::LogicalNotNode::precedence): + (KJS::AddNode::): + (KJS::AddNode::precedence): + (KJS::LeftShiftNode::): + (KJS::LeftShiftNode::precedence): + (KJS::RightShiftNode::): + (KJS::RightShiftNode::precedence): + (KJS::UnsignedRightShiftNode::): + (KJS::UnsignedRightShiftNode::precedence): + (KJS::LessNode::): + (KJS::LessNode::precedence): + (KJS::GreaterNode::): + (KJS::GreaterNode::precedence): + (KJS::LessEqNode::): + (KJS::LessEqNode::precedence): + (KJS::GreaterEqNode::): + (KJS::GreaterEqNode::precedence): + (KJS::InstanceOfNode::): + (KJS::InstanceOfNode::precedence): + (KJS::InNode::): + (KJS::InNode::precedence): + (KJS::EqualNode::): + (KJS::EqualNode::precedence): + (KJS::NotEqualNode::): + (KJS::NotEqualNode::precedence): + (KJS::StrictEqualNode::): + (KJS::StrictEqualNode::precedence): + (KJS::NotStrictEqualNode::): + (KJS::NotStrictEqualNode::precedence): + (KJS::BitAndNode::): + (KJS::BitAndNode::precedence): + (KJS::BitOrNode::): + (KJS::BitOrNode::precedence): + (KJS::BitXOrNode::): + (KJS::BitXOrNode::precedence): + (KJS::LogicalAndNode::): + (KJS::LogicalAndNode::precedence): + (KJS::LogicalOrNode::): + (KJS::LogicalOrNode::precedence): + (KJS::ConditionalNode::): + (KJS::ConditionalNode::precedence): + (KJS::ReadModifyResolveNode::): + (KJS::ReadModifyResolveNode::precedence): + (KJS::AssignResolveNode::): + (KJS::AssignResolveNode::precedence): + (KJS::ReadModifyBracketNode::): + (KJS::ReadModifyBracketNode::precedence): + (KJS::AssignBracketNode::): + (KJS::AssignBracketNode::precedence): + (KJS::AssignDotNode::): + (KJS::AssignDotNode::precedence): + (KJS::ReadModifyDotNode::): + (KJS::ReadModifyDotNode::precedence): + (KJS::AssignErrorNode::): + (KJS::AssignErrorNode::precedence): + (KJS::CommaNode::): + (KJS::CommaNode::precedence): + (KJS::AssignExprNode::): + (KJS::AssignExprNode::precedence): + (KJS::ExprStatementNode::): + (KJS::IfNode::): + (KJS::DoWhileNode::): + (KJS::WhileNode::): + (KJS::ReturnNode::): + (KJS::WithNode::): + (KJS::ThrowNode::): + (KJS::ParameterNode::): + (KJS::CaseClauseNode::): + (KJS::CaseClauseNode::precedence): + (KJS::ClauseListNode::): + (KJS::SwitchNode::): + +2007-11-08 Oliver Hunt + + Reviewed by Sam. + + Add a fast path for bitwise-and of two immediate numbers for a 0.7% improvement in SunSpider (4% bitop improvement). + + This only improves bitwise-and performance, as the additional logic required + for similar code paths on or, xor, and shifting requires additional operations + and branches that negate (and in certain cases, regress) any advantage we might + otherwise receive. + + This improves performance on all bitop tests, the cryptography tests, as well as + the string-base64 and string-unpack-code tests. No significant degradation on + any other tests. + + * kjs/JSImmediate.h: + (KJS::JSImmediate::areBothImmediateNumbers): + (KJS::JSImmediate::andImmediateNumbers): + * kjs/nodes.cpp: + (KJS::BitAndNode::evaluate): + * kjs/value.h: + (KJS::jsNumberFromAnd): + +2007-11-08 Adam Roben + + Stop using KJS inside of MathExtras.h + + Reviewed by Darin. + + * wtf/MathExtras.h: Removed an unused header, and a now-unused + forward-declaration. + (wtf_atan2): Use std::numeric_limits intead of KJS. + +2007-11-08 Sam Weinig + + Windows build fix. + + * kjs/date_object.cpp: + (KJS::DateProtoFuncToLocaleString::callAsFunction): Fix unused arg warning. + (KJS::DateProtoFuncToLocaleDateString::callAsFunction): ditto + (KJS::DateProtoFuncToLocaleTimeString::callAsFunction): ditto + +2007-11-08 Mark Rowe + + Gtk build fix. + + * kjs/lookup.h: Add missing include. + +2007-11-08 Sam Weinig + + Reviewed by Darin. + + Convert JavaScript internal function objects to use one class per + function. This avoids a switch statement inside what used to be + the shared function classes and will allow Shark to better analyze + the code. + + To make this switch, the value property of the HashEntry was changed + to a union of an intptr_t (which is used to continue handle valueGetters) + and function pointer which points to a static constructor for the + individual new function objects. + + SunSpider claims this is a 1.0% speedup. + + * kjs/array_object.cpp: + (KJS::ArrayPrototype::getOwnPropertySlot): + (KJS::getProperty): + (KJS::ArrayProtoFuncToString::callAsFunction): + (KJS::ArrayProtoFuncToLocaleString::callAsFunction): + (KJS::ArrayProtoFuncJoin::callAsFunction): + (KJS::ArrayProtoFuncConcat::callAsFunction): + (KJS::ArrayProtoFuncPop::callAsFunction): + (KJS::ArrayProtoFuncPush::callAsFunction): + (KJS::ArrayProtoFuncReverse::callAsFunction): + (KJS::ArrayProtoFuncShift::callAsFunction): + (KJS::ArrayProtoFuncSlice::callAsFunction): + (KJS::ArrayProtoFuncSort::callAsFunction): + (KJS::ArrayProtoFuncSplice::callAsFunction): + (KJS::ArrayProtoFuncUnShift::callAsFunction): + (KJS::ArrayProtoFuncFilter::callAsFunction): + (KJS::ArrayProtoFuncMap::callAsFunction): + (KJS::ArrayProtoFuncEvery::callAsFunction): + (KJS::ArrayProtoFuncForEach::callAsFunction): + (KJS::ArrayProtoFuncSome::callAsFunction): + (KJS::ArrayProtoFuncIndexOf::callAsFunction): + (KJS::ArrayProtoFuncLastIndexOf::callAsFunction): + * kjs/array_object.h: + (KJS::ArrayPrototype::classInfo): + * kjs/create_hash_table: + * kjs/date_object.cpp: + (KJS::DatePrototype::getOwnPropertySlot): + (KJS::DateProtoFuncToString::callAsFunction): + (KJS::DateProtoFuncToUTCString::callAsFunction): + (KJS::DateProtoFuncToDateString::callAsFunction): + (KJS::DateProtoFuncToTimeString::callAsFunction): + (KJS::DateProtoFuncToLocaleString::callAsFunction): + (KJS::DateProtoFuncToLocaleDateString::callAsFunction): + (KJS::DateProtoFuncToLocaleTimeString::callAsFunction): + (KJS::DateProtoFuncValueOf::callAsFunction): + (KJS::DateProtoFuncGetTime::callAsFunction): + (KJS::DateProtoFuncGetFullYear::callAsFunction): + (KJS::DateProtoFuncGetUTCFullYear::callAsFunction): + (KJS::DateProtoFuncToGMTString::callAsFunction): + (KJS::DateProtoFuncGetMonth::callAsFunction): + (KJS::DateProtoFuncGetUTCMonth::callAsFunction): + (KJS::DateProtoFuncGetDate::callAsFunction): + (KJS::DateProtoFuncGetUTCDate::callAsFunction): + (KJS::DateProtoFuncGetDay::callAsFunction): + (KJS::DateProtoFuncGetUTCDay::callAsFunction): + (KJS::DateProtoFuncGetHours::callAsFunction): + (KJS::DateProtoFuncGetUTCHours::callAsFunction): + (KJS::DateProtoFuncGetMinutes::callAsFunction): + (KJS::DateProtoFuncGetUTCMinutes::callAsFunction): + (KJS::DateProtoFuncGetSeconds::callAsFunction): + (KJS::DateProtoFuncGetUTCSeconds::callAsFunction): + (KJS::DateProtoFuncGetMilliSeconds::callAsFunction): + (KJS::DateProtoFuncGetUTCMilliseconds::callAsFunction): + (KJS::DateProtoFuncGetTimezoneOffset::callAsFunction): + (KJS::DateProtoFuncSetTime::callAsFunction): + (KJS::DateProtoFuncSetMilliSeconds::callAsFunction): + (KJS::DateProtoFuncSetUTCMilliseconds::callAsFunction): + (KJS::DateProtoFuncSetSeconds::callAsFunction): + (KJS::DateProtoFuncSetUTCSeconds::callAsFunction): + (KJS::DateProtoFuncSetMinutes::callAsFunction): + (KJS::DateProtoFuncSetUTCMinutes::callAsFunction): + (KJS::DateProtoFuncSetHours::callAsFunction): + (KJS::DateProtoFuncSetUTCHours::callAsFunction): + (KJS::DateProtoFuncSetDate::callAsFunction): + (KJS::DateProtoFuncSetUTCDate::callAsFunction): + (KJS::DateProtoFuncSetMonth::callAsFunction): + (KJS::DateProtoFuncSetUTCMonth::callAsFunction): + (KJS::DateProtoFuncSetFullYear::callAsFunction): + (KJS::DateProtoFuncSetUTCFullYear::callAsFunction): + (KJS::DateProtoFuncSetYear::callAsFunction): + (KJS::DateProtoFuncGetYear::callAsFunction): + * kjs/date_object.h: + * kjs/lookup.cpp: + (KJS::Lookup::find): + * kjs/lookup.h: + (KJS::HashEntry::): + (KJS::staticFunctionGetter): + (KJS::staticValueGetter): + (KJS::getStaticPropertySlot): + (KJS::getStaticFunctionSlot): + (KJS::lookupPut): + * kjs/math_object.cpp: + (KJS::MathObjectImp::getOwnPropertySlot): + (KJS::MathProtoFuncAbs::callAsFunction): + (KJS::MathProtoFuncACos::callAsFunction): + (KJS::MathProtoFuncASin::callAsFunction): + (KJS::MathProtoFuncATan::callAsFunction): + (KJS::MathProtoFuncATan2::callAsFunction): + (KJS::MathProtoFuncCeil::callAsFunction): + (KJS::MathProtoFuncCos::callAsFunction): + (KJS::MathProtoFuncExp::callAsFunction): + (KJS::MathProtoFuncFloor::callAsFunction): + (KJS::MathProtoFuncLog::callAsFunction): + (KJS::MathProtoFuncMax::callAsFunction): + (KJS::MathProtoFuncMin::callAsFunction): + (KJS::MathProtoFuncPow::callAsFunction): + (KJS::MathProtoFuncRandom::callAsFunction): + (KJS::MathProtoFuncRound::callAsFunction): + (KJS::MathProtoFuncSin::callAsFunction): + (KJS::MathProtoFuncSqrt::callAsFunction): + (KJS::MathProtoFuncTan::callAsFunction): + * kjs/math_object.h: + (KJS::MathObjectImp::classInfo): + (KJS::MathObjectImp::): + * kjs/string_object.cpp: + (KJS::StringPrototype::getOwnPropertySlot): + (KJS::StringProtoFuncToString::callAsFunction): + (KJS::StringProtoFuncValueOf::callAsFunction): + (KJS::StringProtoFuncCharAt::callAsFunction): + (KJS::StringProtoFuncCharCodeAt::callAsFunction): + (KJS::StringProtoFuncConcat::callAsFunction): + (KJS::StringProtoFuncIndexOf::callAsFunction): + (KJS::StringProtoFuncLastIndexOf::callAsFunction): + (KJS::StringProtoFuncMatch::callAsFunction): + (KJS::StringProtoFuncSearch::callAsFunction): + (KJS::StringProtoFuncReplace::callAsFunction): + (KJS::StringProtoFuncSlice::callAsFunction): + (KJS::StringProtoFuncSplit::callAsFunction): + (KJS::StringProtoFuncSubstr::callAsFunction): + (KJS::StringProtoFuncSubstring::callAsFunction): + (KJS::StringProtoFuncToLowerCase::callAsFunction): + (KJS::StringProtoFuncToUpperCase::callAsFunction): + (KJS::StringProtoFuncToLocaleLowerCase::callAsFunction): + (KJS::StringProtoFuncToLocaleUpperCase::callAsFunction): + (KJS::StringProtoFuncLocaleCompare::callAsFunction): + (KJS::StringProtoFuncBig::callAsFunction): + (KJS::StringProtoFuncSmall::callAsFunction): + (KJS::StringProtoFuncBlink::callAsFunction): + (KJS::StringProtoFuncBold::callAsFunction): + (KJS::StringProtoFuncFixed::callAsFunction): + (KJS::StringProtoFuncItalics::callAsFunction): + (KJS::StringProtoFuncStrike::callAsFunction): + (KJS::StringProtoFuncSub::callAsFunction): + (KJS::StringProtoFuncSup::callAsFunction): + (KJS::StringProtoFuncFontcolor::callAsFunction): + (KJS::StringProtoFuncFontsize::callAsFunction): + (KJS::StringProtoFuncAnchor::callAsFunction): + (KJS::StringProtoFuncLink::callAsFunction): + * kjs/string_object.h: + +2007-11-08 Adam Roben + + Windows build fix + + Reviewed by Sam and Ada. + + * wtf/MathExtras.h: Get rid of a circular #include dependency to fix + the build. + +2007-11-08 Adam Roben + + Fix a precedence warning on Windows + + * kjs/JSImmediate.h: + (KJS::JSImmediate::toBoolean): + +2007-11-08 Mark Rowe + + Build fix for JavaScriptGlue. + + * wtf/MathExtras.h: Include stdlib.h for srand and RAND_MAX. + +2007-11-08 Darin Adler + + - Windows build fix + + * kjs/JSImmediate.h: Include MathExtras.h rather than math.h since this file uses "signbit". + +2007-11-08 Oliver Hunt + + Reviewed by Darin. + + Replace the use of floats for immediate values with the use of integers for a 4.5% improvement in SunSpider. + + Unfortunately this change results in NaN, +Inf, -Inf, and -0 being heap allocated now, but + we should now have faster array access, faster immediate to double conversion, and the + potential to further improve bitwise operators in future. + + This also removes the need for unions to avoid strict aliasing problems when extracting + a value from immediates. + + * kjs/JSImmediate.h: + (KJS::JSImmediate::trueImmediate): + (KJS::JSImmediate::falseImmediate): + (KJS::JSImmediate::undefinedImmediate): + (KJS::JSImmediate::nullImmediate): + (KJS::JSImmediate::toBoolean): + * kjs/value.h: + (KJS::jsNaN): + +2007-11-07 Eric Seidel + + Reviewed by Darin and Oliver. + + Add evaluateToNumber parallel evaluation tree to speed up number operations. + Make ImmediateNumberNode a subclass of NumberNode. + Share evaluate logic between evaluate and evaluateToNumber using inline functions + There is still a lot of improvement to be made here. + + SunSpider claims this is a 1.0% speedup overall (nbody 7.9%), base64 slowing 2.0% + Given the huge win that this prepares us for with simple type inferencing I see the small + regression in base64 being worth the substantial overall improvement. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::Node::evaluateToNumber): + (KJS::NumberNode::evaluate): + (KJS::NumberNode::evaluateToNumber): + (KJS::StringNode::evaluateToNumber): + (KJS::LocalVarAccessNode::inlineEvaluate): + (KJS::LocalVarAccessNode::evaluate): + (KJS::LocalVarAccessNode::evaluateToNumber): + (KJS::BracketAccessorNode::inlineEvaluate): + (KJS::BracketAccessorNode::evaluate): + (KJS::BracketAccessorNode::evaluateToNumber): + (KJS::NegateNode::evaluate): + (KJS::NegateNode::evaluateToNumber): + (KJS::MultNode::inlineEvaluateToNumber): + (KJS::MultNode::evaluate): + (KJS::MultNode::evaluateToNumber): + (KJS::DivNode::inlineEvaluateToNumber): + (KJS::DivNode::evaluate): + (KJS::DivNode::evaluateToNumber): + (KJS::ModNode::inlineEvaluateToNumber): + (KJS::ModNode::evaluate): + (KJS::ModNode::evaluateToNumber): + (KJS::throwOutOfMemoryErrorToNumber): + (KJS::addSlowCaseToNumber): + (KJS::add): + (KJS::addToNumber): + (KJS::AddNode::evaluateToNumber): + (KJS::SubNode::inlineEvaluateToNumber): + (KJS::SubNode::evaluate): + (KJS::SubNode::evaluateToNumber): + (KJS::valueForReadModifyAssignment): + (KJS::ReadModifyLocalVarNode::evaluate): + (KJS::ReadModifyResolveNode::evaluate): + (KJS::ReadModifyDotNode::evaluate): + (KJS::ReadModifyBracketNode::evaluate): + * kjs/nodes.h: + (KJS::Node::): + (KJS::NumberNode::): + (KJS::ImmediateNumberNode::): + (KJS::AddNode::precedence): + * kjs/nodes2string.cpp: + (KJS::NumberNode::streamTo): + +2007-11-07 Mark Rowe + + Reviewed by Eric. + + Fix up initialization after being mangled in r27572, and remove the + ternary expression as extraCost will always be zero for the numeric + heap. + + * kjs/collector.cpp: + (KJS::Collector::heapAllocate): + +2007-11-07 Mark Rowe + + Gtk build fix. + + * kjs/regexp_object.cpp: + +2007-11-07 Geoffrey Garen + + Reviewed by Beth Dakin. + + Eliminated a bogus (though compiled-out) branch in the collector. + + * kjs/collector.cpp: + (KJS::Collector::heapAllocate): + +2007-11-06 Geoffrey Garen + + Reviewed by Darin Adler. + + Fixed part of http://bugs.webkit.org/show_bug.cgi?id=15861 + 5.8% of string-validate-input.js is spent creating RegExpImps + + Put RegExpImp properties into a static hashtable to avoid a slew of + PropertyMap churn when creating a RegExpImp. + + Factored important bits of regular expression implementation out of + RegExpImp (the JS object) and into RegExp (the PCRE wrapper class), + making RegExp a ref-counted class. (This will help later.) + + Removed PCRE_POSIX support because I didn't quite know how to test it + and keep it working with these changes. + + 1.1% SunSpider speedup. 5.8% speedup on string-validate-input.js. + + * kjs/regexp.h: A few interface changes: + 1. Renamed "subpatterns()" => "numSubpatterns()" + 2. Made flag enumeration private and replaced it with public getters for + specific flags. + 3. Made RegExp ref-counted so RegExps can be shared by RegExpImps. + 4. Made RegExp take a string of flags instead of an int, eliminating + duplicated flag parsing code elsewhere. + + * kjs/regexp_object.cpp: + (KJS::RegExpProtoFunc::callAsFunction): For RegExp.compile: + - Fixed a bug where compile(undefined) would throw an exception. + - Removed some now-redundant code. + - Used RegExp sharing to eliminate an allocation and a bunch of + PropertyMap thrash. (Not a big win since compile is a deprecated + function. I mainly did this to test the plubming.) + +2007-11-07 Simon Hausmann + + Reviewed by nobody, Qt/Windows build fix. + + JavaScriptCore.pri expects OBJECTS_DIR to be set, so set it in + testkjs.pro, too, where it's included from. + + * kjs/testkjs.pro: + +2007-11-07 Simon Hausmann + + Reviewed by Lars. + + Fix "nmake clean" for the Qt/Windows build by replacing tmp/ with a variable that ends with the correct type of slash/backslash depending on the choice of compiler/make tool. + + * JavaScriptCore.pri: + * pcre/pcre.pri: + +2007-11-07 Lars Knoll + + Reviewed by Simon. + + fix umemcasecmp + + Pretty embarrassing bug. Has the potential to fix quite a few test failures. + + * wtf/unicode/qt4/UnicodeQt4.h: + (WTF::Unicode::umemcasecmp): + +2007-11-06 Maciej Stachowiak + + Reviewed by Eric. + + - only collect when the heap is full, unless we have lots of extra cost garbage + + 1.1% SunSpider speedup. + + This shouldn't hit memory use much since the extra space in those + blocks hangs around either way. + + * kjs/collector.cpp: + (KJS::Collector::heapAllocate): + (KJS::Collector::collect): Fix logic error that reversed the sense of collect's + return value. + +2007-11-06 Oliver Hunt + + Reviewed by Maciej. + + Avoid unnecessarily boxing the result from post inc/decrement for 0.3% gain in sunspider + + We now convert the common 'for (...; ...; ++) ...' to the semantically identical + 'for (...; ...; ++) ...'. + + * kjs/nodes.cpp: + (KJS::PostIncResolveNode::optimizeForUnnecessaryResult): + (KJS::PostIncLocalVarNode::evaluate): + (KJS::PostIncLocalVarNode::optimizeForUnnecessaryResult): + (KJS::PostDecResolveNode::optimizeForUnnecessaryResult): + (KJS::PostDecLocalVarNode::evaluate): + (KJS::PostDecLocalVarNode::optimizeForUnnecessaryResult): + * kjs/nodes.h: + (KJS::PrePostResolveNode::): + (KJS::PostIncResolveNode::): + (KJS::PostIncLocalVarNode::): + (KJS::PostDecResolveNode::): + (KJS::PostDecLocalVarNode::): + (KJS::PreIncResolveNode::): + (KJS::PreDecResolveNode::): + (KJS::ForNode::ForNode): + +2007-11-06 Eric Seidel + + Reviewed by darin. + + This fixes a regressed layout test for string + object + + SunSpider claims this was an overall 0.3% speedup, although some individual tests were slower. + + * kjs/nodes.cpp: + (KJS::add): remove erroneous "fast path" for string + * + +2007-11-06 Geoffrey Garen + + Reviewed by Eric Seidel. + + Added toJSNumber, a fast path for converting a JSValue to a JS number, + and deployed it in postfix expressions. In the fast case this + eliminates a call to jsNumber. + + 0.4% speedup on SunSpider. + + * ChangeLog: + * kjs/nodes.cpp: + (KJS::PostIncResolveNode::evaluate): + (KJS::PostIncLocalVarNode::evaluate): + (KJS::PostDecResolveNode::evaluate): + (KJS::PostDecLocalVarNode::evaluate): + (KJS::PostIncBracketNode::evaluate): + (KJS::PostDecBracketNode::evaluate): + (KJS::PostIncDotNode::evaluate): + (KJS::PostDecDotNode::evaluate): + (KJS::UnaryPlusNode::evaluate): + * kjs/value.h: + (KJS::JSValue::toJSNumber): + +2007-11-06 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15846 + REGRESSION (r27387): Memory corruption when running fast/js/kde/delete.html + + There was a mistake in the algorithm used to find an empty slot in the property + map entries vector; when we were putting in a new property value and not overwriting + an existing deleted sentinel, we would enlarge the entries vector, but would not + overwrite the stale data that's in the new part. It was easy to pin this down by + turning on property map consistency checks -- I never would have landed with this + bug if I had run the regression tests once with consistency checks on! + + * kjs/property_map.cpp: (KJS::PropertyMap::put): Changed logic for the case where + foundDeletedElement is false to always use the item at the end of the entries vector. + Also allowed me to merge with the logic for the "no deleted sentinels at all" case. + +2007-11-06 Oliver Hunt + + RS=Darin. + + Fix previous patch to use a 3 bit shift, a 16 bit shift causes a regression in sunspider. + + * kjs/nodes.cpp: + (KJS::add): + +2007-11-06 Oliver Hunt + + Reviewed by Darin. + + Replace boolean comparisons in AddNode with mask + comparisons for a 0.2% improvement in sunspider. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/nodes.cpp: + (KJS::add): + +2007-11-06 Eric Seidel + + Reviewed by darin. + + SunSpider claims this is a 1.1% speedup. + + * kjs/nodes.cpp: + (KJS::throwOutOfMemoryError): Added, non inline. + (KJS::addSlowCase): renamed from add(), non inline. + (KJS::add): add fast path for String + String, Number + Number and String + * + +2007-11-06 Eric Seidel + + Reviewed by mjs. + + Avoid more UString creation. + + SunSpider claims this is a 0.4% speedup. + + * kjs/regexp_object.cpp: + (KJS::RegExpObjectImp::construct): use UString::find(UChar) + +2007-11-05 Mark Rowe + + Mac build fix. + + * kjs/array_object.cpp: + (KJS::ArrayProtoFunc::callAsFunction): + +2007-11-05 Adam Roben + + Windows build fix + + * kjs/list.h: + +2007-11-05 Mark Rowe + + Build fix. Add missing #include. + + * kjs/operations.cpp: + +2007-11-05 Eric Seidel + + Reviewed by mjs. + + Remove another call to toString(exec) + + SunSpider claims this is a 0.5% speedup. + + * kjs/operations.cpp: + (KJS::equal): remove another toString + +2007-11-05 Eric Seidel + + * kjs/operations.cpp: + (KJS::equal): correct broken change. + +2007-11-05 Eric Seidel + + Reviewed by mjs. + + Remove one more call to toString(exec). + + SunSpider claims this is a 0.7% speedup. + + * kjs/operations.cpp: + (KJS::equal): remove a call to toString() + +2007-11-05 Mark Rowe + + Gtk build fix. + + * pcre/pcre.pri: + +2007-11-05 Mark Rowe + + Gtk build fix. + + * kjs/list.cpp: + +2007-11-05 Geoffrey Garen + + Touched a file to test my new HTTP access. + + * kjs/scope_chain.cpp: + +2007-11-05 Alp Toker + + Unreviewed build fix for qmake-based ports. + + Someone with a better understanding of qmake still needs to sort out + the INCLUDEPATH/DEPENDPATH mess. + + * JavaScriptCore.pri: + +2007-11-05 Geoffrey Garen + + Reviewed by Darin Adler. + + http://bugs.webkit.org/show_bug.cgi?id=15835 + + Switched List implementation from a custom heap allocator to an inline + Vector, for a disappointing .5% SunSpider speedup. + + Also renamed List::slice to List::getSlice because "get" is the + conventional prefix for functions returning a value through an out + parameter. + + * kjs/array_object.cpp: + (KJS::ArrayProtoFunc::callAsFunction): Removed some redundant function + calls and memory accesses. + + * kjs/bool_object.cpp: + (BooleanObjectImp::construct): Removed questionable use of iterator. + + * kjs/list.cpp: + * kjs/list.h: New List class, implemented in terms of Vector. Two + interesting differences: + 1. The inline capacity is 8, not 5. Many of the Lists constructed + during a SunSpider run are larger than 5; almost none are larger + than 8. + + 2. The growth factor is 4, not 2. Since we can guarantee that Lists + aren't long-lived, we can grow them more aggressively, to avoid + excessive copying. + + * kjs/regexp_object.cpp: + (RegExpObjectImp::construct): Removed redundant function calls. + + * kjs/string_object.cpp: + (KJS::StringObjectImp::construct): Removed questionable use of iterator. + + * wtf/Vector.h: + (WTF::::uncheckedAppend): Added a fast, unchecked version of append. + +2007-11-05 Mark Rowe + + Reviewed by Alp Toker. + + Add DEPENDPATH to JavaScriptCore and pcre to help qmake with dependencies. + + * JavaScriptCore.pri: + * pcre/pcre.pri: + +2007-11-04 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15826 + optimize opcode loop and case insensitive ASCII compares for a 30% speedup + + SunSpider says it's 2.6% faster overall, 32.5% in the regular expression tests. + + * pcre/pcre_internal.h: Added OP_ASCII_CHAR and OP_ASCII_LETTER_NC. + + * pcre/pcre_compile.c: + (find_fixedlength): Added cases for OP_ASCII_CHAR and OP_ASCII_LETTER_NC. Also + added OP_NOT since there was no reason it should not be in here. + (could_be_empty_branch): Ditto. + (compile_branch): Streamlined all the single-character cases; there was a bit of + duplicate code. Added cases for OP_ASCII_CHAR and OP_ASCII_LETTER_NC as needed. + But in particular, compile to those opcodes when the single character match is + ASCII. + (find_firstassertedchar): Added cases for OP_ASCII_CHAR and OP_ASCII_LETTER_NC. + + * pcre/pcre_exec.c: (match): Removed the "min", "minimize", and "op" fields from + the matchframe, after I discovered that none of them needed to be saved and restored + across recursive match calls. Also eliminated the ignored result field from the + matchframe, since I discovered that rrc ("recursive result code") was already the + exact same thing. Moved the handling of opcodes higher than OP_BRA into the default + statement of the switch instead of doing them before the switch. This removes a + branch from each iteration of the opcode interpreter, just as removal of "op" + removed at least one store from each iteration. Last, but not least, add the + OP_ASCII_CHAR and OP_ASCII_LETTER_NC functions. Neither can ever match a + surrogate pair and the letter case can be handled efficiently. + +2007-11-04 Darin Adler + + * pcre/pcre_exec.c: (match): Try to fix the Windows build by removing unreachable code. + +2007-11-03 Darin Adler + + - fix non-Mac builds; remove some more unused PCRE stuff + + * pcre/pcre_compile.c: + (compile_branch): Removed branch chain and some unused ESC values. + (compile_regex): Ditto. + (jsRegExpCompile): Ditto. + * pcre/pcre_exec.c: + (match): Removed unused branch targets. Don't use macros any more. + (jsRegExpExecute): More of the same. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Update for removed files. + * JavaScriptCore.xcodeproj/project.pbxproj: Ditto. + * pcre/pcre.pri: Ditto. + + * pcre/MERGING: Removed. + * pcre/pcre_fullinfo.c: Removed. + * pcre/pcre_get.c: Removed. + * pcre/pcre_internal.h: + * pcre/ucp.h: Removed. + +2007-11-03 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15821 + remove unused PCRE features for speed + + A first step toward removing the PCRE features we don't use. + This gives a 0.8% speedup on SunSpider, and a 6.5% speedup on + the SunSpider regular expression test. + + Replaced the public interface with one that doesn't use the + name PCRE. Removed code we don't need for JavaScript and various + configurations we don't use. This is in preparation for still + more changes in the future. We'll probably switch to C++ and + make some even more significant changes to the regexp engine + to get some additional speed. + + There's probably additional unused stuff that I haven't + deleted yet. + + This does mean that our PCRE is now a fork, but I think that's + not really a big deal. + + * JavaScriptCore.exp: Remove the 5 old entry points and add + the 3 new entry points for WebCore's direct use of the regular + expression engine. + + * kjs/config.h: Remove the USE(PCRE16) define. I decided to flip + its sense and now there's a USE(POSIX_REGEX) instead, which should + probably not be set by anyone. Maybe later we'll just get rid of it + altogether. + + * kjs/regexp.h: + * kjs/regexp.cpp: + (KJS::RegExp::RegExp): Switch to new jsRegExp function names and + defines. Cut down on the number of functions used. + (KJS::RegExp::~RegExp): Ditto. + (KJS::RegExp::match): Ditto. + + * pcre/dftables.c: (main): Get rid of ctype_letter and ctype_meta, + which are unused. + + * pcre/pcre-config.h: Get rid of EBCIDIC, PCRE_DATA_SCOPE, const, + size_t, HAVE_STRERROR, HAVE_MEMMOVE, HAVE_BCOPY, NEWLINE, + POSIX_MALLOC_THRESHOLD, NO_RECURSE, SUPPORT_UCP, SUPPORT_UTF8, + and JAVASCRIPT. These are all no longer configurable in our copy + of the library. + + * pcre/pcre.h: Remove the macro-based kjs prefix hack, the PCRE + version macros, PCRE_UTF16, the code to set up PCRE_DATA_SCOPE, + the include of , and most of the constants and + functions defined in this header. Changed the naming scheme to + use a JSRegExp prefix rather than a pcre prefix. In the future, + we'll probably change this to be a C++ header. + + * pcre/pcre_compile.c: Removed all unused code branches, + including many whole functions and various byte codes. + Kept changes outside of removal to a minimum. + (check_escape): + (first_significant_code): + (find_fixedlength): + (find_recurse): + (could_be_empty_branch): + (compile_branch): + (compile_regex): + (is_anchored): + (is_startline): + (find_firstassertedchar): + (jsRegExpCompile): Renamed from pcre_compile2 and changed the + parameters around a bit. + (jsRegExpFree): Added. + + * pcre/pcre_exec.c: Removed many unused opcodes and variables. + Also started tearing down the NO_RECURSE mechanism since it's + now the default. In some cases there were things in the explicit + frame that could be turned into plain old local variables and + other small like optimizations. + (pchars): + (match_ref): + (match): Changed parameters quite a bit since it's now not used + recursively. + (jsRegExpExecute): Renamed from pcre_exec. + + * pcre/pcre_internal.h: Get rid of PCRE_DEFINITION, PCRE_SPTR, + PCRE_IMS, PCRE_ICHANGED, PCRE_NOPARTIAL, PCRE_STUDY_MAPPED, + PUBLIC_OPTIONS, PUBLIC_EXEC_OPTIONS, PUBLIC_DFA_EXEC_OPTIONS, + PUBLIC_STUDY_OPTIONS, MAGIC_NUMBER, 16 of the opcodes, + _pcre_utt, _pcre_utt_size, _pcre_try_flipped, _pcre_ucp_findprop, + and _pcre_valid_utf8. Also moved pcre_malloc and pcre_free here. + + * pcre/pcre_maketables.c: Changed to only compile in dftables. + Also got rid of many of the tables that we don't use. + + * pcre/pcre_tables.c: Removed the unused Unicode property tables. + + * pcre/pcre_ucp_searchfuncs.c: Removed everything except for + _pcre_ucp_othercase. + + * pcre/pcre_xclass.c: (_pcre_xclass): Removed uneeded support + for classes based on Unicode properties. + + * wtf/FastMallocPCRE.cpp: Removed unused bits. It would be good + to eliminate this completely, but we need the regular expression + code to be C++ first. + + * pcre/pcre_fullinfo.c: + * pcre/pcre_get.c: + * pcre/ucp.h: + Files that are no longer needed. I didn't remove them with this + check-in, because I didn't want to modify all the project files. + +2007-11-03 Maciej Stachowiak + + Reviewed by Sam. + + - remove NaN check from JSImmediate::fromDouble for 0.5% SunSpider speedup + + It turns out that doing this check costs more than it saves. + + * kjs/JSImmediate.h: + (KJS::JSImmediate::fromDouble): + +2007-11-03 Sam Weinig + + Reviewed by Oliver. + + Remove dummy variable from ClassInfo reducing the size of the struct by 1 word. + The variable had been kept around for binary compatibility, but since nothing + else is there is no point in continuing to keep it around. + + * API/JSCallbackConstructor.cpp: + * API/JSCallbackFunction.cpp: + * API/JSCallbackObject.cpp: + * bindings/objc/objc_runtime.mm: + * bindings/runtime_array.cpp: + * bindings/runtime_object.cpp: + * kjs/array_instance.cpp: + * kjs/array_object.cpp: + * kjs/bool_object.cpp: + * kjs/date_object.cpp: + * kjs/error_object.cpp: + * kjs/function.cpp: + * kjs/internal.cpp: + * kjs/lookup.h: + * kjs/math_object.cpp: + * kjs/number_object.cpp: + * kjs/object.h: + * kjs/regexp_object.cpp: + * kjs/string_object.cpp: + +2007-11-03 Kevin McCullough + + - Updated testkjs results to make the build bots green until we + can fix the tests that are failing. The new failures are in DST. + + * tests/mozilla/expected.html: + +2007-11-03 Maciej Stachowiak + + Reviewed by Adam. + + - don't print the var twice for ForInNodes with a var declaration + + * kjs/nodes2string.cpp: + (KJS::ForInNode::streamTo): + +2007-11-03 Darin Adler + + * pcre/pcre_compile.c: (check_escape): Windows build fix. Get rid of + C-incompatible declaration. + +2007-11-03 Mark Rowe + + Gtk build fix. + + * kjs/nodes.cpp: Add missing include. + +2007-11-03 Darin Adler + + Reviewed by Maciej. + + - fix http://bugs.webkit.org/show_bug.cgi?id=15814 + fast/js/kde/encode_decode_uri.html fails + + These changes cause us to match the JavaScript specification and pass the + fast/js/kde/encode_decode_uri.html test. + + * kjs/function.cpp: (KJS::encode): Call the UTF-8 string conversion in its + new strict mode, throwing an exception if there are malformed UTF-16 surrogate + pairs in the text. + + * kjs/ustring.h: Added a strict version of the UTF-8 string conversion. + * kjs/ustring.cpp: + (KJS::decodeUTF8Sequence): Removed code to disallow U+FFFE and U+FFFF; while + those might be illegal in some sense, they aren't supposed to get any special + handling in the place where this function is currently used. + (KJS::UString::UTF8String): Added the strictness. + +2007-11-03 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15812 + some JavaScript tests (from the Mozilla test suite) are failing + + Two or three fixes get 7 more of the Mozilla tests passing. + This gets us down from 61 failing tests to 54. + + * kjs/interpreter.h: (KJS::Interpreter::builtinRegExp): + Made this inline and gave it a more specific type. Some day we should + probably do that for all of these -- might even get a bit of a speed + boost from it. + * kjs/interpreter.cpp: Removed Interpreter::builtinRegExp now that it's + inline in the header. + + * kjs/regexp_object.h: + * kjs/regexp_object.cpp: + (KJS::RegExpProtoFunc::callAsFunction): Moved test and exec out of the + switch statement into the RegExpImp object, so they can be shared with + RegExpImp::callAsFunction. + (KJS::RegExpImp::match): Added. Common code used by both test and exec. + (KJS::RegExpImp::test): Added. + (KJS::RegExpImp::exec): Added. + (KJS::RegExpImp::implementsCall): Added. + (KJS::RegExpImp::callAsFunction): Added. + (KJS::RegExpObjectImpPrivate::RegExpObjectImpPrivate): Initialize + lastInput to null rather than empty string -- we take advantage of the + difference in RegExpImp::match. + (KJS::RegExpObjectImp::input): Added. No reason to go through hash tables + just to get at a field like this. + + * pcre/pcre_compile.c: (check_escape): Changed the \u handling to match + the JavaScript specification. If there are not 4 hex digits after the \u, + then it's processed as if it wasn't an escape sequence at all. + + * pcre/pcre_internal.h: Added IS_NEWLINE, with the appropriate definition + for JavaScript (4 specific Unicode values). + * pcre/pcre_exec.c: + (match): Changed all call sites to use IS_NEWLINE. + (pcre_exec): Ditto. + + * tests/mozilla/expected.html: Updated to expect 7 more successful tests. + +2007-11-03 David D. Kilzer + + Sort files(...); sections of Xcode project files. + + Rubber-stamped by Darin. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2007-11-03 Maciej Stachowiak + + Reviewed by Oliver. + + - remove VarDeclListNode and simplify VarDeclNode evaluation for 0.4% SunSpider speedup + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::VarDeclNode::optimizeVariableAccess): + (KJS::VarDeclNode::getDeclarations): + (KJS::VarDeclNode::handleSlowCase): + (KJS::VarDeclNode::evaluateSingle): + (KJS::VarDeclNode::evaluate): + (KJS::VarStatementNode::execute): + * kjs/nodes.h: + (KJS::VarDeclNode::): + (KJS::VarStatementNode::): + * kjs/nodes2string.cpp: + (KJS::VarDeclNode::streamTo): + +2007-11-03 Alexey Proskuryakov + + Reviewed by Darin. + + http://bugs.webkit.org/show_bug.cgi?id=15800 + REGRESSION (r27303): RegExp leaks + + * kjs/regexp_object.h: + (KJS::RegExpImp::setRegExp): + (KJS::RegExpImp::regExp): + (KJS::RegExpImp::classInfo): + * kjs/regexp_object.cpp: + (RegExpImp::RegExpImp): + (RegExpImp::~RegExpImp): + Renamed reg member variable to m_regExp, changed it to use OwnPtr. + +2007-11-02 Maciej Stachowiak + + Reviewed by Oliver. + + - add SourceElements as a typedef for Vector >. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::statementListPushFIFO): + (KJS::statementListGetDeclarations): + (KJS::statementListInitializeDeclarationStacks): + (KJS::statementListInitializeVariableAccessStack): + (KJS::statementListExecute): + (KJS::BlockNode::BlockNode): + (KJS::FunctionBodyNode::FunctionBodyNode): + (KJS::ProgramNode::ProgramNode): + * kjs/nodes.h: + (KJS::CaseClauseNode::): + +2007-11-02 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15791 + change property map data structure for less memory use, better speed + + The property map now has an array of indices and a separate array of + property map entries. This slightly slows down lookup because of a second + memory acess, but makes property maps smaller and faster to iterate in + functions like mark(). + + SunSpider says this is 1.2% faster, although it makes the bitwise-end test + more than 10% slower. To fix that we'll need to optimize global variable lookup. + + * kjs/property_map.cpp: + (KJS::PropertyMapEntry::PropertyMapEntry): + (KJS::PropertyMapHashTable::entries): + (KJS::PropertyMapHashTable::allocationSize): + (KJS::SavedProperties::SavedProperties): + (KJS::SavedProperties::~SavedProperties): + (KJS::PropertyMap::checkConsistency): + (KJS::PropertyMap::~PropertyMap): + (KJS::PropertyMap::clear): + (KJS::PropertyMap::get): + (KJS::PropertyMap::getLocation): + (KJS::PropertyMap::put): + (KJS::PropertyMap::insert): + (KJS::PropertyMap::createTable): + (KJS::PropertyMap::rehash): + (KJS::PropertyMap::remove): + (KJS::PropertyMap::mark): + (KJS::comparePropertyMapEntryIndices): + (KJS::PropertyMap::containsGettersOrSetters): + (KJS::PropertyMap::getEnumerablePropertyNames): + (KJS::PropertyMap::save): + (KJS::PropertyMap::restore): + * kjs/property_map.h: + +2007-11-02 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15807 + HashMap needs a take() function that combines get and remove + + * wtf/HashMap.h: Added take function. Simplistic implementation for now, + but still does only one hash table lookup. + + * kjs/array_instance.cpp: (KJS::ArrayInstance::put): Use take rather than + a find followed by a remove. + +2007-11-02 David Carson + + Reviewed by Darin. + + Fix compiler warning "warning: suggest parentheses around && within ||" + http://bugs.webkit.org/show_bug.cgi?id=15764 + + * kjs/value.h: (KJS::JSValue::isNumber): Add parentheses. + +2007-11-01 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + In preparation for making List a simple stack-allocated Vector: + + Removed all instances of List copying and/or assignment, and made List + inherit from Noncopyable. + + Functions that used to return a List by copy now take List& out + parameters. + + Layout tests and JS tests pass. + + * kjs/list.cpp: + (KJS::List::slice): Replaced copyTail with a more generic slice + alternative. (JavaScriptCore only calls slice(1), but WebCore calls + slice(2)). + +2007-11-01 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed http://bugs.webkit.org/show_bug.cgi?id=15785 + REGRESSION(r27344): Crash on load at finance.yahoo.com + + Reverted a small portion of my last check-in. (The speedup and the List + removal are still there, though.) + + ActivationImp needs to hold a pointer to its function, and mark that + pointer (rather than accessing its function through its ExecState, and + counting on the active scope to mark its function) because a closure + can cause an ActivationImp to outlive its ExecState along with any + active scope. + + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + * kjs/function.cpp: + (KJS::FunctionImp::~FunctionImp): + (KJS::ActivationImp::ActivationImp): + * kjs/function.h: + (KJS::ActivationImp::ActivationImpPrivate::ActivationImpPrivate): + + Also made HashTable a little more crash-happy in debug builds, so + problems like this will show up earlier: + + * wtf/HashTable.h: + (WTF::HashTable::~HashTable): + +2007-11-01 Geoffrey Garen + + Reviewed by Adam Roben. + + Addressed some of Darin's review comments. + + Used perl -p, which is the shorthand while(<>) {}. + + Made sure not to suppress bison's output. + + Added line to removed bison_out.txt, since this script removes other + intermediate files, too. + + * DerivedSources.make: + +2007-11-01 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Removed List from ActivationImp, in preparation for making all lists + stack-allocated. + + Tests pass. + + 1.0% speedup on SunSpider, presumably due to reduced List refcount thrash. + + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + (KJS::ExecState::~ExecState): + * kjs/function.cpp: + (KJS::ActivationImp::ActivationImp): + (KJS::ActivationImp::createArgumentsObject): + * kjs/function.h: + (KJS::ActivationImp::ActivationImpPrivate::ActivationImpPrivate): + +2007-11-01 Adam Roben + + Use jsNumberCell instead of jsNumber when converting double constants to JSValues + + This fixes fast/js/math.html, ecma/Date/15.9.5.10-1.js, and + ecma/Date/15.9.5.12-1.js, which were suffering from a bug in MSVC. + + It also gets rid of an MSVC warning that we previously had to silence. + + Reviewed by Geoff. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Turn + back on the "overflow in constant arithmetic" warning. + * kjs/number_object.cpp: + (NumberObjectImp::getValueProperty): Use jsNumberCell instead of + jsNumber. + +2007-10-31 Adam Roben + + Windows build fix + + * kjs/ExecState.h: + +2007-10-31 Maciej Stachowiak + + Reviewed by Oliver. + + - shave some cycles off of local storage access for a 1% SunSpider speedup + + Keep the LocalStorage pointer in the ExecState, instead of getting + it from the ActivationImp all the time. + + * kjs/ExecState.cpp: + (KJS::ExecState::updateLocalStorage): + * kjs/ExecState.h: + (KJS::ExecState::localStorage): + * kjs/nodes.cpp: + (KJS::LocalVarAccessNode::evaluate): + (KJS::LocalVarFunctionCallNode::evaluate): + (KJS::PostIncLocalVarNode::evaluate): + (KJS::PostDecLocalVarNode::evaluate): + (KJS::LocalVarTypeOfNode::evaluate): + (KJS::PreIncLocalVarNode::evaluate): + (KJS::PreDecLocalVarNode::evaluate): + (KJS::ReadModifyLocalVarNode::evaluate): + (KJS::AssignLocalVarNode::evaluate): + (KJS::FunctionBodyNode::processDeclarationsForFunctionCode): + +2007-10-31 Adam Roben + + Fix a crash on launch due to a static initializer race + + We now use fast inline assembler spinlocks which can be statically + initialized at compile time. + + As a side benefit, this speeds up SunSpider by 0.4%. + + Reviewed by Oliver. + + * wtf/FastMalloc.cpp: + * wtf/TCSpinLock.h: + (TCMalloc_SpinLock::Lock): + (TCMalloc_SpinLock::Unlock): + (TCMalloc_SlowLock): + * wtf/TCSystemAlloc.cpp: + +2007-10-31 Kevin McCullough + + Reviewed by Sam. + + - Corrected spelling. + + * wtf/HashTraits.h: + +2007-10-31 Mark Rowe + + Further Gtk build fixage. + + * kjs/regexp_object.cpp: + +2007-10-31 Mark Rowe + + Gtk build fix. + + * kjs/regexp.h: + +2007-10-31 Darin Adler + + Reviewed by Maciej. + + - fix http://bugs.webkit.org/show_bug.cgi?id=15749 + RegExp/RegExpObjectImp cause needless UString creation + + Speeds things up 0.4% according to SunSpider. + + * kjs/config.h: Define USE(PCRE16) instead of HAVE(PCREPOSIX), + because this library doesn't use the real PCRE -- it uses its + own PCRE that works on UTF-16. + + * kjs/regexp.h: Removed a few unused functions. Changed the ifdef. + Use Noncopyable. Change the return value of match. + * kjs/regexp.cpp: + (KJS::RegExp::RegExp): Call pcre_compile2, for a slight speed boost. + (KJS::RegExp::~RegExp): PCRE16 rather than PCREPOSIX. + (KJS::RegExp::match): Change to return the position as an int and the + ovector as a OwnArrayPtr for efficiency and clearer storage management. + + * kjs/regexp_object.h: Change performMatch and arrayOfMatches to no longer + require a result string. + * kjs/regexp_object.cpp: + (RegExpProtoFunc::callAsFunction): Update for new signature of performMatch. + (RegExpObjectImp::performMatch): Change so it doesn't return a string. + (RegExpObjectImp::arrayOfMatches): Simplify by unifying the handling of + the main result with the backreferences; now it doesn't need to take + a result parameter. + (RegExpObjectImp::getBackref): Minor tweaks. + (RegExpObjectImp::getLastParen): Ditto. + (RegExpObjectImp::getLeftContext): Ditto. + (RegExpObjectImp::getRightContext): Ditto. + (RegExpObjectImp::getValueProperty): Change LastMatch case to call + getBackref(0) so we don't need a separate getLastMatch function. + + * kjs/string_object.cpp: + (KJS::replace): Update to use new performMatch, including merging the + matched string section with the other substrings. + (KJS::StringProtoFunc::callAsFunction): Update functions to use the + new performMatch and match. Also change to use OwnArrayPtr. + +2007-10-31 Oliver Hunt + + * kjs/nodes.h: include OwnPtr.h + +2007-10-31 Oliver Hunt + + Reviewed by Maciej. + + Remove SourceCodeElement class and replaced with a Vector for a 0.8% gain on sunspider + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::statementListPushFIFO): + (KJS::statementListGetDeclarations): + (KJS::statementListInitializeDeclarationStacks): + (KJS::statementListInitializeVariableAccessStack): + (KJS::statementListExecute): + (KJS::BlockNode::optimizeVariableAccess): + (KJS::BlockNode::BlockNode): + (KJS::BlockNode::getDeclarations): + (KJS::BlockNode::execute): + (KJS::CaseClauseNode::optimizeVariableAccess): + (KJS::CaseClauseNode::getDeclarations): + (KJS::CaseClauseNode::evalStatements): + (KJS::FunctionBodyNode::initializeDeclarationStacks): + (KJS::FunctionBodyNode::optimizeVariableAccess): + * kjs/nodes.h: + * kjs/nodes2string.cpp: + (KJS::statementListStreamTo): + (KJS::BlockNode::streamTo): + (KJS::CaseClauseNode::streamTo): + +2007-10-30 Mark Rowe + + * kjs/property_map.cpp: Added a missing using directive to fix the build + for non-Mac ports. Mac worked only because it does the AllInOneFile compile. + +2007-10-31 Maciej Stachowiak + + * kjs/property_map.cpp: Include HashTable.h the right way to fix the build + for non-Mac ports. + +2007-10-31 Alexey Proskuryakov + + Reviewed by Darin. + + http://bugs.webkit.org/show_bug.cgi?id=11001 + WebKit doesn't support RegExp.compile method + + Test: fast/js/regexp-compile.html + + * kjs/regexp_object.cpp: + (RegExpPrototype::RegExpPrototype): + (RegExpProtoFunc::callAsFunction): + * kjs/regexp_object.h: + (KJS::RegExpProtoFunc::): + Added RegExp.compile. + + * tests/mozilla/expected.html: js1_2/regexp/compile.js now passes. + +2007-10-31 Maciej Stachowiak + + Reviewed by Oliver. + + - get rid of integer divide in PropertyMap and HashTable for 1% SunSpider speedup + + Integer divide sucks. Fortunately, a bunch of shifts and XORs + biased towards the high bits is sufficient to provide a good + double hash. Besides the SunSpider win, I used the dump statistics + mode for both to verify that collisions did not increase and that + the longest collision chain is not any longer. + + * kjs/property_map.cpp: + (KJS::doubleHash): + (KJS::PropertyMap::get): + (KJS::PropertyMap::getLocation): + (KJS::PropertyMap::put): + (KJS::PropertyMap::insert): + (KJS::PropertyMap::remove): + (KJS::PropertyMap::checkConsistency): + * wtf/HashTable.h: + (WTF::doubleHash): + (WTF::::lookup): + (WTF::::lookupForWriting): + (WTF::::fullLookupForWriting): + (WTF::::add): + +2007-10-30 Adam Roben + + * kjs/collector.h: Make HeapType public so it can be used for non-member + things like the HeapConstants struct template. Fixes the build on Windows. + +2007-10-30 Adam Roben + + Change ALWAYS_INLINE and WTF_PRIVATE_INLINE to use __forceinline on Windows + + Speeds up SunSpider by 0.4%. + + Reviewed by Steve and Maciej. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Disable + a warning during LTCG in release builds about double -> float + conversion. + * wtf/AlwaysInline.h: + * wtf/FastMalloc.h: + +2007-10-30 Adam Roben + + Use GetCurrentThreadId instead of pthread_self in FastMalloc + + Speeds up SunSpider by 0.3%. + + Reviewed by Steve. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_ThreadCache::InitTSD): + (WTF::TCMalloc_ThreadCache::CreateCacheIfNecessary): + +2007-10-30 Adam Roben + + Switch to a Win32 critical section implementation of spinlocks + + Speeds up SunSpider by 0.4%. + + Reviewed by Steve. + + * wtf/FastMalloc.cpp: + * wtf/TCSpinLock.h: + (TCMalloc_SpinLock::TCMalloc_SpinLock): + (TCMalloc_SpinLock::Init): + (TCMalloc_SpinLock::Finalize): + (TCMalloc_SpinLock::Lock): + (TCMalloc_SpinLock::Unlock): + * wtf/TCSystemAlloc.cpp: + +2007-10-30 Adam Roben + + Fix Bug 15586: REGRESSION (r26759-r26785): Windows nightly builds crash with Safari 3 Public Beta + + http://bugs.webkit.org/show_bug.cgi?id=15586 + + Also fixes: Cannot use regsvr32.exe to register WebKit.dll + + Use Win32 TLS functions instead of __declspec(thread), which breaks + delay-loading. + + Reviewed by Steve. + + * wtf/FastMalloc.cpp: + (WTF::getThreadHeap): + (WTF::TCMalloc_ThreadCache::InitModule): + +2007-10-30 Maciej Stachowiak + + Reviewed by Oliver. + + - allocate numbers in half-size cells, for an 0.5% SunSpider speedup + http://bugs.webkit.org/show_bug.cgi?id=15772 + + We do this by using a single mark bit per two number cells, and + tweaking marking. + + Besides being an 0.5% win overall, this is a 7.1% win on morph. + + * kjs/collector.cpp: + (KJS::Collector::heapAllocate): + (KJS::Collector::markStackObjectsConservatively): + (KJS::Collector::sweep): + * kjs/collector.h: + (KJS::SmallCollectorCell::): + +2007-10-30 Geoffrey Garen + + Reviewed by Adam Roben, Sam Weinig. + + Made conflicts in grammar.y a persistent build failure. + + * DerivedSources.make: + +2007-10-30 Kevin McCullough + + Reviewed by Adam and Geoff. + + - Added a new cast so all the casts are in the same place. + + * API/APICast.h: + (toGlobalRef): + +2007-10-30 Geoffrey Garen + + Reviewed by Darin Adler. + + Fixed shift/reduce conflict introduced in r24457 + + JS tests, including + + ecma_2/Statements/dowhile-001.js + ecma_2/Statements/dowhile-002.js + ecma_2/Statements/dowhile-003.js + ecma_2/Statements/dowhile-004.js + ecma_2/Statements/dowhile-005.js + ecma_2/Statements/dowhile-006.js + ecma_2/Statements/dowhile-007.js + js1_2/statements/do_while.js + + and layout tests, including + + do-while-expression-value.html + do-while-semicolon.html + do-while-without-semicolon.html + + pass. + + * kjs/grammar.y: Use the explicit "error" production, as we do with other + automatic semicolon insertions, to disambiguate "do { } while();" from + "do { } while()" followed by ";" (the empty statement). + +2007-10-29 Oliver Hunt + + Reviewed by Maciej. + + Debranching remaining assignment nodes, and miscellaneous cleanup + + Split read-modify code paths out of AssignBracketNode and AssignDotNode + Removed now unnecessary check for write-only assignment in ReadModifyLocalVarNode + and ReadModifyResolveNode evaluate methods + + Leads to a 1% gain in SunSpider. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::ReadModifyLocalVarNode::evaluate): + (KJS::ReadModifyResolveNode::evaluate): + (KJS::AssignDotNode::evaluate): + (KJS::ReadModifyDotNode::optimizeVariableAccess): + (KJS::ReadModifyDotNode::evaluate): + (KJS::AssignBracketNode::evaluate): + (KJS::ReadModifyBracketNode::optimizeVariableAccess): + (KJS::ReadModifyBracketNode::evaluate): + * kjs/nodes.h: + (KJS::AssignBracketNode::): + (KJS::AssignBracketNode::precedence): + (KJS::AssignDotNode::): + (KJS::AssignDotNode::precedence): + * kjs/nodes2string.cpp: + (KJS::ReadModifyBracketNode::streamTo): + (KJS::AssignBracketNode::streamTo): + (KJS::ReadModifyDotNode::streamTo): + (KJS::AssignDotNode::streamTo): + +2007-10-29 Oliver Hunt + + Debranching various Node::evaluate implementations + + Reviewed by Maciej. + + Split the read-modify-write assignment cases out of AssignResolveNode and into ReadModifyResolveNode + Split the increment and decrement cases for Prefix- and Postfix- ResolveNode, BracketNode, and DotNode + + Gains 1.6% on SunSpider + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::PostIncResolveNode::optimizeVariableAccess): + (KJS::PostIncResolveNode::evaluate): + (KJS::PostIncLocalVarNode::evaluate): + (KJS::PostDecResolveNode::optimizeVariableAccess): + (KJS::PostDecResolveNode::evaluate): + (KJS::PostDecLocalVarNode::evaluate): + (KJS::PostIncBracketNode::evaluate): + (KJS::PostDecBracketNode::evaluate): + (KJS::PostIncDotNode::evaluate): + (KJS::PostDecDotNode::evaluate): + (KJS::PreIncResolveNode::optimizeVariableAccess): + (KJS::PreIncLocalVarNode::evaluate): + (KJS::PreIncResolveNode::evaluate): + (KJS::PreDecResolveNode::optimizeVariableAccess): + (KJS::PreDecLocalVarNode::evaluate): + (KJS::PreDecResolveNode::evaluate): + (KJS::PreIncBracketNode::evaluate): + (KJS::PreDecBracketNode::evaluate): + (KJS::PreIncDotNode::evaluate): + (KJS::PreDecDotNode::evaluate): + (KJS::ReadModifyResolveNode::optimizeVariableAccess): + (KJS::AssignResolveNode::optimizeVariableAccess): + (KJS::AssignLocalVarNode::evaluate): + (KJS::AssignResolveNode::evaluate): + * kjs/nodes.h: + (KJS::PostDecResolveNode::): + (KJS::PostDecResolveNode::precedence): + (KJS::PostDecLocalVarNode::): + (KJS::PostfixBracketNode::): + (KJS::PostfixBracketNode::precedence): + (KJS::PostIncBracketNode::): + (KJS::PostIncBracketNode::isIncrement): + (KJS::PostDecBracketNode::): + (KJS::PostDecBracketNode::isIncrement): + (KJS::PostfixDotNode::): + (KJS::PostfixDotNode::precedence): + (KJS::PostIncDotNode::): + (KJS::PostIncDotNode::isIncrement): + (KJS::PostDecDotNode::): + (KJS::PreIncResolveNode::): + (KJS::PreDecResolveNode::): + (KJS::PreDecResolveNode::precedence): + (KJS::PreDecLocalVarNode::): + (KJS::PrefixBracketNode::): + (KJS::PrefixBracketNode::precedence): + (KJS::PreIncBracketNode::): + (KJS::PreIncBracketNode::isIncrement): + (KJS::PreDecBracketNode::): + (KJS::PreDecBracketNode::isIncrement): + (KJS::PrefixDotNode::): + (KJS::PrefixDotNode::precedence): + (KJS::PreIncDotNode::): + (KJS::PreIncDotNode::isIncrement): + (KJS::PreDecDotNode::): + (KJS::ReadModifyResolveNode::): + (KJS::ReadModifyLocalVarNode::): + (KJS::AssignResolveNode::): + (KJS::AssignResolveNode::precedence): + * kjs/nodes2string.cpp: + (KJS::PostIncResolveNode::streamTo): + (KJS::PostDecResolveNode::streamTo): + (KJS::PostfixBracketNode::streamTo): + (KJS::PostfixDotNode::streamTo): + (KJS::PreIncResolveNode::streamTo): + (KJS::PreDecResolveNode::streamTo): + (KJS::ReadModifyResolveNode::streamTo): + (KJS::AssignResolveNode::streamTo): + +2007-10-29 Maciej Stachowiak + + Not reviewed, build fix. + + - Include Vector.h in a way that actually works. + + * kjs/LocalStorage.h: + +2007-10-29 Maciej Stachowiak + + Not reviewed, build fix. + + - Install LocalStorage.h as a private header. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2007-10-29 Maciej Stachowiak + + Reviewed by Darin. + + - Define good VectorTraits for LocalStorage entry for 0.5% speed improvement on SunSpider. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/LocalStorage.h: Added. + (KJS::LocalStorageEntry::LocalStorageEntry): + (WTF::): + * kjs/function.h: + * kjs/nodes.cpp: + (KJS::FunctionBodyNode::processDeclarationsForFunctionCode): + +2007-10-29 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Some small tweaks that I notice while reviewing Oliver's last patch. + + Includes removal of an unnecessary KJS_CHECKEXCEPTIONVALUE. + + No change in SunSpider because SunSpider doesn't take the code path that + would execute the unnecessary KJS_CHECKEXCEPTIONVALUE much. + + * kjs/nodes.cpp: + (KJS::LocalVarPostfixNode::evaluate): + (KJS::TypeOfResolveNode::optimizeVariableAccess): + (KJS::LocalVarTypeOfNode::evaluate): + (KJS::PrefixResolveNode::optimizeVariableAccess): + (KJS::LocalVarPrefixNode::evaluate): + (KJS::AssignResolveNode::optimizeVariableAccess): + (KJS::LocalVarAssignNode::evaluate): + * kjs/nodes.h: + (KJS::LocalVarTypeOfNode::): + (KJS::PrefixResolveNode::): + (KJS::LocalVarPrefixNode::): + (KJS::AssignResolveNode::): + (KJS::LocalVarAssignNode::): + +2007-10-29 Eric Seidel + + Reviewed by Maciej. + + SunSpider claims this was a 0.7% speedup. + + * kjs/string_object.cpp: + (KJS::StringProtoFunc::callAsFunction): avoid mallocing a jsString in the common case + +2007-10-29 Maciej Stachowiak + + Reviewed by Mark. + + - re-enable asserts for access to empty or deleted keys + + * wtf/HashTable.h: + (WTF::::lookup): + (WTF::::lookupForWriting): + (WTF::::fullLookupForWriting): + (WTF::::add): + +2007-10-29 Eric Seidel + + Build fix only, no review. + + * JavaScriptCore.exp: Export symbol for new StringInstance::getOwnPropertySlot + +2007-10-29 Mark Rowe + + Gtk build fix. Move struct declarations into nodes.h. + + * kjs/grammar.y: + * kjs/nodes.h: + +2007-10-29 Eric Seidel + + Reviewed by darin. + + Give StringInstance a getOwnPropertySlot(ExecState, unsigned, PropertySlot) fastpath, just like Arrays. + Make it a compile time error to use toString(ExecState) on a StringInstance + + SunSpider claims this was a 6.6% speedup overall (22% on string-base64) + + * kjs/internal.h: + (KJS::StringImp::getLength): + * kjs/string_object.cpp: + (KJS::StringInstance::lengthGetter): + (KJS::StringInstance::inlineGetOwnPropertySlot): + (KJS::StringInstance::getOwnPropertySlot): + * kjs/string_object.h: + +2007-10-28 Oliver Hunt + + Reviewed by Darin. + + Add nodes to allow Assignment, TypeOf, and prefix operators to + make use of the new optimised local variable look up. + + 5% gain on sunspider + + * kjs/nodes.cpp: + (KJS::TypeOfResolveNode::optimizeVariableAccess): + (KJS::LocalTypeOfAccessNode::evaluate): + (KJS::PrefixResolveNode::optimizeVariableAccess): + (KJS::PrefixLocalAccessNode::evaluate): + (KJS::AssignResolveNode::optimizeVariableAccess): + (KJS::AssignLocalAccessNode::evaluate): + * kjs/nodes.h: + (KJS::TypeOfResolveNode::): + (KJS::TypeOfResolveNode::precedence): + (KJS::LocalTypeOfAccessNode::): + (KJS::PrefixResolveNode::): + (KJS::PrefixResolveNode::precedence): + (KJS::PrefixLocalAccessNode::): + (KJS::AssignResolveNode::): + (KJS::AssignLocalAccessNode::): + +2007-10-28 Maciej Stachowiak + + Reviewed by Darin. + + - avoid creating and then breaking circular lists in the parser, instead track head and tail pointers at parse time + http://bugs.webkit.org/show_bug.cgi?id=15748 + + Not a significant speedup or slowdown on SunSpider. + + * kjs/Parser.cpp: + (KJS::clearNewNodes): + * kjs/Parser.h: + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::BlockNode::BlockNode): + (KJS::CaseBlockNode::CaseBlockNode): + (KJS::FunctionBodyNode::FunctionBodyNode): + (KJS::SourceElementsNode::SourceElementsNode): + (KJS::ProgramNode::ProgramNode): + * kjs/nodes.h: + (KJS::ElementNode::): + (KJS::ArrayNode::): + (KJS::PropertyListNode::): + (KJS::ObjectLiteralNode::): + (KJS::ArgumentListNode::): + (KJS::ArgumentsNode::): + (KJS::VarDeclListNode::): + (KJS::VarStatementNode::): + (KJS::ForNode::): + (KJS::ParameterNode::): + (KJS::FuncExprNode::): + (KJS::FuncDeclNode::): + (KJS::SourceElementsNode::): + (KJS::CaseClauseNode::): + (KJS::ClauseListNode::): + +2007-10-28 Mark Rowe + + Disable assertions in a manner that doesn't break the Qt Windows build. + + * wtf/HashTable.h: + (WTF::::lookup): + (WTF::::lookupForWriting): + (WTF::::fullLookupForWriting): + +2007-10-28 Geoffrey Garen + + Temporarily disabling some ASSERTs I introduced in my last check-in + because of http://bugs.webkit.org/show_bug.cgi?id=15747 + Lots of layout tests fail the !HashTranslator::equal(KeyTraits::emptyValue() ASSERT + + * wtf/HashTable.h: + (WTF::::lookup): + (WTF::::lookupForWriting): + (WTF::::fullLookupForWriting): + (WTF::::add): + +2007-10-28 Geoffrey Garen + + Reviewed by Darin Adler. + + Fixed http://bugs.webkit.org/show_bug.cgi?id=15746 + #ifndef ASSERT_DISABLED is no good! + + Replaced with #if !ASSERT_DISABLED. + + * wtf/HashTable.h: + (WTF::::lookup): + (WTF::::lookupForWriting): + (WTF::::fullLookupForWriting): + (WTF::::add): + +2007-10-28 Geoffrey Garen + + Reviewed by Darin Adler. + + Added FunctionCallResolveNode, PostfixResolveNode, and DeleteResolveNode + to the AST transfom that replaces slow resolve nodes with fast local + variable alternatives. + + 2.5% speedup on SunSpider. + + Also added some missing copyright notices. + + * kjs/nodes.cpp: + (KJS::FunctionCallResolveNode::optimizeVariableAccess): + (KJS::FunctionCallResolveNode::evaluate): + (KJS::LocalVarFunctionCallNode::evaluate): + (KJS::PostfixResolveNode::optimizeVariableAccess): + (KJS::PostfixResolveNode::evaluate): + (KJS::LocalVarPostfixNode::evaluate): + (KJS::DeleteResolveNode::optimizeVariableAccess): + (KJS::DeleteResolveNode::evaluate): + (KJS::LocalVarDeleteNode::evaluate): + * kjs/nodes.h: + (KJS::FunctionCallResolveNode::): + (KJS::LocalVarFunctionCallNode::LocalVarFunctionCallNode): + (KJS::PostfixResolveNode::): + (KJS::LocalVarPostfixNode::LocalVarPostfixNode): + (KJS::DeleteResolveNode::): + (KJS::LocalVarDeleteNode::LocalVarDeleteNode): + +2007-10-28 Eric Seidel + + Reviewed by darin. + + Inline UString::Rep::deref() for a 0.8% improvement in SunSpider + Add virtual keyword to a few virtual functions previously unmarked. + + * kjs/internal.h: + (KJS::StringImp::type): + (KJS::NumberImp::type): + * kjs/ustring.h: + (KJS::UString::Rep::deref): + +2007-10-28 Darin Adler + + - fix "broken everything" from the storage leak fix + + * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): Added a PlacementNewAdopt constructor. + * kjs/ustring.h: (KJS::UString::UString): Pass PlacementNewAdopt along to RefPtr. + +2007-10-28 Darin Adler + + Reviewed by Adam. + + - turn on unused parameter waring on Mac OS X because it's already on elsewhere + + * Configurations/Base.xcconfig: Took out -wno-unused-parameter. + + * API/JSNode.c: + * API/JSNodeList.c: + * API/minidom.c: + * API/testapi.c: + Fixed unused variables by using them or marked them with UNUSED_PARAM. + + * kjs/CollectorHeapIntrospector.h: (KJS::CollectorHeapIntrospector::zoneCalloc): + Removed parameter names to indicate they are unused. + +2007-10-28 Darin Adler + + Reviewed by Maciej. + + - fix a storage leak where we ref the UString every time we replace + a ResolveNode with a LocalVarAccessNode + + * kjs/identifier.h: (KJS::Identifier::Identifier): Added a constructor + that takes PlacementNewAdopt. + + * kjs/nodes.h: (KJS::ResolveNode::ResolveNode): Initialize the ident + with PlacementNewAdopt instead of the old value of ident. + + * kjs/ustring.h: (KJS::UString::UString): Added a constructor that + takes PlacementNewAdopt. + +2007-10-28 Darin Adler + + - Windows build fix; get rid of unused parameter + + * kjs/nodes.cpp: (KJS::ResolveNode::optimizeVariableAccess): Don't pass it. + * kjs/nodes.h: (KJS::LocalVarAccessNode::LocalVarAccessNode): Remove it. + The assertions weren't all that helpful. + +2007-10-28 Mark Rowe + + Gtk build fix. Add include of MathExtras.h. + + * kjs/string_object.cpp: + +2007-10-28 Mark Rowe + + Reviewed by Maciej and Tim. + + Replace uses of isNaN and isInf with isnan and isinf, and + remove isNaN and isInf. + + * kjs/config.h: Remove unused HAVE_'s. + * kjs/date_object.cpp: + (KJS::DateInstance::getTime): + (KJS::DateInstance::getUTCTime): + (KJS::DateProtoFunc::callAsFunction): + (KJS::DateObjectImp::construct): + (KJS::DateObjectFuncImp::callAsFunction): + * kjs/function.cpp: + (KJS::GlobalFuncImp::callAsFunction): + * kjs/math_object.cpp: + (MathFuncImp::callAsFunction): + * kjs/nodes2string.cpp: + (KJS::isParserRoundTripNumber): + * kjs/number_object.cpp: + (NumberProtoFunc::callAsFunction): + * kjs/operations.cpp: + * kjs/operations.h: + * kjs/string_object.cpp: + (KJS::StringProtoFunc::callAsFunction): + * kjs/ustring.cpp: + (KJS::UString::from): + * kjs/value.cpp: + (KJS::JSValue::toInteger): + (KJS::JSValue::toInt32SlowCase): + (KJS::JSValue::toUInt32SlowCase): + +2007-10-28 Geoffrey Garen + + Build fix: use the new-fangled missingSymbolMarker(). + + * kjs/nodes.cpp: + (KJS::ResolveNode::optimizeVariableAccess): + * kjs/nodes.h: + (KJS::LocalVarAccessNode::LocalVarAccessNode): + +2007-10-28 Geoffrey Garen + + Reviewed by Maciej Stachowiak, Darin Adler. + + Much supporting work done by Maciej Stachowiak, Maks Orlovich, and + Cameron Zwarich. + + AST transfom to replace slow resolve nodes with fast local variable + alternatives that do direct memory access. Currently, only ResolveNode + provides a fast local variable alternative. 6 others are soon to come. + + 16.7% speedup on SunSpider. + + Most of this patch is just scaffolding to support iterating all the + resolve nodes in the AST through optimizeResolveNodes(). In + optimizeResolveNodes(), most classes just push their child nodes onto + the processing stack, while ResolveNodes actually replace themselves in + the tree with more optimized alternatives, if possible. + + Here are the interesting bits: + + * kjs/nodes.h: Added PlacementNewAdoptTag, along with implementations + in Node and ResolveNode. This tag allows you to use placement new to + swap out a base class Node in favor of a subclass copy that holds the + same data. (Without this tag, default initialization would NULL out + RefPtrs, change line numbers, etc.) + + * kjs/nodes.cpp: + (KJS::ResolveNode::evaluate): Since we're taking the slow path, ASSERT + that the fast path is impossible, to make sure we didn't leave anything + on the table. + + (KJS::FunctionBodyNode::optimizeResolveNodes): Here's where the AST + transformation happens. + + (KJS::ResolveNode::optimizeResolveNodes): Here's where the ResolveNode + optimization happens. + + * kjs/function.h: Added symbolTable() accessor for, for the sake of + an ASSERT. + +2007-10-28 Mark Rowe + + Reviewed by Maciej. + + Fix "AllInOneFile.o has a global initializer in it". + + Some versions of gcc generate a global initializer for std::numeric_limits::max(). + We can avoid this by moving it inside an inline function. + + * kjs/SymbolTable.h: + (KJS::missingSymbolMarker): + * kjs/function.cpp: + (KJS::ActivationImp::getOwnPropertySlot): + (KJS::ActivationImp::put): + +2007-10-28 Maciej Stachowiak + + Reviewed by Mark. + + - Added assertions to protect against adding empty or deleted keys to a HashTable + + * wtf/HashTable.h: + (WTF::HashTable::lookup): + (WTF::HashTable::lookupForWriting): + (WTF::HashTable::fullLookupForWriting): + (WTF::HashTable::add): + +2007-10-28 Darin Adler + + - fix GTK build + + * kjs/nodes2string.cpp: (KJS::isParserRoundTripNumber): + Use isNaN and isInf instead of isnan and isinf. + +2007-10-28 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15735 + remove GroupNode to simplify AST and possibly get a modest speedup + + This patch removes 4 node types: GroupNode, PropertyNameNode, + FunctionCallParenBracketNode, and FunctionCallParenDotNode. + + To remove GroupNode, we add knowledge of precedence to the tree nodes, + and use that when serializing to determine where parentheses are needed. + This means we no longer have to represent parentheses in the tree. + + The precedence values are named after productions in the grammar from the + JavaScript standard. + + SunSpider says this is an 0.4% speedup. + + * kjs/function.h: + * kjs/function.cpp: Removed escapeStringForPrettyPrinting -- it's part of + serialization, so I moved it to the file that takes care of that. + + * kjs/grammar.y: Changed makeGetterOrSetterPropertyNode to use 0 to + indicate failure instead of a separate boolean. Got rid of PropertyNameNode + by merging the PropertyName rule into the Property rule (which was easier + than figuring out how to pass the Identifier from one node to another). + Got rid of GroupNode, nodeInsideAllParens(), FunctionCallParenBracketNode, + and FunctionCallParenDotNode. + + * kjs/nodes.h: Removed unused forward declarations and Operator values. + Added Precedence enum, and precedence function to all nodes. Removed + nodeInsideAllParens. Added streamBinaryOperator function for serialization. + Removed GroupNode and PropertyNameNode. Made PropertyNode store an Identifier. + Removed FunctionCallParenBracketNode and FunctionCallParenDotNode. + + * kjs/nodes.cpp: Removed Node::nodinsideAllParens, GroupNode, and PropertyNameNode. + (KJS::PropertyListNode::evaluate): Changed code to get name directly instead + of converting it from an Identifier to a jsString then back to a UString + then into an Identifier again! + + * kjs/nodes2string.cpp: Changed special-token implementation to use a separate + function for each of Endl, Indent, Unindent, and DotExpr instead of using a + single function with a switch. Added a precedence that you can stream in, to + cause the next node serialized to add parentheses based on that precedence value. + (KJS::operatorString): Moved to the top of the file. + (KJS::escapeStringForPrettyPrinting): Moved here from function.cpp. Removed old + workaround for snprintf, since StringExtras.h takes care of that. + (KJS::operator<<): Made the char and char* versions faster by using UString's + character append functions instead of constructing a UString. Added the logic + to the Node* version to add parentheses if needed. + (KJS::Node::streamLeftAssociativeBinaryOperator): Added helper function. + (KJS::ElementNode::streamTo): Use PrecAssignment for the elements. + (KJS::BracketAccessorNode::streamTo): Use PrecCall for the expression before + the bracket. + (KJS::DotAccessorNode::streamTo): Use PrecCall for the expression before the dot. + (KJS::ArgumentListNode::streamTo): Use PrecAssignment for the arguments. + (KJS::NewExprNode::streamTo): Use PrecMember for the expression. + (KJS::FunctionCallValueNode::streamTo): Use PrecCall. + (KJS::FunctionCallBracketNode::streamTo): Ditto. + (KJS::FunctionCallDotNode::streamTo): Ditto. + (KJS::PostfixBracketNode::streamTo): Ditto. + (KJS::PostfixDotNode::streamTo): Ditto. + (KJS::PostfixErrorNode::streamTo): Use PrecLeftHandSide. + (KJS::DeleteBracketNode::streamTo): Use PrecCall. + (KJS::DeleteDotNode::streamTo): Ditto. + (KJS::DeleteValueNode::streamTo): Use PrecUnary. + (KJS::VoidNode::streamTo): Ditto. + (KJS::TypeOfValueNode::streamTo): Ditto. + (KJS::PrefixBracketNode::streamTo): Use PrecCall. + (KJS::PrefixDotNode::streamTo): Ditto. + (KJS::PrefixErrorNode::streamTo): Use PrecUnary. + (KJS::UnaryPlusNode::streamTo): Ditto. + (KJS::NegateNode::streamTo): Ditto. + (KJS::BitwiseNotNode::streamTo): Ditto. + (KJS::LogicalNotNode::streamTo): Ditto. + (KJS::MultNode::streamTo): Use streamLeftAssociativeBinaryOperator. + (KJS::DivNode::streamTo): Ditto. + (KJS::ModNode::streamTo): Ditto. + (KJS::AddNode::streamTo): Ditto. + (KJS::SubNode::streamTo): Ditto. + (KJS::LeftShiftNode::streamTo): Ditto. + (KJS::RightShiftNode::streamTo): Ditto. + (KJS::UnsignedRightShiftNode::streamTo): Ditto. + (KJS::LessNode::streamTo): Ditto. + (KJS::GreaterNode::streamTo): Ditto. + (KJS::LessEqNode::streamTo): Ditto. + (KJS::GreaterEqNode::streamTo): Ditto. + (KJS::InstanceOfNode::streamTo): Ditto. + (KJS::InNode::streamTo): Ditto. + (KJS::EqualNode::streamTo): Ditto. + (KJS::NotEqualNode::streamTo): Ditto. + (KJS::StrictEqualNode::streamTo): Ditto. + (KJS::NotStrictEqualNode::streamTo): Ditto. + (KJS::BitAndNode::streamTo): Ditto. + (KJS::BitXOrNode::streamTo): Ditto. + (KJS::BitOrNode::streamTo): Ditto. + (KJS::LogicalAndNode::streamTo): Ditto. + (KJS::LogicalOrNode::streamTo): Ditto. + (KJS::ConditionalNode::streamTo): Ditto. + (KJS::AssignResolveNode::streamTo): Use PrecAssignment for the right side. + (KJS::AssignBracketNode::streamTo): Use PrecCall for the expression before + the bracket and PrecAssignment for the right side. + (KJS::AssignDotNode::streamTo): Ditto. + (KJS::AssignErrorNode::streamTo): Use PrecLeftHandSide for the left side + and PrecAssignment for the right side. + (KJS::CommaNode::streamTo): Use PrecAssignment for both expressions. + (KJS::AssignExprNode::streamTo): Use PrecAssignment. + +2007-10-28 Kevin Ollivier + + Define wx port and set wx port USE options. + + Reviewed by Adam Roben. + + * wtf/Platform.h: + +2007-10-28 Mark Rowe + + We don't include "config.h" in headers. + + * bindings/jni/jni_instance.h: + * kjs/regexp.h: + * wtf/TCPageMap.h: + * wtf/TCSpinLock.h: + +2007-10-28 Maciej Stachowiak + + Rubber stamped by Mark. + + - avoid using non-portable SIZE_T_MAX in favor of std::numeric_limits + + * kjs/SymbolTable.h: + (KJS::SymbolTableIndexHashTraits::emptyValue): + * kjs/function.cpp: + (KJS::ActivationImp::getOwnPropertySlot): + (KJS::ActivationImp::put): + +2007-10-28 Maciej Stachowiak + + Reviewed by Eric. + + - switch SymbolTable to be a HashMap instead of a PropertyMap for 3% SunSpider speedup + + * kjs/SymbolTable.h: + (KJS::IdentifierRepHash::hash): Special hash function for identifier reps. + (KJS::IdentifierRepHash::equal): ditto + (KJS::SymbolTableIndexHashTraits::emptyValue): Special HashTraits for the index value. + (KJS::SymbolTable): change to a typedef for a HashMap. + * kjs/function.cpp: + (KJS::ActivationImp::getOwnPropertySlot): Adjusted for new SymbolTable API. + (KJS::ActivationImp::deleteProperty): ditto + (KJS::ActivationImp::put): ditto + + * kjs/nodes.cpp: + (KJS::FunctionBodyNode::initializesymbolTable): Adjusted, since + you now have to store a UString::rep, not an identifier. + +2007-10-27 Maciej Stachowiak + + Reviewed by Oliver. + + - numerous HashTable performance improvements + + This does not quite add up to a measurable win on SunSpider, but it allows a + follow-on > 3% improvement and probably helps WebCore too. + + I made the following improvements, among others: + + - Made HashFunctions note whether it is ok to compare a real value with the equal() function + to the empty or deleted value, and used this to optimize the comparisons done in hash lookup. + + - Specialized lookup so it doesn't have to do so many extra branches and build so many extra + std::pairs for cases that don't need them. There are now four versions, one for read-only access, + two for writing, and one folded directly into add() (these all were improvments). + + - Made HashMap::get() use lookup() directly instead of find() to avoid having to build iterators. + + - Made a special constructor for iterators that knows it points to + a valid filled cell and so skips updating itself. + + - Reordered memory accesses in the various lookup functions for better code generation + + - Made simple translators avoid passing a hash code around + + - Other minor tweaks + + * wtf/HashTable.h: + (WTF::): + (WTF::HashTableConstIterator::HashTableConstIterator): + (WTF::HashTableIterator::HashTableIterator): + (WTF::IdentityHashTranslator::translate): + (WTF::HashTable::end): + (WTF::HashTable::lookup): + (WTF::HashTable::lookupForWriting): + (WTF::HashTable::makeKnownGoodIterator): + (WTF::HashTable::makeKnownGoodConstIterator): + (WTF::::lookup): + (WTF::::lookupForWriting): + (WTF::::fullLookupForWriting): + (WTF::::add): + (WTF::::addPassingHashCode): + (WTF::::reinsert): + (WTF::::find): + (WTF::::contains): + * kjs/identifier.cpp: + (WTF::): + * wtf/HashFunctions.h: + (WTF::): + * wtf/HashMap.h: + (WTF::): + (WTF::::get): + * wtf/HashSet.h: + (WTF::): + (WTF::::add): + * wtf/ListHashSet.h: + (WTF::ListHashSetTranslator::translate): + +2007-10-27 Darin Adler + + Reviewed by Eric. + + - fix ASCIICType.h for some Windows compiles + + * wtf/ASCIICType.h: Check the compiler, not the OS, since it's the + compiler/library that has the wchar_t that is just a typedef. + +2007-10-27 Kevin McCullough + + - BuildFix + - Forgot to change the build step when I changed the filename. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2007-10-27 Geoffrey Garen + + Reviewed by Darin Adler. + + Fixed the rest of "ASSERTION FAILED: _hash in KJS::UString::Rep:: + computedHash()" + http://bugs.webkit.org/show_bug.cgi?id=15718 + + * kjs/identifier.cpp: Fixed more cases where an Identifier didn't get a + hash value. Also changed O(n) strlen to O(1) check for empty string. + (KJS::Identifier::add): + + * kjs/ustring.cpp: Changed O(n) strlens to O(1) checks for empty string. + (KJS::UString::UString): + (KJS::UString::operator=): + +2007-10-27 Darin Adler + + Reviewed by Eric. + + - fix pow on Windows + + * wtf/MathExtras.h: (wtf_pow): Add a special case for MSVC, which has + a "pow" function that does not properly handle the case where arg1 is + NaN and arg2 is 0. + + * kjs/math_object.cpp: (MathFuncImp::callAsFunction): Don't explicity + specify "::pow" -- just "pow" is fine. + +2007-10-27 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15711 + force JSImmediate to be inlined for roughly 1.2% SunSpider speedup + + * kjs/JSImmediate.h: Put ALWAYS_INLINE on everything. + + * kjs/object.h: Removed redundant includes. + * kjs/value.h: Ditto. + +2007-10-27 Maciej Stachowiak + + Reviewed by Mark. + + - fixed "ASSERTION FAILED: _hash in KJS::UString::Rep::computedHash()" + http://bugs.webkit.org/show_bug.cgi?id=15718 + + * kjs/identifier.cpp: + (KJS::Identifier::addSlowCase): Ensure that empty Identifiers have a hash computed, + now that we count on all Identifiers already having one. + +2007-10-27 Mark Rowe + + Silence a warning. + + * kjs/SymbolTable.h: + +2007-10-27 Mark Rowe + + Gtk build fix. + + * kjs/function.h: + +2007-10-26 Kevin McCullough + + Rubber stamp by Adam. + + - Renamed JSStringRefCOM to JSStringRefBSTR since it he only thing the + files contain are functions that operate on BSTRs. + + * API/JSStringRefBSTR.cpp: Copied from API/JSStringRefCOM.cpp. + * API/JSStringRefBSTR.h: Copied from API/JSStringRefCOM.h. + * API/JSStringRefCOM.cpp: Removed. + * API/JSStringRefCOM.h: Removed. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2007-10-26 Kevin McCullough + + Reviewed by Adam. + + - Made JSStringCreateWithBSTR capable of handling null BSTRs. + + * API/JSStringRefCOM.cpp: + (JSStringCreateWithBSTR): + +2007-10-26 Sam Weinig + + Windows build fix. + + * kjs/SymbolTable.h: Add header gaurd. + * kjs/nodes.h: #include "SymbolTable.h" + +2007-10-26 Geoffrey Garen + + Suggested by Anders Carlsson. + + Fixed tyop. + + * kjs/function.cpp: + (KJS::ActivationImp::getOwnPropertySlot): + +2007-10-26 Geoffrey Garen + + Suggested by Darin Adler. + + Use computedHash(), which is safer than just directly accessing _hash. + + * kjs/lookup.cpp: + (KJS::Lookup::findEntry): + (KJS::Lookup::find): + +2007-10-26 Geoffrey Garen + + Build fix: svn add SymbolTable.h + + * kjs/SymbolTable.h: Added. + (KJS::SymbolTable::set): + (KJS::SymbolTable::get): + +2007-10-26 Geoffrey Garen + + Build fix: export SymbolTable.h to WebCore. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2007-10-26 Geoffrey Garen + + Comment tweak suggested by Maciej. + + * kjs/function.cpp: + (KJS::ActivationImp::getOwnPropertySlot): + +2007-10-26 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Tweaked property maps to remove 2 branches. 2.5% speedup on SunSpider. + + * kjs/property_map.cpp: Use a special no branch accessor to the UString's + hash value. Also, return immediately instead of branching to the end + of the loop if the value is not found. + (KJS::PropertyMap::get): + (KJS::PropertyMap::getLocation): + (KJS::PropertyMap::put): + (KJS::PropertyMap::insert): + (KJS::PropertyMap::remove): + (KJS::PropertyMap::checkConsistency): + + * kjs/ustring.h: + (KJS::UString::Rep::computedHash): Special no branch accessor to the + UString's hash value. Used when the caller knows that the hash value + has already been computed. (For example, if the caller got the UString + from an Identifier.) + +2007-10-26 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Switched ActivationImp to using a symbol table. For now, though, all + clients take the slow path. + + Net .6% speedup on SunSpider. + + Slowdowns: + - ActivationImp now mallocs in its constructor + - Local variable hits use an extra level of indirection to retrieve + data + - Local variable misses do two lookups + + Speedups: + - Fast initialization of local variables upon function entry + + * JavaScriptCore.xcodeproj/project.pbxproj: Added SymbolTable.h + + * kjs/function.cpp: + (KJS::ActivationImp::ActivationImp): Malloc a private structure to hold + data that won't fit in a JSCell. + (KJS::ActivationImp::argumentsGetter): Use slow symbol table path for + lookup. + (KJS::ActivationImp::getOwnPropertySlot): ditto + (KJS::ActivationImp::deleteProperty): ditto + (KJS::ActivationImp::put): ditto + (KJS::ActivationImp::createArgumentsObject): ditto + + (KJS::ActivationImp::mark): Call JSObject::mark first so that one of + our properties doesn't try to recursively mark us. (This caused a crash + in earlier testing. Not sure why we haven't run into it before.) + + * kjs/nodes.cpp: Functions now build a symbol table the first time + they're called. + (KJS::VarDeclNode::evaluate): + (KJS::FunctionBodyNode::FunctionBodyNode): + (KJS::FunctionBodyNode::initializeSymbolTable): + (KJS::FunctionBodyNode::processDeclarations): + (KJS::FunctionBodyNode::processDeclarationsForFunctionCode): + (KJS::FunctionBodyNode::processDeclarationsForProgramCode): + + * kjs/nodes.h: + (KJS::FunctionBodyNode::symbolTable): + + * wtf/Forward.h: Added Vector. + +2007-10-26 Kevin McCullough + + - Corrected function name mistake in this changelog. + +2007-10-26 Kevin McCullough + Reviewed by Sam and Steve. + + - Added convenience methods for converting between BSTR and JSStringRefs + + * API/JSStringRefCOM.cpp: Added. + (JSStringCreateWithBSTR): + (JSStringCopyBSTR): + * API/JSStringRefCOM.h: Added. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2007-10-26 Mark Rowe + + Windows build fix. + + * kjs/collector.cpp: + (KJS::Collector::collect): + +2007-10-26 Oliver Hunt + + Reviewed by Maciej. + + Make the JSC GC use a separate heap for JSNumbers to get a 0.7-1.4% progression in SunSpider. + + * kjs/CollectorHeapIntrospector.cpp: + (KJS::CollectorHeapIntrospector::init): + (KJS::CollectorHeapIntrospector::enumerate): + * kjs/CollectorHeapIntrospector.h: + * kjs/collector.cpp: + (KJS::Collector::recordExtraCost): + (KJS::Collector::heapAllocate): + (KJS::Collector::allocate): + (KJS::Collector::allocateNumber): + (KJS::Collector::registerThread): + (KJS::Collector::markStackObjectsConservatively): + (KJS::Collector::markMainThreadOnlyObjects): + (KJS::Collector::sweep): + (KJS::Collector::collect): + * kjs/collector.h: + * kjs/internal.h: + (KJS::NumberImp::operator new): + Force numbers to be allocated in the secondary heap. + +2007-10-26 Maciej Stachowiak + + Reviewed by Oliver. + + - encourage GCC a little harder to inline a few hot functions for 1.5% improvement on SunSpider. + + * kjs/value.h: + (KJS::JSValue::getUInt32): + (KJS::JSValue::getTruncatedInt32): + (KJS::JSValue::toNumber): + * wtf/PassRefPtr.h: + (WTF::PassRefPtr::~PassRefPtr): + * wtf/RefPtr.h: + (WTF::RefPtr::operator->): + +2007-10-26 Mark Rowe + + Gtk build fix. + + * kjs/ExecState.h: + +2007-10-26 Maciej Stachowiak + + Reviewed by Mark. + + - Merge Context class fully into ExecState, since they are always created and used together. + + No measurable performance impact but this is a useful cleanup. + + * JavaScriptCore.pri: + * kjs/ExecState.cpp: + (KJS::ExecState::ExecState): + (KJS::ExecState::~ExecState): + (KJS::ExecState::mark): + (KJS::ExecState::lexicalInterpreter): + * kjs/ExecState.h: + (KJS::ExecState::dynamicInterpreter): + (KJS::ExecState::setException): + (KJS::ExecState::clearException): + (KJS::ExecState::exception): + (KJS::ExecState::exceptionSlot): + (KJS::ExecState::hadException): + (KJS::ExecState::scopeChain): + (KJS::ExecState::callingExecState): + (KJS::ExecState::propertyNames): + * kjs/collector.cpp: + (KJS::Collector::reportOutOfMemoryToAllInterpreters): + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + (KJS::FunctionImp::argumentsGetter): + (KJS::FunctionImp::callerGetter): + (KJS::GlobalFuncImp::callAsFunction): + * kjs/interpreter.cpp: + (KJS::Interpreter::Interpreter): + (KJS::Interpreter::init): + (KJS::Interpreter::evaluate): + (KJS::Interpreter::mark): + * kjs/interpreter.h: + (KJS::Interpreter::setCurrentExec): + (KJS::Interpreter::currentExec): + * kjs/nodes.cpp: + (KJS::currentSourceId): + (KJS::currentSourceURL): + (KJS::ThisNode::evaluate): + (KJS::ResolveNode::evaluate): + (KJS::FunctionCallResolveNode::evaluate): + (KJS::PostfixResolveNode::evaluate): + (KJS::DeleteResolveNode::evaluate): + (KJS::TypeOfResolveNode::evaluate): + (KJS::PrefixResolveNode::evaluate): + (KJS::AssignResolveNode::evaluate): + (KJS::VarDeclNode::evaluate): + (KJS::DoWhileNode::execute): + (KJS::WhileNode::execute): + (KJS::ForNode::execute): + (KJS::ForInNode::execute): + (KJS::ContinueNode::execute): + (KJS::BreakNode::execute): + (KJS::ReturnNode::execute): + (KJS::WithNode::execute): + (KJS::SwitchNode::execute): + (KJS::LabelNode::execute): + (KJS::TryNode::execute): + (KJS::FunctionBodyNode::processDeclarationsFunctionCode): + (KJS::FunctionBodyNode::processDeclarationsProgramCode): + (KJS::FunctionBodyNode::processDeclarations): + (KJS::FuncDeclNode::makeFunction): + (KJS::FuncExprNode::evaluate): + +2007-10-26 Mark Rowe + + Windows build fix. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2007-10-26 Mark Rowe + + Gtk build fix. + + * JavaScriptCore.pri: + * kjs/ExecState.cpp: + +2007-10-26 Maciej Stachowiak + + Reviewed by Oliver. + + - moved Context class into ExecState.{h,cpp} in preparation for merging + ExecState and Context classes. + + * kjs/ExecState.h: Moved CodeType enum and Context class here in + preparation for merging ExecState and Context. + * kjs/ExecState.cpp: Moved Context class here from Context.cpp. + (KJS::Context::Context): + (KJS::Context::~Context): + (KJS::Context::mark): + * kjs/context.h: Removed. + * kjs/Context.cpp: Removed. + * kjs/function.h: Removed CodeType enum. + * kjs/LabelStack.h: Added. Pulled LabelStack class out of internal.h. + * kjs/internal.h: Removed LabelStack. + * JavaScriptCore.xcodeproj/project.pbxproj: Added new file, removed ones that are gone. + * kjs/collector.cpp: Fixed includes. + * kjs/function.cpp: ditto + * kjs/internal.cpp: ditto + * kjs/interpreter.cpp: ditto + * kjs/lookup.h: ditto + * kjs/nodes.cpp: ditto + +2007-10-26 Mark Rowe + + Windows build fix. + + * kjs/string_object.cpp: + (KJS::StringObjectFuncImp::callAsFunction): + +2007-10-25 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15703 + fix numeric functions -- improve correctness and speed + + Gives about 1% gain on SunSpider. + + * kjs/value.h: Added toIntegerPreserveNan, removed toUInt16. + (KJS::JSValue::toInt32): Changed to call getTruncatedInt32 in a way that works + with both immediate and number values. + (KJS::JSValue::toUInt32): Ditto. + * kjs/value.cpp: + (KJS::JSValue::toInteger): Moved the logic from roundValue here, with a couple + differences. One is that it now correctly returns 0 for NaN, and another is that + there's no special case for 0 or infinity, since the general case already handles + those correctly. + (KJS::JSValue::toIntegerPreserveNaN): Added. Like toInteger, but without the + check for NaN. + (KJS::JSValue::toInt32SlowCase): Call toNumber instead of roundValue. The + truncation done by the typecast already does the necessary truncation that + roundValue was doing. + (KJS::JSValue::toUInt32SlowCase): Ditto. + (KJS::JSValue::toUInt16): Removed. + + * kjs/internal.h: Removed roundValue. + * kjs/internal.cpp: Ditto. + + * kjs/array_object.cpp: (KJS::ArrayProtoFunc::callAsFunction): Remove unneeded + code to handle NaN in Array.slice; toInteger now never returns NaN as specified. + + * kjs/date_object.cpp: + (KJS::fillStructuresUsingTimeArgs): Replaced call to roundValue with a call to + toNumber as specified. + (KJS::DateProtoFunc::callAsFunction): In SetTime case, replaced call to roundValue + with a call to toNumber and timeClip as specified. + (KJS::DateObjectImp::construct): Removed unnecessary checks of numArgs in cases + where the default behavior of toInt32 (returning 0) was already correct. Replaced + call to roundValue with a call to toNumber as specified. + (KJS::DateObjectFuncImp::callAsFunction): Ditto. + + * kjs/math_object.cpp: (MathFuncImp::callAsFunction): Removed unnecessary special + cases for the pow function that the library already handles correctly. + + * kjs/number_object.cpp: (NumberProtoFunc::callAsFunction): Changed ToString to + call toIntegerPreserveNaN, so we can continue to handle the NaN case differently. + The real toInteger now returns 0 for NaN. Took out unneeded special case in + ToFixed for undefined; was only needed because our toInteger was wrong. Same + thing in ToExponential. Changed ToPrecision to call toIntegerPreserveNaN. + + * kjs/string_object.cpp: + (KJS::StringProtoFunc::callAsFunction): Took out CharAt and CharCodeAt special + cases for undefined that were only needed because toInteger was wrong. Same in + IndexOf, and was able to remove some special cases. In LastIndexOf, used + toIntegerPreserveNaN, but was able to remove some special cases there too. + Changed Substr implementation to preserve correct behavior with the change + to toInteger and match the specification. Also made sure we weren't converting + an out of range double to an int. + (KJS::StringObjectFuncImp::callAsFunction): Changed constructor to just use + toUInt32, because truncating toUInt32 to 16 bits is the same thing and there's + no reason to have toUInt16 as a second, less-optimized function that's only + called at this one call site. + + * wtf/MathExtras.h: Added trunc function for Windows. + +2007-10-25 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Tweaked the inner hashtable lookup loop to remove a branch in the "not + found" case. .5% speedup on SunSpider. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * wtf/HashTable.h: + (WTF::::lookup): + +2007-10-25 Maciej Stachowiak + + Reviewed by Oliver. + + - fold together toPrimitive() and toNumber() conversions for 0.5% gain on SunSpider + + * kjs/nodes.cpp: + (KJS::SubNode::evaluate): Subtract directly, since toPrimitive() is not + adding any value over toNumber() here. + (KJS::valueForReadModifyAssignment): Ditto. + (KJS::lessThan): Use new getPrimitiveNumber() method to avoid some virtual calls + and branches. + (KJS::lessThanEq): Ditto. + * JavaScriptCore.exp: Export new functions as needed. + * kjs/value.h: + (KJS::JSValue::toPrimitive): Fixed formatting. + (KJS::JSValue::getPrimitiveNumber): New method - this simultaneously converts + to number and tells you whether a toPrimitive() conversion with a Number hint + would have given a string. + * kjs/internal.cpp: + (KJS::StringImp::getPrimitiveNumber): Implemented. + (KJS::NumberImp::getPrimitiveNumber): ditto + (KJS::GetterSetterImp::getPrimitiveNumber): ditto + (KJS::StringImp::toPrimitive): Fixed formatting. + (KJS::NumberImp::toPrimitive): ditto + (KJS::GetterSetterImp::toPrimitive): ditto + * kjs/internal.h: + * kjs/object.cpp: + (KJS::JSObject::getPrimitiveNumber): Implemented. + * kjs/object.h: + +2007-10-25 Sam Weinig + + Reviewed by Adam Roben. + + Remove JSStringRefCFHack from windows as it is no longer needed. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2007-10-25 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Rolled out my last patch. It turns out that I needed 2 words, not 1, + so it didn't help. + +2007-10-25 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed http://bugs.webkit.org/show_bug.cgi?id=15694 + Shrink the size of an activation object by 1 word + + This is in preparation for adding a symbol table to the activation + object. + + The basic strategy here is to rely on the mutual exclusion between + the arguments object pointer and the function pointer (you only need + the latter in order to create the former), and store them in the same + place. The LazyArgumentsObject class encapsulates this strategy. + + Also inlined the ArgumentsImp constructor, for good measure. + + SunSpider reports no regression. Regression tests pass. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/Context.cpp: + (KJS::Context::~Context): + * kjs/function.cpp: + (KJS::ActivationImp::LazyArgumentsObject::createArgumentsObject): + (KJS::ActivationImp::LazyArgumentsObject::mark): + (KJS::ActivationImp::argumentsGetter): + (KJS::ActivationImp::mark): + * kjs/function.h: + (KJS::ActivationImp::LazyArgumentsObject::LazyArgumentsObject): + (KJS::ActivationImp::LazyArgumentsObject::getOrCreate): + (KJS::ActivationImp::LazyArgumentsObject::resetArguments): + (KJS::ActivationImp::LazyArgumentsObject::setArgumentsObject): + (KJS::ActivationImp::LazyArgumentsObject::argumentsObject): + (KJS::ActivationImp::LazyArgumentsObject::setFunction): + (KJS::ActivationImp::LazyArgumentsObject::function): + (KJS::ActivationImp::LazyArgumentsObject::createdArgumentsObject): + (KJS::ActivationImp::LazyArgumentsObject::): + (KJS::ActivationImp::ActivationImp::ActivationImp): + (KJS::ActivationImp::resetArguments): + +2007-10-25 Adam Roben + + Change JavaScriptCore.vcproj to use DerivedSources.make + + We were trying to emulate the logic of make in + build-generated-files.sh, but we got it wrong. We now use a + build-generated-files very much like the one that WebCore uses to + invoke make. + + We also now only have a Debug configuration of dftables which we build + even when doing a Release build of JavaScriptCore. dftables also no + longer has the "_debug" name suffix. + + Changes mostly made by Darin, reviewed by me. + + * DerivedSources.make: Add a variable to set the extension used for + the dftables executable. + * JavaScriptCore.vcproj/JavaScriptCore.sln: Updated to use Debug + dftables in Release configurations. + * JavaScriptCore.vcproj/JavaScriptCoreSubmit.sln: Ditto. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + - Updated include path to point to the new location of the derived + sources. + - Modified pre-build event to pass the right arguments to + build-generated-files.sh and not call dftables directly. + - Added the derived source files to the project. + - Removed grammarWrapper.cpp, which isn't needed now that we're + compiling grammar.cpp directly. + * JavaScriptCore.vcproj/JavaScriptCore/build-generated-files.sh: + Slightly modified from the WebCore version. + * JavaScriptCore.vcproj/JavaScriptCore/grammarWrapper.cpp: Removed. + * JavaScriptCore.vcproj/dftables/dftables.vcproj: + - Changed the output location to match Mac. + - Removed the Release configuration. + - Removed the _debug suffix. + +2007-10-25 Geoffrey Garen + + Reviewed by Eric Seidel. + + Slightly elaborated the differences between declaration procesing in + Function Code and Program Code. + + .3% speedup on SunSpider. + + * kjs/nodes.cpp: + (KJS::FunctionBodyNode::processDeclarationsFunctionCode): + (KJS::FunctionBodyNode::processDeclarationsProgramCode): Store a + minimum set of attributes instead of recomputing all the time. Also, + ignore m_parameters, since programs don't have arguments. + +2007-10-25 Eric Seidel + + Reviewed by Maciej. + + More preparation work before adding long-running mode to testkjs. + + * kjs/testkjs.cpp: + (TestFunctionImp::callAsFunction): + (prettyPrintScript): + (runWithScripts): + (parseArguments): + (kjsmain): + (fillBufferWithContentsOfFile): + +2007-10-25 Eric Seidel + + Reviewed by Maciej. + + Bring testkjs code out of the dark ages in preparation for more + radical improvements (like long-running testing support!) + + * kjs/testkjs.cpp: + (TestFunctionImp::callAsFunction): + (setupInterpreter): + (doIt): + (fillBufferWithContentsOfFile): + +2007-10-25 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Make a fast path for declaration processing inside Function Code. + + Lifted declaration processing code up from individual declaration nodes + and into processDeclarations. + + Broke out processDeclarations into two cases, depending on the type of + code. This eliminates 2 branches, and facilitates more radical + divergeance in the future. + + 2.5% SunSpider speedup. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/nodes.cpp: + (KJS::FunctionBodyNode::initializeDeclarationStacks): + (KJS::FunctionBodyNode::processDeclarationsFunctionCode): + (KJS::FunctionBodyNode::processDeclarationsProgramCode): + (KJS::FunctionBodyNode::execute): + (KJS::FuncDeclNode::makeFunction): + * kjs/nodes.h: + +2007-10-25 Maciej Stachowiak + + Reviewed by Adam. + + - add header includes needed on platforms that don't use AllInOneFile.cpp + + * API/JSCallbackObject.cpp: + * kjs/Context.cpp: + * kjs/ExecState.cpp: + * kjs/array_instance.cpp: + * kjs/function_object.cpp: + * kjs/interpreter.cpp: + * kjs/nodes.cpp: + +2007-10-25 Eric Seidel + + Reviewed by Geoff. + + * JavaScriptCore.xcodeproj/project.pbxproj: re-mark JSGlobalObject.h as private + +2007-10-25 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed http://bugs.webkit.org/show_bug.cgi?id=15683 + Re-order declaration initialization to avoid calling hasProperty inside + VarDeclNode::processDeclaration + + .7% speedup on SunSpider. + + * kjs/function.h: + * kjs/function.cpp: Merged parameter processing into FunctionBodyNode's + other processing of declared symbols, so the order of execution could + change. + + * kjs/nodes.cpp: + (KJS::VarDeclNode::getDeclarations): Added special case for the + "arguments" property name, explained in the comment. + + (KJS::VarDeclNode::processDeclaration): Removed call to hasProperty + in the case of function code, since we know the declared symbol + management will resolve conflicts between symbols. Yay! + + (KJS::VarDeclListNode::getDeclarations): Now that VarDeclNode's + implementation of getDeclarations is non-trivial, we can't take a + short-cut here any longer -- we need to put the VarDecl node on the + stack so it gets processed normally. + + (KJS::FunctionBodyNode::processDeclarations): Changed the order of + processing to enforce mutual exclusion rules. + + * kjs/nodes.h: + (KJS::DeclarationStacks::DeclarationStacks): Structure includes an + ExecState now, for fast access to the "arguments" property name. + +2007-10-24 Eric Seidel + + Reviewed by Maciej. + + Add a JSGlobalObject class and remove the InterpreterMap + http://bugs.webkit.org/show_bug.cgi?id=15681 + + This required making JSCallbackObject a template class to allow for + JSGlobalObjects with JSCallbackObject functionality. + + SunSpider claims this was a 0.5% speedup. + + * API/JSCallbackObject.cpp: + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: Copied from API/JSCallbackObject.cpp. + (KJS::::JSCallbackObject): + (KJS::::init): + (KJS::::~JSCallbackObject): + (KJS::::initializeIfNeeded): + (KJS::::className): + (KJS::::getOwnPropertySlot): + (KJS::::put): + (KJS::::deleteProperty): + (KJS::::implementsConstruct): + (KJS::::construct): + (KJS::::implementsHasInstance): + (KJS::::hasInstance): + (KJS::::implementsCall): + (KJS::::callAsFunction): + (KJS::::getPropertyNames): + (KJS::::toNumber): + (KJS::::toString): + (KJS::::setPrivate): + (KJS::::getPrivate): + (KJS::::inherits): + (KJS::::cachedValueGetter): + (KJS::::staticValueGetter): + (KJS::::staticFunctionGetter): + (KJS::::callbackGetter): + * API/JSClassRef.cpp: + (OpaqueJSClass::prototype): + * API/JSContextRef.cpp: + (JSGlobalContextCreate): + * API/JSObjectRef.cpp: + (JSObjectMake): + (JSObjectGetPrivate): + (JSObjectSetPrivate): + * API/JSValueRef.cpp: + (JSValueIsObjectOfClass): + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * bindings/c/c_utility.cpp: + (KJS::Bindings::convertValueToNPVariant): + * bindings/jni/jni_jsobject.cpp: + * bindings/objc/objc_utility.mm: + (KJS::Bindings::convertValueToObjcValue): + * kjs/Context.cpp: + (KJS::Context::Context): + * kjs/ExecState.cpp: + (KJS::ExecState::lexicalInterpreter): + * kjs/JSGlobalObject.h: Added. + (KJS::JSGlobalObject::JSGlobalObject): + (KJS::JSGlobalObject::isGlobalObject): + (KJS::JSGlobalObject::interpreter): + (KJS::JSGlobalObject::setInterpreter): + * kjs/array_instance.cpp: + * kjs/context.h: + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + (KJS::GlobalFuncImp::callAsFunction): + * kjs/interpreter.cpp: + (KJS::Interpreter::Interpreter): + (KJS::Interpreter::init): + (KJS::Interpreter::~Interpreter): + (KJS::Interpreter::globalObject): + (KJS::Interpreter::initGlobalObject): + (KJS::Interpreter::evaluate): + * kjs/interpreter.h: + * kjs/lookup.h: + (KJS::cacheGlobalObject): + * kjs/object.h: + (KJS::JSObject::isGlobalObject): + * kjs/testkjs.cpp: + +2007-10-24 Eric Seidel + + Build fix for Gtk, no review. + + * kjs/collector.cpp: #include "context.h" + +2007-10-24 Eric Seidel + + Reviewed by Maciej. + + Stop checking isOutOfMemory after every allocation, instead let the collector + notify all ExecStates if we ever hit this rare condition. + + SunSpider claims this was a 2.2% speedup. + + * kjs/collector.cpp: + (KJS::Collector::collect): + (KJS::Collector::reportOutOfMemoryToAllInterpreters): + * kjs/collector.h: + * kjs/nodes.cpp: + (KJS::TryNode::execute): + +2007-10-24 Mark Rowe + + Gtk build fix. + + * kjs/identifier.h: Remove extra qualification. + +2007-10-24 Geoffrey Garen + + Reviewed by Sam Weinig. + + Disable ALWAYS_INLINE in debug builds, since it drives the debugger + crazy. + + * wtf/AlwaysInline.h: + +2007-10-24 Geoffrey Garen + + Reviewed by Sam Weinig. + + Inlined the fast path for creating an Identifier from an Identifier. + + This is a .4% speedup on SunSpider overall, but as big as a 2.5% + speedup on certain individual tests. 65% of the Identifiers creating + by SunSpider are already Identifiers. + + (The main reason I'm making this change is that it resolves a large + regression in a patch I haven't checked in yet.) + + * JavaScriptCore.exp: + * kjs/identifier.cpp: + (KJS::Identifier::addSlowCase): + * kjs/identifier.h: + (KJS::Identifier::Identifier::add): + +2007-10-24 Lars Knoll + + Reviewed by Simon. + + some changes to the way JS values are converted to Qt values in the script bindings. Added support for converting JS arrays into QStringList's. + + * bindings/qt/qt_instance.cpp: + (KJS::Bindings::QtInstance::invokeMethod): + * bindings/qt/qt_runtime.cpp: + (KJS::Bindings::convertValueToQVariant): + (KJS::Bindings::QtField::setValueToInstance): + +2007-10-24 Oliver Hunt + + Reviewed by Darin. + + Remove old relation method, replace with specialised LessThan and lessThenEq functions for a 0.5-0.6% improvement in SunSpider + + * kjs/nodes.cpp: + (KJS::lessThan): + (KJS::lessThanEq): + (KJS::LessNode::evaluate): + (KJS::GreaterNode::evaluate): + (KJS::LessEqNode::evaluate): + (KJS::GreaterEqNode::evaluate): + * kjs/operations.cpp: + * kjs/operations.h: + +2007-10-24 Eric Seidel + + Reviewed by darin. + + * kjs/nodes.h: + (KJS::ImmediateNumberNode::): Fix ASSERT correctness (and debug build!) + +2007-10-24 Darin Adler + + Reviewed by Eric. + + * kjs/object.cpp: (KJS::JSObject::defaultValue): Get rid of a little + Identifier ref/deref for what SunSpider claims is a 0.4% speedup. + +2007-10-24 Darin Adler + + Reviewed by Maciej. + + - separate out the code to create a hash table the first time from the code + to rehash + + SunSpider claims this was a 0.7% speedup. + + * kjs/property_map.cpp: + (KJS::PropertyMap::expand): Changed to call either createTable or rehash. + (KJS::PropertyMap::createTable): Added. For the case where we had no table. + (KJS::PropertyMap::rehash): Removed code needed only in the case where we + had no table. + * kjs/property_map.h: Added createTable. + +2007-10-24 Eric Seidel + + Reviewed by darin. + + Add ImmediateNumberNode to hold a JSValue* instead of a double for numbers + which can be represented by JSImmediate. + + SunSpider claims this was a 0.6% speedup. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::NumberNode::evaluate): + (KJS::ImmediateNumberNode::evaluate): + * kjs/nodes.h: + (KJS::Node::): + (KJS::ImmediateNumberNode::): + * kjs/nodes2string.cpp: + (ImmediateNumberNode::streamTo): + +2007-10-24 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15657 + change static hash tables to use powers of two for speed + + Seems to give 0.7% SunSpider speedup. + + * kjs/create_hash_table: Updated to generate new format. + * kjs/lookup.cpp: + (KJS::keysMatch): Took out unneeded typecast. + (KJS::findEntry): Updated to expect table type 3 -- changed the printf to a plain old assert. + Replaced the modulus with a bit mask. + (KJS::Lookup::findEntry): Get the hash directly, since we know identifiers already have computed + their hash -- saves a branch. + (KJS::Lookup::find): Ditto. + * kjs/lookup.h: Changed attr from 2-byte value to one-byte value. Replaced hashSize with hashSizeMask. + +2007-10-24 Maciej Stachowiak + + Reviewed by Darin. + + - remove KJS_CHECKEXCEPTIONs in places where exceptions can't happen for 0.6% SunSpider speedup + + * kjs/nodes.cpp: + (KJS::DoWhileNode::execute): + (KJS::WhileNode::execute): + (KJS::ForNode::execute): + (KJS::ForInNode::execute): + (KJS::SourceElementsNode::execute): + +2007-10-23 Darin Adler + + Reviewed by Maciej. + + * kjs/JSImmediate.h: (KJS::JSImmediate::getUInt32): + Changed an && to an & for a 1% gain in SunSpider. + +2007-10-23 Oliver Hunt + + Reviewed by Maciej. + + Reduce branching in implementations of some operator implementations, yielding 1.3% boost to SunSpider. + + * kjs/nodes.cpp: + (KJS::MultNode::evaluate): + (KJS::DivNode::evaluate): + (KJS::ModNode::evaluate): + (KJS::add): + (KJS::sub): + (KJS::AddNode::evaluate): + (KJS::SubNode::evaluate): + (KJS::valueForReadModifyAssignment): + * kjs/operations.cpp: + * kjs/operations.h: + +2007-10-23 Oliver Hunt + + Reviewed by Maciej. + + Separating all of the simple (eg. non-read-modify-write) binary operators + into separate classes in preparation for further JS optimisations. + + Happily this produces a 0.8% to 1.0% performance increase in SunSpider with + no further work. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * kjs/grammar.y: + * kjs/nodes.cpp: + (KJS::MultNode::evaluate): + (KJS::DivNode::evaluate): + (KJS::ModNode::evaluate): + (KJS::AddNode::evaluate): + (KJS::SubNode::evaluate): + (KJS::LeftShiftNode::evaluate): + (KJS::RightShiftNode::evaluate): + (KJS::UnsignedRightShiftNode::evaluate): + (KJS::LessNode::evaluate): + (KJS::GreaterNode::evaluate): + (KJS::LessEqNode::evaluate): + (KJS::GreaterEqNode::evaluate): + (KJS::InstanceOfNode::evaluate): + (KJS::InNode::evaluate): + (KJS::EqualNode::evaluate): + (KJS::NotEqualNode::evaluate): + (KJS::StrictEqualNode::evaluate): + (KJS::NotStrictEqualNode::evaluate): + (KJS::BitAndNode::evaluate): + (KJS::BitXOrNode::evaluate): + (KJS::BitOrNode::evaluate): + (KJS::LogicalAndNode::evaluate): + (KJS::LogicalOrNode::evaluate): + * kjs/nodes.h: + (KJS::MultNode::): + (KJS::DivNode::): + (KJS::ModNode::): + (KJS::AddNode::): + (KJS::SubNode::): + (KJS::LeftShiftNode::): + (KJS::RightShiftNode::): + (KJS::UnsignedRightShiftNode::): + (KJS::LessNode::): + (KJS::GreaterNode::): + (KJS::LessEqNode::): + (KJS::GreaterEqNode::): + (KJS::InstanceOfNode::): + (KJS::InNode::): + (KJS::EqualNode::): + (KJS::NotEqualNode::): + (KJS::StrictEqualNode::): + (KJS::NotStrictEqualNode::): + (KJS::BitAndNode::): + (KJS::BitOrNode::): + (KJS::BitXOrNode::): + (KJS::LogicalAndNode::): + (KJS::LogicalOrNode::): + * kjs/nodes2string.cpp: + (MultNode::streamTo): + (DivNode::streamTo): + (ModNode::streamTo): + (AddNode::streamTo): + (SubNode::streamTo): + (LeftShiftNode::streamTo): + (RightShiftNode::streamTo): + (UnsignedRightShiftNode::streamTo): + (LessNode::streamTo): + (GreaterNode::streamTo): + (LessEqNode::streamTo): + (GreaterEqNode::streamTo): + (InstanceOfNode::streamTo): + (InNode::streamTo): + (EqualNode::streamTo): + (NotEqualNode::streamTo): + (StrictEqualNode::streamTo): + (NotStrictEqualNode::streamTo): + (BitAndNode::streamTo): + (BitXOrNode::streamTo): + (BitOrNode::streamTo): + (LogicalAndNode::streamTo): + +2007-10-23 Darin Adler + + Reviewed by Maciej. + + - fix http://bugs.webkit.org/show_bug.cgi?id=15639 + fix Math.abs(0), Math.ceil(-0), and Math.floor(-0) + + Test: fast/js/math.html + + * kjs/math_object.cpp: (MathFuncImp::callAsFunction): + Fix abs to look at the sign bit. Add a special case for values in the range + between -0 and -1 and a special case for ceil and for -0 for floor. + +2007-10-23 Darin Adler + + Reviewed by Eric. + + - streamline exception handling code for a >1% speed-up of SunSpider + + * kjs/nodes.cpp: Changed macros to use functions for everything that's not + part of normal execution. We'll take function call overhead when propagating + an exception or out of memory. + (KJS::createOutOfMemoryCompletion): Added. + (KJS::substitute): Use append instead of the relatively inefficient + operator. + (KJS::Node::rethrowException): Added. + * kjs/nodes.h: Added rethrowException. + +2007-10-22 Darin Adler + + Reviewed by Maciej. + + - fix http://bugs.webkit.org/show_bug.cgi?id=15636 + some JavaScriptCore regression tests are failing due to numeric conversion + + This should restore correctness and make speed better too, restoring some + of the optimization we lost in my last check-in. + + * kjs/JSImmediate.h: + (KJS::JSImmediate::getTruncatedInt32): Added. Uses the range checking idiom + I used in my patch yesterday. + (KJS::JSImmediate::getTruncatedUInt32): Ditto. + + * kjs/internal.h: Removed getInt32 and added getTruncatedInt/UInt32. + * kjs/internal.cpp: + (KJS::NumberImp::getUInt32): Changed to always use double, since I can't find + a way to write this more efficiently for float. + (KJS::NumberImp::getTruncatedInt32): Added. + (KJS::NumberImp::getTruncatedUInt32): Added. + + * kjs/value.h: Removed getInt32 and added getTruncatedInt/UInt32. + (KJS::JSValue::getUInt32): + (KJS::JSValue::getTruncatedInt32): Added. + (KJS::JSValue::getTruncatedUInt32): Added. + (KJS::JSValue::toInt32): Changed getInt32 call to getTruncatedInt32. + (KJS::JSValue::toUInt32): Changed getUInt32 call to getTruncatedUInt32. + * kjs/value.cpp: + (KJS::JSCell::getTruncatedInt32): Added. + (KJS::JSCell::getTruncatedUInt32): Added. + (KJS::JSValue::toInteger): Changed getUInt32 call to getTruncatedInt32. + (KJS::JSValue::toInt32SlowCase): Removed extra getInt32 call I accidentally + had left in here. + (KJS::JSValue::toUInt32SlowCase): Ditto. + (KJS::JSValue::toUInt16): Changed getUInt32 call to getTruncatedUInt32. + + * JavaScriptCore.exp: Updated. + +2007-10-22 Darin Adler + + Reviewed by Geoff. + + - fix http://bugs.webkit.org/show_bug.cgi?id=15632 + js1_5/Array/array-001.js test failing + + One of the JavaScriptCore tests was failing; it failed because of + my change to NumberImp::getUInt32. The incorrect code I copied was + from JSImmediate::getUInt32, and was a pre-existing bug. + + This patch fixes correctness, but will surely slow down SunSpider. + We may be able to code this tighter and get the speed back. + + * kjs/JSImmediate.h: + (KJS::JSImmediate::getInt32): Renamed from toInt32 to more accurately + reflect the fact that this function only returns true if the value is + accurate (no fractional part, etc.). Changed code so that it returns + false when the value has a fraction. + (KJS::JSImmediate::getUInt32): Ditto. + + * kjs/internal.cpp: + (KJS::NumberImp::getInt32): Changed code so that it returns false when + the value has a fraction. Restores the old behavior. + (KJS::NumberImp::getUInt32): Ditto. + + * kjs/value.h: + (KJS::JSValue::getInt32): Updated for name change. + (KJS::JSValue::getUInt32): Ditto. + (KJS::JSValue::toInt32): Ditto. + (KJS::JSValue::toUInt32): Ditto. + +2007-10-22 Darin Adler + + Reviewed by Brady. + + - fix crash seen when running JavaScriptCore tests + + * kjs/array_instance.cpp: (KJS::ArrayInstance::mark): + Copy and paste error: I accidentally had code here that was + making a copy of the HashMap -- that's illegal inside a mark + function and was unnecessary. The other callsite was modifying + the map as it iterated it, but this function is not. + +2007-10-22 Maciej Stachowiak + + Reviewed by Oliver. + + - Avoid moving floats into integer registers in jsNumber() for 3% speedup on SunSpider + http://bugs.webkit.org/show_bug.cgi?id=15627 + + * kjs/JSImmediate.h: + (KJS::JSImmediate::fromDouble): Avoid moving floats to integer + registers since this is very slow. + +2007-10-22 Darin Adler + + Reviewed by Eric Seidel. + + - http://bugs.webkit.org/show_bug.cgi?id=15617 + improve speed of integer conversions + + Makes SunSpider 6% faster. + + * kjs/JSImmediate.h: Added toInt32 and toUInt32, with separate versions for + 32-bit and 64-bit. + * kjs/value.h: + (KJS::JSValue::getUInt32): Call JSImmediate::toUInt32. + + * kjs/internal.h: Added getInt32. + * kjs/internal.cpp: + (KJS::NumberImp::getInt32): Added. + (KJS::NumberImp::getUInt32): Replaced with more-optimal implementation + stolen from JSValue. + + * kjs/value.h: + (KJS::jsNumber): Marked ALWAYS_INLINE, because this wasn't getting + inlined. + (KJS::JSValue::getInt32): Added. + (KJS::JSValue::getUInt32): Changed to call the new JSImmediate::toUInt32 + to avoid converting from float to double. + (KJS::JSValue::toInt32): Made inline, separated out the slow case. + (KJS::JSValue::toUInt32): Ditto. + * kjs/value.cpp: + (KJS::JSCell::getInt32): Added. + (KJS::JSValue::toInt32SlowCase): Renamed from toInt32. Changed to use the + new getInt32. Added a faster case for in-range numbers. + (KJS::JSValue::toUInt32SlowCase): Ditto. + (KJS::JSValue::toUInt16): Added a faster case for in-range numbers. + + * JavaScriptCore.exp: Updated for changes. + +2007-10-22 Adam Roben + + Windows build fix + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Turn off + warning about implicit conversion to bool. + +2007-10-22 Mark Rowe + + Gtk build fix. + + * kjs/array_instance.cpp: + +2007-10-22 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15606 + make cut-off for sparse vs. dense arrays smarter for speed with large arrays + + Makes the morph test in SunSpider 26% faster, and the overall + benchmark 3% faster. + + This also fixes some small problems we had with the distinction + between nonexistent and undefined values in arrays. + + * kjs/array_instance.h: Tweaked formatting and naming. + * kjs/array_instance.cpp: Copied from kjs/array_object.cpp. + (KJS::storageSize): Added. Computes the size of the storage given a vector length. + (KJS::increasedVectorLength): Added. Implements the rule for resizing the vector. + (KJS::isDenseEnoughForVector): Added. + (KJS::ArrayInstance::ArrayInstance): Initialize the new fields. + (KJS::ArrayInstance::~ArrayInstance): Since m_storage is now never 0, delete it. + (KJS::ArrayInstance::getItem): Updated for name changes. + (KJS::ArrayInstance::lengthGetter): Ditto. + (KJS::ArrayInstance::inlineGetOwnPropertySlot): Added. Allows both versions of + getOwnPropertySlot to share more code. + (KJS::ArrayInstance::getOwnPropertySlot): Just refactored, no code change. + (KJS::ArrayInstance::put): Added logic for extending the vector as long as the + array is dense enough. Also keep m_numValuesInVector up to date. + (KJS::ArrayInstance::deleteProperty): Added code to keep m_numValuesInVector + up to date. + (KJS::ArrayInstance::getPropertyNames): Fixed bug where this would omit names + for array indices with undefined values. + (KJS::ArrayInstance::increaseVectorLength): Renamed from resizeStorage. Also + simplified to only handle getting larger. + (KJS::ArrayInstance::setLength): Added code to update m_numValuesInVector, to + zero out the unused part of the vector and to delete the map if it's no longer + needed. + (KJS::ArrayInstance::mark): Tweaked formatting. + (KJS::compareByStringForQSort): Ditto. + (KJS::ArrayInstance::sort): Ditto. + (KJS::CompareWithCompareFunctionArguments::CompareWithCompareFunctionArguments): + Ditto. + (KJS::compareWithCompareFunctionForQSort): Ditto. + (KJS::ArrayInstance::compactForSorting): Fixed bug where this would turn + undefined values into nonexistent values in some cases. + + * kjs/array_object.h: Removed MAX_ARRAY_INDEX. + * kjs/array_object.cpp: Removed ArrayInstance. Moved to a separate file. + + * JavaScriptCore.pri: Added array_instance.cpp. + * JavaScriptCore.xcodeproj/project.pbxproj: Ditto. + * kjs/AllInOneFile.cpp: Ditto. + +2007-10-22 Andrew Wellington + + Reviewed by Mark Rowe. + + Fix for local database support after r26879 + Ensure that ENABLE_DATABASE and ENABLE_ICONDATABASE are correctly set + + * Configurations/JavaScriptCore.xcconfig: + +2007-10-22 Simon Hausmann + + Reviewed by Alp. + + Build fix for the non-qmake builds. + + * wtf/Platform.h: Default to enabling the database features unless + otherwise specified. (similar to ENABLE_ICONDATABASE) + +2007-10-22 Holger Freyther + + Reviewed by Simon Hausmann . + + * Do not build testkjs as an application bundle. This is + needed for run-javascriptcore-tests on OSX. + * Also, based on r26633, allow to test the WebKit/Qt port on OSX. + * Set DYLD_LIBRARY_PATH if it was set in the environment. It must be set + as we do not have -rpath on OSX. + + * kjs/testkjs.pro: + +2007-10-21 Mark Rowe + + Reviewed by Alp. + + http://bugs.webkit.org/show_bug.cgi?id=15575 + Bug 15575: [GTK] Implement threading using GThread + + * wtf/Platform.h: Do not enable pthreads for Gtk. + +2007-10-21 Mark Rowe + + Reviewed by Mitz. + + Fix http://bugs.webkit.org/show_bug.cgi?id=15603 + Bug 15603: Regression(r26847): Crash when sorting an empty array from JavaScript + + * kjs/array_object.cpp: + (KJS::freeStorage): Reinstate null-check that was removed in r26847. + +2007-10-21 Darin Adler + + - fix Windows build + + * kjs/array_instance.h: Removed unused ExecState parameter. + * kjs/array_object.cpp: + (KJS::ArrayInstance::put): Ditto. + (KJS::ArrayInstance::setLength): Ditto. + +2007-10-21 Darin Adler + + * kjs/array_object.cpp: (KJS::ArrayInstance::put): + Add missing assignment that was causing regression test crash. + +2007-10-21 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15585 + speed up sparse arrays by using a custom map + + Speeds up SunSpider by 10%. + + * kjs/array_object.cpp: + (allocateStorage): Leave room for an additional pointer. + (reallocateStorage): Ditto. + (freeStorage): Ditto. + (ArrayInstance::~ArrayInstance): Delete the overflow map if present. + (ArrayInstance::getItem): Read values from the overflow map if present. + Removed the check of length, since it slows down the common case. + (ArrayInstance::getOwnPropertySlot): Ditto. Also removed the fallback + to the property map. + (ArrayInstance::put): Write values into the overflow map as needed. + Also create overflow map when needed. + (ArrayInstance::deleteProperty): Remove values from the overflow map + as appropriate. + (ArrayInstance::getPropertyNames): Add a name for each identifier in + the property map. This is extremely inefficient. + (ArrayInstance::setLength): Remove any values in the overflow map + that are past the new length, as we formerly did with the property map. + (ArrayInstance::mark): Mark any values in the overflow map. + (compareByStringForQSort): Removed unneeded undefined case, since + compactForSorting guarantees we will have no undefined values. + (compareWithCompareFunctionForQSort): Ditto. + (ArrayInstance::compactForSorting): Copy all the values out of the + overflow map and destroy it. + + * kjs/property_map.h: Removed now-unused getSparseArrayPropertyNames. + * kjs/property_map.cpp: Ditto. + +2007-10-20 Darin Adler + + Reviewed by Maciej. + + - http://bugs.webkit.org/show_bug.cgi?id=15579 + stop churning identifier reference counts copying Completion objects + + * kjs/completion.h: Replace the Identifier with an Identifier*. + * kjs/nodes.cpp: + (ForInNode::execute): Update for change to Completion constructor. + (ContinueNode::execute): Ditto. + (BreakNode::execute): Ditto. + +2007-10-20 Mark Rowe + + Reviewed by Alp. + + Gtk changes needed to enable HTML 5 client-side database storage. + + * wtf/Platform.h: Have Gtk use pthreads for now. + +2007-10-20 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed http://bugs.webkit.org/show_bug.cgi?id=15570 + Store gathered declaration nodes in the function body node. + + This means that you only have to gather the declaration nodes the first + time the function executes. Performance gain of 2.10% on SunSpider, + 0.90% on command-line JS iBench. + + * kjs/nodes.cpp: Split declaration stack initialization code off into + initializeDeclarationStacks(). + (FunctionBodyNode::FunctionBodyNode): + (FunctionBodyNode::initializeDeclarationStacks): + (FunctionBodyNode::processDeclarations): + + * kjs/nodes.h: Changed DeclarationStacks structure to hold references, + since the actual Vectors are now stored either on the stack or in the + function body node. + +2007-10-19 Geoffrey Garen + + Reviewed by Darin Adler. + + http://bugs.webkit.org/show_bug.cgi?id=15559 + Moved processDeclarations call into FunctionBodyNode::execute + + To improve encapsulation, moved processDeclarations call into + FunctionBodyNode::execute. Also marked processDeclarations + ALWAYS_INLINE, since it has only 1 caller now. This is a .71% speedup + on command-line JS iBench. + + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + (KJS::GlobalFuncImp::callAsFunction): + * kjs/function.h: + * kjs/interpreter.cpp: + (KJS::Interpreter::evaluate): + * kjs/nodes.cpp: + (FunctionBodyNode::execute): + * kjs/nodes.h: + +2007-10-19 Brady Eidson + + Reviewed by Sam + + Queue -> Deque! and small style tweaks + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj + * wtf/Deque.h: Added. + (WTF::DequeNode::DequeNode): + (WTF::Deque::Deque): + (WTF::Deque::~Deque): + (WTF::Deque::size): + (WTF::Deque::isEmpty): + (WTF::Deque::append): + (WTF::Deque::prepend): + (WTF::Deque::first): + (WTF::Deque::last): + (WTF::Deque::removeFirst): + (WTF::Deque::clear): + * wtf/Queue.h: Removed. + + +2007-10-19 Brady Eidson + + Reviewed by Oliver + + Added a simple LinkedList based Queue to wtf + We can make a better, more sophisticated an efficient one later, but have + needed one for some time, now! + + * JavaScriptCore.xcodeproj/project.pbxproj: + * wtf/Queue.h: Added. + (WTF::QueueNode::QueueNode): + (WTF::Queue::Queue): + (WTF::Queue::~Queue): + (WTF::Queue::size): + (WTF::Queue::isEmpty): + (WTF::Queue::append): + (WTF::Queue::prepend): + (WTF::Queue::first): + (WTF::Queue::last): + (WTF::Queue::removeFirst): + (WTF::Queue::clear): + +2007-10-19 Nikolas Zimmermann + + Reviewed by Anders. + + Try to fix Qt/Win build slave, by including windows.h also on Qt/Win. + + * kjs/testkjs.cpp: Change PLATFORM(WIN) to PLATFORM(WIN_OS) + +2007-10-19 Simon Hausmann + + Reviewed by Lars. + + Fix compilation on Windows when wchar_t is a typedef instead of a native type (triggered by -Zc:wchar_t-). + Don't provide the wchar_t overloads then as they conflict with the unsigned short ones. + + * wtf/ASCIICType.h: + (WTF::isASCIIAlpha): + (WTF::isASCIIAlphanumeric): + (WTF::isASCIIDigit): + (WTF::isASCIIHexDigit): + (WTF::isASCIILower): + (WTF::isASCIISpace): + (WTF::toASCIILower): + (WTF::toASCIIUpper): + +2007-10-19 Simon Hausmann + + Reviewed by Lars. + + Another build fix for the windows/qt build: Apply the same fix as in revision 26686 also to kjs/config.h to disable the disallowctype feature. + + * kjs/config.h: + +2007-10-18 Maciej Stachowiak + + Reviewed by Adam. + + - use __declspec(thread) for fast thread-local storage on Windows + + - 2.2% speedup on sunspider (on Windows) + - 7% speedup on the string section + - 6% speedup on JS iBench + + - fixed PLT on Windows got 2.5% slower between r25406 and r25422 + - fixed at least some of + + Reviewed by Mark Rowe. + + - fix http://bugs.webkit.org/show_bug.cgi?id=15543 + REGRESSION (r26697): + GoogleDocs: Can't create new documents or open existing ones + + Test: fast/js/regexp-non-character.html + + * pcre/pcre_compile.c: (check_escape): Take out the checks for valid characters + in the \u sequences -- not needed and actively harmful. + +2007-10-17 Anders Carlsson + + Reviewed by Oliver. + + * wtf/Platform.h: + #define USE_PTHREADS on Mac. + +2007-10-17 Geoffrey Garen + + Reviewed by Darin Adler. + + Merged DeclaredFunctionImp into FunctionImp (the base class) because + the distinction between the two was unused. + + Removed codeType() from FunctionImp because FunctionImp and its + subclasses all returned FunctionCode, so it was unused, practically + speaking. + + Removed a different codeType() from GlobalFuncImp because it was unused. + (Perhaps it was vestigial from a time when GlobalFuncImp used to + inherit from FunctionImp.) + + * bindings/runtime_method.cpp: + * bindings/runtime_method.h: + * kjs/function.cpp: + (KJS::FunctionImp::FunctionImp): + (KJS::FunctionImp::callAsFunction): + (KJS::FunctionImp::construct): + (KJS::FunctionImp::execute): + (KJS::FunctionImp::processVarDecls): + * kjs/function.h: + (KJS::FunctionImp::implementsConstruct): + (KJS::FunctionImp::scope): + * kjs/function_object.cpp: + (FunctionProtoFunc::callAsFunction): + (FunctionObjectImp::construct): + * kjs/nodes.cpp: + (FuncDeclNode::processFuncDecl): + (FuncExprNode::evaluate): + +2007-10-17 Adam Roben + + Windows build fix part 2. + + Fix was by Darin, reviewed by Anders and Adam. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Add + FastMallocPCRE.cpp to the project, and let Visual Studio have its way + with the post-build step. + * pcre/pcre.h: Don't DLL export the entry points just because this + is Win32 -- this is an internal copy of PCRE and should be private. + * pcre/pcre_compile.c: Fix an uninitialized variable warning -- + there's no real problem but it's better to quiet the compiler by + tweaking the code slightly than turn off the warning entirely. + +2007-10-17 Adam Roben + + Windows build fix. + + Reviewed by Anders. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Disable + some mismatched signed/unsigned comparison warnings. + * pcre/pcre_exec.c: + (match): #if-out some labels that don't seem to exist. + +2007-10-17 Mark Rowe + + Gtk build fix. + + * JavaScriptCore.pri: Add FastMallocPCRE.cpp. + * pcre/pcre_get. #if out two functions that depend on pcre_get_stringnumber, which + is currently unavailable for UTF-16. + +2007-10-16 Darin Adler + + Reviewed by Geoff. + + - merged PCRE changes between 6.4 and 6.5 + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + Removed pcre_config.c, pcre_globals.c, pcre_info.c, pcre_maketables.c, + pcre_printint.src, pcre_refcount.c, pcre_study.c, pcre_try_flipped.c, + pcre_ucp_findchar.c, pcre_version.c, and ucptable.c. Added pcre_ucp_searchfuncs.c. + + * pcre/AUTHORS: + * pcre/LICENCE: + * pcre/MERGING: + * pcre/dftables.c: + * pcre/pcre-config.h: + * pcre/pcre.h: + * pcre/pcre.pri: + * pcre/pcre_compile.c: + * pcre/pcre_exec.c: + * pcre/pcre_fullinfo.c: + * pcre/pcre_get.c: + * pcre/pcre_internal.h: + * pcre/pcre_maketables.c: + * pcre/pcre_ord2utf8.c: + * pcre/pcre_tables.c: + * pcre/pcre_ucp_searchfuncs.c: Copied from pcre/pcre_ucp_findchar.c. + * pcre/pcre_xclass.c: + * pcre/ucp.h: + * pcre/ucpinternal.h: + * pcre/ucptable.c: + Updated with new versions from the PCRE 6.5 release, merged with changes. + + * pcre/pcre_config.c: Removed. + * pcre/pcre_globals.c: Removed. + * pcre/pcre_info.c: Removed. + * pcre/pcre_printint.src: Removed. + * pcre/pcre_refcount.c: Removed. + * pcre/pcre_study.c: Removed. + * pcre/pcre_try_flipped.c: Removed. + * pcre/pcre_ucp_findchar.c: Removed. + * pcre/pcre_version.c: Removed. + +2007-10-16 Geoffrey Garen + + Reviewed by Darin Adler. + + Removed KJS_VERBOSE because it was getting in the way of readability, + and the messages didn't seem very helpful. + + * kjs/function.cpp: + (KJS::FunctionImp::callAsFunction): + (KJS::FunctionImp::passInParameters): + * kjs/lookup.h: + (KJS::lookupPut): + * kjs/object.cpp: + (KJS::JSObject::put): + * kjs/value.h: + +2007-10-16 Geoffrey Garen + + Reviewed by Darin Adler. + + Removed the Parameter class because it was a redundant wrapper around + Identifier. + + * kjs/function.cpp: + (KJS::FunctionImp::passInParameters): + (KJS::FunctionImp::getParameterName): + * kjs/nodes.cpp: + (FunctionBodyNode::addParam): + * kjs/nodes.h: + (KJS::FunctionBodyNode::): + +2007-10-16 Geoffrey Garen + + Reviewed by Darin Adler. + + Global replace of assert with ASSERT. + +2007-10-16 Adam Roben + + Make testkjs not delay-load WebKit + + Soon, delay-loading WebKit will be impossible (because we will be + using __declspec(thread) for thread-local storage). This change + prepares testkjs for the future. + + Reviewed by Sam. + + * JavaScriptCore.vcproj/JavaScriptCore.sln: Removed WebKitInitializer, + added FindSafari. + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: Don't link against + WebKitInitializer, don't delay-load WebKit. + * kjs/testkjs.cpp: Don't use WebKitInitializer. + +2007-10-16 Adam Roben + + Updated testkjs for the rename of WebKit_debug.dll to WebKit.dll for the Debug configuration + + Reviewed by Kevin McCullough. + + * JavaScriptCore.vcproj/debug.vsprops: Added WebKitDLLConfigSuffix. + * JavaScriptCore.vcproj/debug_internal.vsprops: Ditto. + * JavaScriptCore.vcproj/release.vsprops: Ditto. + * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: Use + WebKitDLLConfigSuffix when referring to WebKit.dll, and fixed a typo + in the name of icuuc36[_debug].dll. + +2007-10-16 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Re-structured variable and function declaration code. + + Command-line JS iBench shows no regression. + + Here are the changes: + + 1. Function declarations are now processed at the same time as var + declarations -- namely, immediately upon entry to an execution context. + This does not match Firefox, which waits to process a function + declaration until the declaration's containing block executes, but it + does match IE and the ECMA spec. (10.1.3 states that var and function + declarations should be processed at the same time -- namely, "On + entering an execution context." 12.2 states that "A Block does not + define a new execution scope.") + + 2. Declaration processing proceeds iteratively now, rather than + recursively, storing the nodes is finds in stacks. This will later + facilitate an optimization to hold on to the gathered declaration nodes, + rather than re-fetching them in every function call. + [ http://bugs.webkit.org/show_bug.cgi?id=14868 ] + + Modified these tests because they expected the incorrect Mozilla + behavior described above: + + * tests/mozilla/ecma_3/Function/scope-001.js: + * tests/mozilla/js1_5/Scope/regress-184107.js: + +2007-10-16 Darin Adler + + - try to fix the GTK build + + * kjs/ustring.cpp: Include ASCIICType.h, not ASCIICtype.h. + +2007-10-16 Darin Adler + + - try to fix the Windows build + + * kjs/date_object.cpp: (KJS::parseDate): A couple instances of isspace were + in here. Not sure why it wasn't failing elsewhere. Changed to isASCIISpace. + +2007-10-16 Darin Adler + + - try to fix the GTK build + + * kjs/ustring.cpp: Include ASCIICType.h. + +2007-10-16 Darin Adler + + Reviewed by Maciej and Geoff (and looked over by Eric). + + - http://bugs.webkit.org/show_bug.cgi?id=15519 + eliminate use of for processing ASCII + + * wtf/ASCIICType.h: Added. + * wtf/DisallowCType.h: Added. + + * kjs/config.h: Include DisallowCType.h. + + * kjs/date_object.cpp: + (KJS::skipSpacesAndComments): + (KJS::findMonth): + (KJS::parseDate): + * kjs/function.cpp: + (KJS::decode): + * kjs/ustring.cpp: + (KJS::UString::toDouble): + Use ASCIICType.h functions instead of ctype.h ones. + +2007-10-14 Maciej Stachowiak + + Reviewed by Darin. + + - fixes for "New JavaScript benchmark" + http://bugs.webkit.org/show_bug.cgi?id=15515 + + * kjs/testkjs.cpp: + (TestFunctionImp::callAsFunction): Implement "load" for compatibility + with SpiderMonkey. + (TestFunctionImp::): ditto + (doIt): ditto + (kjsmain): Drop useless --> from output. + +2007-10-15 Geoffrey Garen + + Removed unnecessary #include. + + * API/JSObjectRef.cpp: + +2007-10-15 Geoffrey Garen + + Double-reverse build fix. My tree was out of date. + + * kjs/nodes.cpp: + (NumberNode::evaluate): + +2007-10-15 Geoffrey Garen + + Build fix. + + * kjs/nodes.cpp: + (NumberNode::evaluate): + +2007-10-15 Geoffrey Garen + + Reviewed by Darin Adler. + + Removed surprising self-named "hack" that made nested functions + available as named properties of their containing functions, and placed + containing function objects in the scope chains of nested functions. + + There were a few reasons to remove this "hack:" + + 1. It contradicted FF, IE, and the ECMA spec. + + 2. It incurred a performance penalty, since merely parsing a function + required parsing its body for nested functions (and so on). + + 3. SVN history contains no explanation for why it was added. It was just + legacy code in a large merge a long, long time ago. + + [ Patch broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ] + + * kjs/nodes.cpp: + (FuncDeclNode::processFuncDecl): + +2007-10-15 Geoffrey Garen + + Reviewed by Darin Adler. + + Removed the concept of AnonymousCode. It was unused, and it doesn't + exist in the ECMA spec. + + [ Patch broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ] + + * kjs/Context.cpp: + (KJS::Context::Context): + * kjs/function.h: + * kjs/nodes.cpp: + (ReturnNode::execute): + +2007-10-15 Geoffrey Garen + + Reviewed by Darin Adler. + + Made function parameters DontDelete. This matches FF and the vague + description in ECMA 10.1.3. It's also required in order to make + symbol table based lookup of function parameters valid. (If the + parameters aren't DontDelete, you can't guarantee that you'll find + them later in the symbol table.) + + [ Patch broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ] + + * kjs/function.cpp: + (KJS::FunctionImp::passInParameters): + +2007-10-15 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Some Vector optimizations. These are especially important when using + Vector as a stack for implementing recursive algorithms iteratively. + + [ Broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ] + + 1. Added shrink(), which is a version of resize() that you can call + to save a branch / improve code generation and inlining when you know + that the vector is not getting bigger. + + 2. Changed subclassing relationship in VectorBuffer to remove a call to + fastFree() in the destructor for the inlineCapacity != 0 template + specialization. This brings inline Vectors one step closer to true + stack-allocated arrays. + + Also changed abort() to CRASH(), since the latter works better. + + * wtf/Vector.h: + (WTF::VectorBufferBase::allocateBuffer): + (WTF::VectorBufferBase::deallocateBuffer): + (WTF::VectorBufferBase::VectorBufferBase): + (WTF::VectorBufferBase::~VectorBufferBase): + (WTF::): + (WTF::VectorBuffer::VectorBuffer): + (WTF::VectorBuffer::~VectorBuffer): + (WTF::VectorBuffer::deallocateBuffer): + (WTF::VectorBuffer::releaseBuffer): + (WTF::Vector::clear): + (WTF::Vector::removeLast): + (WTF::::operator): + (WTF::::fill): + (WTF::::shrink): + +2007-10-12 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed http://bugs.webkit.org/show_bug.cgi?id=15490 + Iteration statements sometimes incorrectly evaluate to the empty value + (KDE r670547). + + [ Broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ] + + This patch is a merge of KDE r670547, with substantial modification + for performance. + + It fixes do-while statements to evaluate to a value. (They used + to evaluate to the empty value in all cases.) + + It also fixes SourceElementsNode to maintain the value of abnormal + completions like "break" and "continue." + + It also re-works the main execution loop in SourceElementsNode so that + it (1) makes a little more sense and (2) avoids unnecessary work. This + is a .28% speedup on command-line JS iBench. + + * kjs/nodes.cpp: + (DoWhileNode::execute): + (SourceElementsNode::execute): + +2007-10-15 Simon Hausmann + + Reviewed by Lars. + + Fix compilation with gcc 4.3 by including 'limits' due to the use of std::numeric_limits. + + * wtf/HashTraits.h: + +2007-10-5 Kevin Ollivier + + Reviewed by Adam. + + Add support for MSVC7, and fix cases where PLATFORM(WIN) should + be PLATFORM(WIN_OS) for other ports building on Windows. + + * kjs/DateMath.cpp: + (KJS::getDSTOffsetSimple): + * kjs/JSImmediate.h: + * wtf/Assertions.cpp: + * wtf/Assertions.h: + * wtf/Platform.h: + * wtf/StringExtras.h: + (snprintf): + (vsnprintf): + +2007-10-14 Cameron Zwarich + + Reviewed by Darin. + + Adds NegateNode optimization from KJS. The relevant revision in KDE + is 666736. + + * kjs/grammar.y: + * kjs/nodes.cpp: + (NumberNode::evaluate): + * kjs/nodes.h: + (KJS::Node::): + (KJS::NumberNode::): + * kjs/nodes2string.cpp: + (NumberNode::streamTo): + +2007-10-14 Jason Foreman + + Reviewed by Maciej. + + Fix http://bugs.webkit.org/show_bug.cgi?id=15145 + + Ensure that if adjusting n to minimize the difference of n*intPow10(e-p+1) to x, + that the property n < intPow10(p) is maintained. + + * kjs/number_object.cpp: + (NumberProtoFunc::callAsFunction): + +== Rolled over to ChangeLog-2007-10-14 == diff --git a/DerivedSources.make b/DerivedSources.make index 4f89a6f..4b33682 100644 --- a/DerivedSources.make +++ b/DerivedSources.make @@ -1,4 +1,4 @@ -# Copyright (C) 2006 Apple Computer, Inc. All rights reserved. +# Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -25,41 +25,51 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. VPATH = \ - $(JavaScriptCore)/kjs \ + $(JavaScriptCore) \ + $(JavaScriptCore)/parser \ $(JavaScriptCore)/pcre \ + $(JavaScriptCore)/docs \ + $(JavaScriptCore)/runtime \ + $(JavaScriptCore)/interpreter \ + $(JavaScriptCore)/jit \ # .PHONY : all all : \ - array_object.lut.h \ + ArrayPrototype.lut.h \ chartables.c \ - date_object.lut.h \ - grammar.cpp \ - lexer.lut.h \ - math_object.lut.h \ - number_object.lut.h \ - regexp_object.lut.h \ - string_object.lut.h \ + DatePrototype.lut.h \ + Grammar.cpp \ + Lexer.lut.h \ + MathObject.lut.h \ + NumberConstructor.lut.h \ + RegExpConstructor.lut.h \ + RegExpObject.lut.h \ + StringPrototype.lut.h \ + docs/bytecode.html \ # # lookup tables for classes %.lut.h: create_hash_table %.cpp $^ -i > $@ -lexer.lut.h: create_hash_table keywords.table +Lexer.lut.h: create_hash_table Keywords.table $^ > $@ # JavaScript language grammar -grammar.cpp: grammar.y - bison -d -p kjsyy $< -o $@ > bison_out.txt 2>&1 - perl -p -e 'END { if ($$conflict) { unlink "grammar.cpp"; die; } } $$conflict ||= /conflict/' < bison_out.txt - touch grammar.cpp.h - touch grammar.hpp - cat grammar.cpp.h grammar.hpp > grammar.h - rm -f grammar.cpp.h grammar.hpp bison_out.txt +Grammar.cpp: Grammar.y + bison -d -p jscyy $< -o $@ > bison_out.txt 2>&1 + perl -p -e 'END { if ($$conflict) { unlink "Grammar.cpp"; die; } } $$conflict ||= /conflict/' < bison_out.txt + touch Grammar.cpp.h + touch Grammar.hpp + cat Grammar.cpp.h Grammar.hpp > Grammar.h + rm -f Grammar.cpp.h Grammar.hpp bison_out.txt # character tables for PCRE chartables.c : dftables $^ $@ + +docs/bytecode.html: make-bytecode-docs.pl Interpreter.cpp + perl $^ $@ diff --git a/ForwardingHeaders/JavaScriptCore/JSLock.h b/ForwardingHeaders/JavaScriptCore/JSLock.h deleted file mode 100644 index 8519612..0000000 --- a/ForwardingHeaders/JavaScriptCore/JSLock.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/ForwardingHeaders/JavaScriptCore/OpaqueJSString.h b/ForwardingHeaders/JavaScriptCore/OpaqueJSString.h new file mode 100644 index 0000000..51e029e --- /dev/null +++ b/ForwardingHeaders/JavaScriptCore/OpaqueJSString.h @@ -0,0 +1 @@ +#include diff --git a/ForwardingHeaders/JavaScriptCore/WebKitAvailability.h b/ForwardingHeaders/JavaScriptCore/WebKitAvailability.h new file mode 100644 index 0000000..0c58890 --- /dev/null +++ b/ForwardingHeaders/JavaScriptCore/WebKitAvailability.h @@ -0,0 +1 @@ +#include diff --git a/GNUmakefile.am b/GNUmakefile.am index b1f0274..3d90470 100644 --- a/GNUmakefile.am +++ b/GNUmakefile.am @@ -1,171 +1,535 @@ -# tell automake to create gensources/ for us -nodist_EXTRA_libJavaScriptCore_la_SOURCES = \ - DerivedSources/dummy.cxx - javascriptcore_cppflags += \ + -I$(srcdir)/JavaScriptCore/API \ -I$(srcdir)/JavaScriptCore/ForwardingHeaders \ - -I$(srcdir)/JavaScriptCore/bindings \ - -I$(srcdir)/JavaScriptCore/bindings/c \ + -I$(srcdir)/JavaScriptCore/interpreter \ + -I$(srcdir)/JavaScriptCore/bytecode \ + -I$(srcdir)/JavaScriptCore/bytecompiler \ + -I$(srcdir)/JavaScriptCore/debugger \ + -I$(srcdir)/JavaScriptCore/jit \ + -I$(srcdir)/JavaScriptCore/pcre \ + -I$(srcdir)/JavaScriptCore/profiler \ + -I$(srcdir)/JavaScriptCore/runtime \ + -I$(srcdir)/JavaScriptCore/wrec \ + -I$(srcdir)/JavaScriptCore/jit \ + -I$(srcdir)/JavaScriptCore/assembler \ + -I$(srcdir)/JavaScriptCore/wtf/unicode \ -I$(top_builddir)/JavaScriptCore/pcre \ - -I$(top_builddir)/JavaScriptCore/kjs + -I$(top_builddir)/JavaScriptCore/parser \ + -I$(top_builddir)/JavaScriptCore/runtime javascriptcore_h_api += \ - JavaScriptCore/API/JavaScript.h \ - JavaScriptCore/API/JavaScriptCore.h \ JavaScriptCore/API/JSBase.h \ JavaScriptCore/API/JSContextRef.h \ JavaScriptCore/API/JSObjectRef.h \ + JavaScriptCore/API/JSStringRef.h \ JavaScriptCore/API/JSStringRefBSTR.h \ JavaScriptCore/API/JSStringRefCF.h \ - JavaScriptCore/API/JSStringRef.h \ - JavaScriptCore/API/JSValueRef.h + JavaScriptCore/API/JSValueRef.h \ + JavaScriptCore/API/JavaScript.h \ + JavaScriptCore/API/JavaScriptCore.h \ + JavaScriptCore/API/WebKitAvailability.h javascriptcore_built_nosources += \ - JavaScriptCore/kjs/array_object.lut.h \ - JavaScriptCore/kjs/date_object.lut.h \ - JavaScriptCore/kjs/math_object.lut.h \ - JavaScriptCore/kjs/number_object.lut.h \ - JavaScriptCore/kjs/regexp_object.lut.h \ - JavaScriptCore/kjs/string_object.lut.h \ - JavaScriptCore/pcre/chartables.c \ - DerivedSources/lexer.lut.h + DerivedSources/Lexer.lut.h \ + JavaScriptCore/runtime/ArrayPrototype.lut.h \ + JavaScriptCore/runtime/DatePrototype.lut.h \ + JavaScriptCore/runtime/MathObject.lut.h \ + JavaScriptCore/runtime/NumberConstructor.lut.h \ + JavaScriptCore/runtime/RegExpConstructor.lut.h \ + JavaScriptCore/runtime/RegExpObject.lut.h \ + JavaScriptCore/runtime/StringPrototype.lut.h \ + JavaScriptCore/pcre/chartables.c javascriptcore_sources += \ + JavaScriptCore/API/APICast.h \ JavaScriptCore/API/JSBase.cpp \ + JavaScriptCore/API/JSBasePrivate.h \ JavaScriptCore/API/JSCallbackConstructor.cpp \ + JavaScriptCore/API/JSCallbackConstructor.h \ JavaScriptCore/API/JSCallbackFunction.cpp \ + JavaScriptCore/API/JSCallbackFunction.h \ JavaScriptCore/API/JSCallbackObject.cpp \ + JavaScriptCore/API/JSCallbackObject.h \ + JavaScriptCore/API/JSCallbackObjectFunctions.h \ JavaScriptCore/API/JSClassRef.cpp \ + JavaScriptCore/API/JSClassRef.h \ JavaScriptCore/API/JSContextRef.cpp \ JavaScriptCore/API/JSObjectRef.cpp \ + JavaScriptCore/API/JSRetainPtr.h \ JavaScriptCore/API/JSStringRef.cpp \ JavaScriptCore/API/JSValueRef.cpp \ - JavaScriptCore/bindings/NP_jsobject.cpp \ - JavaScriptCore/bindings/c/c_class.cpp \ - JavaScriptCore/bindings/c/c_instance.cpp \ - JavaScriptCore/bindings/c/c_runtime.cpp \ - JavaScriptCore/bindings/c/c_utility.cpp \ - JavaScriptCore/bindings/npruntime.cpp \ - JavaScriptCore/bindings/runtime.cpp \ - JavaScriptCore/bindings/runtime_array.cpp \ - JavaScriptCore/bindings/runtime_method.cpp \ - JavaScriptCore/bindings/runtime_object.cpp \ - JavaScriptCore/bindings/runtime_root.cpp \ - JavaScriptCore/kjs/JSGlobalObject.cpp \ - JavaScriptCore/kjs/JSVariableObject.cpp \ + JavaScriptCore/API/OpaqueJSString.cpp \ + JavaScriptCore/API/OpaqueJSString.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/APICast.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSBase.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSContextRef.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSObjectRef.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSRetainPtr.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSStringRef.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSStringRefCF.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSValueRef.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/JavaScript.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/JavaScriptCore.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/OpaqueJSString.h \ + JavaScriptCore/ForwardingHeaders/JavaScriptCore/WebKitAvailability.h \ + JavaScriptCore/JavaScriptCorePrefix.h \ + JavaScriptCore/jit/ExecutableAllocator.h \ + JavaScriptCore/jit/JIT.cpp \ + JavaScriptCore/jit/JITCall.cpp \ + JavaScriptCore/jit/JITPropertyAccess.cpp \ + JavaScriptCore/jit/JITArithmetic.cpp \ + JavaScriptCore/jit/ExecutableAllocator.cpp \ + JavaScriptCore/jit/ExecutableAllocatorPosix.cpp \ + JavaScriptCore/jit/JIT.h \ + JavaScriptCore/jit/JITInlineMethods.h \ + JavaScriptCore/bytecode/StructureStubInfo.cpp \ + JavaScriptCore/bytecode/StructureStubInfo.h \ + JavaScriptCore/bytecode/CodeBlock.cpp \ + JavaScriptCore/bytecode/CodeBlock.h \ + JavaScriptCore/bytecode/JumpTable.cpp \ + JavaScriptCore/bytecode/JumpTable.h \ + JavaScriptCore/bytecode/EvalCodeCache.h \ + JavaScriptCore/runtime/ExceptionHelpers.cpp \ + JavaScriptCore/runtime/ExceptionHelpers.h \ + JavaScriptCore/bytecode/Instruction.h \ + JavaScriptCore/bytecompiler/Label.h \ + JavaScriptCore/interpreter/Interpreter.cpp \ + JavaScriptCore/interpreter/Interpreter.h \ + JavaScriptCore/bytecode/Opcode.cpp \ + JavaScriptCore/bytecode/Opcode.h \ + JavaScriptCore/interpreter/Register.h \ + JavaScriptCore/bytecompiler/RegisterID.h \ + JavaScriptCore/bytecode/SamplingTool.cpp \ + JavaScriptCore/bytecode/SamplingTool.h \ + JavaScriptCore/bytecompiler/SegmentedVector.h \ + JavaScriptCore/config.h \ + JavaScriptCore/debugger/DebuggerActivation.cpp \ + JavaScriptCore/debugger/DebuggerActivation.h \ + JavaScriptCore/debugger/DebuggerCallFrame.cpp \ + JavaScriptCore/debugger/DebuggerCallFrame.h \ + JavaScriptCore/icu/unicode/parseerr.h \ + JavaScriptCore/icu/unicode/platform.h \ + JavaScriptCore/icu/unicode/putil.h \ + JavaScriptCore/icu/unicode/uchar.h \ + JavaScriptCore/icu/unicode/ucnv.h \ + JavaScriptCore/icu/unicode/ucnv_err.h \ + JavaScriptCore/icu/unicode/ucol.h \ + JavaScriptCore/icu/unicode/uconfig.h \ + JavaScriptCore/icu/unicode/uenum.h \ + JavaScriptCore/icu/unicode/uiter.h \ + JavaScriptCore/icu/unicode/uloc.h \ + JavaScriptCore/icu/unicode/umachine.h \ + JavaScriptCore/icu/unicode/unorm.h \ + JavaScriptCore/icu/unicode/urename.h \ + JavaScriptCore/icu/unicode/uset.h \ + JavaScriptCore/icu/unicode/ustring.h \ + JavaScriptCore/icu/unicode/utf.h \ + JavaScriptCore/icu/unicode/utf16.h \ + JavaScriptCore/icu/unicode/utf8.h \ + JavaScriptCore/icu/unicode/utf_old.h \ + JavaScriptCore/icu/unicode/utypes.h \ + JavaScriptCore/icu/unicode/uversion.h \ + JavaScriptCore/assembler/X86Assembler.h \ + JavaScriptCore/assembler/AssemblerBuffer.h \ + JavaScriptCore/assembler/MacroAssembler.h \ + JavaScriptCore/os-win32/stdbool.h \ + JavaScriptCore/os-win32/stdint.h \ + JavaScriptCore/pcre/pcre.h \ JavaScriptCore/pcre/pcre_compile.cpp \ JavaScriptCore/pcre/pcre_exec.cpp \ + JavaScriptCore/pcre/pcre_internal.h \ JavaScriptCore/pcre/pcre_tables.cpp \ JavaScriptCore/pcre/pcre_ucp_searchfuncs.cpp \ JavaScriptCore/pcre/pcre_xclass.cpp \ + JavaScriptCore/pcre/ucpinternal.h \ + JavaScriptCore/profiler/CallIdentifier.h \ + JavaScriptCore/profiler/HeavyProfile.cpp \ + JavaScriptCore/profiler/HeavyProfile.h \ + JavaScriptCore/profiler/Profile.cpp \ + JavaScriptCore/profiler/Profile.h \ + JavaScriptCore/profiler/ProfileGenerator.cpp \ + JavaScriptCore/profiler/ProfileGenerator.h \ + JavaScriptCore/profiler/ProfileNode.cpp \ + JavaScriptCore/profiler/ProfileNode.h \ + JavaScriptCore/profiler/Profiler.cpp \ + JavaScriptCore/profiler/Profiler.h \ + JavaScriptCore/profiler/TreeProfile.cpp \ + JavaScriptCore/profiler/TreeProfile.h \ + JavaScriptCore/interpreter/CallFrame.cpp \ + JavaScriptCore/interpreter/CallFrame.h \ + JavaScriptCore/runtime/InitializeThreading.cpp \ + JavaScriptCore/runtime/InitializeThreading.h \ + JavaScriptCore/runtime/JSActivation.cpp \ + JavaScriptCore/runtime/JSActivation.h \ + JavaScriptCore/runtime/JSByteArray.cpp \ + JavaScriptCore/runtime/JSByteArray.h \ + JavaScriptCore/runtime/JSGlobalData.cpp \ + JavaScriptCore/runtime/JSGlobalData.h \ + JavaScriptCore/runtime/JSNotAnObject.cpp \ + JavaScriptCore/runtime/JSNotAnObject.h \ + JavaScriptCore/runtime/JSPropertyNameIterator.cpp \ + JavaScriptCore/runtime/JSPropertyNameIterator.h \ + JavaScriptCore/runtime/SmallStrings.cpp \ + JavaScriptCore/runtime/SmallStrings.h \ + JavaScriptCore/runtime/Structure.cpp \ + JavaScriptCore/runtime/Structure.h \ + JavaScriptCore/runtime/StructureChain.cpp \ + JavaScriptCore/runtime/StructureChain.h \ + JavaScriptCore/runtime/StructureTransitionTable.h \ + JavaScriptCore/runtime/TypeInfo.h \ + JavaScriptCore/wrec/CharacterClass.cpp \ + JavaScriptCore/wrec/CharacterClass.h \ + JavaScriptCore/wrec/CharacterClassConstructor.cpp \ + JavaScriptCore/wrec/CharacterClassConstructor.h \ + JavaScriptCore/wrec/Escapes.h \ + JavaScriptCore/wrec/Quantifier.h \ + JavaScriptCore/wrec/WREC.cpp \ + JavaScriptCore/wrec/WREC.h \ + JavaScriptCore/wrec/WRECFunctors.cpp \ + JavaScriptCore/wrec/WRECFunctors.h \ + JavaScriptCore/wrec/WRECGenerator.cpp \ + JavaScriptCore/wrec/WRECGenerator.h \ + JavaScriptCore/wrec/WRECParser.cpp \ + JavaScriptCore/wrec/WRECParser.h \ + JavaScriptCore/wtf/ASCIICType.h \ + JavaScriptCore/wtf/AVLTree.h \ + JavaScriptCore/wtf/AlwaysInline.h \ JavaScriptCore/wtf/Assertions.cpp \ + JavaScriptCore/wtf/Assertions.h \ + JavaScriptCore/wtf/ByteArray.cpp \ + JavaScriptCore/wtf/ByteArray.h \ + JavaScriptCore/wtf/CurrentTime.cpp \ + JavaScriptCore/wtf/CurrentTime.h \ + JavaScriptCore/wtf/Deque.h \ + JavaScriptCore/wtf/DisallowCType.h \ + JavaScriptCore/wtf/Forward.h \ + JavaScriptCore/wtf/GOwnPtr.cpp \ + JavaScriptCore/wtf/GOwnPtr.h \ + JavaScriptCore/wtf/GetPtr.h \ + JavaScriptCore/wtf/HashCountedSet.h \ + JavaScriptCore/wtf/HashFunctions.h \ + JavaScriptCore/wtf/HashIterators.h \ + JavaScriptCore/wtf/HashMap.h \ + JavaScriptCore/wtf/HashSet.h \ JavaScriptCore/wtf/HashTable.cpp \ - JavaScriptCore/wtf/unicode/UTF8.cpp + JavaScriptCore/wtf/HashTable.h \ + JavaScriptCore/wtf/HashTraits.h \ + JavaScriptCore/wtf/ListHashSet.h \ + JavaScriptCore/wtf/ListRefPtr.h \ + JavaScriptCore/wtf/Locker.h \ + JavaScriptCore/wtf/MainThread.cpp \ + JavaScriptCore/wtf/MainThread.h \ + JavaScriptCore/wtf/MathExtras.h \ + JavaScriptCore/wtf/MessageQueue.h \ + JavaScriptCore/wtf/Noncopyable.h \ + JavaScriptCore/wtf/NotFound.h \ + JavaScriptCore/wtf/OwnArrayPtr.h \ + JavaScriptCore/wtf/OwnPtr.h \ + JavaScriptCore/wtf/PassRefPtr.h \ + JavaScriptCore/wtf/Platform.h \ + JavaScriptCore/wtf/PtrAndFlags.h \ + JavaScriptCore/wtf/RandomNumber.cpp \ + JavaScriptCore/wtf/RandomNumber.h \ + JavaScriptCore/wtf/RandomNumberSeed.h \ + JavaScriptCore/wtf/RefCounted.h \ + JavaScriptCore/wtf/RefCountedLeakCounter.cpp \ + JavaScriptCore/wtf/RefCountedLeakCounter.h \ + JavaScriptCore/wtf/RefPtr.h \ + JavaScriptCore/wtf/RefPtrHashMap.h \ + JavaScriptCore/wtf/RetainPtr.h \ + JavaScriptCore/wtf/StdLibExtras.h \ + JavaScriptCore/wtf/StringExtras.h \ + JavaScriptCore/wtf/TCPackedCache.h \ + JavaScriptCore/wtf/TCPageMap.h \ + JavaScriptCore/wtf/TCSpinLock.h \ + JavaScriptCore/wtf/ThreadSpecific.h \ + JavaScriptCore/wtf/Threading.h \ + JavaScriptCore/wtf/Threading.cpp \ + JavaScriptCore/wtf/ThreadingGtk.cpp \ + JavaScriptCore/wtf/ThreadingPthreads.cpp \ + JavaScriptCore/wtf/UnusedParam.h \ + JavaScriptCore/wtf/Vector.h \ + JavaScriptCore/wtf/VectorTraits.h \ + JavaScriptCore/wtf/gtk/MainThreadGtk.cpp \ + JavaScriptCore/wtf/unicode/Collator.h \ + JavaScriptCore/wtf/unicode/CollatorDefault.cpp \ + JavaScriptCore/wtf/unicode/UTF8.cpp \ + JavaScriptCore/wtf/unicode/UTF8.h \ + JavaScriptCore/wtf/unicode/Unicode.h \ + JavaScriptCore/wtf/unicode/icu/CollatorICU.cpp \ + JavaScriptCore/wtf/unicode/icu/UnicodeIcu.h # Debug build if ENABLE_DEBUG javascriptcore_built_sources += \ - DerivedSources/grammar.h \ - DerivedSources/grammar.cpp + DerivedSources/Grammar.cpp \ + DerivedSources/Grammar.h javascriptcore_sources += \ - JavaScriptCore/kjs/CommonIdentifiers.cpp \ - JavaScriptCore/kjs/DateMath.cpp \ - JavaScriptCore/kjs/ExecState.cpp \ - JavaScriptCore/kjs/JSImmediate.cpp \ - JavaScriptCore/kjs/JSLock.cpp \ - JavaScriptCore/kjs/JSWrapperObject.cpp \ - JavaScriptCore/kjs/Parser.cpp \ - JavaScriptCore/kjs/PropertyNameArray.cpp \ - JavaScriptCore/kjs/array_instance.cpp \ - JavaScriptCore/kjs/array_object.cpp \ - JavaScriptCore/kjs/bool_object.cpp \ - JavaScriptCore/kjs/collector.cpp \ - JavaScriptCore/kjs/date_object.cpp \ - JavaScriptCore/kjs/debugger.cpp \ - JavaScriptCore/kjs/dtoa.cpp \ - JavaScriptCore/kjs/error_object.cpp \ - JavaScriptCore/kjs/function.cpp \ - JavaScriptCore/kjs/function_object.cpp \ - JavaScriptCore/kjs/identifier.cpp \ - JavaScriptCore/kjs/internal.cpp \ - JavaScriptCore/kjs/interpreter.cpp \ - JavaScriptCore/kjs/lexer.cpp \ - JavaScriptCore/kjs/list.cpp \ - JavaScriptCore/kjs/lookup.cpp \ - JavaScriptCore/kjs/math_object.cpp \ - JavaScriptCore/kjs/nodes.cpp \ - JavaScriptCore/kjs/nodes2string.cpp \ - JavaScriptCore/kjs/number_object.cpp \ - JavaScriptCore/kjs/object.cpp \ - JavaScriptCore/kjs/object_object.cpp \ - JavaScriptCore/kjs/operations.cpp \ - JavaScriptCore/kjs/property_map.cpp \ - JavaScriptCore/kjs/property_slot.cpp \ - JavaScriptCore/kjs/regexp.cpp \ - JavaScriptCore/kjs/regexp_object.cpp \ - JavaScriptCore/kjs/scope_chain.cpp \ - JavaScriptCore/kjs/string_object.cpp \ - JavaScriptCore/kjs/ustring.cpp \ - JavaScriptCore/kjs/value.cpp \ + JavaScriptCore/interpreter/RegisterFile.cpp \ + JavaScriptCore/interpreter/RegisterFile.h \ + JavaScriptCore/bytecompiler/BytecodeGenerator.cpp \ + JavaScriptCore/bytecompiler/BytecodeGenerator.h \ + JavaScriptCore/bytecompiler/LabelScope.h \ + JavaScriptCore/debugger/Debugger.cpp \ + JavaScriptCore/debugger/Debugger.h \ + JavaScriptCore/parser/Lexer.cpp \ + JavaScriptCore/parser/Lexer.h \ + JavaScriptCore/parser/NodeInfo.h \ + JavaScriptCore/parser/Nodes.cpp \ + JavaScriptCore/parser/Nodes.h \ + JavaScriptCore/parser/Parser.cpp \ + JavaScriptCore/parser/Parser.h \ + JavaScriptCore/parser/ResultType.h \ + JavaScriptCore/parser/SourceCode.h \ + JavaScriptCore/parser/SourceProvider.h \ + JavaScriptCore/runtime/ArgList.cpp \ + JavaScriptCore/runtime/ArgList.h \ + JavaScriptCore/runtime/Arguments.cpp \ + JavaScriptCore/runtime/Arguments.h \ + JavaScriptCore/runtime/ArrayConstructor.cpp \ + JavaScriptCore/runtime/ArrayConstructor.h \ + JavaScriptCore/runtime/ArrayPrototype.cpp \ + JavaScriptCore/runtime/ArrayPrototype.h \ + JavaScriptCore/runtime/BatchedTransitionOptimizer.h \ + JavaScriptCore/runtime/BooleanConstructor.cpp \ + JavaScriptCore/runtime/BooleanConstructor.h \ + JavaScriptCore/runtime/BooleanObject.cpp \ + JavaScriptCore/runtime/BooleanObject.h \ + JavaScriptCore/runtime/BooleanPrototype.cpp \ + JavaScriptCore/runtime/BooleanPrototype.h \ + JavaScriptCore/runtime/CallData.cpp \ + JavaScriptCore/runtime/CallData.h \ + JavaScriptCore/runtime/ClassInfo.h \ + JavaScriptCore/runtime/Collector.cpp \ + JavaScriptCore/runtime/Collector.h \ + JavaScriptCore/runtime/CollectorHeapIterator.h \ + JavaScriptCore/runtime/CommonIdentifiers.cpp \ + JavaScriptCore/runtime/CommonIdentifiers.h \ + JavaScriptCore/runtime/Completion.h \ + JavaScriptCore/runtime/ConstructData.cpp \ + JavaScriptCore/runtime/ConstructData.h \ + JavaScriptCore/runtime/DateConstructor.cpp \ + JavaScriptCore/runtime/DateConstructor.h \ + JavaScriptCore/runtime/DateInstance.cpp \ + JavaScriptCore/runtime/DateInstance.h \ + JavaScriptCore/runtime/DateMath.cpp \ + JavaScriptCore/runtime/DateMath.h \ + JavaScriptCore/runtime/DatePrototype.cpp \ + JavaScriptCore/runtime/DatePrototype.h \ + JavaScriptCore/runtime/Error.cpp \ + JavaScriptCore/runtime/Error.h \ + JavaScriptCore/runtime/ErrorConstructor.cpp \ + JavaScriptCore/runtime/ErrorConstructor.h \ + JavaScriptCore/runtime/ErrorInstance.cpp \ + JavaScriptCore/runtime/ErrorInstance.h \ + JavaScriptCore/runtime/ErrorPrototype.cpp \ + JavaScriptCore/runtime/ErrorPrototype.h \ + JavaScriptCore/runtime/FunctionConstructor.cpp \ + JavaScriptCore/runtime/FunctionConstructor.h \ + JavaScriptCore/runtime/FunctionPrototype.cpp \ + JavaScriptCore/runtime/FunctionPrototype.h \ + JavaScriptCore/runtime/GetterSetter.cpp \ + JavaScriptCore/runtime/GetterSetter.h \ + JavaScriptCore/runtime/GlobalEvalFunction.cpp \ + JavaScriptCore/runtime/GlobalEvalFunction.h \ + JavaScriptCore/runtime/Identifier.cpp \ + JavaScriptCore/runtime/Identifier.h \ + JavaScriptCore/runtime/InternalFunction.cpp \ + JavaScriptCore/runtime/InternalFunction.h \ + JavaScriptCore/runtime/Completion.cpp \ + JavaScriptCore/runtime/JSArray.cpp \ + JavaScriptCore/runtime/JSArray.h \ + JavaScriptCore/runtime/JSCell.cpp \ + JavaScriptCore/runtime/JSCell.h \ + JavaScriptCore/runtime/JSFunction.cpp \ + JavaScriptCore/runtime/JSFunction.h \ + JavaScriptCore/runtime/JSGlobalObject.cpp \ + JavaScriptCore/runtime/JSGlobalObject.h \ + JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp \ + JavaScriptCore/runtime/JSGlobalObjectFunctions.h \ + JavaScriptCore/runtime/JSImmediate.cpp \ + JavaScriptCore/runtime/JSImmediate.h \ + JavaScriptCore/runtime/JSLock.cpp \ + JavaScriptCore/runtime/JSLock.h \ + JavaScriptCore/runtime/JSNumberCell.cpp \ + JavaScriptCore/runtime/JSNumberCell.h \ + JavaScriptCore/runtime/JSObject.cpp \ + JavaScriptCore/runtime/JSObject.h \ + JavaScriptCore/runtime/JSStaticScopeObject.cpp \ + JavaScriptCore/runtime/JSStaticScopeObject.h \ + JavaScriptCore/runtime/JSString.cpp \ + JavaScriptCore/runtime/JSString.h \ + JavaScriptCore/runtime/JSType.h \ + JavaScriptCore/runtime/JSValue.cpp \ + JavaScriptCore/runtime/JSValue.h \ + JavaScriptCore/runtime/JSVariableObject.cpp \ + JavaScriptCore/runtime/JSVariableObject.h \ + JavaScriptCore/runtime/JSWrapperObject.cpp \ + JavaScriptCore/runtime/JSWrapperObject.h \ + JavaScriptCore/runtime/Lookup.cpp \ + JavaScriptCore/runtime/Lookup.h \ + JavaScriptCore/runtime/MathObject.cpp \ + JavaScriptCore/runtime/MathObject.h \ + JavaScriptCore/runtime/NativeErrorConstructor.cpp \ + JavaScriptCore/runtime/NativeErrorConstructor.h \ + JavaScriptCore/runtime/NativeErrorPrototype.cpp \ + JavaScriptCore/runtime/NativeErrorPrototype.h \ + JavaScriptCore/runtime/NumberConstructor.cpp \ + JavaScriptCore/runtime/NumberConstructor.h \ + JavaScriptCore/runtime/NumberObject.cpp \ + JavaScriptCore/runtime/NumberObject.h \ + JavaScriptCore/runtime/NumberPrototype.cpp \ + JavaScriptCore/runtime/NumberPrototype.h \ + JavaScriptCore/runtime/ObjectConstructor.cpp \ + JavaScriptCore/runtime/ObjectConstructor.h \ + JavaScriptCore/runtime/ObjectPrototype.cpp \ + JavaScriptCore/runtime/ObjectPrototype.h \ + JavaScriptCore/runtime/Operations.cpp \ + JavaScriptCore/runtime/Operations.h \ + JavaScriptCore/runtime/PropertyMapHashTable.h \ + JavaScriptCore/runtime/PropertyNameArray.cpp \ + JavaScriptCore/runtime/PropertyNameArray.h \ + JavaScriptCore/runtime/PropertySlot.cpp \ + JavaScriptCore/runtime/PropertySlot.h \ + JavaScriptCore/runtime/Protect.h \ + JavaScriptCore/runtime/PrototypeFunction.cpp \ + JavaScriptCore/runtime/PrototypeFunction.h \ + JavaScriptCore/runtime/PutPropertySlot.h \ + JavaScriptCore/runtime/RegExp.cpp \ + JavaScriptCore/runtime/RegExp.h \ + JavaScriptCore/runtime/RegExpConstructor.cpp \ + JavaScriptCore/runtime/RegExpConstructor.h \ + JavaScriptCore/runtime/RegExpMatchesArray.h \ + JavaScriptCore/runtime/RegExpObject.cpp \ + JavaScriptCore/runtime/RegExpObject.h \ + JavaScriptCore/runtime/RegExpPrototype.cpp \ + JavaScriptCore/runtime/RegExpPrototype.h \ + JavaScriptCore/runtime/ScopeChain.cpp \ + JavaScriptCore/runtime/ScopeChain.h \ + JavaScriptCore/runtime/ScopeChainMark.h \ + JavaScriptCore/runtime/StringConstructor.cpp \ + JavaScriptCore/runtime/StringConstructor.h \ + JavaScriptCore/runtime/StringObject.cpp \ + JavaScriptCore/runtime/StringObject.h \ + JavaScriptCore/runtime/StringObjectThatMasqueradesAsUndefined.h \ + JavaScriptCore/runtime/StringPrototype.cpp \ + JavaScriptCore/runtime/StringPrototype.h \ + JavaScriptCore/runtime/SymbolTable.h \ + JavaScriptCore/runtime/Tracing.h \ + JavaScriptCore/runtime/UString.cpp \ + JavaScriptCore/runtime/UString.h \ JavaScriptCore/wtf/FastMalloc.cpp \ - JavaScriptCore/wtf/TCSystemAlloc.cpp + JavaScriptCore/wtf/FastMalloc.h \ + JavaScriptCore/wtf/MallocZoneSupport.h \ + JavaScriptCore/wtf/TCSystemAlloc.cpp \ + JavaScriptCore/wtf/TCSystemAlloc.h \ + JavaScriptCore/wtf/dtoa.cpp \ + JavaScriptCore/wtf/dtoa.h else javascriptcore_built_nosources += \ - DerivedSources/grammar.h \ - DerivedSources/grammar.cpp + DerivedSources/Grammar.cpp \ + DerivedSources/Grammar.h javascriptcore_sources += \ - JavaScriptCore/kjs/AllInOneFile.cpp + JavaScriptCore/AllInOneFile.cpp endif # END ENABLE_DEBUG -DerivedSources/grammar.h: DerivedSources/grammar.cpp; +DerivedSources/Grammar.h: DerivedSources/Grammar.cpp; -DerivedSources/grammar.cpp: $(srcdir)/JavaScriptCore/kjs/grammar.y - $(BISON) -d -p kjsyy $(srcdir)/JavaScriptCore/kjs/grammar.y -o $@ > bison_out.txt 2>&1 - $(PERL) -p -e 'END { if ($$conflict) { unlink "grammar.cpp"; die; } } $$conflict ||= /conflict/' < bison_out.txt - cat $(GENSOURCES)/grammar.hpp > $(GENSOURCES)/grammar.h - rm -f $(GENSOURCES)/grammar.hpp bison_out.txt +DerivedSources/Grammar.cpp: $(srcdir)/JavaScriptCore/parser/Grammar.y + $(BISON) -d -p jscyy $(srcdir)/JavaScriptCore/parser/Grammar.y -o $@ > bison_out.txt 2>&1 + $(PERL) -p -e 'END { if ($$conflict) { unlink "Grammar.cpp"; die; } } $$conflict ||= /conflict/' < bison_out.txt + cat $(GENSOURCES)/Grammar.hpp > $(GENSOURCES)/Grammar.h + rm -f $(GENSOURCES)/Grammar.hpp bison_out.txt -DerivedSources/lexer.lut.h: $(CREATE_HASH_TABLE) $(srcdir)/JavaScriptCore/kjs/keywords.table +DerivedSources/Lexer.lut.h: $(CREATE_HASH_TABLE) $(srcdir)/JavaScriptCore/parser/Keywords.table $(PERL) $^ > $@ -%_object.lut.h: $(CREATE_HASH_TABLE) %_object.cpp - $^ -i > $@ +JavaScriptCore/%.lut.h: $(CREATE_HASH_TABLE) $(srcdir)/JavaScriptCore/%.cpp + $(PERL) $^ -i > $@ JavaScriptCore/pcre/chartables.c: $(srcdir)/JavaScriptCore/pcre/dftables - $^ $@ + $(PERL) $^ $@ + +bin_PROGRAMS += \ + Programs/jsc noinst_PROGRAMS += \ - Programs/minidom \ - Programs/testkjs + Programs/minidom # minidom Programs_minidom_SOURCES = \ - JavaScriptCore/API/JSNode.c \ - JavaScriptCore/API/JSNodeList.c \ - JavaScriptCore/API/Node.c \ - JavaScriptCore/API/NodeList.c \ - JavaScriptCore/API/minidom.c -Programs_minidom_CPPFLAGS = $(global_cppflags) -Programs_minidom_CXXFLAGS = $(global_cxxflags) $(global_cflags) -Programs_minidom_LDADD = libJavaScriptCore.la -Programs_minidom_LDFLAGS = -rpath $(CURDIR)/.libs - -# testkjs -Programs_testkjs_SOURCES = JavaScriptCore/kjs/testkjs.cpp -Programs_testkjs_CPPFLAGS = $(global_cppflags) -Programs_testkjs_CXXFLAGS = $(global_cxxflags) $(global_cflags) -Programs_testkjs_LDADD = libJavaScriptCore.la -Programs_testkjs_LDFLAGS = -rpath $(CURDIR)/.libs + JavaScriptCore/API/tests/JSNode.c \ + JavaScriptCore/API/tests/JSNode.h \ + JavaScriptCore/API/tests/JSNodeList.c \ + JavaScriptCore/API/tests/JSNodeList.h \ + JavaScriptCore/API/tests/Node.c \ + JavaScriptCore/API/tests/Node.h \ + JavaScriptCore/API/tests/NodeList.c \ + JavaScriptCore/API/tests/NodeList.h \ + JavaScriptCore/API/tests/minidom.c + +Programs_minidom_CPPFLAGS = \ + $(global_cppflags) \ + $(javascriptcore_cppflags) + +Programs_minidom_CFLAGS = \ + -ansi \ + -fno-strict-aliasing \ + -O2 \ + $(global_cflags) \ + $(GLOBALDEPS_CFLAGS) + +Programs_minidom_LDADD = \ + libJavaScriptCore.la \ + -lm \ + -lstdc++ + +# jsc +Programs_jsc_SOURCES = \ + JavaScriptCore/jsc.cpp + +Programs_jsc_CPPFLAGS = \ + $(global_cppflags) \ + $(javascriptcore_cppflags) + +Programs_jsc_CXXFLAGS = \ + -fno-strict-aliasing \ + -O2 \ + $(global_cxxflags) \ + $(global_cflags) \ + $(GLOBALDEPS_CFLAGS) \ + $(UNICODE_CFLAGS) + +Programs_jsc_LDADD = \ + libJavaScriptCore.la + +javascriptcore_dist += \ + $(CREATE_HASH_TABLE) \ + JavaScriptCore/AUTHORS \ + JavaScriptCore/COPYING.LIB \ + JavaScriptCore/ChangeLog \ + JavaScriptCore/THANKS \ + JavaScriptCore/icu/LICENSE \ + JavaScriptCore/icu/README \ + JavaScriptCore/pcre/COPYING \ + JavaScriptCore/pcre/AUTHORS \ + JavaScriptCore/pcre/dftables \ + JavaScriptCore/pcre/ucptable.cpp \ + JavaScriptCore/parser/Grammar.y \ + JavaScriptCore/parser/Keywords.table # Clean rules for JavaScriptCore CLEANFILES += \ - JavaScriptCore/kjs/array_object.lut.h \ - JavaScriptCore/kjs/date_object.lut.h \ - JavaScriptCore/kjs/math_object.lut.h \ - JavaScriptCore/kjs/number_object.lut.h \ - JavaScriptCore/kjs/regexp_object.lut.h \ - JavaScriptCore/kjs/string_object.lut.h \ - JavaScriptCore/pcre/chartables.c + JavaScriptCore/runtime/ArrayPrototype.lut.h \ + JavaScriptCore/runtime/DatePrototype.lut.h \ + JavaScriptCore/runtime/MathObject.lut.h \ + JavaScriptCore/runtime/NumberConstructor.lut.h \ + JavaScriptCore/runtime/RegExpConstructor.lut.h \ + JavaScriptCore/runtime/RegExpObject.lut.h \ + JavaScriptCore/runtime/StringPrototype.lut.h \ + JavaScriptCore/pcre/chartables.c \ + Programs/jsc \ + Programs/minidom diff --git a/Info.plist b/Info.plist index 1bb58dc..17949b0 100644 --- a/Info.plist +++ b/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${PRODUCT_NAME} CFBundleGetInfoString - ${BUNDLE_VERSION}, Copyright 2003-2007 Apple Inc.; Copyright 1999-2001 Harri Porten <porten@kde.org>; Copyright 2001 Peter Kelly <pmk@post.com>; Copyright 1997-2005 University of Cambridge; Copyright 1991, 2000, 2001 by Lucent Technologies. + ${BUNDLE_VERSION}, Copyright 2003-2009 Apple Inc.; Copyright 1999-2001 Harri Porten <porten@kde.org>; Copyright 2001 Peter Kelly <pmk@post.com>; Copyright 1997-2005 University of Cambridge; Copyright 1991, 2000, 2001 by Lucent Technologies. CFBundleIdentifier com.apple.${PRODUCT_NAME} CFBundleInfoDictionaryVersion @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - ${BUNDLE_VERSION} + ${SHORT_VERSION_STRING} CFBundleVersion ${BUNDLE_VERSION} diff --git a/JavaScriptCore.exp b/JavaScriptCore.exp index 123f80e..5e1bb78 100644 --- a/JavaScriptCore.exp +++ b/JavaScriptCore.exp @@ -3,9 +3,15 @@ _JSClassCreate _JSClassRelease _JSClassRetain _JSContextGetGlobalObject +_JSContextGetGroup +_JSContextGroupCreate +_JSContextGroupRelease +_JSContextGroupRetain +_JSEndProfiling _JSEvaluateScript _JSGarbageCollect _JSGlobalContextCreate +_JSGlobalContextCreateInGroup _JSGlobalContextRelease _JSGlobalContextRetain _JSObjectCallAsConstructor @@ -20,9 +26,13 @@ _JSObjectHasProperty _JSObjectIsConstructor _JSObjectIsFunction _JSObjectMake +_JSObjectMakeArray _JSObjectMakeConstructor +_JSObjectMakeDate +_JSObjectMakeError _JSObjectMakeFunction _JSObjectMakeFunctionWithCallback +_JSObjectMakeRegExp _JSObjectSetPrivate _JSObjectSetProperty _JSObjectSetPropertyAtIndex @@ -32,6 +42,8 @@ _JSPropertyNameArrayGetCount _JSPropertyNameArrayGetNameAtIndex _JSPropertyNameArrayRelease _JSPropertyNameArrayRetain +_JSReportExtraMemoryCost +_JSStartProfiling _JSStringCopyCFString _JSStringCreateWithCFString _JSStringCreateWithCharacters @@ -73,221 +85,285 @@ _WTFReportAssertionFailure _WTFReportAssertionFailureWithMessage _WTFReportError _WTFReportFatalError -#__NPN_CreateObject -#__NPN_DeallocateObject -#__NPN_Enumerate -#__NPN_Evaluate -#__NPN_GetIntIdentifier -#__NPN_GetProperty -#__NPN_GetStringIdentifier -#__NPN_GetStringIdentifiers -#__NPN_IdentifierIsString -#__NPN_Invoke -#__NPN_InvokeDefault -#__NPN_ReleaseObject -#__NPN_ReleaseVariantValue -#__NPN_RemoveProperty -#__NPN_RetainObject -#__NPN_SetException -#__NPN_SetProperty -#__NPN_UTF8FromIdentifier __Z12jsRegExpFreeP8JSRegExp __Z15jsRegExpCompilePKti24JSRegExpIgnoreCaseOption23JSRegExpMultilineOptionPjPPKc __Z15jsRegExpExecutePK8JSRegExpPKtiiPii -#__Z23_NPN_CreateScriptObjectP4_NPPPN3KJS8JSObjectEN3WTF10PassRefPtrINS1_8Bindings10RootObjectEEE -#__Z25_NPN_CreateNoScriptObjectv -__ZN3KJS10Identifier11addSlowCaseEPNS_7UString3RepE -__ZN3KJS10Identifier3addEPKNS_5UCharEi -__ZN3KJS10Identifier3addEPKc -__ZN3KJS10Identifier5equalEPKNS_7UString3RepEPKc -__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeE -__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc -__ZN3KJS11Interpreter11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeE -__ZN3KJS11Interpreter21shouldPrintExceptionsEv -__ZN3KJS11Interpreter24setShouldPrintExceptionsEb -__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_10SourceCodeEPNS_7JSValueE -__ZN3KJS11JSImmediate4typeEPKNS_7JSValueE -__ZN3KJS11JSImmediate8toObjectEPKNS_7JSValueEPNS_9ExecStateE -__ZN3KJS11JSImmediate8toStringEPKNS_7JSValueE -__ZN3KJS11ProgramNode6createERKNS_10SourceCodeEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS7_IPNS_12FuncDeclNodeELm16EEE -__ZN3KJS11PropertyMap11getLocationERKNS_10IdentifierE -__ZN3KJS11PropertyMap5clearEv -__ZN3KJS11PropertyMap7restoreERKNS_15SavedPropertiesE -__ZN3KJS11PropertyMapD1Ev -__ZN3KJS12DateInstance4infoE -__ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_ -__ZN3KJS12jsNumberCellEd -__ZN3KJS13ArrayInstance4infoE -__ZN3KJS13StatementNode6setLocEii -__ZN3KJS13jsOwnedStringERKNS_7UStringE -__ZN3KJS14JSGlobalObject10globalExecEv -__ZN3KJS14JSGlobalObject15restoreBuiltinsERKNS_13SavedBuiltinsE -__ZN3KJS14JSGlobalObject16stopTimeoutCheckEv -__ZN3KJS14JSGlobalObject17startTimeoutCheckEv -__ZN3KJS14JSGlobalObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS14JSGlobalObject4initEv -__ZN3KJS14JSGlobalObject4markEv -__ZN3KJS14JSGlobalObject5resetEPNS_7JSValueE -__ZN3KJS14JSGlobalObject6s_headE -__ZN3KJS14JSGlobalObjectD2Ev -__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE -__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE -__ZN3KJS14StringInstance3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS14StringInstance4infoE -__ZN3KJS14StringInstanceC1EPNS_8JSObjectERKNS_7UStringE -__ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE -__ZN3KJS15GlobalExecStateC1EPNS_14JSGlobalObjectE -__ZN3KJS15JSWrapperObject4markEv -__ZN3KJS15SavedPropertiesC1Ev -__ZN3KJS15SavedPropertiesD1Ev -__ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE -__ZN3KJS16JSVariableObject19restoreLocalStorageERKNS_15SavedPropertiesE -__ZN3KJS16ParserRefCounted3refEv -__ZN3KJS16ParserRefCounted5derefEv -__ZN3KJS16RuntimeObjectImp4infoE -__ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE -__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectERKNS_4ListEE -__ZN3KJS19InternalFunctionImp4infoE -__ZN3KJS19InternalFunctionImpC2EPNS_17FunctionPrototypeERKNS_10IdentifierE -__ZN3KJS23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS4List15expandAndAppendEPNS_7JSValueE -__ZN3KJS4List7markSetEv -__ZN3KJS6JSCell9getObjectEv -__ZN3KJS6JSCellnwEm -__ZN3KJS6JSLock12DropAllLocksC1Ev -__ZN3KJS6JSLock12DropAllLocksD1Ev -__ZN3KJS6JSLock14registerThreadEv -__ZN3KJS6JSLock4lockEv -__ZN3KJS6JSLock6unlockEv -__ZN3KJS6JSLock9lockCountEv -__ZN3KJS6Lookup9findEntryEPKNS_9HashTableERKNS_10IdentifierE -__ZN3KJS6Parser5parseEPiPNS_7UStringE -__ZN3KJS6parserEv -__ZN3KJS7CStringD1Ev -__ZN3KJS7UString3Rep4nullE -__ZN3KJS7UString3Rep7destroyEv -__ZN3KJS7UString4fromEj -__ZN3KJS7UString6appendERKS0_ -__ZN3KJS7UStringC1EPKNS_5UCharEi -__ZN3KJS7UStringC1EPKc -__ZN3KJS7UStringC1ERKS0_S2_ -__ZN3KJS7UStringaSEPKc -__ZN3KJS8Bindings10RootObject10invalidateEv -__ZN3KJS8Bindings10RootObject11gcUnprotectEPNS_8JSObjectE -__ZN3KJS8Bindings10RootObject17_createRootObjectE -__ZN3KJS8Bindings10RootObject19setCreateRootObjectEPFN3WTF10PassRefPtrIS1_EEPvE -__ZN3KJS8Bindings10RootObject6createEPKvPNS_14JSGlobalObjectE -__ZN3KJS8Bindings10RootObject9gcProtectEPNS_8JSObjectE -__ZN3KJS8Bindings10RootObjectD1Ev -__ZN3KJS8Bindings10throwErrorEPNS_9ExecStateENS_9ErrorTypeEP8NSString -__ZN3KJS8Bindings23convertObjcValueToValueEPNS_9ExecStateEPvNS0_13ObjcValueTypeEPNS0_10RootObjectE -__ZN3KJS8Bindings23convertValueToObjcValueEPNS_9ExecStateEPNS_7JSValueENS0_13ObjcValueTypeE -__ZN3KJS8Bindings24findProtectingRootObjectEPNS_8JSObjectE -__ZN3KJS8Bindings8Instance18didExecuteFunctionEv -__ZN3KJS8Bindings8Instance19createRuntimeObjectEPS1_ -__ZN3KJS8Bindings8Instance21setDidExecuteFunctionEPFvPNS_9ExecStateEPNS_8JSObjectEE -__ZN3KJS8Bindings8Instance32createBindingForLanguageInstanceENS1_15BindingLanguageEPvN3WTF10PassRefPtrINS0_10RootObjectEEE -__ZN3KJS8Debugger6attachEPNS_14JSGlobalObjectE -__ZN3KJS8Debugger12sourceUnusedEPNS_9ExecStateEl -__ZN3KJS8DebuggerC2Ev -__ZN3KJS8DebuggerD2Ev -__ZN3KJS8JSObject11hasInstanceEPNS_9ExecStateEPNS_7JSValueE -__ZN3KJS8JSObject12removeDirectERKNS_10IdentifierE -__ZN3KJS8JSObject14callAsFunctionEPNS_9ExecStateEPS0_RKNS_4ListE -__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj -__ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE -__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE -__ZN3KJS8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRPNS_7JSValueE -__ZN3KJS8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPPNS_7JSValueE -__ZN3KJS8JSObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS8JSObject3putEPNS_9ExecStateEjPNS_7JSValueEi -__ZN3KJS8JSObject4callEPNS_9ExecStateEPS0_RKNS_4ListE -__ZN3KJS8JSObject4markEv -__ZN3KJS8JSObject9constructEPNS_9ExecStateERKNS_4ListE -__ZN3KJS8JSObject9constructEPNS_9ExecStateERKNS_4ListERKNS_10IdentifierERKNS_7UStringEi -__ZN3KJS8JSObject9putDirectERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS8JSObject9putDirectERKNS_10IdentifierEii -__ZN3KJS8jsStringEPKc -__ZN3KJS8jsStringERKNS_7UStringE -__ZN3KJS9Collector15recordExtraCostEm -__ZN3KJS9Collector17globalObjectCountEv -__ZN3KJS9Collector20protectedObjectCountEv -__ZN3KJS9Collector23collectOnMainThreadOnlyEPNS_7JSValueE -__ZN3KJS9Collector25protectedObjectTypeCountsEv -__ZN3KJS9Collector26protectedGlobalObjectCountEv -__ZN3KJS9Collector4sizeEv -__ZN3KJS9Collector7collectEv -__ZN3KJS9Collector7protectEPNS_7JSValueE -__ZN3KJS9Collector9unprotectEPNS_7JSValueE -__ZN3KJS9ExecState16activeExecStatesEv -__ZN3KJSeqERKNS_7UStringEPKc +__ZN14OpaqueJSString6createERKN3JSC7UStringE +__ZN3JSC10Identifier11addSlowCaseEPNS_12JSGlobalDataEPNS_7UString3RepE +__ZN3JSC10Identifier11addSlowCaseEPNS_9ExecStateEPNS_7UString3RepE +__ZN3JSC10Identifier24checkSameIdentifierTableEPNS_12JSGlobalDataEPNS_7UString3RepE +__ZN3JSC10Identifier24checkSameIdentifierTableEPNS_9ExecStateEPNS_7UString3RepE +__ZN3JSC10Identifier3addEPNS_9ExecStateEPKc +__ZN3JSC10Identifier5equalEPKNS_7UString3RepEPKc +__ZN3JSC10JSFunction4infoE +__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeE +__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc +__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringE +__ZN3JSC11JSByteArray15createStructureENS_10JSValuePtrE +__ZN3JSC11JSByteArrayC1EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS3_9ByteArrayEPKNS_9ClassInfoE +__ZN3JSC11JSImmediate12nonInlineNaNEv +__ZN3JSC11JSImmediate8toObjectENS_10JSValuePtrEPNS_9ExecStateE +__ZN3JSC11JSImmediate8toStringENS_10JSValuePtrE +__ZN3JSC11JSImmediate9prototypeENS_10JSValuePtrEPNS_9ExecStateE +__ZN3JSC11ProfileNode4sortEPFbRKN3WTF6RefPtrIS0_EES5_E +__ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeE +__ZN3JSC12DateInstance4infoE +__ZN3JSC12JSGlobalData10ClientDataD2Ev +__ZN3JSC12JSGlobalData12createLeakedEv +__ZN3JSC12JSGlobalData14sharedInstanceEv +__ZN3JSC12JSGlobalData6createEv +__ZN3JSC12JSGlobalDataD1Ev +__ZN3JSC12SamplingTool13notifyOfScopeEPNS_9ScopeNodeE +__ZN3JSC12SamplingTool4dumpEPNS_9ExecStateE +__ZN3JSC12SamplingTool4stopEv +__ZN3JSC12SamplingTool5startEj +__ZN3JSC12SmallStrings17createEmptyStringEPNS_12JSGlobalDataE +__ZN3JSC12StringObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC12StringObject14toThisJSStringEPNS_9ExecStateE +__ZN3JSC12StringObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE +__ZN3JSC12StringObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC12StringObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC12StringObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC12StringObject4infoE +__ZN3JSC12StringObjectC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEERKNS_7UStringE +__ZN3JSC12jsNumberCellEPNS_9ExecStateEd +__ZN3JSC13StatementNode6setLocEii +__ZN3JSC13jsOwnedStringEPNS_12JSGlobalDataERKNS_7UStringE +__ZN3JSC14JSGlobalObject10globalExecEv +__ZN3JSC14JSGlobalObject12defineGetterEPNS_9ExecStateERKNS_10IdentifierEPNS_8JSObjectE +__ZN3JSC14JSGlobalObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPNS_8JSObjectE +__ZN3JSC14JSGlobalObject14setTimeoutTimeEj +__ZN3JSC14JSGlobalObject16stopTimeoutCheckEv +__ZN3JSC14JSGlobalObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrEj +__ZN3JSC14JSGlobalObject17startTimeoutCheckEv +__ZN3JSC14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC14JSGlobalObject4initEPNS_8JSObjectE +__ZN3JSC14JSGlobalObject4markEv +__ZN3JSC14JSGlobalObjectD2Ev +__ZN3JSC14JSGlobalObjectnwEmPNS_12JSGlobalDataE +__ZN3JSC14constructArrayEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSC15JSWrapperObject4markEv +__ZN3JSC15toInt32SlowCaseEdRb +__ZN3JSC16FunctionBodyNode13finishParsingEPNS_10IdentifierEm +__ZN3JSC16FunctionBodyNode14copyParametersEv +__ZN3JSC16FunctionBodyNode6createEPNS_12JSGlobalDataEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm0EEEPNS6_INS5_6RefPtrINS_12FuncDeclNodeEEELm0EEERKNS_10SourceCodeEji +__ZN3JSC16InternalFunction4infoE +__ZN3JSC16InternalFunction4nameEPNS_12JSGlobalDataE +__ZN3JSC16InternalFunctionC2EPNS_12JSGlobalDataEN3WTF10PassRefPtrINS_9StructureEEERKNS_10IdentifierE +__ZN3JSC16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE +__ZN3JSC16ParserRefCounted3refEv +__ZN3JSC16ParserRefCounted5derefEv +__ZN3JSC16toUInt32SlowCaseEdRb +__ZN3JSC17BytecodeGenerator21setDumpsGeneratedCodeEb +__ZN3JSC17PropertyNameArray3addEPNS_7UString3RepE +__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_10JSValuePtrES2_PNS_8JSObjectESA_RKNS_7ArgListEE +__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFNS_10JSValuePtrES2_PNS_8JSObjectES6_RKNS_7ArgListEE +__ZN3JSC17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi +__ZN3JSC18DebuggerActivationC1EPNS_8JSObjectE +__ZN3JSC19constructEmptyArrayEPNS_9ExecStateE +__ZN3JSC19initializeThreadingEv +__ZN3JSC20constructEmptyObjectEPNS_9ExecStateE +__ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC25evaluateInGlobalCallFrameERKNS_7UStringERNS_10JSValuePtrEPNS_14JSGlobalObjectE +__ZN3JSC4Heap11objectCountEv +__ZN3JSC4Heap14allocateNumberEm +__ZN3JSC4Heap14primaryHeapEndEv +__ZN3JSC4Heap15recordExtraCostEm +__ZN3JSC4Heap16primaryHeapBeginEv +__ZN3JSC4Heap17globalObjectCountEv +__ZN3JSC4Heap20protectedObjectCountEv +__ZN3JSC4Heap24setGCProtectNeedsLockingEv +__ZN3JSC4Heap25protectedObjectTypeCountsEv +__ZN3JSC4Heap26protectedGlobalObjectCountEv +__ZN3JSC4Heap4heapENS_10JSValuePtrE +__ZN3JSC4Heap6isBusyEv +__ZN3JSC4Heap7collectEv +__ZN3JSC4Heap7destroyEv +__ZN3JSC4Heap7protectENS_10JSValuePtrE +__ZN3JSC4Heap8allocateEm +__ZN3JSC4Heap9unprotectENS_10JSValuePtrE +__ZN3JSC4callEPNS_9ExecStateENS_10JSValuePtrENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE +__ZN3JSC5equalEPKNS_7UString3RepES3_ +__ZN3JSC6JSCell11getCallDataERNS_8CallDataE +__ZN3JSC6JSCell11getJSNumberEv +__ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateEj +__ZN3JSC6JSCell14toThisJSStringEPNS_9ExecStateE +__ZN3JSC6JSCell16getConstructDataERNS_13ConstructDataE +__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC6JSCell3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC6JSCell3putEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3JSC6JSCell9getObjectEv +__ZN3JSC6JSCellnwEmPNS_9ExecStateE +__ZN3JSC6JSLock12DropAllLocksC1EPNS_9ExecStateE +__ZN3JSC6JSLock12DropAllLocksC1Eb +__ZN3JSC6JSLock12DropAllLocksD1Ev +__ZN3JSC6JSLock4lockEb +__ZN3JSC6JSLock6unlockEb +__ZN3JSC6JSLock9lockCountEv +__ZN3JSC6JSLockC1EPNS_9ExecStateE +__ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE +__ZN3JSC7ArgList10slowAppendENS_10JSValuePtrE +__ZN3JSC7CStringD1Ev +__ZN3JSC7CStringaSERKS0_ +__ZN3JSC7JSArray4infoE +__ZN3JSC7Profile10restoreAllEv +__ZN3JSC7Profile5focusEPKNS_11ProfileNodeE +__ZN3JSC7Profile7excludeEPKNS_11ProfileNodeE +__ZN3JSC7Profile7forEachEMNS_11ProfileNodeEFvvE +__ZN3JSC7UString3Rep11computeHashEPKti +__ZN3JSC7UString3Rep14nullBaseStringE +__ZN3JSC7UString3Rep7destroyEv +__ZN3JSC7UString4fromEi +__ZN3JSC7UString4fromEj +__ZN3JSC7UString6appendEPKc +__ZN3JSC7UString6appendERKS0_ +__ZN3JSC7UStringC1EPKc +__ZN3JSC7UStringC1EPKti +__ZN3JSC7UStringaSEPKc +__ZN3JSC8Debugger6attachEPNS_14JSGlobalObjectE +__ZN3JSC8Debugger6detachEPNS_14JSGlobalObjectE +__ZN3JSC8DebuggerC2Ev +__ZN3JSC8DebuggerD2Ev +__ZN3JSC8JSObject11hasInstanceEPNS_9ExecStateENS_10JSValuePtrES3_ +__ZN3JSC8JSObject12defineGetterEPNS_9ExecStateERKNS_10IdentifierEPS0_ +__ZN3JSC8JSObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPS0_ +__ZN3JSC8JSObject12lookupGetterEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC8JSObject12lookupSetterEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC8JSObject14deletePropertyEPNS_9ExecStateEj +__ZN3JSC8JSObject15unwrappedObjectEv +__ZN3JSC8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE +__ZN3JSC8JSObject17createInheritorIDEv +__ZN3JSC8JSObject17putDirectFunctionEPNS_9ExecStateEPNS_16InternalFunctionEj +__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrEj +__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateEjNS_10JSValuePtrEj +__ZN3JSC8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRNS_10JSValuePtrE +__ZN3JSC8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPNS_10JSValuePtrE +__ZN3JSC8JSObject23allocatePropertyStorageEmm +__ZN3JSC8JSObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC8JSObject3putEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3JSC8JSObject4markEv +__ZN3JSC8Profiler13stopProfilingEPNS_9ExecStateERKNS_7UStringE +__ZN3JSC8Profiler14startProfilingEPNS_9ExecStateERKNS_7UStringE +__ZN3JSC8Profiler8profilerEv +__ZN3JSC8evaluateEPNS_9ExecStateERNS_10ScopeChainERKNS_10SourceCodeENS_10JSValuePtrE +__ZN3JSC8jsStringEPNS_12JSGlobalDataERKNS_7UStringE +__ZN3JSC9CodeBlockD1Ev +__ZN3JSC9CodeBlockD2Ev +__ZN3JSC9Structure17stopIgnoringLeaksEv +__ZN3JSC9Structure18startIgnoringLeaksEv +__ZN3JSC9Structure21addPropertyTransitionEPS0_RKNS_10IdentifierEjRm +__ZN3JSC9Structure22materializePropertyMapEv +__ZN3JSC9Structure25changePrototypeTransitionEPS0_NS_10JSValuePtrE +__ZN3JSC9Structure28addPropertyWithoutTransitionERKNS_10IdentifierEj +__ZN3JSC9Structure3getERKNS_10IdentifierERj +__ZN3JSC9Structure40addPropertyTransitionToExistingStructureEPS0_RKNS_10IdentifierEjRm +__ZN3JSC9StructureC1ENS_10JSValuePtrERKNS_8TypeInfoE +__ZN3JSC9StructureD1Ev +__ZN3JSC9constructEPNS_9ExecStateENS_10JSValuePtrENS_13ConstructTypeERKNS_13ConstructDataERKNS_7ArgListE +__ZN3JSCeqERKNS_7UStringEPKc +__ZN3JSCeqERKNS_7UStringES2_ +__ZN3JSCgtERKNS_7UStringES2_ +__ZN3JSCltERKNS_7UStringES2_ __ZN3WTF10fastCallocEmm __ZN3WTF10fastMallocEm +__ZN3WTF11currentTimeEv __ZN3WTF11fastReallocEPvm +__ZN3WTF12createThreadEPFPvS0_ES0_ +__ZN3WTF12createThreadEPFPvS0_ES0_PKc +__ZN3WTF12detachThreadEj +__ZN3WTF12isMainThreadEv +__ZN3WTF12randomNumberEv +__ZN3WTF13currentThreadEv +__ZN3WTF13tryFastCallocEmm +__ZN3WTF15ThreadCondition4waitERNS_5MutexE +__ZN3WTF15ThreadCondition6signalEv +__ZN3WTF15ThreadCondition9broadcastEv +__ZN3WTF15ThreadConditionC1Ev +__ZN3WTF15ThreadConditionD1Ev +__ZN3WTF16callOnMainThreadEPFvPvES0_ __ZN3WTF16fastZeroedMallocEm +__ZN3WTF19initializeThreadingEv +__ZN3WTF20fastMallocStatisticsEv +__ZN3WTF21RefCountedLeakCounter16suppressMessagesEPKc +__ZN3WTF21RefCountedLeakCounter24cancelMessageSuppressionEPKc +__ZN3WTF21RefCountedLeakCounter9decrementEv +__ZN3WTF21RefCountedLeakCounter9incrementEv +__ZN3WTF21RefCountedLeakCounterC1EPKc +__ZN3WTF21RefCountedLeakCounterD1Ev +__ZN3WTF23waitForThreadCompletionEjPPv __ZN3WTF27releaseFastMallocFreeMemoryEv +__ZN3WTF28setMainThreadCallbacksPausedEb +__ZN3WTF36lockAtomicallyInitializedStaticMutexEv +__ZN3WTF38unlockAtomicallyInitializedStaticMutexEv +__ZN3WTF5Mutex4lockEv +__ZN3WTF5Mutex6unlockEv +__ZN3WTF5Mutex7tryLockEv +__ZN3WTF5MutexC1Ev +__ZN3WTF5MutexD1Ev +__ZN3WTF6strtodEPKcPPc +__ZN3WTF7Unicode18convertUTF16ToUTF8EPPKtS2_PPcS4_b +__ZN3WTF8Collator18setOrderLowerFirstEb +__ZN3WTF8CollatorC1EPKc +__ZN3WTF8CollatorD1Ev __ZN3WTF8fastFreeEPv -__ZNK3KJS11PropertyMap3getERKNS_10IdentifierE -__ZNK3KJS11PropertyMap4saveERNS_15SavedPropertiesE -__ZNK3KJS12DateInstance7getTimeERdRi -__ZNK3KJS13ArrayInstance7getItemEj -__ZNK3KJS14JSGlobalObject12saveBuiltinsERNS_13SavedBuiltinsE -__ZNK3KJS16JSVariableObject16saveLocalStorageERNS_15SavedPropertiesE -__ZNK3KJS19InternalFunctionImp14implementsCallEv -__ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv -__ZNK3KJS4List8getSliceEiRS0_ -__ZN3KJS4Node8toStringEv -__ZNK3KJS6JSCell17getTruncatedInt32ERi -__ZNK3KJS6JSCell18getTruncatedUInt32ERj -__ZNK3KJS6JSCell9getNumberERd -__ZNK3KJS6JSCell9getNumberEv -__ZNK3KJS6JSCell9getStringERNS_7UStringE -__ZNK3KJS6JSCell9getStringEv -__ZNK3KJS6JSCell9getUInt32ERj -__ZNK3KJS7JSValue15toInt32SlowCaseEPNS_9ExecStateERb -__ZNK3KJS7JSValue16toUInt32SlowCaseEPNS_9ExecStateERb -__ZNK3KJS7JSValue7toFloatEPNS_9ExecStateE -__ZNK3KJS7JSValue9toIntegerEPNS_9ExecStateE -__ZNK3KJS7UString10UTF8StringEb -__ZNK3KJS7UString14toStrictUInt32EPb -__ZNK3KJS7UString5asciiEv -__ZNK3KJS7UString6is8BitEv -__ZNK3KJS7UString6substrEii -__ZNK3KJS7UString8toUInt32EPb -__ZNK3KJS7UString8toUInt32EPbb -__ZNK3KJS8Bindings10RootObject12globalObjectEv -__ZNK3KJS8Bindings8Instance10rootObjectEv -__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE -__ZNK3KJS8JSObject14implementsCallEv -__ZNK3KJS8JSObject19implementsConstructEv -__ZNK3KJS8JSObject21implementsHasInstanceEv -__ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE -__ZNK3KJS8JSObject3getEPNS_9ExecStateEj -__ZNK3KJS8JSObject4typeEv -__ZNK3KJS8JSObject6canPutEPNS_9ExecStateERKNS_10IdentifierE -__ZNK3KJS8JSObject8toNumberEPNS_9ExecStateE -__ZNK3KJS8JSObject8toObjectEPNS_9ExecStateE -__ZNK3KJS8JSObject8toStringEPNS_9ExecStateE -__ZNK3KJS8JSObject9classInfoEv -__ZNK3KJS8JSObject9classNameEv -__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE -__ZNK3KJS9ExecState19lexicalGlobalObjectEv -__ZTVN3KJS14JSGlobalObjectE -__ZTVN3KJS14StringInstanceE -__ZTVN3KJS15JSWrapperObjectE -__ZTVN3KJS16JSVariableObjectE -__ZTVN3KJS19InternalFunctionImpE -__ZTVN3KJS8JSObjectE -_jscore_collector_introspection +__ZN3WTF9ByteArray6createEm +__ZNK3JSC10JSValuePtr9toIntegerEPNS_9ExecStateE +__ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_16InternalFunctionE +__ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_10JSValuePtrE +__ZNK3JSC12DateInstance7getTimeERdRi +__ZNK3JSC12StringObject12toThisStringEPNS_9ExecStateE +__ZNK3JSC12StringObject8toStringEPNS_9ExecStateE +__ZNK3JSC14JSGlobalObject14isDynamicScopeEv +__ZNK3JSC16InternalFunction9classInfoEv +__ZNK3JSC16JSVariableObject16isVariableObjectEv +__ZNK3JSC16JSVariableObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj +__ZNK3JSC17DebuggerCallFrame10thisObjectEv +__ZNK3JSC17DebuggerCallFrame12functionNameEv +__ZNK3JSC17DebuggerCallFrame4typeEv +__ZNK3JSC17DebuggerCallFrame8evaluateERKNS_7UStringERNS_10JSValuePtrE +__ZNK3JSC4Heap10statisticsEv +__ZNK3JSC6JSCell12toThisObjectEPNS_9ExecStateE +__ZNK3JSC6JSCell12toThisStringEPNS_9ExecStateE +__ZNK3JSC6JSCell14isGetterSetterEv +__ZNK3JSC6JSCell17getTruncatedInt32ERi +__ZNK3JSC6JSCell18getTruncatedUInt32ERj +__ZNK3JSC6JSCell9classInfoEv +__ZNK3JSC6JSCell9getStringERNS_7UStringE +__ZNK3JSC6JSCell9getStringEv +__ZNK3JSC6JSCell9getUInt32ERj +__ZNK3JSC7ArgList8getSliceEiRS0_ +__ZNK3JSC7UString10UTF8StringEb +__ZNK3JSC7UString14toStrictUInt32EPb +__ZNK3JSC7UString5asciiEv +__ZNK3JSC7UString6is8BitEv +__ZNK3JSC7UString6substrEii +__ZNK3JSC7UString8toUInt32EPb +__ZNK3JSC7UString8toUInt32EPbb +__ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateEj +__ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE +__ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE +__ZNK3JSC8JSObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj +__ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE +__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateE +__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE +__ZNK3JSC8JSObject9classNameEv +__ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE +__ZNK3JSC9HashTable11createTableEPNS_12JSGlobalDataE +__ZNK3JSC9HashTable11deleteTableEv +__ZNK3WTF8Collator7collateEPKtmS2_m +__ZTVN3JSC12StringObjectE +__ZTVN3JSC14JSGlobalObjectE +__ZTVN3JSC15JSWrapperObjectE +__ZTVN3JSC16InternalFunctionE +__ZTVN3JSC16JSVariableObjectE +__ZTVN3JSC8JSObjectE +__ZTVN3JSC8JSStringE _jscore_fastmalloc_introspection _kJSClassDefinitionEmpty -_kjs_strtod -_JSLockDropAllLocks -_JSLockRecoverAllLocks -_JSSetJavaScriptCollectionThread diff --git a/JavaScriptCore.iPhone.order b/JavaScriptCore.iPhone.order new file mode 100644 index 0000000..7be22ae --- /dev/null +++ b/JavaScriptCore.iPhone.order @@ -0,0 +1,806 @@ +__ZN3JSC19initializeThreadingEv +dyld_stub_binding_helper +__ZN3JSCL23initializeThreadingOnceEv +__ZN3WTF19initializeThreadingEv +__ZN3WTF10fastMallocEm +__ZN3WTF10fastMallocILb1EEEPvm +__ZN3WTF20TCMalloc_ThreadCache10InitModuleEv +__ZN3WTFL15InitSizeClassesEv +__Z20TCMalloc_SystemAllocmPmm +__ZN3WTF20TCMalloc_ThreadCache22CreateCacheIfNecessaryEv +__ZN3WTF25TCMalloc_Central_FreeList11RemoveRangeEPPvS2_Pi +__ZN3WTF25TCMalloc_Central_FreeList18FetchFromSpansSafeEv +__ZN3WTF17TCMalloc_PageHeap10AllocLargeEm +__ZN3WTF17TCMalloc_PageHeap8GrowHeapEm +__ZN3WTFL13MetaDataAllocEm +__Z22TCMalloc_SystemReleasePvm +__ZN3WTFL25identifierByPthreadHandleERKP17_opaque_pthread_t +__ZN3WTFL35establishIdentifierForPthreadHandleERP17_opaque_pthread_t +__ZN3WTF9HashTableIjSt4pairIjP17_opaque_pthread_tENS_18PairFirstExtractorIS4_EENS_7IntHashIjEENS_14PairHashTraitsINS_10HashTraitsIjEENSA_IS3_EEEESB_E6rehashEi +__ZN3WTF16fastZeroedMallocEm +__ZN3WTF8fastFreeEPv +__ZN3WTF22initializeMainNSThreadEv +__ZN3WTF20initializeMainThreadEv +__ZN3WTF5MutexC1Ev +__ZN3JSC17initializeUStringEv +__ZN3JSC12initDateMathEv +__ZN3WTF11currentTimeEv +__ZN3WTF14FastMallocZone4sizeEP14_malloc_zone_tPKv +__ZN3WTF20TCMalloc_ThreadCache18DestroyThreadCacheEPv +__ZN3WTF20TCMalloc_ThreadCache11DeleteCacheEPS0_ +__ZN3WTF25TCMalloc_Central_FreeList11InsertRangeEPvS1_i +__ZN3WTF25TCMalloc_Central_FreeList18ReleaseListToSpansEPv +__ZN3WTF36lockAtomicallyInitializedStaticMutexEv +__ZN3WTF38unlockAtomicallyInitializedStaticMutexEv +__ZN3JSC8DebuggerC2Ev +__ZN3WTF5Mutex4lockEv +__ZN3WTF5Mutex6unlockEv +__ZN3WTF6strtodEPKcPPc +__ZN3JSC6JSLock12DropAllLocksC1Eb +__ZN3JSCL17createJSLockCountEv +__ZN3JSC6JSLock12DropAllLocksD1Ev +__ZN3WTF15ThreadConditionC1Ev +__ZN3WTF12createThreadEPFPvS0_ES0_PKc +__ZN3WTF20createThreadInternalEPFPvS0_ES0_PKc +__ZN3WTF15ThreadCondition4waitERNS_5MutexE +__ZN3WTFL16threadEntryPointEPv +__ZN3WTF5MutexD1Ev +__ZN3WTF13currentThreadEv +__ZN3WTF15ThreadCondition9broadcastEv +__ZN3WTF15ThreadCondition6signalEv +__ZN3WTF16callOnMainThreadEPFvPvES0_ +__ZN3WTF6VectorINS_19FunctionWithContextELm0EE14expandCapacityEm +__ZN3WTF37scheduleDispatchFunctionsOnMainThreadEv +__ZN3WTF12mainNSThreadEv +-[WTFMainThreadCaller call] +__ZN3WTF31dispatchFunctionsFromMainThreadEv +__ZN3WTF11fastReallocEPvm +__ZN3WTF11fastReallocILb1EEEPvS1_m +__ZN3WTF25TCMalloc_Central_FreeList11ShrinkCacheEib +__ZN3JSC7UStringC1EPKti +__ZN3JSC7UStringC2EPKti +__ZN3JSC12JSGlobalData12createLeakedEv +__ZN3JSC12JSGlobalDataC2Eb +__ZN3JSC11InterpreterC1Ev +__ZN3JSC11InterpreterC2Ev +__ZN3JSC11Interpreter14privateExecuteENS0_13ExecutionFlagEPNS_12RegisterFileEPNS_9ExecStateEPNS_10JSValuePtrE +__ZN3WTF7HashMapIPvN3JSC8OpcodeIDENS_7PtrHashIS1_EENS_10HashTraitsIS1_EENS6_IS3_EEE3addERKS1_RKS3_ +__ZN3WTF9HashTableIPvSt4pairIS1_N3JSC8OpcodeIDEENS_18PairFirstExtractorIS5_EENS_7PtrHashIS1_EENS_14PairHashTraitsINS_10HashTraitsIS1_EENSB_IS4_EEEESC_E6expandEv +__ZN3JSC9StructureC1ENS_10JSValuePtrERKNS_8TypeInfoE +__ZN3JSC7JSArrayC1EN3WTF10PassRefPtrINS_9StructureEEE +__ZN3JSC7JSArrayD1Ev +__ZN3JSC7JSArrayD2Ev +__ZN3WTF10RefCountedIN3JSC9StructureEE5derefEv +__ZN3JSC9StructureD1Ev +__ZN3JSC9StructureD2Ev +__ZN3JSC11JSByteArray15createStructureENS_10JSValuePtrE +__ZN3JSC11JSByteArrayD1Ev +__ZN3JSC8JSStringD1Ev +__ZN3WTF6RefPtrIN3JSC7UString3RepEED1Ev +__ZN3JSC10JSFunctionD1Ev +__ZN3JSC8JSObjectD2Ev +__ZN3JSC21createIdentifierTableEv +__ZN3JSC17CommonIdentifiersC1EPNS_12JSGlobalDataE +__ZN3JSC17CommonIdentifiersC2EPNS_12JSGlobalDataE +__ZN3JSC10Identifier3addEPNS_12JSGlobalDataEPKc +__ZN3WTF7HashSetIPN3JSC7UString3RepENS_7StrHashIS4_EENS_10HashTraitsIS4_EEE3addIPKcNS1_17CStringTranslatorEEESt4pairINS_24HashTableIteratorAdapterINS_9HashTableIS4_S4_NS_17IdentityExtractorIS4_EES6_S8_S8_EES4_EEbERKT_ +__ZN3WTF9HashTableIPN3JSC7UString3RepES4_NS_17IdentityExtractorIS4_EENS_7StrHashIS4_EENS_10HashTraitsIS4_EESA_E6rehashEi +__ZN3WTF7HashMapIPKcNS_6RefPtrIN3JSC7UString3RepEEENS_7PtrHashIS2_EENS_10HashTraitsIS2_EENSA_IS7_EEE3addERKS2_RKS7_ +__ZN3WTF9HashTableIPKcSt4pairIS2_NS_6RefPtrIN3JSC7UString3RepEEEENS_18PairFirstExtractorIS9_EENS_7PtrHashIS2_EENS_14PairHashTraitsINS_10HashTraitsIS2_EENSF_IS8_EEEESG_E6rehashEi +__ZN3JSC12SmallStringsC1Ev +__ZN3JSC5LexerC1EPNS_12JSGlobalDataE +__ZN3JSC5LexerC2EPNS_12JSGlobalDataE +__ZN3JSC4HeapC1EPNS_12JSGlobalDataE +__ZN3JSC27startProfilerServerIfNeededEv ++[ProfilerServer sharedProfileServer] +-[ProfilerServer init] +__ZN3JSC11Interpreter10initializeEPNS_12JSGlobalDataE +__ZN3JSC4Heap8allocateEm +__ZN3JSCL13allocateBlockILNS_8HeapTypeE0EEEPNS_14CollectorBlockEv +__ZN3JSC14JSGlobalObjectnwEmPNS_12JSGlobalDataE +__ZN3JSC14JSGlobalObject4initEPNS_8JSObjectE +__ZN3JSC14JSGlobalObject5resetENS_10JSValuePtrE +__ZN3JSC4Heap12heapAllocateILNS_8HeapTypeE0EEEPvm +__ZN3JSC17FunctionPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEE +__ZN3JSC8jsStringEPNS_12JSGlobalDataERKNS_7UStringE +__ZN3JSC12SmallStrings17createEmptyStringEPNS_12JSGlobalDataE +__ZN3JSC7UStringC1EPKc +__ZN3JSCL9createRepEPKc +__ZN3JSC8JSObject9putDirectERKNS_10IdentifierENS_10JSValuePtrEjbRNS_15PutPropertySlotE +__ZN3JSC9Structure40addPropertyTransitionToExistingStructureEPS0_RKNS_10IdentifierEjRm +__ZN3JSC9Structure3getERKNS_10IdentifierERj +__ZN3JSC9Structure21addPropertyTransitionEPS0_RKNS_10IdentifierEjRm +__ZN3JSC9Structure3putERKNS_10IdentifierEj +__ZN3JSC9Structure28addPropertyWithoutTransitionERKNS_10IdentifierEj +__ZN3JSC17FunctionPrototype21addFunctionPropertiesEPNS_9ExecStateEPNS_9StructureE +__ZN3JSC17PrototypeFunctionC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_10JSValuePtrES2_PNS_8JSObjectESA_RKNS_7ArgListEE +__ZN3JSC8JSObject34putDirectFunctionWithoutTransitionEPNS_9ExecStateEPNS_16InternalFunctionEj +__ZN3JSC15ObjectPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_ +__ZN3JSC9Structure26rehashPropertyMapHashTableEj +__ZN3JSC15StringPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEE +__ZN3JSC16BooleanPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_ +__ZN3JSC15NumberPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_ +__ZN3JSC12jsNumberCellEPNS_9ExecStateEd +__ZN3JSCL13allocateBlockILNS_8HeapTypeE1EEEPNS_14CollectorBlockEv +__ZN3JSC15RegExpPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_ +__ZN3JSC14ErrorPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_ +__ZN3JSC20NativeErrorPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEERKNS_7UStringES9_ +__ZN3JSC17ObjectConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_15ObjectPrototypeE +__ZN3JSC19FunctionConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_17FunctionPrototypeE +__ZNK3JSC16InternalFunction9classInfoEv +__ZN3JSC16ArrayConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_14ArrayPrototypeE +__ZNK3JSC14ArrayPrototype9classInfoEv +__ZN3JSC17StringConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_PNS_15StringPrototypeE +__ZNK3JSC15StringPrototype9classInfoEv +__ZN3JSC18BooleanConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_16BooleanPrototypeE +__ZNK3JSC13BooleanObject9classInfoEv +__ZN3JSC17NumberConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_15NumberPrototypeE +__ZN3JSC15DateConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_PNS_13DatePrototypeE +__ZNK3JSC13DatePrototype9classInfoEv +__ZN3JSC17RegExpConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_15RegExpPrototypeE +__ZN3JSC16ErrorConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_14ErrorPrototypeE +__ZNK3JSC13ErrorInstance9classInfoEv +__ZN3JSC22NativeErrorConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_20NativeErrorPrototypeE +__ZN3JSC10Identifier11addSlowCaseEPNS_12JSGlobalDataEPNS_7UString3RepE +__ZN3JSC10MathObjectC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEE +__ZN3JSC12SmallStrings24singleCharacterStringRepEh +__ZN3WTF7HashMapINS_6RefPtrIN3JSC7UString3RepEEENS2_16SymbolTableEntryENS2_17IdentifierRepHashENS_10HashTraitsIS5_EENS2_26SymbolTableIndexHashTraitsEE3addEPS4_RKS6_ +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEESt4pairIS5_NS2_16SymbolTableEntryEENS_18PairFirstExtractorIS8_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS_10HashTraitsIS5_EENS2_26SymbolTableIndexHashTraitsEEESE_E6expandEv +__ZN3JSC9Structure25changePrototypeTransitionEPS0_NS_10JSValuePtrE +__ZN3JSC9Structure17copyPropertyTableEv +__ZN3JSC14JSGlobalObject14setTimeoutTimeEj +__ZN3JSC14JSGlobalObject10globalExecEv +__ZN3JSC10Identifier3addEPNS_9ExecStateEPKc +__ZN3JSC4Heap4heapENS_10JSValuePtrE +__ZN3JSC4Heap7protectENS_10JSValuePtrE +__ZN3WTF7HashMapIPN3JSC6JSCellEjNS_7PtrHashIS3_EENS_10HashTraitsIS3_EENS6_IjEEE3addERKS3_RKj +__ZN3WTF9HashTableIPN3JSC6JSCellESt4pairIS3_jENS_18PairFirstExtractorIS5_EENS_7PtrHashIS3_EENS_14PairHashTraitsINS_10HashTraitsIS3_EENSB_IjEEEESC_E6rehashEi +__ZN3JSC6JSCellnwEmPNS_9ExecStateE +__ZN3JSC10Identifier11addSlowCaseEPNS_9ExecStateEPNS_7UString3RepE +__ZNK3JSC9HashTable11createTableEPNS_12JSGlobalDataE +__ZN3JSC14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC8JSObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC14JSGlobalObject17startTimeoutCheckEv +__ZN3JSC11Interpreter17resetTimeoutCheckEv +__ZN3JSC8evaluateEPNS_9ExecStateERNS_10ScopeChainERKNS_10SourceCodeENS_10JSValuePtrE +__ZN3JSC6JSLock4lockEb +__ZN3JSC6Parser5parseINS_11ProgramNodeEEEN3WTF10PassRefPtrIT_EEPNS_9ExecStateEPNS_8DebuggerERKNS_10SourceCodeEPiPNS_7UStringE +__ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE +__ZN3JSC7UStringaSEPKc +__Z10jscyyparsePv +__ZN3JSC5Lexer3lexEPvS1_ +__ZN3WTF6VectorItLm0EE6appendItEEvRKT_ +__ZN3WTF6VectorItLm0EE15reserveCapacityEm +__ZN3JSC10Identifier3addEPNS_12JSGlobalDataEPKti +__ZN3WTF7HashSetIPN3JSC7UString3RepENS_7StrHashIS4_EENS_10HashTraitsIS4_EEE3addINS1_11UCharBufferENS1_21UCharBufferTranslatorEEESt4pairINS_24HashTableIteratorAdapterINS_9HashTableIS4_S4_NS_17IdentityExtractorIS4_EES6_S8_S8_EES4_EEbERKT_ +__ZN3WTF7HashSetIPN3JSC16ParserRefCountedENS_7PtrHashIS3_EENS_10HashTraitsIS3_EEE3addERKS3_ +__ZN3WTF9HashTableIPN3JSC16ParserRefCountedES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E6rehashEi +__ZN3JSC16ParserRefCountedC2EPNS_12JSGlobalDataE +__ZN3JSC16ParserRefCounted3refEv +__ZL14makeAssignNodePvPN3JSC14ExpressionNodeENS0_8OperatorES2_bbiii +__ZNK3JSC11ResolveNode10isLocationEv +__ZNK3JSC11ResolveNode13isResolveNodeEv +__ZN3JSC14SourceElements6appendEN3WTF10PassRefPtrINS_13StatementNodeEEE +__ZNK3JSC13StatementNode16isEmptyStatementEv +__Z21mergeDeclarationListsIPN3JSC20ParserRefCountedDataIN3WTF6VectorINS2_6RefPtrINS0_12FuncDeclNodeEEELm0EEEEEET_SA_SA_ +__ZL20makeFunctionCallNodePvN3JSC8NodeInfoIPNS0_14ExpressionNodeEEENS1_IPNS0_13ArgumentsNodeEEEiii +__ZNK3JSC15DotAccessorNode10isLocationEv +__ZNK3JSC14ExpressionNode13isResolveNodeEv +__ZNK3JSC14ExpressionNode21isBracketAccessorNodeEv +__ZN3WTF7HashMapIPN3JSC16ParserRefCountedEjNS_7PtrHashIS3_EENS_10HashTraitsIS3_EENS6_IjEEE3addERKS3_RKj +__ZN3WTF9HashTableIPN3JSC16ParserRefCountedESt4pairIS3_jENS_18PairFirstExtractorIS5_EENS_7PtrHashIS3_EENS_14PairHashTraitsINS_10HashTraitsIS3_EENSB_IjEEEESC_E6rehashEi +__ZN3JSC6Parser16didFinishParsingEPNS_14SourceElementsEPNS_20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm0EEEEEPNS3_INS5_INS4_6RefPtrINS_12FuncDeclNodeEEELm0EEEEEjii +__ZN3JSC5Lexer5clearEv +__ZN3JSC16ParserRefCounted16deleteNewObjectsEPNS_12JSGlobalDataE +__ZN3JSC11ResolveNodeD0Ev +__ZN3JSC15DotAccessorNodeD0Ev +__ZN3JSC12NodeReleaser15releaseAllNodesEPNS_16ParserRefCountedE +__ZN3JSC15DotAccessorNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC12NodeReleaser7releaseINS_14ExpressionNodeEEEvRN3WTF6RefPtrIT_EE +__ZN3JSC12NodeReleaser5adoptEN3WTF10PassRefPtrINS_16ParserRefCountedEEE +__ZN3JSC16ParserRefCounted9hasOneRefEv +__ZN3JSC16ParserRefCounted5derefEv +__ZN3JSC9ScopeNodeC2EPNS_12JSGlobalDataERKNS_10SourceCodeEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm0EEEPNS9_INS8_6RefPtrINS_12FuncDeclNodeEEELm0EEEji +__ZN3WTF6VectorINS_6RefPtrIN3JSC13StatementNodeEEELm0EE14shrinkCapacityEm +__ZN3JSC14SourceElementsD0Ev +__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateE +__ZN3JSC11Interpreter7executeEPNS_11ProgramNodeEPNS_9ExecStateEPNS_14ScopeChainNodeEPNS_8JSObjectEPNS_10JSValuePtrE +__ZN3JSC11ProgramNode16generateBytecodeEPNS_14ScopeChainNodeE +__ZN3JSC9CodeBlockC2EPNS_9ScopeNodeENS_8CodeTypeEN3WTF10PassRefPtrINS_14SourceProviderEEEj +__ZN3WTF7HashSetIPN3JSC16ProgramCodeBlockENS_7PtrHashIS3_EENS_10HashTraitsIS3_EEE3addERKS3_ +__ZN3WTF9HashTableIPN3JSC16ProgramCodeBlockES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E6rehashEi +__ZN3JSC17BytecodeGeneratorC2EPNS_11ProgramNodeEPKNS_8DebuggerERKNS_10ScopeChainEPN3WTF7HashMapINS9_6RefPtrINS_7UString3RepEEENS_16SymbolTableEntryENS_17IdentifierRepHashENS9_10HashTraitsISE_EENS_26SymbolTableIndexHashTraitsEEEPNS_16ProgramCodeBlockE +__ZN3WTF6VectorIN3JSC11InstructionELm0EE15reserveCapacityEm +__ZN3JSC9Structure22toDictionaryTransitionEPS0_ +__ZN3JSC17BytecodeGenerator11newRegisterEv +__ZN3JSC9Structure24fromDictionaryTransitionEPS0_ +__ZN3JSC17BytecodeGenerator8generateEv +__ZN3JSC11ProgramNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator13emitDebugHookENS_11DebugHookIDEii +__ZN3JSC17BytecodeGenerator11addConstantENS_10JSValuePtrE +__ZN3WTF7HashMapIPN3JSC23JSValueEncodedAsPointerEjNS_7PtrHashIS3_EENS1_17BytecodeGenerator17JSValueHashTraitsENS_10HashTraitsIjEEE3addERKS3_RKj +__ZN3WTF9HashTableIPN3JSC23JSValueEncodedAsPointerESt4pairIS3_jENS_18PairFirstExtractorIS5_EENS_7PtrHashIS3_EENS_14PairHashTraitsINS1_17BytecodeGenerator17JSValueHashTraitsENS_10HashTraitsIjEEEESC_E6rehashEi +__ZN3WTF6VectorIN3JSC8RegisterELm0EE14expandCapacityEm +__ZN3JSC17BytecodeGenerator8emitMoveEPNS_10RegisterIDES2_ +__ZNK3JSC13StatementNode6isLoopEv +__ZN3JSC17BytecodeGenerator8emitNodeEPNS_10RegisterIDEPNS_4NodeE +__ZN3WTF6VectorIN3JSC8LineInfoELm0EE14expandCapacityEm +__ZN3JSC17ExprStatementNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17AssignResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator11registerForERKNS_10IdentifierE +__ZN3JSC17BytecodeGenerator18findScopedPropertyERKNS_10IdentifierERiRmbRPNS_8JSObjectE +__ZN3JSC17BytecodeGenerator15emitResolveBaseEPNS_10RegisterIDERKNS_10IdentifierE +__ZN3JSC17BytecodeGenerator11addConstantERKNS_10IdentifierE +__ZN3WTF7HashMapINS_6RefPtrIN3JSC7UString3RepEEEiNS2_17IdentifierRepHashENS_10HashTraitsIS5_EENS2_17BytecodeGenerator28IdentifierMapIndexHashTraitsEE3addEPS4_RKi +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEESt4pairIS5_iENS_18PairFirstExtractorIS7_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS_10HashTraitsIS5_EENS2_17BytecodeGenerator28IdentifierMapIndexHashTraitsEEESD_E6rehashEi +__ZN3WTF6VectorIN3JSC10IdentifierELm0EE14expandCapacityEm +__ZN3JSC15DotAccessorNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC11ResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3WTF6VectorIN3JSC19ExpressionRangeInfoELm0EE14expandCapacityEm +__ZN3JSC17BytecodeGenerator12newTemporaryEv +__ZN3JSC17BytecodeGenerator11emitResolveEPNS_10RegisterIDERKNS_10IdentifierE +__ZN3WTF6VectorIjLm0EE14expandCapacityEm +__ZN3JSC17BytecodeGenerator11emitGetByIdEPNS_10RegisterIDES2_RKNS_10IdentifierE +__ZN3JSC17BytecodeGenerator11emitPutByIdEPNS_10RegisterIDERKNS_10IdentifierES2_ +__ZN3JSC10StringNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3WTF7HashMapIPN3JSC7UString3RepEPNS1_8JSStringENS1_17IdentifierRepHashENS_10HashTraitsIS4_EENS8_IS6_EEE3addERKS4_RKS6_ +__ZN3WTF9HashTableIPN3JSC7UString3RepESt4pairIS4_PNS1_8JSStringEENS_18PairFirstExtractorIS8_EENS1_17IdentifierRepHashENS_14PairHashTraitsINS_10HashTraitsIS4_EENSD_IS7_EEEESE_E6rehashEi +__ZN3JSC19FunctionCallDotNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3WTF6VectorIN3JSC11InstructionELm0EE6appendIiEEvRKT_ +__ZN3JSC17BytecodeGenerator8emitCallENS_8OpcodeIDEPNS_10RegisterIDES3_S3_PNS_13ArgumentsNodeEjjj +__ZN3JSC16ArgumentListNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator10emitOpcodeENS_8OpcodeIDE +__ZN3JSC12JSGlobalData22numericCompareFunctionEPNS_9ExecStateE +__ZNK3JSC21UStringSourceProvider6lengthEv +__ZNK3JSC21UStringSourceProvider4dataEv +__ZN3JSC16FunctionBodyNode13finishParsingERKNS_10SourceCodeEPNS_13ParameterNodeE +__ZN3JSC19extractFunctionBodyEPNS_11ProgramNodeE +__ZNK3JSC17ExprStatementNode15isExprStatementEv +__ZNK3JSC12FuncExprNode14isFuncExprNodeEv +__ZN3JSC16FunctionBodyNode16generateBytecodeEPNS_14ScopeChainNodeE +__ZN3JSC6Parser14reparseInPlaceEPNS_12JSGlobalDataEPNS_16FunctionBodyNodeE +__ZL11makeSubNodePvPN3JSC14ExpressionNodeES2_b +__ZN3JSC14ExpressionNode14stripUnaryPlusEv +__ZNK3JSC14ExpressionNode8isNumberEv +__ZN3JSC9CodeBlockC1EPNS_9ScopeNodeENS_8CodeTypeEN3WTF10PassRefPtrINS_14SourceProviderEEEj +__ZN3JSC17BytecodeGeneratorC2EPNS_16FunctionBodyNodeEPKNS_8DebuggerERKNS_10ScopeChainEPN3WTF7HashMapINS9_6RefPtrINS_7UString3RepEEENS_16SymbolTableEntryENS_17IdentifierRepHashENS9_10HashTraitsISE_EENS_26SymbolTableIndexHashTraitsEEEPNS_9CodeBlockE +__ZN3JSC17BytecodeGenerator12addParameterERKNS_10IdentifierE +__ZN3JSC16FunctionBodyNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC9BlockNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC10ReturnNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC12BinaryOpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC7SubNode8opcodeIDEv +__ZNK3JSC11ResolveNode6isPureERNS_17BytecodeGeneratorE +__ZN3JSC17BytecodeGenerator12emitBinaryOpENS_8OpcodeIDEPNS_10RegisterIDES3_S3_NS_12OperandTypesE +__ZN3JSC17BytecodeGenerator10emitReturnEPNS_10RegisterIDE +__ZNK3JSC9BlockNode7isBlockEv +__ZNK3JSC10ReturnNode12isReturnNodeEv +__ZN3JSC9CodeBlock11shrinkToFitEv +__ZN3WTF6VectorIN3JSC11InstructionELm0EE14shrinkCapacityEm +__ZN3WTF6VectorIjLm0EE14shrinkCapacityEm +__ZN3WTF6VectorIN3JSC10IdentifierELm0EE14shrinkCapacityEm +__ZN3JSC9BlockNodeD0Ev +__ZN3JSC9BlockNode12releaseNodesERNS_12NodeReleaserE +__ZN3WTF6VectorINS_6RefPtrIN3JSC16ParserRefCountedEEELm0EE15reserveCapacityEm +__ZN3JSC10ReturnNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC12BinaryOpNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC16ParserRefCounted12releaseNodesERNS_12NodeReleaserE +__ZN3JSC10ReturnNodeD0Ev +__ZN3JSC7SubNodeD0Ev +__ZN3JSC12BinaryOpNodeD2Ev +__ZN3JSC17BytecodeGeneratorD2Ev +__ZN3WTF6VectorIN3JSC11InstructionELm0EEaSERKS3_ +__ZN3JSC11ProgramNodeD0Ev +__ZN3JSC9ScopeNodeD2Ev +__ZN3JSC9ScopeNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC17ExprStatementNodeD0Ev +__ZN3JSC12FuncExprNodeD0Ev +__ZN3JSC12FuncExprNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC12NodeReleaser21adoptFunctionBodyNodeERN3WTF6RefPtrINS_16FunctionBodyNodeEEE +__ZN3JSC13ParameterNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13ParameterNodeD0Ev +__ZN3JSC16FunctionBodyNodeD0Ev +__ZN3JSC7UString3Rep7destroyEv +__ZN3JSC10Identifier6removeEPNS_7UString3RepE +__ZN3JSC9CodeBlockD1Ev +__ZN3JSC9CodeBlockD2Ev +__ZN3JSC21UStringSourceProviderD0Ev +__ZN3JSC17AssignResolveNodeD0Ev +__ZN3JSC17AssignResolveNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC10StringNodeD0Ev +__ZN3JSC19FunctionCallDotNodeD0Ev +__ZN3JSC19FunctionCallDotNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13ArgumentsNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC16ArgumentListNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13ArgumentsNodeD0Ev +__ZN3JSC16ArgumentListNodeD0Ev +__ZN3JSC14JSGlobalObject13copyGlobalsToERNS_12RegisterFileE +__ZN3JSC11Interpreter11resolveBaseEPNS_9ExecStateEPNS_11InstructionE +__ZN3JSC11Interpreter13resolveGlobalEPNS_9ExecStateEPNS_11InstructionERNS_10JSValuePtrE +__ZN3JSC11Interpreter15tryCacheGetByIDEPNS_9ExecStateEPNS_9CodeBlockEPNS_11InstructionENS_10JSValuePtrERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSC11Interpreter15tryCachePutByIDEPNS_9ExecStateEPNS_9CodeBlockEPNS_11InstructionENS_10JSValuePtrERKNS_15PutPropertySlotE +__ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC17PrototypeFunctionC2EPNS_9ExecStateEiRKNS_10IdentifierEPFNS_10JSValuePtrES2_PNS_8JSObjectES6_RKNS_7ArgListEE +__ZN3JSC17PrototypeFunction11getCallDataERNS_8CallDataE +__ZNK3JSC8JSString8toStringEPNS_9ExecStateE +__ZNK3JSC9CodeBlock15derefStructuresEPNS_11InstructionE +__ZN3JSC14JSGlobalObject16stopTimeoutCheckEv +__ZN3WTF6VectorINS_6RefPtrIN3JSC12FuncDeclNodeEEELm0EE15reserveCapacityEm +__ZN3JSC20ParserRefCountedDataIN3WTF6VectorINS1_6RefPtrINS_12FuncDeclNodeEEELm0EEEED0Ev +__ZN3WTF6VectorINS_6RefPtrIN3JSC12FuncDeclNodeEEELm0EEaSERKS5_ +__ZN3JSC8JSObject12removeDirectERKNS_10IdentifierE +__ZN3JSC9Structure31removePropertyWithoutTransitionERKNS_10IdentifierE +__ZN3JSC9Structure6removeERKNS_10IdentifierE +__ZN3JSC17BytecodeGenerator12addGlobalVarERKNS_10IdentifierEbRPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator15emitNewFunctionEPNS_10RegisterIDEPNS_12FuncDeclNodeE +__ZN3JSC9CodeBlock25createRareDataIfNecessaryEv +__ZN3JSC13AssignDotNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC10StringNode6isPureERNS_17BytecodeGeneratorE +__ZN3JSC12FuncDeclNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3WTF6VectorIN3JSC15SimpleJumpTableELm0EE14shrinkCapacityEm +__ZN3WTF6VectorIN3JSC15StringJumpTableELm0EE14shrinkCapacityEm +__ZN3JSC13AssignDotNodeD0Ev +__ZN3JSC13AssignDotNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC12FuncDeclNode12makeFunctionEPNS_9ExecStateEPNS_14ScopeChainNodeE +__ZN3JSC12FuncDeclNodeD0Ev +__ZN3JSC12FuncDeclNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC4Heap9unprotectENS_10JSValuePtrE +__ZN3JSC5Lexer7record8Ei +__ZL26appendToVarDeclarationListPvRPN3JSC20ParserRefCountedDataIN3WTF6VectorISt4pairINS0_10IdentifierEjELm0EEEEERKS5_j +__ZN3WTF6VectorISt4pairIN3JSC10IdentifierEjELm0EE14expandCapacityEmPKS4_ +__ZN3WTF6VectorISt4pairIN3JSC10IdentifierEjELm0EE15reserveCapacityEm +__ZL20makeVarStatementNodePvPN3JSC14ExpressionNodeE +__ZN3JSC20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm0EEEED0Ev +__ZN3WTF6VectorISt4pairIN3JSC10IdentifierEjELm0EEaSERKS5_ +__ZNK3JSC7UString14toStrictUInt32EPb +__ZN3JSC16VarStatementNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC16VarStatementNodeD0Ev +__ZN3JSC16VarStatementNode12releaseNodesERNS_12NodeReleaserE +__ZL12makeMultNodePvPN3JSC14ExpressionNodeES2_b +__ZNK3JSC10NumberNode8isNumberEv +__ZL11makeAddNodePvPN3JSC14ExpressionNodeES2_b +__ZN3JSC10NumberNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator8emitLoadEPNS_10RegisterIDEd +__ZN3WTF7HashMapIdN3JSC10JSValuePtrENS_9FloatHashIdEENS_10HashTraitsIdEENS5_IS2_EEE3addERKdRKS2_ +__ZN3WTF9HashTableIdSt4pairIdN3JSC10JSValuePtrEENS_18PairFirstExtractorIS4_EENS_9FloatHashIdEENS_14PairHashTraitsINS_10HashTraitsIdEENSA_IS3_EEEESB_E6rehashEi +__ZN3JSC11NewExprNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator13emitConstructEPNS_10RegisterIDES2_PNS_13ArgumentsNodeEjjj +__ZN3WTF6VectorIN3JSC20GetByIdExceptionInfoELm0EE14expandCapacityEm +__ZNK3JSC7AddNode8opcodeIDEv +__ZNK3JSC14ExpressionNode6isPureERNS_17BytecodeGeneratorE +__ZNK3JSC8MultNode8opcodeIDEv +__ZNK3JSC10NumberNode6isPureERNS_17BytecodeGeneratorE +__ZN3JSC10NumberNodeD0Ev +__ZN3JSC11NewExprNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11NewExprNodeD0Ev +__ZN3JSC7AddNodeD0Ev +__ZN3JSC8MultNodeD0Ev +__ZN3JSC15DateConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL28constructWithDateConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSC13constructDateEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSC13DatePrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL20dateProtoFuncGetTimeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC6JSCell8isObjectEPKNS_9ClassInfoE +__ZNK3JSC12DateInstance9classInfoEv +__ZN3JSCL20dateProtoFuncSetTimeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC12JSNumberCell8toNumberEPNS_9ExecStateE +__ZN3JSC11BooleanNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC11BooleanNodeD0Ev +__ZN3JSC4Heap7collectEv +__ZN3JSC4Heap30markStackObjectsConservativelyEv +__ZN3JSC4Heap31markCurrentThreadConservativelyEv +__ZN3JSC4Heap39markCurrentThreadConservativelyInternalEv +__ZN3JSC4Heap18markConservativelyEPvS1_ +__ZN3JSC4Heap20markProtectedObjectsEv +__ZN3JSC8JSObject4markEv +__ZN3JSC6JSCell4markEv +__ZN3JSC14JSGlobalObject4markEv +__ZN3JSC7JSArray4markEv +__ZN3JSC15JSWrapperObject4markEv +__ZN3JSC18GlobalEvalFunction4markEv +__ZN3JSC12SmallStrings4markEv +__ZN3JSC4Heap5sweepILNS_8HeapTypeE0EEEmv +__ZN3JSC14JSGlobalObjectD2Ev +__ZN3JSC17FunctionPrototypeD1Ev +__ZN3JSC17PrototypeFunctionD1Ev +__ZN3JSC15ObjectPrototypeD1Ev +__ZN3JSC14ArrayPrototypeD1Ev +__ZN3JSC15StringPrototypeD1Ev +__ZN3JSC16BooleanPrototypeD1Ev +__ZN3JSC15NumberPrototypeD1Ev +__ZN3JSC13DatePrototypeD1Ev +__ZN3JSC12DateInstanceD2Ev +__ZN3JSC15RegExpPrototypeD1Ev +__ZN3JSC14ErrorPrototypeD1Ev +__ZN3JSC20NativeErrorPrototypeD1Ev +__ZN3JSC17ObjectConstructorD1Ev +__ZN3JSC19FunctionConstructorD1Ev +__ZN3JSC16ArrayConstructorD1Ev +__ZN3JSC17StringConstructorD1Ev +__ZN3JSC18BooleanConstructorD1Ev +__ZN3JSC17NumberConstructorD1Ev +__ZN3JSC15DateConstructorD1Ev +__ZN3JSC17RegExpConstructorD1Ev +__ZN3JSC16ErrorConstructorD1Ev +__ZN3JSC22NativeErrorConstructorD1Ev +__ZN3JSC10MathObjectD1Ev +__ZN3JSC18GlobalEvalFunctionD1Ev +__ZN3JSC12DateInstanceD1Ev +__ZN3JSC4Heap5sweepILNS_8HeapTypeE1EEEmv +__ZN3JSC6IfNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator8newLabelEv +__ZN3JSC17BytecodeGenerator15emitJumpIfFalseEPNS_10RegisterIDEPNS_5LabelE +__ZN3JSC17BytecodeGenerator9emitLabelEPNS_5LabelE +__ZN3JSC6IfNodeD0Ev +__ZN3JSC6IfNode12releaseNodesERNS_12NodeReleaserE +__ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE +__ZN3JSC10JSFunction4markEv +__ZN3JSC16FunctionBodyNode4markEv +__ZN3JSC23FunctionCallResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator19emitResolveFunctionEPNS_10RegisterIDES2_RKNS_10IdentifierE +__ZNK3JSC12NotEqualNode8opcodeIDEv +__ZNK3JSC14ExpressionNode6isNullEv +__ZN3JSC13LogicalOpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC8LessNode8opcodeIDEv +__ZN3JSC23FunctionCallResolveNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC23FunctionCallResolveNodeD0Ev +__ZN3JSC12NotEqualNodeD0Ev +__ZN3JSC13LogicalOpNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13LogicalOpNodeD0Ev +__ZN3JSC8LessNodeD0Ev +__ZN3JSC11Interpreter18resolveBaseAndFuncEPNS_9ExecStateEPNS_11InstructionERNS_10JSValuePtrE +__ZN3JSC18globalFuncParseIntEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11JSImmediate12nonInlineNaNEv +__ZN3JSC8JSString18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC15StringPrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC12StringObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL22stringProtoFuncIndexOfEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC8JSString12toThisStringEPNS_9ExecStateE +__ZNK3JSC7UString4findERKS0_i +__ZN3JSC10JSFunction11getCallDataERNS_8CallDataE +__ZNK3JSC16JSVariableObject16isVariableObjectEv +__ZN3JSC17BytecodeGenerator16emitGetScopedVarEPNS_10RegisterIDEmiNS_10JSValuePtrE +__ZNK3JSC13StatementNode12isReturnNodeEv +__ZN3JSC12SmallStrings27createSingleCharacterStringEPNS_12JSGlobalDataEh +__ZN3JSC9EqualNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator14emitEqualityOpENS_8OpcodeIDEPNS_10RegisterIDES3_S3_ +__ZNK3JSC13StatementNode7isBlockEv +__ZNK3JSC14JSGlobalObject14isDynamicScopeEv +__ZN3JSC9EqualNodeD0Ev +__ZN3JSC11concatenateEPNS_7UString3RepES2_ +__ZNK3JSC9CodeBlock13refStructuresEPNS_11InstructionE +__ZN3JSC9CodeBlock4markEv +__ZNK3JSC12JSNumberCell8toStringEPNS_9ExecStateE +__ZN3JSC7UString4fromEd +__ZN3WTF4dtoaEdiPiS0_PPc +__ZN3WTFL3d2bEdPiS0_ +__ZN3JSC19BracketAccessorNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator12emitGetByValEPNS_10RegisterIDES2_S2_ +__ZN3JSC19BracketAccessorNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC19BracketAccessorNodeD0Ev +__ZN3JSC10JSFunction18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC10JSFunction16getConstructDataERNS_13ConstructDataE +__ZL15makePostfixNodePvPN3JSC14ExpressionNodeENS0_8OperatorEiii +__ZNK3JSC19BracketAccessorNode10isLocationEv +__ZNK3JSC19BracketAccessorNode21isBracketAccessorNodeEv +__ZNK3JSC7ForNode6isLoopEv +__ZN3JSC7ForNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator13newLabelScopeENS_10LabelScope4TypeEPKNS_10IdentifierE +__ZN3JSC17BytecodeGenerator8emitJumpEPNS_5LabelE +__ZN3JSC17AssignBracketNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC8ThisNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator12emitPutByValEPNS_10RegisterIDES2_S2_ +__ZN3JSC18PostfixResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator14emitJumpIfTrueEPNS_10RegisterIDEPNS_5LabelE +__ZN3JSC7ForNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC7ForNodeD0Ev +__ZN3JSC18PostfixResolveNodeD0Ev +__ZN3JSC17AssignBracketNodeD0Ev +__ZN3JSC17AssignBracketNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC8ThisNodeD0Ev +__ZN3JSC8JSObject17createInheritorIDEv +__ZN3JSC10JSFunction15argumentsGetterEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZNK3JSC11Interpreter17retrieveArgumentsEPNS_9ExecStateEPNS_10JSFunctionE +__ZN3JSC9Arguments18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC9Arguments18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC8JSObject3putEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3JSCL21dateProtoFuncGetMonthEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC12DateInstance21msToGregorianDateTimeEdbRNS_17GregorianDateTimeE +__ZN3JSC21msToGregorianDateTimeEdbRNS_17GregorianDateTimeE +__ZN3JSCL12getDSTOffsetEdd +__ZN3JSC8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC8JSObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL20dateProtoFuncGetDateEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11concatenateEPNS_7UString3RepEi +__ZN3JSC21ReadModifyResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC21ReadModifyResolveNodeD0Ev +__ZN3JSC21ReadModifyResolveNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSCL20dateProtoFuncGetYearEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC10IfElseNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC10LessEqNode8opcodeIDEv +__ZN3JSC10IfElseNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC10IfElseNodeD0Ev +__ZN3JSC10LessEqNodeD0Ev +__ZN3JSCL21dateProtoFuncGetHoursEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL23dateProtoFuncGetMinutesEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC19ReverseBinaryOpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC13GreaterEqNode8opcodeIDEv +__ZN3JSC13GreaterEqNodeD0Ev +__ZN3JSC9ArgumentsD1Ev +__ZN3JSC9ArgumentsD2Ev +__ZN3JSC8WithNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator13emitPushScopeEPNS_10RegisterIDE +__ZN3WTF6VectorIN3JSC18ControlFlowContextELm0EE14expandCapacityEm +__ZNK3JSC11GreaterNode8opcodeIDEv +__ZN3JSC11UnaryOpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC14LogicalNotNode8opcodeIDEv +__ZN3JSC8WithNodeD0Ev +__ZN3JSC8WithNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11GreaterNodeD0Ev +__ZN3JSC11UnaryOpNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC14LogicalNotNodeD0Ev +__ZN3JSC14ExpressionNodeD2Ev +__ZN3JSC10JSValuePtr13equalSlowCaseEPNS_9ExecStateES0_S0_ +__ZN3JSC11Interpreter7resolveEPNS_9ExecStateEPNS_11InstructionERNS_10JSValuePtrE +__ZNK3JSC8NullNode6isNullEv +__ZN3JSC8NullNodeD0Ev +__ZN3JSC8NullNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC9ForInNodeC2EPNS_12JSGlobalDataERKNS_10IdentifierEPNS_14ExpressionNodeES7_PNS_13StatementNodeEiii +__ZNK3JSC9ForInNode6isLoopEv +__ZN3JSC9ForInNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator20emitNextPropertyNameEPNS_10RegisterIDES2_PNS_5LabelE +__ZN3JSC9ForInNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC9ForInNodeD0Ev +__ZN3JSC8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE +__ZN3JSC9Structure26getEnumerablePropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayEPNS_8JSObjectE +__ZN3JSC9Structure35getEnumerableNamesFromPropertyTableERNS_17PropertyNameArrayE +__ZNK3JSC6JSCell9classInfoEv +__ZN3JSC14StructureChainC1EPNS_9StructureE +__ZN3JSC14StructureChainC2EPNS_9StructureE +__ZN3JSC13jsOwnedStringEPNS_12JSGlobalDataERKNS_7UStringE +__ZN3JSC16globalFuncEscapeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11JSImmediate8toStringENS_10JSValuePtrE +__ZN3JSC7UString4fromEi +__ZN3JSC7UString6appendERKS0_ +__ZN3JSC22JSPropertyNameIterator10invalidateEv +__ZNK3JSC18EmptyStatementNode16isEmptyStatementEv +__ZN3JSC18EmptyStatementNodeD0Ev +__ZN3JSCL20dateProtoFuncSetYearEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC21gregorianDateTimeToMSERKNS_17GregorianDateTimeEdb +__ZN3JSCL15dateToDayInYearEiii +__ZN3JSCL21dateProtoFuncSetMonthEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL23setNewValueFromDateArgsEPNS_9ExecStateENS_10JSValuePtrERKNS_7ArgListEib +__ZN3JSCL20dateProtoFuncSetDateEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL24dateProtoFuncToGMTStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCplERKNS_7UStringES2_ +__ZN3JSC10formatTimeERKNS_17GregorianDateTimeEb +__ZN3JSC22JSPropertyNameIteratorD1Ev +__ZN3JSC8JSObjectD1Ev +__ZNK3JSC8JSString11toPrimitiveEPNS_9ExecStateENS_22PreferredPrimitiveTypeE +__ZN3JSC9parseDateERKNS_7UStringE +__ZNK3JSC7UString10UTF8StringEb +__ZN3WTF7Unicode18convertUTF16ToUTF8EPPKtS2_PPcS4_b +__ZN3JSC16ArrayConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL29constructWithArrayConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSCL27constructArrayWithSizeQuirkEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSC7JSArrayC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEERKNS_7ArgListE +__ZL14makePrefixNodePvPN3JSC14ExpressionNodeENS0_8OperatorEiii +__ZN3JSC13PrefixDotNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC9WhileNode6isLoopEv +__ZN3JSC9WhileNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC20EvalFunctionCallNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator19emitResolveWithBaseEPNS_10RegisterIDES2_RKNS_10IdentifierE +__ZN3JSC9WhileNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13PrefixDotNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13PrefixDotNodeD0Ev +__ZN3JSC20EvalFunctionCallNodeD0Ev +__ZN3JSC20EvalFunctionCallNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC9WhileNodeD0Ev +__ZN3JSC12JSActivationC1EPNS_9ExecStateEN3WTF10PassRefPtrINS_16FunctionBodyNodeEEE +__ZN3JSC12JSActivationC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_16FunctionBodyNodeEEE +__ZN3JSC12JSActivation18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZL11makeDivNodePvPN3JSC14ExpressionNodeES2_b +__ZN3JSC15ConditionalNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC7DivNode8opcodeIDEv +__ZN3JSC15ConditionalNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC15ConditionalNodeD0Ev +__ZN3JSC7DivNodeD0Ev +__ZN3JSC7JSArrayC2EN3WTF10PassRefPtrINS_9StructureEEEj +__ZN3JSC7JSArray3putEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3JSC7JSArray18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC7JSArray3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3WTF7HashMapISt4pairINS_6RefPtrIN3JSC7UString3RepEEEjEPNS3_9StructureENS3_28StructureTransitionTableHashENS3_34StructureTransitionTableHashTraitsENS_10HashTraitsIS9_EEE3addERKS7_RKS9_ +__ZN3WTF9HashTableISt4pairINS_6RefPtrIN3JSC7UString3RepEEEjES1_IS7_PNS3_9StructureEENS_18PairFirstExtractorISA_EENS3_28StructureTransitionTableHashENS_14PairHashTraitsINS3_34StructureTransitionTableHashTraitsENS_10HashTraitsIS9_EEEESF_E6rehashEi +__ZN3JSC17StringConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL30constructWithStringConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSC12StringObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC7JSArray18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC11Interpreter22resolveBaseAndPropertyEPNS_9ExecStateEPNS_11InstructionERNS_10JSValuePtrE +__ZN3JSC9Structure22materializePropertyMapEv +__ZN3JSC8JSObject23allocatePropertyStorageEmm +__ZN3JSCL21stringProtoFuncCharAtEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC12StringObject12toThisStringEPNS_9ExecStateE +__ZN3JSC12JSActivationD1Ev +__ZN3JSC12JSActivationD2Ev +__ZN3JSC11Interpreter14uncachePutByIDEPNS_9CodeBlockEPNS_11InstructionE +__ZN3JSC12StringObjectD1Ev +__ZN3JSCL26stringProtoFuncToLowerCaseEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC8JSString14toThisJSStringEPNS_9ExecStateE +__ZN3JSC7JSArray11putSlowCaseEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3WTF11fastReallocILb0EEEPvS1_m +__ZN3JSCL24stringProtoFuncSubstringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11jsSubstringEPNS_12JSGlobalDataERKNS_7UStringEjj +__ZN3JSCL20stringProtoFuncSplitEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC19constructEmptyArrayEPNS_9ExecStateE +__ZNK3JSC11BooleanNode6isPureERNS_17BytecodeGeneratorE +__ZNK3JSC7ModNode8opcodeIDEv +__ZN3JSC7ModNodeD0Ev +__ZN3JSCL23dateProtoFuncGetSecondsEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC17BytecodeGenerator16emitPutScopedVarEmiPNS_10RegisterIDENS_10JSValuePtrE +__ZN3JSC18globalFuncUnescapeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC7UString6appendEt +__ZN3JSC11Interpreter8callEvalEPNS_9ExecStateEPNS_12RegisterFileEPNS_8RegisterEiiRNS_10JSValuePtrE +__ZN3JSC5Lexer10scanRegExpEv +__ZN3JSC7UStringC2ERKN3WTF6VectorItLm0EEE +__ZNK3JSC9BitOrNode8opcodeIDEv +__ZN3JSC9BitOrNodeD0Ev +__ZNK3JSC8JSString9toBooleanEPNS_9ExecStateE +__ZN3JSC10MathObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL19mathProtoFuncRandomEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3WTF16weakRandomNumberEv +__ZNK3JSC13UnaryPlusNode8opcodeIDEv +__ZN3JSC13UnaryPlusNodeD0Ev +__ZNK3JSC8JSString8toNumberEPNS_9ExecStateE +__ZNK3JSC7UString8toDoubleEbb +__ZNK3JSC7UString10getCStringERN3WTF6VectorIcLm32EEE +__ZN3JSCL30dateProtoFuncGetTimezoneOffsetEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL18mathProtoFuncFloorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL18mathProtoFuncRoundEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL13jsAddSlowCaseEPNS_9ExecStateENS_10JSValuePtrES2_ +__ZN3JSC20globalFuncParseFloatEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC7UString4fromEj +__ZN3JSC9CommaNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC9CommaNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC16VarDeclCommaNodeD0Ev +__ZN3JSC7UStringC2EPtib +__ZN3JSC11concatenateEPNS_7UString3RepEd +__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE +__ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE +__ZN3WTF6VectorIPNS0_IN3JSC10IdentifierELm64EEELm32EE14expandCapacityEm +__ZN3JSC17ObjectLiteralNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC12FuncExprNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator25emitNewFunctionExpressionEPNS_10RegisterIDEPNS_12FuncExprNodeE +__ZN3JSC10RegExpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC6RegExp6createEPNS_12JSGlobalDataERKNS_7UStringES5_ +__Z15jsRegExpCompilePKti24JSRegExpIgnoreCaseOption23JSRegExpMultilineOptionPjPPKc +__ZL30calculateCompiledPatternLengthPKti24JSRegExpIgnoreCaseOptionR11CompileDataR9ErrorCode +__ZL11checkEscapePPKtS0_P9ErrorCodeib +__ZL13compileBranchiPiPPhPPKtS3_P9ErrorCodeS_S_R11CompileData +__ZN3JSC17BytecodeGenerator13emitNewRegExpEPNS_10RegisterIDEPNS_6RegExpE +__ZN3WTF6VectorINS_6RefPtrIN3JSC6RegExpEEELm0EE14expandCapacityEm +__ZN3JSC9ArrayNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator12emitNewArrayEPNS_10RegisterIDEPNS_11ElementNodeE +__ZL14compileBracketiPiPPhPPKtS3_P9ErrorCodeiS_S_R11CompileData +__ZL17bracketIsAnchoredPKh +__ZL32branchFindFirstAssertedCharacterPKhb +__ZL20branchNeedsLineStartPKhjj +__ZN3JSC16PropertyListNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17ObjectLiteralNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC17ObjectLiteralNodeD0Ev +__ZN3JSC10RegExpNodeD0Ev +__ZN3JSC9ArrayNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC9ArrayNodeD0Ev +__ZN3JSC16PropertyListNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC12PropertyNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC16PropertyListNodeD0Ev +__ZN3JSC12PropertyNodeD0Ev +__ZN3JSC20constructEmptyObjectEPNS_9ExecStateE +__ZN3JSC12FuncExprNode12makeFunctionEPNS_9ExecStateEPNS_14ScopeChainNodeE +__ZN3JSC12RegExpObjectC1EN3WTF10PassRefPtrINS_9StructureEEENS2_INS_6RegExpEEE +__ZN3JSCL7dateNowEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC14constructArrayEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSC17RegExpConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL21callRegExpConstructorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC15constructRegExpEPNS_9ExecStateERKNS_7ArgListE +__ZNK3JSC14ExpressionNode10isLocationEv +__ZN3JSC21FunctionCallValueNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC21FunctionCallValueNodeD0Ev +__ZN3JSC21FunctionCallValueNode12releaseNodesERNS_12NodeReleaserE +__ZN3WTF7HashSetINS_6RefPtrIN3JSC7UString3RepEEENS2_17IdentifierRepHashENS_10HashTraitsIS5_EEE3addERKS5_ +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEES5_NS_17IdentityExtractorIS5_EENS2_17IdentifierRepHashENS_10HashTraitsIS5_EESA_E6rehashEi +__ZN3JSC11ElementNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11ElementNodeD0Ev +__ZNK3JSC12JSActivation14isDynamicScopeEv +__ZN3JSC4Heap24setGCProtectNeedsLockingEv +__ZN3WTF15ThreadConditionD1Ev +__ZN3JSC17PrefixResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17PrefixResolveNodeD0Ev +__ZNK3JSC7UString8toUInt32EPbb +__ZN3JSC7UString17expandPreCapacityEi +__ZN3WTF17TCMalloc_PageHeap3NewEm +__ZN3JSC6JSCell9getObjectEv +__ZN3JSC4callEPNS_9ExecStateENS_10JSValuePtrENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE +__ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE +__ZN3JSC11Interpreter7executeEPNS_16FunctionBodyNodeEPNS_9ExecStateEPNS_10JSFunctionEPNS_8JSObjectERKNS_7ArgListEPNS_14ScopeChainNodeEPNS_10JSValuePtrE +__ZN3JSCL22stringProtoFuncReplaceEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC6JSCell11getCallDataERNS_8CallDataE +__ZNK3JSC12RegExpObject9classInfoEv +__ZN3JSC17RegExpConstructor12performMatchEPNS_6RegExpERKNS_7UStringEiRiS6_PPi +__ZN3JSC6RegExp5matchERKNS_7UStringEiPN3WTF11OwnArrayPtrIiEE +__Z15jsRegExpExecutePK8JSRegExpPKtiiPii +__ZNK3JSC7UString30spliceSubstringsWithSeparatorsEPKNS0_5RangeEiPKS0_i +__ZL5matchPKtPKhiR9MatchData +__ZN3JSC9ThrowNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC9ThrowNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC9ThrowNodeD0Ev +__ZN3JSC17StringConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL21callStringConstructorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC17DeleteBracketNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17DeleteBracketNodeD0Ev +__ZN3JSC17DeleteBracketNode12releaseNodesERNS_12NodeReleaserE +__ZNK3JSC6JSCell9getUInt32ERj +__ZN3JSC8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC9Structure24removePropertyTransitionEPS0_RKNS_10IdentifierERm +__ZN3JSC14ArrayPrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL18arrayProtoFuncPushEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL18arrayProtoFuncJoinEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3WTF7HashSetIPN3JSC8JSObjectENS_7PtrHashIS3_EENS_10HashTraitsIS3_EEE3addERKS3_ +__ZN3WTF9HashTableIPN3JSC8JSObjectES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E6rehashEi +__ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC11Interpreter14uncacheGetByIDEPNS_9CodeBlockEPNS_11InstructionE +__ZNK3JSC6JSCell17getTruncatedInt32ERi +__ZN3JSC15toInt32SlowCaseEdRb +__ZN3JSC10JSFunction3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZNK3JSC7ArgList8getSliceEiRS0_ +__ZN3JSC12RegExpObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL18regExpObjectSourceEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL19regExpProtoFuncExecEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC12RegExpObject5matchEPNS_9ExecStateERKNS_7ArgListE +__ZNK3JSC12JSNumberCell9toBooleanEPNS_9ExecStateE +__ZN3JSC28globalFuncDecodeURIComponentEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL6decodeEPNS_9ExecStateERKNS_7ArgListEPKcb +__ZN3JSC18RegExpMatchesArrayC2EPNS_9ExecStateEPNS_24RegExpConstructorPrivateE +__ZN3JSC18RegExpMatchesArray18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC18RegExpMatchesArray17fillArrayInstanceEPNS_9ExecStateE +__ZN3JSC18RegExpMatchesArray18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC28globalFuncEncodeURIComponentEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL6encodeEPNS_9ExecStateERKNS_7ArgListEPKc +__ZN3JSC7UString6appendEPKc +__ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_10JSValuePtrE +__ZN3JSC9CodeBlock27lineNumberForBytecodeOffsetEPNS_9ExecStateEj +__ZN3JSC9CodeBlock34reparseForExceptionInfoIfNecessaryEPNS_9ExecStateE +__ZN3JSC6Parser7reparseINS_16FunctionBodyNodeEEEN3WTF10PassRefPtrIT_EEPNS_12JSGlobalDataEPS5_ +__ZN3JSC16FunctionBodyNode6createEPNS_12JSGlobalDataEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm0EEEPNS6_INS5_6RefPtrINS_12FuncDeclNodeEEELm0EEERKNS_10SourceCodeEji +__ZN3JSC13StatementNode6setLocEii +__ZN3JSC16FunctionBodyNode14copyParametersEv +__ZN3JSC16FunctionBodyNode13finishParsingEPNS_10IdentifierEm +__ZN3JSC16FunctionBodyNode31bytecodeForExceptionInfoReparseEPNS_14ScopeChainNodeEPNS_9CodeBlockE +__ZN3JSC9CodeBlock43hasGlobalResolveInstructionAtBytecodeOffsetEj +__ZN3JSCL22functionProtoFuncApplyEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC9Arguments9classInfoEv +__ZN3JSC9Arguments11fillArgListEPNS_9ExecStateERNS_7ArgListE +__ZN3JSC7TryNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator9emitCatchEPNS_10RegisterIDEPNS_5LabelES4_ +__ZN3WTF6VectorIN3JSC11HandlerInfoELm0EE14expandCapacityEm +__ZN3JSC17BytecodeGenerator16emitPushNewScopeEPNS_10RegisterIDERNS_10IdentifierES2_ +__ZN3JSC7TryNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC7TryNodeD0Ev +__ZN3JSCL21stringProtoFuncSubstrEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC10JSValuePtr9toIntegerEPNS_9ExecStateE +__ZN3JSCltERKNS_7UStringES2_ +__ZN3JSC9BreakNodeD0Ev +__ZN3JSC17BytecodeGenerator14emitJumpScopesEPNS_5LabelEi +__ZN3JSC9BreakNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator11breakTargetERKNS_10IdentifierE +__ZNK3JSC10ScopeChain10localDepthEv +__ZNK3JSC12JSActivation9classInfoEv +__ZN3JSCL30comparePropertyMapEntryIndicesEPKvS1_ +__ZN3WTF6VectorIN3JSC10IdentifierELm20EE15reserveCapacityEm +__ZN3JSCL19regExpProtoFuncTestEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3WTF12detachThreadEj +__ZN3WTFL26pthreadHandleForIdentifierEj +__ZN3WTFL31clearPthreadHandleForIdentifierEj +__ZN3JSC18RegExpMatchesArrayD1Ev +__ZN3JSC12RegExpObjectD1Ev +__Z12jsRegExpFreeP8JSRegExp +__ZN3JSC6RegExpD1Ev diff --git a/JavaScriptCore.order b/JavaScriptCore.order index f9f8238..05c300c 100644 --- a/JavaScriptCore.order +++ b/JavaScriptCore.order @@ -1,1532 +1,1638 @@ +__ZN3WTF19initializeThreadingEv __ZN3WTF10fastMallocEm +__ZN3WTF10fastMallocILb1EEEPvm __ZN3WTF20TCMalloc_ThreadCache10InitModuleEv -__ZN3WTF15InitSizeClassesEv +__ZN3WTFL15InitSizeClassesEv __Z20TCMalloc_SystemAllocmPmm -__ZN3WTF17TCMalloc_PageHeap4initEv __ZN3WTF20TCMalloc_ThreadCache22CreateCacheIfNecessaryEv __ZN3WTF25TCMalloc_Central_FreeList11RemoveRangeEPPvS2_Pi __ZN3WTF25TCMalloc_Central_FreeList18FetchFromSpansSafeEv __ZN3WTF17TCMalloc_PageHeap10AllocLargeEm __ZN3WTF17TCMalloc_PageHeap8GrowHeapEm -__ZN3WTF13MetaDataAllocEm -__ZN3WTF17TCMalloc_PageHeap19IncrementalScavengeEm +__ZN3WTFL13MetaDataAllocEm +__ZN3WTF20initializeMainThreadEv +__ZN3WTF5MutexC1Ev +__ZN3WTF36lockAtomicallyInitializedStaticMutexEv +__ZN3WTF38unlockAtomicallyInitializedStaticMutexEv +__ZN3JSC19initializeThreadingEv +__ZN3JSCL23initializeThreadingOnceEv +__ZN3JSC17initializeUStringEv +__ZN3JSC12initDateMathEv +__ZN3WTF11currentTimeEv +__ZN3WTF15ThreadConditionC1Ev +__ZN3WTF5Mutex4lockEv +__ZN3WTF5Mutex6unlockEv __ZN3WTF8fastFreeEPv +__ZN3WTF12createThreadEPFPvS0_ES0_PKc +__ZN3WTF20createThreadInternalEPFPvS0_ES0_PKc +__ZN3WTFL35establishIdentifierForPthreadHandleERP17_opaque_pthread_t +__ZN3WTFL16threadEntryPointEPv +__ZN3WTF7HashMapIjP17_opaque_pthread_tNS_7IntHashIjEENS_10HashTraitsIjEENS5_IS2_EEE3addERKjRKS2_ +__ZN3WTF9HashTableIjSt4pairIjP17_opaque_pthread_tENS_18PairFirstExtractorIS4_EENS_7IntHashIjEENS_14PairHashTraitsINS_10HashTraitsIjEENSA_IS3_EEEESB_E6rehashEi __ZN3WTF16fastZeroedMallocEm +__ZN3WTF5MutexD1Ev +__ZN3WTF25TCMalloc_Central_FreeList11InsertRangeEPvS1_i +__ZN3WTF25TCMalloc_Central_FreeList18ReleaseListToSpansEPv __ZN3WTF14FastMallocZone4sizeEP14_malloc_zone_tPKv -__ZN3KJS8Bindings10RootObject19setCreateRootObjectEPFN3WTF10PassRefPtrIS1_EEPvE -__ZN3KJS8Bindings8Instance21setDidExecuteFunctionEPFvPNS_9ExecStateEPNS_8JSObjectEE -_kjs_strtod -__Z15jsRegExpCompilePKti24JSRegExpIgnoreCaseOption23JSRegExpMultilineOptionPjPPKc -__Z30calculateCompiledPatternLengthPKti24JSRegExpIgnoreCaseOptionR11CompileDataR9ErrorCode -__Z11checkEscapePPKtS0_P9ErrorCodeib -__Z13compileBranchiPiPPhPPKtS3_P9ErrorCodeS_S_R11CompileData -__Z15jsRegExpExecutePK8JSRegExpPKtiiPii +__ZN3WTF13currentThreadEv +__ZN3WTF16callOnMainThreadEPFvPvES0_ +__ZN3WTF6VectorINS_19FunctionWithContextELm0EE14expandCapacityEm +__ZN3WTF37scheduleDispatchFunctionsOnMainThreadEv +__ZN3WTF15ThreadCondition4waitERNS_5MutexE +__ZN3JSC8DebuggerC2Ev +__ZN3WTF6strtodEPKcPPc +__ZN3WTF15ThreadCondition6signalEv +__ZN3WTF15ThreadCondition9broadcastEv +__ZN3JSC12JSGlobalData12createLeakedEv +__ZN3JSC12JSGlobalDataC2Eb +__ZN3JSC11InterpreterC1Ev +__ZN3JSC11Interpreter14privateExecuteENS0_13ExecutionFlagEPNS_12RegisterFileEPNS_9ExecStateEPNS_10JSValuePtrE +__ZN3WTF7HashMapIPvN3JSC8OpcodeIDENS_7PtrHashIS1_EENS_10HashTraitsIS1_EENS6_IS3_EEE3addERKS1_RKS3_ +__ZN3WTF9HashTableIPvSt4pairIS1_N3JSC8OpcodeIDEENS_18PairFirstExtractorIS5_EENS_7PtrHashIS1_EENS_14PairHashTraitsINS_10HashTraitsIS1_EENSB_IS4_EEEESC_E6expandEv +__ZN3JSC9StructureC1ENS_10JSValuePtrERKNS_8TypeInfoE +__ZN3JSC7JSArrayC1EN3WTF10PassRefPtrINS_9StructureEEE +__ZN3JSC7JSArrayD0Ev +__ZN3WTF10RefCountedIN3JSC9StructureEE5derefEv +__ZN3JSC9StructureD1Ev +__ZN3JSC11JSByteArray15createStructureENS_10JSValuePtrE +__ZN3JSC21createIdentifierTableEv +__ZN3JSC17CommonIdentifiersC1EPNS_12JSGlobalDataE +__ZN3JSC10Identifier3addEPNS_12JSGlobalDataEPKc +__ZN3WTF9HashTableIPKcSt4pairIS2_NS_6RefPtrIN3JSC7UString3RepEEEENS_18PairFirstExtractorIS9_EENS_7PtrHashIS2_EENS_14PairHashTraitsINS_10HashTraitsIS2_EENSF_IS8_EEEESG_E4findIS2_NS_22IdentityHashTranslatorIS2_S9_SD_EEEENS_17HashTableIteratorIS2_S9_SB_SD_SI_SG_EERKT_ +__ZN3WTF9HashTableIPN3JSC7UString3RepES4_NS_17IdentityExtractorIS4_EENS_7StrHashIS4_EENS_10HashTraitsIS4_EESA_E6rehashEi +__ZN3WTF9HashTableIPKcSt4pairIS2_NS_6RefPtrIN3JSC7UString3RepEEEENS_18PairFirstExtractorIS9_EENS_7PtrHashIS2_EENS_14PairHashTraitsINS_10HashTraitsIS2_EENSF_IS8_EEEESG_E6expandEv +__ZN3WTF9HashTableIPN3JSC7UString3RepES4_NS_17IdentityExtractorIS4_EENS_7StrHashIS4_EENS_10HashTraitsIS4_EESA_E4findIS4_NS_22IdentityHashTranslatorIS4_S4_S8_EEEENS_17HashTableIteratorIS4_S4_S6_S8_SA_SA_EERKT_ +__ZN3JSC12SmallStringsC1Ev +__ZN3JSC5LexerC1EPNS_12JSGlobalDataE +__ZN3JSC4HeapC1EPNS_12JSGlobalDataE +__ZN3JSC19ExecutableAllocator17intializePageSizeEv +__ZN3JSC14ExecutablePool11systemAllocEm +__ZN3JSC27startProfilerServerIfNeededEv ++[ProfilerServer sharedProfileServer] +-[ProfilerServer init] +__ZN3JSC11Interpreter10initializeEPNS_12JSGlobalDataE +__ZN3JSC3JITC1EPNS_12JSGlobalDataEPNS_9CodeBlockE +__ZN3JSC3JIT35privateCompileCTIMachineTrampolinesEv +__ZN3JSC15AssemblerBuffer11ensureSpaceEi +__ZN3JSC12X86Assembler23X86InstructionFormatter9oneByteOpENS0_15OneByteOpcodeIDEiNS_3X8610RegisterIDEi +__ZN3JSC12X86Assembler23X86InstructionFormatter9oneByteOpENS0_15OneByteOpcodeIDEiNS_3X8610RegisterIDE +__ZN3JSC14MacroAssembler4pokeENS_3X8610RegisterIDEi +__ZN3JSC3JIT32compileOpCallInitializeCallFrameEv +__ZN3JSC14MacroAssembler5jnz32ENS_3X8610RegisterIDENS0_5Imm32E __ZN3WTF11fastReallocEPvm -__ZN3KJS6JSLock4lockEv -__ZN3KJS20createDidLockJSMutexEv -__ZN3KJS6JSLock14registerThreadEv -__ZN3KJS9Collector14registerThreadEv -__ZN3KJS29initializeRegisteredThreadKeyEv -__ZN3KJS6JSLock6unlockEv -__ZN3KJS15SavedPropertiesC1Ev -__ZN3KJS6JSCellnwEm -__ZN3KJS9Collector12heapAllocateILNS0_8HeapTypeE0EEEPvm -__ZN3KJS15GlobalExecStateC1EPNS_14JSGlobalObjectE -__ZN3KJS17CommonIdentifiers6sharedEv -__ZN3KJS17CommonIdentifiersC2Ev -__ZN3KJS10IdentifierC1EPKc -__ZN3KJS10Identifier3addEPKc -__ZN3WTF7HashSetIPN3KJS7UString3RepENS_7StrHashIS4_EENS_10HashTraitsIS4_EEE3addINS1_11UCharBufferENS1_21UCharBufferTranslatorEEESt4pairINS_24HashTableIteratorAdapterINS_9HashTableIS4_S4_NS_17IdentityExtractorIS4_EES6_S8_S8_EES4_EEbERKT_ -__ZN3WTF9HashTableIPN3KJS7UString3RepES4_NS_17IdentityExtractorIS4_EENS_7StrHashIS4_EENS_10HashTraitsIS4_EESA_E6rehashEi -__ZN3KJS14JSGlobalObject4initEv -__ZN3KJS14JSGlobalObject5resetEPNS_7JSValueE -__ZN3KJS11PropertyMap5clearEv -__ZN3KJS17FunctionPrototypeC2EPNS_9ExecStateE -__ZN3KJS11PropertyMap3putERKNS_10IdentifierEPNS_7JSValueEjb -__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEPNS_17FunctionPrototypeEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectERKNS_4ListEE -__ZN3KJS19InternalFunctionImpC2EPNS_17FunctionPrototypeERKNS_10IdentifierE -__ZN3KJS11PropertyMap11createTableEv -__ZN3KJS15ObjectPrototypeC2EPNS_9ExecStateEPNS_17FunctionPrototypeE -__ZN3KJS11PropertyMap6rehashEj -__ZN3KJS14ArrayPrototypeC1EPNS_9ExecStateEPNS_15ObjectPrototypeE -__ZN3KJS13ArrayInstanceC2EPNS_8JSObjectEj -__ZN3KJS15StringPrototypeC2EPNS_9ExecStateEPNS_15ObjectPrototypeE -__ZN3KJS8jsStringEPKc -__ZN3KJS16BooleanPrototypeC2EPNS_9ExecStateEPNS_15ObjectPrototypeEPNS_17FunctionPrototypeE -__ZN3KJS15NumberPrototypeC2EPNS_9ExecStateEPNS_15ObjectPrototypeEPNS_17FunctionPrototypeE -__ZN3KJS13DatePrototypeC1EPNS_9ExecStateEPNS_15ObjectPrototypeE -__ZN3KJS12jsNumberCellEd -__ZN3KJS9Collector12heapAllocateILNS0_8HeapTypeE1EEEPvm -__ZN3KJS15RegExpPrototypeC2EPNS_9ExecStateEPNS_15ObjectPrototypeEPNS_17FunctionPrototypeE -__ZN3WTF9HashTableIPN3KJS7UString3RepES4_NS_17IdentityExtractorIS4_EENS_7StrHashIS4_EENS_10HashTraitsIS4_EESA_E4findIS4_NS_22IdentityHashTranslatorIS4_S4_S8_EEEENS_17HashTableIteratorIS4_S4_S6_S8_SA_SA_EERKT_ -__ZN3KJS14ErrorPrototypeC2EPNS_9ExecStateEPNS_15ObjectPrototypeEPNS_17FunctionPrototypeE -__ZN3KJS7UStringC1EPKc -__ZN3KJS20NativeErrorPrototypeC1EPNS_9ExecStateEPNS_14ErrorPrototypeERKNS_7UStringES7_ -__ZN3KJS8jsStringERKNS_7UStringE -__ZN3KJS15ObjectObjectImpC2EPNS_9ExecStateEPNS_15ObjectPrototypeEPNS_17FunctionPrototypeE -__ZN3KJS17FunctionObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeE -__ZNK3KJS19InternalFunctionImp9classInfoEv -__ZN3KJS14ArrayObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_14ArrayPrototypeE -__ZNK3KJS14ArrayPrototype9classInfoEv -__ZN3KJS15StringObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_15StringPrototypeE -__ZNK3KJS15StringPrototype9classInfoEv -__ZN3KJS19StringObjectFuncImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeERKNS_10IdentifierE -__ZN3KJS16BooleanObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_16BooleanPrototypeE -__ZNK3KJS15BooleanInstance9classInfoEv -__ZN3KJS15NumberObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_15NumberPrototypeE -__ZNK3KJS14NumberInstance9classInfoEv -__ZN3KJS13DateObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_13DatePrototypeE -__ZNK3KJS13DatePrototype9classInfoEv -__ZN3KJS15RegExpObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_15RegExpPrototypeE -__ZN3KJS14ErrorObjectImpC2EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_14ErrorPrototypeE -__ZNK3KJS13ErrorInstance9classInfoEv -__ZN3KJS14NativeErrorImpC1EPNS_9ExecStateEPNS_17FunctionPrototypeEPNS_20NativeErrorPrototypeE -__ZNK3KJS11PropertyMap3getERKNS_10IdentifierE -__ZNK3KJS9StringImp4typeEv -__ZN3KJS10Identifier11addSlowCaseEPNS_7UString3RepE -__ZN3WTF9HashTableIPN3KJS7UString3RepES4_NS_17IdentityExtractorIS4_EENS_7StrHashIS4_EENS_10HashTraitsIS4_EESA_E3addIS4_S4_NS_17HashSetTranslatorILb1ES4_SA_SA_S8_EEEESt4pairINS_17HashTableIteratorIS4_S4_S6_S8_SA_SA_EEbERKT_RKT0_ -__ZN3KJS8JSObject9putDirectERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS13MathObjectImpC1EPNS_9ExecStateEPNS_15ObjectPrototypeE -__ZN3KJS8JSObject17putDirectFunctionEPNS_19InternalFunctionImpEi -__ZNK3KJS8JSObject4typeEv -__ZN3KJS9Collector23collectOnMainThreadOnlyEPNS_7JSValueE -__ZN3KJS9Collector7protectEPNS_7JSValueE -__ZN3WTF9HashTableIiSt4pairIiiENS_18PairFirstExtractorIS2_EENS_7IntHashIiEENS_14PairHashTraitsINS_10HashTraitsIiEES9_EES9_E3addIPN3KJS8JSObjectEjNS_17HashMapTranslatorILb1ES1_ISF_jENS_18PairBaseHashTraitsINS8_ISF_EENS8_IjEEEESA_NS_7PtrHashISF_EEEEEES1_INS_17HashTableIteratorIiS2_S4_S6_SA_S9_EEbERKT_RKT0_ -__ZN3WTF9HashTableIiSt4pairIiiENS_18PairFirstExtractorIS2_EENS_7IntHashIiEENS_14PairHashTraitsINS_10HashTraitsIiEES9_EES9_E6rehashEi -__ZN3KJS6JSCell9getObjectEv -__ZN3KJS8Bindings10RootObject6createEPKvPNS_14JSGlobalObjectE -__ZN3KJS8Bindings10RootObjectC2EPKvPNS_14JSGlobalObjectE -__ZN3WTF9HashTableIiiNS_17IdentityExtractorIiEENS_7IntHashIiEENS_10HashTraitsIiEES6_E6rehashEi -__ZN3KJS8Bindings10RootObject9gcProtectEPNS_8JSObjectE -__ZNK3KJS14JSGlobalObject12saveBuiltinsERNS_13SavedBuiltinsE -__ZN3KJS21SavedBuiltinsInternalC2Ev -__ZNK3KJS11PropertyMap4saveERNS_15SavedPropertiesE -__ZN3KJS30comparePropertyMapEntryIndicesEPKvS1_ -__ZN3WTF9HashTableIiSt4pairIiiENS_18PairFirstExtractorIS2_EENS_7IntHashIiEENS_14PairHashTraitsINS_10HashTraitsIiEES9_EES9_E4findIiNS_22IdentityHashTranslatorIiS2_S6_EEEENS_17HashTableIteratorIiS2_S4_S6_SA_S9_EERKT_ -__ZNK3KJS16JSVariableObject16saveLocalStorageERNS_15SavedPropertiesE -__ZN3KJS13ActivationImpD0Ev -__ZN3KJS8JSObject12removeDirectERKNS_10IdentifierE -__ZN3KJS11PropertyMap6removeERKNS_10IdentifierE -__ZN3KJS7UString3Rep7destroyEv -__ZN3KJS10Identifier6removeEPNS_7UString3RepE -__ZN3KJS8Bindings10RootObject10invalidateEv -__ZN3KJS9Collector9unprotectEPNS_7JSValueE -__ZN3WTF9HashTableIiiNS_17IdentityExtractorIiEENS_7IntHashIiEENS_10HashTraitsIiEES6_E4findIiNS_22IdentityHashTranslatorIiiS4_EEEENS_17HashTableIteratorIiiS2_S4_S6_S6_EERKT_ -__ZN3KJS8Bindings10RootObjectD1Ev -__ZN3KJS14JSGlobalObject10globalExecEv -__ZN3KJS14JSGlobalObject17startTimeoutCheckEv -__ZN3KJS7UStringC1EPKNS_5UCharEi -__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE -__ZN3KJS6ParserC2Ev -__ZN3KJS6Parser5parseINS_11ProgramNodeEEEN3WTF10PassRefPtrIT_EERKNS_7UStringEiPKNS_5UCharEjPiSD_PS7_ -__ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE -__ZN3KJS7UStringaSEPKc -__ZN3KJS5LexerC2Ev -__ZN3WTF6VectorIcLm0EE15reserveCapacityEm -__ZN3WTF6VectorIN3KJS5UCharELm0EE15reserveCapacityEm -__ZN3WTF6VectorIPN3KJS7UStringELm0EE15reserveCapacityEm -__ZN3WTF6VectorIPN3KJS10IdentifierELm0EE15reserveCapacityEm -__Z10kjsyyparsev -__Z8kjsyylexv -__ZN3KJS5Lexer3lexEv -__ZN3KJS5Lexer14makeIdentifierERKN3WTF6VectorINS_5UCharELm0EEE -__ZN3KJS10Identifier3addEPKNS_5UCharEi -__ZN3KJS5Lexer15matchPunctuatorEiiii -__ZN3KJS7UStringC2ERKN3WTF6VectorINS_5UCharELm0EEE -__ZN3KJS14ExpressionNodeC2ENS_6JSTypeE -__ZN3KJS16ParserRefCountedC2Ev -__ZN3KJS7UStringC1ERKS0_ -__ZN3KJS4NodeC2Ev -__ZN3KJS10IdentifierC1ERKS0_ -__ZN3WTF6RefPtrIN3KJS14ExpressionNodeEEC1EPS2_ -__ZN3KJS16ParserRefCounted3refEv -__ZN3WTF6RefPtrIN3KJS12PropertyNodeEEC1EPS2_ -__ZN3WTF10ListRefPtrIN3KJS16PropertyListNodeEEC1Ev -__ZN3KJS11ResolveNodeC1ERKNS_10IdentifierE -__ZN3KJS14ExpressionNodeC2Ev -__ZN3WTF10ListRefPtrIN3KJS16ArgumentListNodeEEC1Ev -__Z20makeFunctionCallNodePN3KJS14ExpressionNodeEPNS_13ArgumentsNodeE -__ZNK3KJS15DotAccessorNode10isLocationEv -__ZNK3KJS14ExpressionNode13isResolveNodeEv -__ZNK3KJS14ExpressionNode21isBracketAccessorNodeEv -__Z14makeNumberNoded -__Z14makeNegateNodePN3KJS14ExpressionNodeE -__ZNK3KJS10NumberNode8isNumberEv -__ZN3KJS19ImmediateNumberNode8setValueEd -__ZN3KJS5lexerEv -__ZN3KJS5Lexer10scanRegExpEv -__ZN3KJS6RegExp6createERKNS_7UStringES3_ -__ZNK3KJS7UString4findENS_5UCharEi -__ZN3KJS17ObjectLiteralNodeC1EPNS_16PropertyListNodeE -__Z14compileBracketiPiPPhPPKtS3_P9ErrorCodeiS_S_R11CompileData -__ZN3KJS16FunctionBodyNode6createEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE -__ZN3KJS16FunctionBodyNodeC2EPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE -__ZN3KJS9ScopeNodeC2EPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE -__ZN3KJS9BlockNodeC1EPNS_14SourceElementsE -__ZN3KJS13StatementNodeC2Ev -__ZN3WTF6RefPtrIN3KJS13ParameterNodeEEC1EPS2_ -__ZN3WTF6RefPtrIN3KJS16FunctionBodyNodeEEC1EPS2_ -__ZN3KJS12FuncExprNode9addParamsEv -__ZN3WTF10ListRefPtrIN3KJS13ParameterNodeEEC1Ev -__ZN3KJS10ReturnNodeC1EPNS_14ExpressionNodeE -__Z23allowAutomaticSemicolonv -__ZN3KJS14SourceElementsC1Ev -__ZN3WTF10PassRefPtrIN3KJS13StatementNodeEEC1EPS2_ -__ZN3KJS14SourceElements6appendEN3WTF10PassRefPtrINS_13StatementNodeEEE -__ZNK3KJS13StatementNode16isEmptyStatementEv -__ZN3WTF6VectorINS_6RefPtrIN3KJS13StatementNodeEEELm0EE14expandCapacityEm -__ZN3WTF6VectorINS_6RefPtrIN3KJS13StatementNodeEEELm0EE15reserveCapacityEm -__ZN3WTF6VectorIN3KJS10IdentifierELm0EE14expandCapacityEmPKS2_ -__ZN3WTF6VectorIN3KJS10IdentifierELm0EE14expandCapacityEm -__ZN3WTF6VectorIN3KJS10IdentifierELm0EE15reserveCapacityEm -__ZN3KJS20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEEC1Ev -__Z26appendToVarDeclarationListRPN3KJS20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEEERKS4_j -__Z20makeVarStatementNodePN3KJS14ExpressionNodeE -__Z14makeAssignNodePN3KJS14ExpressionNodeENS_8OperatorES1_ -__ZN3KJS17ExprStatementNodeC1EPNS_14ExpressionNodeE -__ZN3KJS6IfNodeC2EPNS_14ExpressionNodeEPNS_13StatementNodeE -__Z21mergeDeclarationListsIPN3KJS20ParserRefCountedDataIN3WTF6VectorISt4pairINS0_10IdentifierEjELm16EEEEEET_SA_SA_ -__Z21mergeDeclarationListsIPN3KJS20ParserRefCountedDataIN3WTF6VectorIPNS0_12FuncDeclNodeELm16EEEEEET_S9_S9_ -__ZNK3KJS11ResolveNode10isLocationEv -__ZNK3KJS11ResolveNode13isResolveNodeEv -__Z22combineVarInitializersPN3KJS14ExpressionNodeEPNS_17AssignResolveNodeE -__ZN3KJS14ExpressionNode28optimizeForUnnecessaryResultEv -__ZN3WTF6VectorIPN3KJS10IdentifierELm0EE14expandCapacityEmPKS3_ -__ZN3WTF6VectorIPN3KJS10IdentifierELm0EE14expandCapacityEm -__ZN3KJS12FuncDeclNode9addParamsEv -__ZN3WTF6VectorIPN3KJS12FuncDeclNodeELm16EEC1Ev -__ZN3WTF6VectorISt4pairIN3KJS10IdentifierEjELm16EE6appendIS4_EEvPKT_m -__ZN3KJS16ParserRefCounted5derefEv -__ZN3KJS20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEED1Ev -__Z12makeLessNodePN3KJS14ExpressionNodeES1_ -__Z15makePostfixNodePN3KJS14ExpressionNodeENS_8OperatorE -__ZN3WTF6RefPtrIN3KJS13StatementNodeEEC1EPS2_ -__ZN3KJS18PostIncResolveNode28optimizeForUnnecessaryResultEv -__ZN3WTF6VectorISt4pairIN3KJS10IdentifierEjELm16EEaSERKS5_ -__ZN3WTF6VectorIPN3KJS12FuncDeclNodeELm16EEaSERKS4_ -__ZNK3KJS14ExpressionNode10isLocationEv -__ZNK3KJS19BracketAccessorNode10isLocationEv -__ZNK3KJS19BracketAccessorNode21isBracketAccessorNodeEv -__ZN3KJS9ForInNodeC1ERKNS_10IdentifierEPNS_14ExpressionNodeES5_PNS_13StatementNodeE -__ZN3KJS9ThrowNodeC1EPNS_14ExpressionNodeE -__Z14makeTypeOfNodePN3KJS14ExpressionNodeE -__ZN3WTF6VectorINS_6RefPtrIN3KJS13StatementNodeEEELm0EEC1Ev -__ZN3WTF6RefPtrIN3KJS14CaseClauseNodeEEC1EPS2_ -__ZN3WTF10ListRefPtrIN3KJS14ClauseListNodeEEC1Ev -__ZN3KJS13CaseBlockNodeC2EPNS_14ClauseListNodeEPNS_14CaseClauseNodeES2_ -__Z11makeAddNodePN3KJS14ExpressionNodeES1_ -__ZN3WTF10ListRefPtrIN3KJS11ElementNodeEEC1Ev -__ZN3WTF6RefPtrIN3KJS11ElementNodeEEC1EPS2_ -__ZNK3KJS18EmptyStatementNode16isEmptyStatementEv -__ZN3KJS9BreakNodeC1Ev -__Z32branchFindFirstAssertedCharacterPKhb -__Z20branchNeedsLineStartPKhjj -__ZN3KJS10IdentifierC1ERKNS_7UStringE -__ZN3WTF6RefPtrIN3KJS7UString3RepEED1Ev -__ZN3KJS9CommaNodeC2EPNS_14ExpressionNodeES2_ -__Z14makePrefixNodePN3KJS14ExpressionNodeENS_8OperatorE -__ZN3WTF6RefPtrIN3KJS13ArgumentsNodeEEC1EPS2_ -__ZN3WTF6VectorIPN3KJS7UStringELm0EE14expandCapacityEmPKS3_ -__ZN3WTF6VectorIPN3KJS7UStringELm0EE14expandCapacityEm -__ZN3WTF6VectorIN3KJS5UCharELm0EE14expandCapacityEmPKS2_ -__ZN3WTF6VectorIN3KJS5UCharELm0EE14expandCapacityEm -__ZNK3KJS14ExpressionNode8isNumberEv -__ZN3KJS19PlaceholderTrueNodeC1Ev -__ZN3KJS18EmptyStatementNodeC1Ev -__Z14makeDeleteNodePN3KJS14ExpressionNodeE -__Z15isCountedRepeatPKtS0_ -__ZN3KJS12ContinueNodeC1Ev -__ZN3KJS9ForInNodeC1EPNS_14ExpressionNodeES2_PNS_13StatementNodeE -__ZN3KJS18PostDecResolveNode28optimizeForUnnecessaryResultEv -__Z17bracketIsAnchoredPKh -__ZN3WTF6VectorISt4pairIN3KJS10IdentifierEjELm16EE14expandCapacityEmPKS4_ -__ZN3WTF6VectorISt4pairIN3KJS10IdentifierEjELm16EE14expandCapacityEm -__ZN3WTF6VectorISt4pairIN3KJS10IdentifierEjELm16EE15reserveCapacityEm -__ZN3KJS7UString4fromEd -_kjs_dtoa -_d2b -_Balloc -__ZN3KJS6parserEv -__ZN3KJS6Parser16didFinishParsingEPNS_14SourceElementsEPNS_20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEEEPNS3_INS5_IPNS_12FuncDeclNodeELm16EEEEEi -__ZN3KJS5Lexer5clearEv -__ZN3WTF25TCMalloc_Central_FreeList11InsertRangeEPvS1_i +__ZN3WTF11fastReallocILb1EEEPvS1_m +__ZN3JSC4Heap8allocateEm +__ZN3JSCL13allocateBlockILNS_8HeapTypeE0EEEPNS_14CollectorBlockEv +__ZN3JSC14JSGlobalObjectnwEmPNS_12JSGlobalDataE +__ZN3JSC14JSGlobalObject4initEPNS_8JSObjectE +__ZN3JSC14JSGlobalObject5resetENS_10JSValuePtrE +__ZN3JSC4Heap12heapAllocateILNS_8HeapTypeE0EEEPvm +__ZN3JSC17FunctionPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEE +__ZN3JSC8jsStringEPNS_12JSGlobalDataERKNS_7UStringE +__ZN3JSC12SmallStrings17createEmptyStringEPNS_12JSGlobalDataE +__ZN3JSC7UStringC1EPKc +__ZN3JSCL9createRepEPKc +__ZN3JSC8JSObject9putDirectERKNS_10IdentifierENS_10JSValuePtrEjbRNS_15PutPropertySlotE +__ZN3JSC9Structure40addPropertyTransitionToExistingStructureEPS0_RKNS_10IdentifierEjRm +__ZN3JSC9Structure3getERKNS_10IdentifierERj +__ZN3JSC9Structure21addPropertyTransitionEPS0_RKNS_10IdentifierEjRm +__ZN3JSC9Structure3putERKNS_10IdentifierEj +__ZN3JSC9Structure28addPropertyWithoutTransitionERKNS_10IdentifierEj +__ZN3JSC17FunctionPrototype21addFunctionPropertiesEPNS_9ExecStateEPNS_9StructureE +__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_10JSValuePtrES2_PNS_8JSObjectESA_RKNS_7ArgListEE +__ZN3JSC8JSObject34putDirectFunctionWithoutTransitionEPNS_9ExecStateEPNS_16InternalFunctionEj +__ZN3JSC15ObjectPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_ +__ZN3JSC9Structure26rehashPropertyMapHashTableEj +__ZN3JSC15StringPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEE +__ZN3JSC16BooleanPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_ +__ZN3JSC15NumberPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_ +__ZN3JSC12jsNumberCellEPNS_9ExecStateEd +__ZN3JSCL13allocateBlockILNS_8HeapTypeE1EEEPNS_14CollectorBlockEv +__ZN3JSC15RegExpPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_ +__ZN3JSC14ErrorPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_ +__ZN3WTF6RefPtrIN3JSC7UString3RepEED1Ev +__ZN3JSC20NativeErrorPrototypeC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEERKNS_7UStringES9_ +__ZN3JSC17ObjectConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_15ObjectPrototypeE +__ZN3JSC19FunctionConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_17FunctionPrototypeE +__ZNK3JSC16InternalFunction9classInfoEv +__ZN3JSC16ArrayConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_14ArrayPrototypeE +__ZNK3JSC14ArrayPrototype9classInfoEv +__ZN3JSC17StringConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_PNS_15StringPrototypeE +__ZNK3JSC15StringPrototype9classInfoEv +__ZN3JSC18BooleanConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_16BooleanPrototypeE +__ZNK3JSC13BooleanObject9classInfoEv +__ZN3JSC17NumberConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_15NumberPrototypeE +__ZN3JSC15DateConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPS5_PNS_13DatePrototypeE +__ZNK3JSC13DatePrototype9classInfoEv +__ZN3JSC17RegExpConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_15RegExpPrototypeE +__ZN3JSC16ErrorConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_14ErrorPrototypeE +__ZNK3JSC13ErrorInstance9classInfoEv +__ZN3JSC22NativeErrorConstructorC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS_20NativeErrorPrototypeE +__ZN3JSC10Identifier11addSlowCaseEPNS_12JSGlobalDataEPNS_7UString3RepE +__ZN3WTF7HashSetIPN3JSC7UString3RepENS_7StrHashIS4_EENS_10HashTraitsIS4_EEE3addERKS4_ +__ZN3JSC10MathObjectC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEE +__ZN3JSC12SmallStrings24singleCharacterStringRepEh +__ZN3WTF7HashMapINS_6RefPtrIN3JSC7UString3RepEEENS2_16SymbolTableEntryENS2_17IdentifierRepHashENS_10HashTraitsIS5_EENS2_26SymbolTableIndexHashTraitsEE3addEPS4_RKS6_ +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEESt4pairIS5_NS2_16SymbolTableEntryEENS_18PairFirstExtractorIS8_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS_10HashTraitsIS5_EENS2_26SymbolTableIndexHashTraitsEEESE_E6rehashEi +__ZN3JSC9Structure25changePrototypeTransitionEPS0_NS_10JSValuePtrE +__ZN3JSC9Structure17copyPropertyTableEv +__ZN3JSC14JSGlobalObject14setTimeoutTimeEj +__ZN3JSC14JSGlobalObject10globalExecEv +__ZN3JSC10Identifier3addEPNS_9ExecStateEPKc +__ZN3JSC4Heap4heapENS_10JSValuePtrE +__ZN3JSC4Heap7protectENS_10JSValuePtrE +__ZN3WTF7HashMapIPN3JSC6JSCellEjNS_7PtrHashIS3_EENS_10HashTraitsIS3_EENS6_IjEEE3addERKS3_RKj +__ZN3WTF9HashTableIPN3JSC6JSCellESt4pairIS3_jENS_18PairFirstExtractorIS5_EENS_7PtrHashIS3_EENS_14PairHashTraitsINS_10HashTraitsIS3_EENSB_IjEEEESC_E6rehashEi +__ZN3JSC6JSCellnwEmPNS_9ExecStateE +__ZN3JSC14JSGlobalObject17startTimeoutCheckEv +__ZN3JSC11Interpreter17resetTimeoutCheckEv +__ZN3JSC8evaluateEPNS_9ExecStateERNS_10ScopeChainERKNS_10SourceCodeENS_10JSValuePtrE +__ZN3JSC6JSLock4lockEb +__ZN3JSC6Parser5parseINS_11ProgramNodeEEEN3WTF10PassRefPtrIT_EEPNS_9ExecStateEPNS_8DebuggerERKNS_10SourceCodeEPiPNS_7UStringE +__ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE +__ZN3JSC7UStringaSEPKc +__Z10jscyyparsePv +__ZN3JSC5Lexer3lexEPvS1_ +__ZN3WTF6VectorItLm0EE15reserveCapacityEm +__ZN3WTF6VectorItLm0EE6appendItEEvRKT_ +__ZN3JSC10Identifier3addEPNS_12JSGlobalDataEPKti +__ZN3WTF7HashSetIPN3JSC7UString3RepENS_7StrHashIS4_EENS_10HashTraitsIS4_EEE3addIPKcNS1_17CStringTranslatorEEESt4pairINS_24HashTableIteratorAdapterINS_9HashTableIS4_S4_NS_17IdentityExtractorIS4_EES6_S8_S8_EES4_EEbERKT_ +__ZNK3JSC9HashTable11createTableEPNS_12JSGlobalDataE +__ZN3WTF7HashSetIPN3JSC16ParserRefCountedENS_7PtrHashIS3_EENS_10HashTraitsIS3_EEE3addERKS3_ +__ZN3WTF9HashTableIPN3JSC16ParserRefCountedES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E6rehashEi +__ZN3JSC16ParserRefCountedC2EPNS_12JSGlobalDataE +__ZN3JSC16ParserRefCounted3refEv +__ZL20makeFunctionCallNodePvN3JSC8NodeInfoIPNS0_14ExpressionNodeEEENS1_IPNS0_13ArgumentsNodeEEEiii +__ZNK3JSC15DotAccessorNode10isLocationEv +__ZNK3JSC14ExpressionNode13isResolveNodeEv +__ZNK3JSC14ExpressionNode21isBracketAccessorNodeEv +__ZN3WTF7HashMapIPN3JSC16ParserRefCountedEjNS_7PtrHashIS3_EENS_10HashTraitsIS3_EENS6_IjEEE3addERKS3_RKj +__ZN3WTF9HashTableIPN3JSC16ParserRefCountedESt4pairIS3_jENS_18PairFirstExtractorIS5_EENS_7PtrHashIS3_EENS_14PairHashTraitsINS_10HashTraitsIS3_EENSB_IjEEEESC_E6rehashEi +__ZN3JSC14SourceElements6appendEN3WTF10PassRefPtrINS_13StatementNodeEEE +__ZNK3JSC13StatementNode16isEmptyStatementEv +__ZN3JSC6Parser16didFinishParsingEPNS_14SourceElementsEPNS_20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm0EEEEEPNS3_INS5_INS4_6RefPtrINS_12FuncDeclNodeEEELm0EEEEEjii +__ZN3JSC5Lexer5clearEv +__ZN3WTF6VectorIN3JSC10IdentifierELm64EE14shrinkCapacityEm +__ZN3WTF15deleteAllValuesIPN3JSC16ParserRefCountedEKNS_9HashTableIS3_S3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EESA_EEEEvRT0_ +__ZN3JSC15DotAccessorNodeD1Ev +__ZN3JSC12NodeReleaser15releaseAllNodesEPNS_16ParserRefCountedE +__ZN3JSC15DotAccessorNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC12NodeReleaser5adoptEN3WTF10PassRefPtrINS_16ParserRefCountedEEE +__ZN3JSC16ParserRefCounted9hasOneRefEv +__ZN3JSC16ParserRefCounted5derefEv +__ZN3JSC9ScopeNodeC2EPNS_12JSGlobalDataERKNS_10SourceCodeEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm0EEEPNS9_INS8_6RefPtrINS_12FuncDeclNodeEEELm0EEEji +__ZN3WTF6VectorINS_6RefPtrIN3JSC13StatementNodeEEELm0EE14shrinkCapacityEm +__ZN3JSC14SourceElementsD1Ev +__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateE +__ZN3JSC11Interpreter7executeEPNS_11ProgramNodeEPNS_9ExecStateEPNS_14ScopeChainNodeEPNS_8JSObjectEPNS_10JSValuePtrE +__ZN3JSC11ProgramNode16generateBytecodeEPNS_14ScopeChainNodeE +__ZN3JSC9CodeBlockC1EPNS_9ScopeNodeENS_8CodeTypeEN3WTF10PassRefPtrINS_14SourceProviderEEEj +__ZN3WTF7HashSetIPN3JSC16ProgramCodeBlockENS_7PtrHashIS3_EENS_10HashTraitsIS3_EEE3addERKS3_ +__ZN3WTF9HashTableIPN3JSC16ProgramCodeBlockES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E6rehashEi +__ZN3JSC17BytecodeGeneratorC2EPNS_11ProgramNodeEPKNS_8DebuggerERKNS_10ScopeChainEPN3WTF7HashMapINS9_6RefPtrINS_7UString3RepEEENS_16SymbolTableEntryENS_17IdentifierRepHashENS9_10HashTraitsISE_EENS_26SymbolTableIndexHashTraitsEEEPNS_16ProgramCodeBlockE +__ZN3WTF6VectorIN3JSC11InstructionELm0EE14expandCapacityEm +__ZN3JSC9Structure22toDictionaryTransitionEPS0_ +__ZN3JSC17BytecodeGenerator11newRegisterEv +__ZN3JSC9Structure24fromDictionaryTransitionEPS0_ +__ZN3JSC17BytecodeGenerator8generateEv +__ZN3JSC11ProgramNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator13emitDebugHookENS_11DebugHookIDEii +__ZN3JSC17BytecodeGenerator11addConstantENS_10JSValuePtrE +__ZN3WTF9HashTableIPN3JSC23JSValueEncodedAsPointerESt4pairIS3_jENS_18PairFirstExtractorIS5_EENS_7PtrHashIS3_EENS_14PairHashTraitsINS1_17BytecodeGenerator17JSValueHashTraitsENS_10HashTraitsIjEEEESC_E6expandEv +__ZN3WTF6VectorIN3JSC8RegisterELm0EE14expandCapacityEm +__ZNK3JSC13StatementNode6isLoopEv +__ZN3JSC17BytecodeGenerator8emitNodeEPNS_10RegisterIDEPNS_4NodeE +__ZN3WTF6VectorIN3JSC8LineInfoELm0EE14expandCapacityEm +__ZN3JSC17ExprStatementNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC19FunctionCallDotNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC11ResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator11registerForERKNS_10IdentifierE +__ZN3WTF6VectorIN3JSC19ExpressionRangeInfoELm0EE14expandCapacityEm +__ZN3JSC17BytecodeGenerator11emitGetByIdEPNS_10RegisterIDES2_RKNS_10IdentifierE +__ZN3WTF6VectorIN3JSC17StructureStubInfoELm0EE14expandCapacityEm +__ZN3JSC17BytecodeGenerator11addConstantERKNS_10IdentifierE +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEESt4pairIS5_iENS_18PairFirstExtractorIS7_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS_10HashTraitsIS5_EENS2_17BytecodeGenerator28IdentifierMapIndexHashTraitsEEESD_E6expandEv +__ZN3WTF6VectorIN3JSC10IdentifierELm0EE14expandCapacityEm +__ZN3JSC17BytecodeGenerator8emitCallENS_8OpcodeIDEPNS_10RegisterIDES3_S3_PNS_13ArgumentsNodeEjjj +__ZN3WTF6VectorIN3JSC12CallLinkInfoELm0EE14expandCapacityEm +__ZN3JSC9CodeBlock11shrinkToFitEv +__ZN3WTF6VectorIN3JSC11InstructionELm0EE14shrinkCapacityEm +__ZN3WTF6VectorIN3JSC17StructureStubInfoELm0EE14shrinkCapacityEm +__ZN3WTF6VectorIN3JSC17GlobalResolveInfoELm0EE14shrinkCapacityEm +__ZN3WTF6VectorIPN3JSC12CallLinkInfoELm0EE14shrinkCapacityEm +__ZN3WTF6VectorIN3JSC10IdentifierELm0EE14shrinkCapacityEm +__ZN3JSC17ExprStatementNodeD1Ev +__ZN3JSC19FunctionCallDotNodeD1Ev +__ZN3JSC19FunctionCallDotNode12releaseNodesERNS_12NodeReleaserE +__ZN3WTF6VectorINS_6RefPtrIN3JSC16ParserRefCountedEEELm0EE14expandCapacityEm +__ZN3JSC16ParserRefCounted12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13ArgumentsNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11ResolveNodeD1Ev +__ZN3JSC13ArgumentsNodeD1Ev +__ZN3JSC14JSGlobalObject13copyGlobalsToERNS_12RegisterFileE +__ZN3JSC3JIT14privateCompileEv +__ZN3JSC3JIT22privateCompileMainPassEv +__ZN3JSC3JIT21compileGetByIdHotPathEiiPNS_10IdentifierEj +__ZN3WTF6VectorIN3JSC13SlowCaseEntryELm0EE14expandCapacityEm +__ZN3JSC3JIT13compileOpCallENS_8OpcodeIDEPNS_11InstructionEj +__ZN3WTF6VectorIN3JSC10CallRecordELm0EE14expandCapacityEm +__ZN3JSC3JIT22privateCompileLinkPassEv +__ZN3JSC3JIT23privateCompileSlowCasesEv +__ZN3JSC3JIT22compileGetByIdSlowCaseEiiPNS_10IdentifierERPNS_13SlowCaseEntryEj +__ZN3JSC3JIT21compileOpCallSlowCaseEPNS_11InstructionERPNS_13SlowCaseEntryEjNS_8OpcodeIDE +__ZN3JSC3JIT22compileOpCallSetupArgsEPNS_11InstructionE +__ZN3JSC12X86Assembler3jneEv +__ZN3WTF6VectorIN3JSC10CallRecordELm0EE6appendIS2_EEvRKT_ +__ZN3JSC9CodeBlock10setJITCodeERNS_10JITCodeRefE +__ZN3JSC17BytecodeGenerator18dumpsGeneratedCodeEv +__ZN3WTF10RefCountedIN3JSC14ExecutablePoolEE5derefEv +ctiTrampoline +__ZN3JSC11Interpreter16cti_op_get_by_idEPvz +__ZNK3JSC10JSValuePtr3getEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC10MathObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFNS_10JSValuePtrES2_PNS_8JSObjectES6_RKNS_7ArgListEE +__ZN3JSC27ctiPatchCallByReturnAddressEPvS0_ +__ZN3JSC11Interpreter25cti_op_call_NotJSFunctionEPvz +__ZN3JSC17PrototypeFunction11getCallDataERNS_8CallDataE +__ZN3JSCL19mathProtoFuncRandomEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3WTF12randomNumberEv +__ZN3JSC11ProgramNodeD1Ev +__ZN3WTF9HashTableIPN3JSC16ProgramCodeBlockES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E4findIS3_NS_22IdentityHashTranslatorIS3_S3_S7_EEEENS_17HashTableIteratorIS3_S3_S5_S7_S9_S9_EERKT_ +__ZN3JSC9CodeBlockD2Ev +__ZN3JSC17StructureStubInfo5derefEv +__ZN3JSC9ScopeNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC14JSGlobalObject16stopTimeoutCheckEv +__ZN3JSC4Heap9unprotectENS_10JSValuePtrE +__ZNK3JSC12JSNumberCell8toStringEPNS_9ExecStateE +__ZN3JSC7UString4fromEd +__ZN3WTF4dtoaEdiPiS0_PPc +__ZN3WTFL3d2bEdPiS0_ +__ZN3WTFL8pow5multEPNS_6BigintEi +__ZN3WTFL4multEPNS_6BigintES1_ +__ZN3WTFL6lshiftEPNS_6BigintEi +__ZN3WTFL6quoremEPNS_6BigintES1_ +__ZN3WTFL4diffEPNS_6BigintES1_ +__ZN3JSC7UString3Rep7destroyEv +-[WTFMainThreadCaller call] +__ZN3WTF31dispatchFunctionsFromMainThreadEv +__ZN3JSC4Heap7collectEv +__ZN3JSC4Heap30markStackObjectsConservativelyEv +__ZN3JSC4Heap31markCurrentThreadConservativelyEv +__ZN3JSC4Heap39markCurrentThreadConservativelyInternalEv +__ZN3JSC4Heap18markConservativelyEPvS1_ +__ZN3JSC4Heap20markProtectedObjectsEv +__ZN3JSC12SmallStrings4markEv +__ZN3JSC6JSCell4markEv +__ZN3JSC4Heap5sweepILNS_8HeapTypeE0EEEmv +__ZN3JSC14JSGlobalObjectD2Ev +__ZN3JSC17FunctionPrototypeD0Ev +__ZN3JSC17PrototypeFunctionD0Ev +__ZN3JSC16BooleanPrototypeD0Ev +__ZN3JSC15NumberPrototypeD0Ev +__ZN3JSC14ErrorPrototypeD0Ev +__ZN3JSC17ObjectConstructorD0Ev +__ZN3JSC16ArrayConstructorD0Ev +__ZN3JSC17StringConstructorD0Ev +__ZN3JSC18BooleanConstructorD0Ev +__ZN3JSC17NumberConstructorD0Ev +__ZN3JSC17RegExpConstructorD0Ev +__ZN3JSC16ErrorConstructorD0Ev +__ZN3JSC22NativeErrorConstructorD0Ev +__ZN3JSC18GlobalEvalFunctionD0Ev +__ZN3JSC4Heap5sweepILNS_8HeapTypeE1EEEmv __ZN3WTF25TCMalloc_Central_FreeList11ShrinkCacheEib -__ZN3WTF25TCMalloc_Central_FreeList18ReleaseListToSpansEPv -__ZN3WTF15deleteAllValuesIPN3KJS16ParserRefCountedEKNS_9HashTableIiiNS_17IdentityExtractorIiEENS_7IntHashIiEENS_10HashTraitsIiEESA_EEEEvRT0_ -__ZN3KJS19BracketAccessorNodeD1Ev -__ZN3KJS11ProgramNodeC2EPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE -__ZNK3KJS8JSObject8toObjectEPNS_9ExecStateE -__ZN3KJS11ProgramNode7executeEPNS_9ExecStateE -__ZN3KJS11ProgramNode21initializeSymbolTableEPNS_9ExecStateE -__ZN3WTF6VectorImLm0EE6resizeEm -__ZN3WTF6VectorImLm0EE14expandCapacityEm -__ZN3WTF6VectorImLm0EE15reserveCapacityEm -__ZN3WTF9HashTableINS_6RefPtrIN3KJS7UString3RepEEESt4pairIS5_mENS_18PairFirstExtractorIS7_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS2_23IdentifierRepHashTraitsENS2_26SymbolTableIndexHashTraitsEEESC_E3addIS5_mNS_17HashMapTranslatorILb1ES7_NS_18PairBaseHashTraitsISC_SD_EESE_SA_EEEES6_INS_17HashTableIteratorIS5_S7_S9_SA_SE_SC_EEbERKT_RKT0_ -__ZN3WTF9HashTableINS_6RefPtrIN3KJS7UString3RepEEESt4pairIS5_mENS_18PairFirstExtractorIS7_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS2_23IdentifierRepHashTraitsENS2_26SymbolTableIndexHashTraitsEEESC_E6rehashEi -__ZN3KJS14JSGlobalObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZNK3WTF7HashMapINS_6RefPtrIN3KJS7UString3RepEEEmNS2_17IdentifierRepHashENS2_23IdentifierRepHashTraitsENS2_26SymbolTableIndexHashTraitsEE3getEPS4_ -__ZN3KJS11PropertyMap11getLocationERKNS_10IdentifierE -__ZN3KJS6Lookup9findEntryEPKNS_9HashTableERKNS_10IdentifierE -__ZNK3KJS7UString14toStrictUInt32EPb -__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3WTF6VectorIN3KJS17LocalStorageEntryELm32EE15reserveCapacityEm -__ZN3KJS11FunctionImpC2EPNS_9ExecStateERKNS_10IdentifierEPNS_16FunctionBodyNodeERKNS_10ScopeChainE -__ZN3KJS15ObjectObjectImp9constructEPNS_9ExecStateERKNS_4ListE -__ZN3KJS9ScopeNode22optimizeVariableAccessEPNS_9ExecStateE -__ZN3WTF6VectorIPN3KJS4NodeELm16EE14expandCapacityEm -__ZN3WTF6VectorIPN3KJS4NodeELm16EE15reserveCapacityEm -__ZN3KJS16VarStatementNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS17AssignResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS17ObjectLiteralNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS16PropertyListNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS12PropertyNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS4Node22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPS0_Lm16EEE -__ZN3KJS14LogicalNotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS14LogicalAndNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS15DotAccessorNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS11ResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS11GreaterNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS19FunctionCallDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS13ArgumentsNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS16ArgumentListNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS9EqualNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS18NotStrictEqualNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS6IfNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS17ExprStatementNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS13AssignDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS13LogicalOrNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS8WithNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS9BlockNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS23FunctionCallResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS21FunctionCallValueNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS9ArrayNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS11ElementNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS10IfElseNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS7AddNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS6InNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS11NewExprNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS16VarStatementNode7executeEPNS_9ExecStateE -__ZN3KJS18AssignLocalVarNode8evaluateEPNS_9ExecStateE -__ZN3KJS17ObjectLiteralNode8evaluateEPNS_9ExecStateE -__ZN3KJS16PropertyListNode8evaluateEPNS_9ExecStateE -__ZN3KJS10StringNode8evaluateEPNS_9ExecStateE -__ZN3KJS13jsOwnedStringERKNS_7UStringE -__ZN3KJS8JSObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS14LogicalNotNode8evaluateEPNS_9ExecStateE -__ZN3KJS14LogicalNotNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS14LogicalAndNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS15DotAccessorNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS11ResolveNode8evaluateEPNS_9ExecStateE -__ZN3KJS11GreaterNode8evaluateEPNS_9ExecStateE -__ZN3KJS19FunctionCallDotNode8evaluateEPNS_9ExecStateE -__ZN3KJS15DotAccessorNode8evaluateEPNS_9ExecStateE -__ZNK3KJS9ExecState19lexicalGlobalObjectEv -__ZNK3KJS9StringImp8toObjectEPNS_9ExecStateE -__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS15StringPrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS20staticFunctionGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectERKNS_4ListEE -__ZNK3KJS19InternalFunctionImp14implementsCallEv -__ZN3KJS16ArgumentListNode12evaluateListEPNS_9ExecStateERNS_4ListE -__ZN3KJS17PrototypeFunction14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS22stringProtoFuncIndexOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS14StringInstance9classInfoEv -__ZNK3KJS9StringImp8toStringEPNS_9ExecStateE -__ZNK3KJS7JSValue9toIntegerEPNS_9ExecStateE -__ZNK3KJS7UString4findERKS0_i -__ZN3KJS19ImmediateNumberNode8evaluateEPNS_9ExecStateE -__ZN3KJS14LogicalAndNode8evaluateEPNS_9ExecStateE -__ZN3KJS9EqualNode8evaluateEPNS_9ExecStateE -__ZN3KJS5equalEPNS_9ExecStateEPNS_7JSValueES3_ -__ZN3KJS19FunctionCallDotNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS10RegExpNode8evaluateEPNS_9ExecStateE -__ZN3KJS15RegExpObjectImp15createRegExpImpEPNS_9ExecStateEN3WTF10PassRefPtrINS_6RegExpEEE -__ZN3KJS20stringProtoFuncMatchEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS9RegExpImp9classInfoEv -__ZN3KJS15RegExpObjectImp12performMatchEPNS_6RegExpERKNS_7UStringEiRiS6_PPi -__ZN3KJS6RegExp5matchERKNS_7UStringEiPN3WTF11OwnArrayPtrIiEE -__Z5matchPKtPKhiR9MatchData -__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE -__ZN3KJS18NotStrictEqualNode8evaluateEPNS_9ExecStateE -__ZNK3KJS7UString8toUInt32EPbb -__ZNK3KJS7UString8toDoubleEbb -__ZN3KJS11strictEqualEPNS_9ExecStateEPNS_7JSValueES3_ -__ZN3KJS12FuncExprNode8evaluateEPNS_9ExecStateE -__ZN3KJS14JSGlobalObject17tearOffActivationEPNS_9ExecStateEb -__ZN3KJS6IfNode7executeEPNS_9ExecStateE -__ZN3KJS18LocalVarAccessNode8evaluateEPNS_9ExecStateE -__ZN3KJS17ExprStatementNode7executeEPNS_9ExecStateE -__ZN3KJS13AssignDotNode8evaluateEPNS_9ExecStateE -__ZN3KJS11FunctionImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS17FunctionExecStateC1EPNS_14JSGlobalObjectEPNS_8JSObjectEPNS_16FunctionBodyNodeEPNS_9ExecStateEPNS_11FunctionImpERKNS_4ListE -__ZN3KJS14JSGlobalObject14pushActivationEPNS_9ExecStateE -__ZN3KJS13ActivationImp4initEPNS_9ExecStateE -__ZN3KJS16FunctionBodyNode7executeEPNS_9ExecStateE -__ZN3KJS16FunctionBodyNode21initializeSymbolTableEPNS_9ExecStateE -__ZN3KJS9ForInNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS17AssignBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS19BracketAccessorNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS10ReturnNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS9ForInNode7executeEPNS_9ExecStateE -__ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE -__ZNK3KJS11PropertyMap26getEnumerablePropertyNamesERNS_17PropertyNameArrayE -__ZNK3KJS8JSObject9classInfoEv -__ZN3KJS13ActivationImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS13ActivationImp3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS17AssignBracketNode8evaluateEPNS_9ExecStateE -__ZNK3KJS6JSCell9getUInt32ERj -__ZN3KJS19BracketAccessorNode8evaluateEPNS_9ExecStateE -__ZN3KJS10ReturnNode7executeEPNS_9ExecStateE -__ZN3KJS14JSGlobalObject13popActivationEv -__ZN3KJS11FunctionImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS10NumberNode8evaluateEPNS_9ExecStateE -__ZN3KJS9CommaNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS13ActivationImpC1ERKNS0_14ActivationDataEb -__ZN3WTF6VectorIN3KJS17LocalStorageEntryELm32EEC2ERKS3_ -__ZN3KJS13ActivationImp15argumentsGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS13ActivationImp21createArgumentsObjectEPNS_9ExecStateE -__ZN3KJS9ArgumentsC2EPNS_9ExecStateEPNS_11FunctionImpERKNS_4ListEPNS_13ActivationImpE -__ZN3KJS14IndexToNameMapC2EPNS_11FunctionImpERKNS_4ListE -__ZN3KJS11FunctionImp16getParameterNameEi -__ZN3KJS7UString4fromEj -__ZN3KJS9Arguments18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS9CommaNode8evaluateEPNS_9ExecStateE -__ZN3KJS8ThisNode8evaluateEPNS_9ExecStateE -__ZN3KJS23FunctionCallResolveNode8evaluateEPNS_9ExecStateE -__ZN3KJS9WhileNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS18PostDecResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS18LocalVarAccessNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS13LogicalOrNode8evaluateEPNS_9ExecStateE -__ZN3KJS11NewExprNode8evaluateEPNS_9ExecStateE -__ZNK3KJS14ArrayObjectImp19implementsConstructEv -__ZN3KJS14ArrayObjectImp9constructEPNS_9ExecStateERKNS_4ListE -__ZN3KJS9WhileNode7executeEPNS_9ExecStateE -__ZN3KJS19PostDecLocalVarNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE -__ZN3KJS13ArrayInstance3putEPNS_9ExecStateEjPNS_7JSValueEi -__ZN3KJS15RegExpObjectImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS15RegExpObjectImp3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS7ForNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS8LessNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS17PreIncResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS8NullNode8evaluateEPNS_9ExecStateE -__ZN3KJS13ArrayInstance18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE -__ZN3KJS17TypeOfResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS18LocalVarTypeOfNode8evaluateEPNS_9ExecStateE -__ZN3KJS18typeStringForValueEPNS_7JSValueE -__ZNK3KJS8JSObject21masqueradeAsUndefinedEv -__ZNK3KJS8JSObject14implementsCallEv -__ZN3KJS12FuncDeclNode7executeEPNS_9ExecStateE -__ZN3KJS11FunctionImp3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS9ArrayNode8evaluateEPNS_9ExecStateE -__ZN3KJS13ArrayInstanceC2EPNS_8JSObjectERKNS_4ListE -__ZN3KJS13ArrayInstance3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS13ArrayInstance9setLengthEj -__ZN3KJS7ForNode7executeEPNS_9ExecStateE -__ZN3KJS8LessNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS13ArrayInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS13ArrayInstance12lengthGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS14ArrayPrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS18arrayProtoFuncPushEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS8TrueNode8evaluateEPNS_9ExecStateE -__ZN3KJS9BlockNode7executeEPNS_9ExecStateE -__ZN3KJS18PreIncLocalVarNode8evaluateEPNS_9ExecStateE -__ZN3KJS14StringInstance3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZN3KJS13LogicalOrNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS8WithNode7executeEPNS_9ExecStateE -__ZN3KJS15NumberObjectImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS24LocalVarFunctionCallNode8evaluateEPNS_9ExecStateE -__ZN3KJS15ConditionalNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS22stringProtoFuncReplaceEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS7replaceEPNS_9ExecStateEPNS_9StringImpEPNS_7JSValueES5_ -__ZNK3KJS7UString30spliceSubstringsWithSeparatorsEPKNS0_5RangeEiPKS0_i -__ZN3KJS15ConditionalNode8evaluateEPNS_9ExecStateE -__ZNK3KJS9StringImp9toBooleanEPNS_9ExecStateE -__ZN3KJS20stringProtoFuncSplitEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS7UString6substrEii -__ZN3KJS7UString3Rep6createEN3WTF10PassRefPtrIS1_EEii -__ZN3KJS7TryNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS15LessNumbersNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS15DotAccessorNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS10NumberNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS7TryNode7executeEPNS_9ExecStateE -__ZN3KJS21arrayProtoFuncForEachEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS18PostIncResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS18PostIncResolveNode8evaluateEPNS_9ExecStateE -__ZN3KJS13ActivationImp18isActivationObjectEv -__ZN3KJS13MathObjectImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS21FunctionCallValueNode8evaluateEPNS_9ExecStateE -__ZN3KJS12NotEqualNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS9FalseNode8evaluateEPNS_9ExecStateE -__ZN3KJS19arrayProtoFuncShiftEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS13ArrayInstance14deletePropertyEPNS_9ExecStateEj -__ZNK3KJS11FunctionImp19implementsConstructEv -__ZN3KJS11FunctionImp9constructEPNS_9ExecStateERKNS_4ListE -__ZN3KJS9EqualNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS25functionProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS11FunctionImp9classInfoEv -__ZNK3KJS4Node8toStringEv -__ZNK3KJS9ScopeNode8streamToERNS_12SourceStreamE -__ZN3KJS7UString6appendEt -__ZN3KJS7UString6appendERKS0_ -__ZN3KJS7UString6appendEPKc -__ZN3KJS7UString14expandCapacityEi -__ZN3KJS12SourceStreamlsEPKNS_4NodeE -__ZNK3KJS17ExprStatementNode8streamToERNS_12SourceStreamE -__ZNK3KJS4Node21needsParensIfLeftmostEv -__ZNK3KJS23FunctionCallResolveNode8streamToERNS_12SourceStreamE -__ZNK3KJS13ArgumentsNode8streamToERNS_12SourceStreamE -__ZNK3KJS16ArgumentListNode8streamToERNS_12SourceStreamE -__ZNK3KJS11ResolveNode10precedenceEv -__ZNK3KJS11ResolveNode8streamToERNS_12SourceStreamE -__ZNK3KJS13AssignDotNode8streamToERNS_12SourceStreamE -__ZNK3KJS8ThisNode10precedenceEv -__ZNK3KJS8ThisNode8streamToERNS_12SourceStreamE -__ZNK3KJS19FunctionCallDotNode10precedenceEv -__ZNK3KJS19FunctionCallDotNode8streamToERNS_12SourceStreamE -__ZNK3KJS16FunctionBodyNode11paramStringEv -__ZNK3KJS15RegExpObjectImp14arrayOfMatchesEPNS_9ExecStateE -__ZN3KJS9Arguments17mappedIndexGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS19arrayProtoFuncSliceEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS22functionProtoFuncApplyEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS13ArrayInstance9classInfoEv -__ZN3KJS24substituteBackreferencesERKNS_7UStringES2_PiPNS_6RegExpE -__ZNK3KJS15DotAccessorNode10precedenceEv -__ZNK3KJS15DotAccessorNode8streamToERNS_12SourceStreamE -__ZNK3KJS16VarStatementNode8streamToERNS_12SourceStreamE -__ZNK3KJS17AssignResolveNode8streamToERNS_12SourceStreamE -__ZNK3KJS6IfNode8streamToERNS_12SourceStreamE -__ZNK3KJS14LogicalNotNode8streamToERNS_12SourceStreamE -__ZNK3KJS9ArrayNode10precedenceEv -__ZNK3KJS9ArrayNode8streamToERNS_12SourceStreamE -__ZNK3KJS11ElementNode8streamToERNS_12SourceStreamE -__ZNK3KJS10StringNode10precedenceEv -__ZNK3KJS10StringNode8streamToERNS_12SourceStreamE -__ZN3KJS29escapeStringForPrettyPrintingERKNS_7UStringE -__ZNK3KJS9BlockNode8streamToERNS_12SourceStreamE -__ZNK3KJS17AssignBracketNode8streamToERNS_12SourceStreamE -__ZNK3KJS10IfElseNode8streamToERNS_12SourceStreamE -__ZNK3KJS9EqualNode8streamToERNS_12SourceStreamE -__ZNK3KJS9EqualNode10precedenceEv -__ZN3KJS35streamLeftAssociativeBinaryOperatorERNS_12SourceStreamENS_10PrecedenceEPKcPKNS_4NodeES7_ -__ZNK3KJS17ReadModifyDotNode8streamToERNS_12SourceStreamE -__ZNK3KJS7AddNode10precedenceEv -__ZNK3KJS7AddNode8streamToERNS_12SourceStreamE -__ZNK3KJS15ConditionalNode10precedenceEv -__ZNK3KJS15ConditionalNode8streamToERNS_12SourceStreamE -__ZNK3KJS10RegExpNode10precedenceEv -__ZNK3KJS10RegExpNode8streamToERNS_12SourceStreamE -__ZNK3KJS21ReadModifyResolveNode8streamToERNS_12SourceStreamE -__ZNK3KJS7TryNode8streamToERNS_12SourceStreamE -__ZNK3KJS11NewExprNode10precedenceEv -__ZNK3KJS11NewExprNode8streamToERNS_12SourceStreamE -__ZNK3KJS10NumberNode10precedenceEv -__ZNK3KJS10NumberNode8streamToERNS_12SourceStreamE -__ZN3KJS12SourceStreamlsEd -__ZNK3KJS13LogicalOrNode10precedenceEv -__ZNK3KJS13LogicalOrNode8streamToERNS_12SourceStreamE -__ZNK3KJS8NullNode10precedenceEv -__ZNK3KJS8NullNode8streamToERNS_12SourceStreamE -__ZNK3KJS14LogicalAndNode8streamToERNS_12SourceStreamE -__ZNK3KJS14LogicalAndNode10precedenceEv -__ZNK3KJS14LogicalNotNode10precedenceEv -__ZN3KJS7UString17expandPreCapacityEi -__ZN3KJS19BracketAccessorNode17evaluateToBooleanEPNS_9ExecStateE -__ZNK3KJS11GreaterNode10precedenceEv -__ZNK3KJS11GreaterNode8streamToERNS_12SourceStreamE -__ZNK3KJS17ObjectLiteralNode10precedenceEv -__ZNK3KJS17ObjectLiteralNode8streamToERNS_12SourceStreamE -__ZNK3KJS16PropertyListNode8streamToERNS_12SourceStreamE -__ZNK3KJS12PropertyNode8streamToERNS_12SourceStreamE -__ZNK3KJS8LessNode10precedenceEv -__ZNK3KJS8LessNode8streamToERNS_12SourceStreamE -__ZNK3KJS19BracketAccessorNode10precedenceEv -__ZNK3KJS19BracketAccessorNode8streamToERNS_12SourceStreamE -__ZNK3KJS15TypeOfValueNode10precedenceEv -__ZNK3KJS15TypeOfValueNode8streamToERNS_12SourceStreamE -__ZNK3KJS7ForNode8streamToERNS_12SourceStreamE -__ZNK3KJS9CommaNode8streamToERNS_12SourceStreamE -__ZNK3KJS17AssignResolveNode10precedenceEv -__ZNK3KJS23FunctionCallResolveNode10precedenceEv -__ZNK3KJS12FuncExprNode10precedenceEv -__ZNK3KJS12FuncExprNode8streamToERNS_12SourceStreamE -__ZNK3KJS13ParameterNode8streamToERNS_12SourceStreamE -__ZNK3KJS9ForInNode8streamToERNS_12SourceStreamE -__ZNK3KJS10ReturnNode8streamToERNS_12SourceStreamE -__ZNK3KJS13GreaterEqNode10precedenceEv -__ZNK3KJS13GreaterEqNode8streamToERNS_12SourceStreamE -__ZNK3KJS8TrueNode10precedenceEv -__ZNK3KJS8TrueNode8streamToERNS_12SourceStreamE -__ZNK3KJS21FunctionCallValueNode8streamToERNS_12SourceStreamE -__ZN3KJS11ElementNode8evaluateEPNS_9ExecStateE -__ZNK3KJS8MultNode10precedenceEv -__ZNK3KJS8MultNode8streamToERNS_12SourceStreamE -__ZN3KJS21functionProtoFuncCallEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS4List8getSliceEiRS0_ -__ZN3KJS10IfElseNode7executeEPNS_9ExecStateE -__ZN3KJS6InNode17evaluateToBooleanEPNS_9ExecStateE -__ZNK3KJS12NotEqualNode10precedenceEv -__ZNK3KJS12NotEqualNode8streamToERNS_12SourceStreamE -__ZN3KJS17AssignResolveNode8evaluateEPNS_9ExecStateE -__ZN3KJS13DeleteDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS12ContinueNode7executeEPNS_9ExecStateE -__ZN3KJS13DeleteDotNode8evaluateEPNS_9ExecStateE -__ZN3KJS11FunctionImp14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZNK3KJS11PropertyMap3getERKNS_10IdentifierERj -__ZN3KJS11GreaterNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS13PrefixDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS13PreIncDotNode8evaluateEPNS_9ExecStateE -__ZN3KJS14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZNK3KJS8JSObject8toStringEPNS_9ExecStateE -__ZNK3KJS8JSObject11toPrimitiveEPNS_9ExecStateENS_6JSTypeE -__ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE -__ZN3KJS22arrayProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3WTF9HashTableIiiNS_17IdentityExtractorIiEENS_7IntHashIiEENS_10HashTraitsIiEES6_E3addIPN3KJS16RuntimeObjectImpESB_NS_17HashSetTranslatorILb1ESB_NS5_ISB_EES6_NS_7PtrHashISB_EEEEEESt4pairINS_17HashTableIteratorIiiS2_S4_S6_S6_EEbERKT_RKT0_ -__ZN3KJS11JSImmediate8toStringEPKNS_7JSValueE -__ZN3KJS12NotEqualNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS21arrayProtoFuncIndexOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS14ErrorObjectImp19implementsConstructEv -__ZN3KJS14ErrorObjectImp9constructEPNS_9ExecStateERKNS_4ListE -__ZN3KJS9Collector7collectEv -__ZN3KJS9Collector31markCurrentThreadConservativelyEv -__ZN3KJS9Collector30markStackObjectsConservativelyEPvS1_ -__ZN3KJS6JSCell4markEv -__ZN3KJS8JSObject4markEv -__ZNK3KJS11PropertyMap4markEv -__ZN3KJS11FunctionImp4markEv -__ZN3KJS14JSGlobalObject4markEv -__ZN3KJS16JSVariableObject4markEv -__ZN3KJS13ArrayInstance4markEv -__ZN3KJS15JSWrapperObject4markEv -__ZN3KJS13ActivationImp4markEv -__ZN3KJS13ActivationImp12markChildrenEv -__ZN3KJS14NativeErrorImp4markEv -__ZN3KJS9Arguments4markEv -__ZN3KJS9Collector20markProtectedObjectsEv -__ZN3KJS9Collector5sweepILNS0_8HeapTypeE0EEEmb -__ZN3KJS11PropertyMapD1Ev -__ZN3KJS11FunctionImpD0Ev -__ZN3KJS9StringImpD0Ev -__ZN3KJS9RegExpImpD0Ev -__ZN3KJS13ArrayInstanceD0Ev -__ZN3KJS9ArgumentsD0Ev -__ZN3KJS9Collector5sweepILNS0_8HeapTypeE1EEEmb -__ZN3KJS14AddStringsNode8evaluateEPNS_9ExecStateE -__ZN3KJS17AddStringLeftNode8evaluateEPNS_9ExecStateE -__ZNK3KJS9StringImp11toPrimitiveEPNS_9ExecStateENS_6JSTypeE -__ZN3KJS7AddNode8evaluateEPNS_9ExecStateE -__ZN3KJS21stringProtoFuncCharAtEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS26stringProtoFuncToUpperCaseEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS24stringProtoFuncSubstringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS26stringProtoFuncToLowerCaseEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS7UString8toUInt32EPb -__ZN3KJS22ReadModifyLocalVarNode8evaluateEPNS_9ExecStateE -__ZN3KJS19PostIncLocalVarNode8evaluateEPNS_9ExecStateE -__ZN3KJS17PreDecResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS18PreDecLocalVarNode8evaluateEPNS_9ExecStateE -__ZN3KJS8MultNode16evaluateToNumberEPNS_9ExecStateE -__ZNK3KJS9NumberImp4typeEv -__ZN3KJS20dateProtoFuncSetTimeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS7SubNode16evaluateToNumberEPNS_9ExecStateE -__ZNK3KJS9StringImp8toNumberEPNS_9ExecStateE -__ZN3KJS18globalFuncParseIntEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS7JSValue15toInt32SlowCaseEPNS_9ExecStateERb -__ZN3KJS24dateProtoFuncToGMTStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS10formatTimeERKNS_17GregorianDateTimeEb -__ZNK3KJS15RegExpObjectImp19implementsConstructEv -__ZN3KJS15RegExpObjectImp9constructEPNS_9ExecStateERKNS_4ListE -__ZN3KJS19regExpProtoFuncExecEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE -__ZN3KJS35stringInstanceNumericPropertyGetterEPNS_9ExecStateEPNS_8JSObjectEjRKNS_12PropertySlotE -__ZN3KJS23FunctionCallResolveNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS15globalFuncIsNaNEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS20dateProtoFuncSetYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS21gregorianDateTimeToMSERKNS_17GregorianDateTimeEdb -__ZN3KJS15dateToDayInYearEiii -__ZN3KJS21ReadModifyBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZNK3KJS15ObjectObjectImp19implementsConstructEv -__ZN3KJS21ReadModifyBracketNode8evaluateEPNS_9ExecStateE -__ZNK3KJS9ExecState12hadExceptionEv -__ZNK3KJS7JSValue8toObjectEPNS_9ExecStateE -__ZNK3KJS7JSValue8toStringEPNS_9ExecStateE -__ZN3KJS7UStringD1Ev -__ZN3KJS8JSObject15getPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZNK3KJS12PropertySlot8getValueEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierE -__ZNK3WTF6RefPtrIN3KJS14ExpressionNodeEE3getEv -__ZN3KJS3addEPNS_9ExecStateEPNS_7JSValueES3_ -__ZN3KJS10IdentifierD1Ev -__ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS20arrayProtoFuncConcatEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS14ExpressionNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS9BreakNode7executeEPNS_9ExecStateE -__ZN3KJS18arrayProtoFuncJoinEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS11JSImmediate8toObjectEPKNS_7JSValueEPNS_9ExecStateE -__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc -__ZN3KJS5Error6createEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringEiiS6_ -__ZN3KJS14NativeErrorImp9constructEPNS_9ExecStateERKNS_4ListE -__ZNK3KJS6JSCell17getTruncatedInt32ERi -__ZN3KJS15StringObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS9Collector15recordExtraCostEm -__ZN3KJS22objectProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS8JSObject9classNameEv -__ZN3KJS14PostDecDotNode8evaluateEPNS_9ExecStateE -__ZN3KJS9CommaNodeD1Ev -__ZN3KJS28globalFuncDecodeURIComponentEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS6decodeEPNS_9ExecStateERKNS_4ListEPKcb -__ZN3KJS19BracketAccessorNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS15TypeOfValueNodeD1Ev -__ZN3KJS17PrototypeFunctionD0Ev -__ZN3KJS13ErrorInstanceD0Ev -__ZN3KJS18mathProtoFuncRoundEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS23FunctionCallResolveNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS13GreaterEqNodeD1Ev -__ZN3KJS7ModNodeD1Ev -__ZN3KJS24LocalVarFunctionCallNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS4List15expandAndAppendEPNS_7JSValueE -__ZN3WTF6VectorIPN3KJS7JSValueELm8EE15reserveCapacityEm -__ZN3KJS10SwitchNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS13CaseBlockNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS14ClauseListNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS14CaseClauseNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS10SwitchNode7executeEPNS_9ExecStateE -__ZN3KJS13CaseBlockNode12executeBlockEPNS_9ExecStateEPNS_7JSValueE -__ZN3KJS18NotStrictEqualNode17evaluateToBooleanEPNS_9ExecStateE -__Z23_NPN_CreateScriptObjectP4_NPPPN3KJS8JSObjectEN3WTF10PassRefPtrINS1_8Bindings10RootObjectEEE -__NPN_CreateObject -__Z10jsAllocateP4_NPPP7NPClass -__NPN_RetainObject -__NPN_Evaluate -__ZNK3KJS8Bindings10RootObject12globalObjectEv -__ZN3KJS8Bindings22convertNPStringToUTF16EPK9_NPStringPPtPj -__ZN3KJS8Bindings36convertUTF8ToUTF16WithLatin1FallbackEPKciPPtPj -__ZN3WTF7Unicode18convertUTF8ToUTF16EPPKcS2_PPtS4_b -__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiS5_PNS_7JSValueE -__ZN3KJS8Bindings23convertValueToNPVariantEPNS_9ExecStateEPNS_7JSValueEP10_NPVariant -__ZN3KJS11JSImmediate4typeEPKNS_7JSValueE -__NPN_GetStringIdentifier -__ZN3KJS8Bindings26identifierFromNPIdentifierEPKc -__NPN_Invoke -__ZN3KJS8Bindings14findRootObjectEPNS_14JSGlobalObjectE -__NPN_ReleaseVariantValue -__ZNK3KJS7UString10UTF8StringEb +__ZN3WTF14FastMallocZone9forceLockEP14_malloc_zone_t +__ZN3WTF14FastMallocZone11forceUnlockEP14_malloc_zone_t +__ZN3JSC7UStringC1EPKti +__ZN3JSC5Lexer7record8Ei +__ZN3JSC16FunctionBodyNode13finishParsingERKNS_10SourceCodeEPNS_13ParameterNodeE +__ZN3WTF6VectorINS_6RefPtrIN3JSC12FuncDeclNodeEEELm0EE15reserveCapacityEm +__ZN3JSC10Identifier6removeEPNS_7UString3RepE +__ZN3WTF6VectorINS_6RefPtrIN3JSC12FuncDeclNodeEEELm0EEaSERKS5_ +__ZN3JSC8JSObject12removeDirectERKNS_10IdentifierE +__ZN3JSC9Structure31removePropertyWithoutTransitionERKNS_10IdentifierE +__ZN3JSC9Structure6removeERKNS_10IdentifierE +__ZN3JSC17BytecodeGenerator12addGlobalVarERKNS_10IdentifierEbRPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator15emitNewFunctionEPNS_10RegisterIDEPNS_12FuncDeclNodeE +__ZN3JSC9CodeBlock25createRareDataIfNecessaryEv +__ZN3JSC12FuncDeclNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3WTF6VectorIN3JSC15SimpleJumpTableELm0EE14shrinkCapacityEm +__ZN3WTF6VectorIN3JSC15StringJumpTableELm0EE14shrinkCapacityEm +__ZN3JSC3JIT11emitCTICallEPFvPvzE +__ZN3JSC11Interpreter15cti_op_new_funcEPvz +__ZN3JSC12FuncDeclNode12makeFunctionEPNS_9ExecStateEPNS_14ScopeChainNodeE +__ZN3JSC11Interpreter10cti_op_endEPvz +__ZN3JSC12FuncDeclNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC12NodeReleaser21adoptFunctionBodyNodeERN3WTF6RefPtrINS_16FunctionBodyNodeEEE +__ZN3JSC8JSObject4markEv +__ZN3JSC14JSGlobalObject4markEv +__ZN3JSC7JSArray4markEv +__ZN3JSC15JSWrapperObject4markEv +__ZN3JSC18GlobalEvalFunction4markEv +__ZNK3JSC10NumberNode8isNumberEv +__ZN3JSC5Lexer10scanRegExpEv +__ZN3JSC7UStringC2ERKN3WTF6VectorItLm0EEE +__ZL26appendToVarDeclarationListPvRPN3JSC20ParserRefCountedDataIN3WTF6VectorISt4pairINS0_10IdentifierEjELm0EEEEERKS5_j +__ZN3WTF6VectorISt4pairIN3JSC10IdentifierEjELm0EE14expandCapacityEmPKS4_ +__ZN3WTF6VectorISt4pairIN3JSC10IdentifierEjELm0EE15reserveCapacityEm +__ZL20makeVarStatementNodePvPN3JSC14ExpressionNodeE +__ZL14makeAssignNodePvPN3JSC14ExpressionNodeENS0_8OperatorES2_bbiii +__Z21mergeDeclarationListsIPN3JSC20ParserRefCountedDataIN3WTF6VectorINS2_6RefPtrINS0_12FuncDeclNodeEEELm0EEEEEET_SA_SA_ +__ZN3JSC20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm0EEEED1Ev +__ZN3WTF6VectorIPNS0_IN3JSC10IdentifierELm64EEELm32EE14expandCapacityEm +__ZNK3JSC18EmptyStatementNode16isEmptyStatementEv +__ZNK3JSC14ExpressionNode10isLocationEv +__ZL11makeAddNodePvPN3JSC14ExpressionNodeES2_b +__ZNK3JSC14ExpressionNode8isNumberEv +__ZN3JSC16PropertyListNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator11emitPutByIdEPNS_10RegisterIDERKNS_10IdentifierES2_ +__ZN3JSC11UnaryOpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC13LogicalOpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator8newLabelEv +__ZN3JSC17BytecodeGenerator15emitJumpIfFalseEPNS_10RegisterIDEPNS_5LabelE +__ZNK3JSC14LogicalNotNode8opcodeIDEv +__ZN3JSC17BytecodeGenerator9emitLabelEPNS_5LabelE +__ZN3WTF6VectorIjLm0EE15reserveCapacityEm +__ZN3JSC19ReverseBinaryOpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC10NumberNode6isPureERNS_17BytecodeGeneratorE +__ZN3JSC17BytecodeGenerator11emitResolveEPNS_10RegisterIDERKNS_10IdentifierE +__ZN3WTF6VectorIN3JSC17GlobalResolveInfoELm0EE14expandCapacityEm +__ZNK3JSC11GreaterNode8opcodeIDEv +__ZN3JSC17BytecodeGenerator12emitBinaryOpENS_8OpcodeIDEPNS_10RegisterIDES3_S3_NS_12OperandTypesE +__ZN3JSC9EqualNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC14ExpressionNode6isNullEv +__ZN3JSC17BytecodeGenerator14emitEqualityOpENS_8OpcodeIDEPNS_10RegisterIDES3_S3_ +__ZN3JSC10RegExpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC6RegExp6createEPNS_12JSGlobalDataERKNS_7UStringES5_ +__ZN3JSC4WREC9Generator13compileRegExpEPNS_12JSGlobalDataERKNS_7UStringEPjPPKcRN3WTF6RefPtrINS_14ExecutablePoolEEEbb +__ZN3JSC4WREC9Generator13generateEnterEv +__ZN3JSC4WREC9Generator17generateSaveIndexEv +__ZN3JSC4WREC6Parser16parseDisjunctionERNS_14MacroAssembler8JumpListE +__ZN3JSC4WREC6Parser16parseAlternativeERNS_14MacroAssembler8JumpListE +__ZN3JSC4WREC9Generator32generatePatternCharacterSequenceERNS_14MacroAssembler8JumpListEPim +__ZN3JSC4WREC9Generator28generatePatternCharacterPairERNS_14MacroAssembler8JumpListEii +__ZN3WTF6VectorIN3JSC14MacroAssembler4JumpELm16EE6appendIS3_EEvRKT_ +__ZN3JSC12X86Assembler7cmpl_irEiNS_3X8610RegisterIDE +__ZN3JSC4WREC9Generator24generatePatternCharacterERNS_14MacroAssembler8JumpListEi +__ZN3JSC4WREC9Generator21generateLoadCharacterERNS_14MacroAssembler8JumpListE +__ZN3JSC4WREC14CharacterClass7newlineEv +__ZN3JSC4WREC6Parser29parseCharacterClassQuantifierERNS_14MacroAssembler8JumpListERKNS0_14CharacterClassEb +__ZN3JSC4WREC6Parser17consumeQuantifierEv +__ZN3JSC4WREC9Generator24generateGreedyQuantifierERNS_14MacroAssembler8JumpListERNS0_19GenerateAtomFunctorEjj +__ZN3JSC4WREC29GenerateCharacterClassFunctor12generateAtomEPNS0_9GeneratorERNS_14MacroAssembler8JumpListE +__ZN3JSC4WREC9Generator22generateCharacterClassERNS_14MacroAssembler8JumpListERKNS0_14CharacterClassEb +__ZN3JSC4WREC9Generator30generateCharacterClassInvertedERNS_14MacroAssembler8JumpListERKNS0_14CharacterClassE +__ZN3JSC4WREC29GenerateCharacterClassFunctor9backtrackEPNS0_9GeneratorE +__ZN3JSC4WREC9Generator18generateBacktrack1Ev +__ZN3JSC15AssemblerBuffer4growEv +__ZN3JSC12X86Assembler7addl_irEiNS_3X8610RegisterIDE +__ZN3JSC4WREC9Generator21generateReturnSuccessEv +__ZN3JSC4WREC9Generator22generateIncrementIndexEPNS_14MacroAssembler4JumpE +__ZN3JSC4WREC9Generator27generateJumpIfNotEndOfInputENS_14MacroAssembler5LabelE +__ZN3JSC4WREC9Generator21generateReturnFailureEv +__ZN3JSC17BytecodeGenerator13emitNewRegExpEPNS_10RegisterIDEPNS_6RegExpE +__ZN3JSC12BinaryOpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC18NotStrictEqualNode8opcodeIDEv +__ZNK3JSC14ExpressionNode6isPureERNS_17BytecodeGeneratorE +__ZN3JSC4WREC9Generator20generateAssertionBOLERNS_14MacroAssembler8JumpListE +__ZN3JSC4WREC6Parser13consumeEscapeEb +__ZN3WTF6VectorIiLm8EE14expandCapacityEm +__ZN3JSC4WREC6Parser16parseParenthesesERNS_14MacroAssembler8JumpListE +__Z15jsRegExpCompilePKti24JSRegExpIgnoreCaseOption23JSRegExpMultilineOptionPjPPKc +__ZL30calculateCompiledPatternLengthPKti24JSRegExpIgnoreCaseOptionR11CompileDataR9ErrorCode +__ZL11checkEscapePPKtS0_P9ErrorCodeib +__ZL13compileBranchiPiPPhPPKtS3_P9ErrorCodeS_S_R11CompileData +__ZN3JSC4WREC14CharacterClass6spacesEv +__ZN3JSC4WREC6Parser23parseNonCharacterEscapeERNS_14MacroAssembler8JumpListERKNS0_6EscapeE +__ZN3JSC12X86Assembler23X86InstructionFormatter9twoByteOpENS0_15TwoByteOpcodeIDE +__ZN3JSC4WREC9Generator35generateCharacterClassInvertedRangeERNS_14MacroAssembler8JumpListES4_PKNS0_14CharacterRangeEjPjPKtj +__ZN3JSC4WREC9Generator20terminateAlternativeERNS_14MacroAssembler8JumpListES4_ +__ZN3JSC4WREC6Parser19parseCharacterClassERNS_14MacroAssembler8JumpListE +__ZN3JSC4WREC14CharacterClass8wordcharEv +__ZN3JSC4WREC25CharacterClassConstructor6appendERKNS0_14CharacterClassE +__ZN3JSC4WREC25CharacterClassConstructor5flushEv +__ZN3JSC4WREC25CharacterClassConstructor9addSortedERN3WTF6VectorItLm0EEEt +__ZN3WTF6VectorItLm0EE14expandCapacityEm +__ZN3JSC4WREC25CharacterClassConstructor14addSortedRangeERN3WTF6VectorINS0_14CharacterRangeELm0EEEtt +__ZN3WTF6VectorIN3JSC4WREC14CharacterRangeELm0EE14expandCapacityEm +__ZN3JSC4WREC25CharacterClassConstructor3putEt +__ZN3JSC4WREC9Generator20terminateDisjunctionERNS_14MacroAssembler8JumpListE +__ZN3JSC11NewExprNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator13emitConstructEPNS_10RegisterIDES2_PNS_13ArgumentsNodeEjjj +__ZN3WTF6VectorIN3JSC20GetByIdExceptionInfoELm0EE14expandCapacityEm +__ZN3JSC16VarStatementNodeD1Ev +__ZN3JSC16VarStatementNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC17AssignResolveNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC17ObjectLiteralNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC16PropertyListNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC12PropertyNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11UnaryOpNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13LogicalOpNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC12BinaryOpNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC17AssignResolveNodeD1Ev +__ZN3JSC17ObjectLiteralNodeD1Ev +__ZN3JSC16PropertyListNodeD1Ev +__ZN3JSC12PropertyNodeD1Ev +__ZN3JSC14LogicalNotNodeD1Ev +__ZN3JSC10RegExpNodeD1Ev +__ZN3JSC13LogicalOpNodeD1Ev +__ZN3JSC9EqualNodeD1Ev +__ZN3JSC18NotStrictEqualNodeD1Ev +__ZN3JSC6IfNodeD1Ev +__ZN3JSC6IfNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13AssignDotNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC8WithNodeD1Ev +__ZN3JSC8WithNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC21FunctionCallValueNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC21FunctionCallValueNodeD1Ev +__ZN3JSC9ArrayNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC9ArrayNodeD1Ev +__ZN3JSC11ElementNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC10IfElseNodeD1Ev +__ZN3JSC10IfElseNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC7AddNodeD1Ev +__ZN3JSC11NewExprNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11NewExprNodeD1Ev +__ZN3JSC3JIT21compilePutByIdHotPathEiPNS_10IdentifierEij +__ZN3WTF6VectorIN3JSC9JumpTableELm0EE14expandCapacityEm +__ZN3WTF6VectorIN3JSC13SlowCaseEntryELm0EE6appendIS2_EEvRKT_ +__ZN3JSC12X86Assembler23X86InstructionFormatter9oneByteOpENS0_15OneByteOpcodeIDEiNS_3X8610RegisterIDES4_ii +__ZN3JSC3JIT11emitCTICallEPFPNS_23JSValueEncodedAsPointerEPvzE +__ZN3JSC3JIT17compileOpStrictEqEPNS_11InstructionENS0_21CompileOpStrictEqTypeE +__ZN3JSC3JIT23compileFastArith_op_addEPNS_11InstructionE +__ZN3JSC3JIT22compilePutByIdSlowCaseEiPNS_10IdentifierEiRPNS_13SlowCaseEntryEj +__ZN3JSC3JIT27compileOpConstructSetupArgsEPNS_11InstructionE +__ZN3JSC3JIT11emitCTICallEPFPNS_8JSObjectEPvzE +__ZN3JSC12SmallStrings27createSingleCharacterStringEPNS_12JSGlobalDataEh +__ZN3JSC11Interpreter17cti_op_new_objectEPvz +__ZN3JSC20constructEmptyObjectEPNS_9ExecStateE +__ZN3JSC11Interpreter16cti_op_put_by_idEPvz +__ZN3JSC8JSObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC11Interpreter12cti_op_jtrueEPvz +__ZN3JSC11Interpreter10cti_op_notEPvz +__ZN3WTF7HashMapISt4pairINS_6RefPtrIN3JSC7UString3RepEEEjEPNS3_9StructureENS3_28StructureTransitionTableHashENS3_34StructureTransitionTableHashTraitsENS_10HashTraitsIS9_EEE3addERKS7_RKS9_ +__ZN3WTF9HashTableISt4pairINS_6RefPtrIN3JSC7UString3RepEEEjES1_IS7_PNS3_9StructureEENS_18PairFirstExtractorISA_EENS3_28StructureTransitionTableHashENS_14PairHashTraitsINS3_34StructureTransitionTableHashTraitsENS_10HashTraitsIS9_EEEESF_E6rehashEi +__ZN3JSC11Interpreter21cti_op_resolve_globalEPvz +__ZN3JSC8JSString18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC15StringPrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC12StringObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL22stringProtoFuncIndexOfEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC8JSString12toThisStringEPNS_9ExecStateE +__ZNK3JSC10JSValuePtr9toIntegerEPNS_9ExecStateE +__ZN3JSC11JSImmediate12nonInlineNaNEv +__ZNK3JSC7UString4findERKS0_i +__ZN3JSC11Interpreter11cti_op_lessEPvz +__ZN3JSC11Interpreter17cti_op_new_regexpEPvz +__ZN3JSC12RegExpObjectC1EN3WTF10PassRefPtrINS_9StructureEEENS2_INS_6RegExpEEE +__ZN3JSCL20stringProtoFuncMatchEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC6JSCell8isObjectEPKNS_9ClassInfoE +__ZNK3JSC12RegExpObject9classInfoEv +__ZN3JSC17RegExpConstructor12performMatchEPNS_6RegExpERKNS_7UStringEiRiS6_PPi +__ZN3JSC6RegExp5matchERKNS_7UStringEiPN3WTF11OwnArrayPtrIiEE +__ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE +__ZNK3JSC7UString8toUInt32EPbb +__ZNK3JSC7UString8toDoubleEbb +__ZN3WTF6VectorIcLm32EE6resizeEm +__ZN3JSC11Interpreter16cti_op_nstricteqEPvz +__ZN3JSC10JSValuePtr19strictEqualSlowCaseES0_S0_ +__ZN3JSC11Interpreter19cti_op_new_func_expEPvz +__ZN3JSC12FuncExprNode12makeFunctionEPNS_9ExecStateEPNS_14ScopeChainNodeE +__ZNK3JSC19BracketAccessorNode10isLocationEv +__ZNK3JSC19BracketAccessorNode21isBracketAccessorNodeEv +__ZN3JSC9ForInNodeC2EPNS_12JSGlobalDataERKNS_10IdentifierEPNS_14ExpressionNodeES7_PNS_13StatementNodeEiii +__ZN3JSC19BracketAccessorNodeD1Ev +__ZN3JSC19BracketAccessorNode12releaseNodesERNS_12NodeReleaserE +__ZNK3JSC9ForInNode6isLoopEv +__ZN3JSC9ForInNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSCL20dateProtoFuncSetTimeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC20EvalFunctionCallNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator19emitResolveWithBaseEPNS_10RegisterIDES2_RKNS_10IdentifierE +__ZN3JSC20EvalFunctionCallNodeD1Ev +__ZN3JSC20EvalFunctionCallNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC3JIT26compileOpCallEvalSetupArgsEPNS_11InstructionE +__ZN3JSC11Interpreter24cti_op_resolve_with_baseEPvz +__ZN3JSC11Interpreter16cti_op_call_evalEPvz +__ZN3JSC11Interpreter8callEvalEPNS_9ExecStateEPNS_12RegisterFileEPNS_8RegisterEiiRNS_10JSValuePtrE +__ZNK3WTF7HashMapINS_6RefPtrIN3JSC7UString3RepEEENS1_INS2_8EvalNodeEEENS_7StrHashIS5_EENS_10HashTraitsIS5_EENSA_IS7_EEE3getEPS4_ +__ZN3JSC7UString3Rep11computeHashEPKti +__ZN3JSC6Parser5parseINS_8EvalNodeEEEN3WTF10PassRefPtrIT_EEPNS_9ExecStateEPNS_8DebuggerERKNS_10SourceCodeEPiPNS_7UStringE +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEESt4pairIS5_NS1_INS2_8EvalNodeEEEENS_18PairFirstExtractorIS9_EENS_7StrHashIS5_EENS_14PairHashTraitsINS_10HashTraitsIS5_EENSF_IS8_EEEESG_E6rehashEi +__ZN3JSC9ExecState9thisValueEv +__ZN3JSC11Interpreter7executeEPNS_8EvalNodeEPNS_9ExecStateEPNS_8JSObjectEiPNS_14ScopeChainNodeEPNS_10JSValuePtrE +__ZN3JSC8EvalNode16generateBytecodeEPNS_14ScopeChainNodeE +__ZN3JSC17BytecodeGeneratorC2EPNS_8EvalNodeEPKNS_8DebuggerERKNS_10ScopeChainEPN3WTF7HashMapINS9_6RefPtrINS_7UString3RepEEENS_16SymbolTableEntryENS_17IdentifierRepHashENS9_10HashTraitsISE_EENS_26SymbolTableIndexHashTraitsEEEPNS_13EvalCodeBlockE +__ZN3JSC8EvalNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC18globalFuncParseIntEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL24dateProtoFuncToGMTStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC10formatTimeERKNS_17GregorianDateTimeEb +__ZN3JSC9BreakNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator11breakTargetERKNS_10IdentifierE +__ZN3JSC9BreakNodeD1Ev +__ZN3JSC8JSString18getPrimitiveNumberEPNS_9ExecStateERdRNS_10JSValuePtrE +__ZNK3JSC8JSString8toNumberEPNS_9ExecStateE +__ZL18makeRightShiftNodePvPN3JSC14ExpressionNodeES2_b +__ZN3JSC4WREC14CharacterClass6digitsEv +__ZNK3JSC14RightShiftNode8opcodeIDEv +__ZN3JSC14RightShiftNodeD1Ev +__ZN3JSC3JIT26compileFastArith_op_rshiftEjjj +__ZN3JSC3JIT30compileFastArithSlow_op_rshiftEjjjRPNS_13SlowCaseEntryE +__ZN3JSCL20dateProtoFuncSetYearEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC21gregorianDateTimeToMSERKNS_17GregorianDateTimeEdb +__ZN3JSCL15dateToDayInYearEiii +__ZN3JSC8EvalNode4markEv +__ZN3JSC19JSStaticScopeObjectD0Ev +__ZN3JSC18PostfixBracketNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC18PostfixBracketNodeD1Ev +__ZN3JSC18PostfixBracketNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC9ForInNodeC2EPNS_12JSGlobalDataEPNS_14ExpressionNodeES4_PNS_13StatementNodeE +__ZN3JSC21ReadModifyBracketNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC21ReadModifyBracketNodeD1Ev +__ZN3JSC21ReadModifyBracketNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSCL20arrayProtoFuncConcatEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC17RegExpConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL30constructWithRegExpConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSC15constructRegExpEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC8JSObject9classNameEv +__ZN3JSC18RegExpMatchesArray18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL20stringProtoFuncSliceEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC8NullNode6isNullEv +__ZN3JSC17StringConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL21callStringConstructorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC12StringObject8toStringEPNS_9ExecStateE +__ZN3JSCL23stringProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter28cti_op_get_by_id_string_failEPvz +__ZN3JSCL19regExpProtoFuncExecEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter16cti_op_is_numberEPvz +__ZNK3JSC12StringObject9classInfoEv +__ZN3JSC11Interpreter16cti_op_is_objectEPvz +__ZN3JSC3JIT30privateCompileGetByIdChainListEPNS_17StructureStubInfoEPNS_30PolymorphicAccessStructureListEiPNS_9StructureEPNS_14StructureChainEmmPNS_9ExecStateE +__ZN3JSCL23numberProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC10Identifier5equalEPKNS_7UString3RepEPKc +__ZNK3JSC6JSCell17getTruncatedInt32ERi +__ZN3JSC15toInt32SlowCaseEdRb +__ZNK3JSC12JSNumberCell9toBooleanEPNS_9ExecStateE +__ZN3JSC9Structure24removePropertyTransitionEPS0_RKNS_10IdentifierERm +__ZN3JSC11Interpreter10cti_op_subEPvz +__ZN3JSC28globalFuncEncodeURIComponentEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL6encodeEPNS_9ExecStateERKNS_7ArgListEPKc +__ZNK3JSC7UString10UTF8StringEb __ZN3WTF7Unicode18convertUTF16ToUTF8EPPKtS2_PPcS4_b -__Z35NPN_InitializeVariantWithStringCopyP10_NPVariantPK9_NPString -__ZN3KJS7CStringD1Ev -__NPN_ReleaseObject -__Z12jsDeallocateP8NPObject -__ZN3KJS8Bindings10RootObject11gcUnprotectEPNS_8JSObjectE -__ZN3KJS6JSLock12DropAllLocksC1Ev -__ZN3KJS6JSLock12DropAllLocksD1Ev -_pow5mult -_quorem -_diff -__ZN3WTF6VectorIPN3KJS12FuncDeclNodeELm16EE14expandCapacityEmPKS3_ -__ZN3WTF6VectorIPN3KJS12FuncDeclNodeELm16EE14expandCapacityEm -__ZN3WTF6VectorIPN3KJS12FuncDeclNodeELm16EE15reserveCapacityEm -__ZN3KJS10NumberNode8setValueEd -__ZN3KJS11ResolveNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS21dateProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS24dateProtoFuncGetFullYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS12NotEqualNode8evaluateEPNS_9ExecStateE -__ZN3KJS14InstanceOfNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS17PreIncResolveNode8evaluateEPNS_9ExecStateE -__ZNK3KJS9NumberImp9toBooleanEPNS_9ExecStateE -__ZN3KJS10LessEqNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS29objectProtoFuncHasOwnPropertyEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS10LessEqNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS13UnaryPlusNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS17DeleteBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS17DeleteBracketNode8evaluateEPNS_9ExecStateE -__ZN3KJS20arrayProtoFuncSpliceEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS17staticValueGetterINS_13MathObjectImpEEEPNS_7JSValueEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZNK3KJS13MathObjectImp16getValuePropertyEPNS_9ExecStateEi -__NPN_DeallocateObject -__ZN3KJS14PostIncDotNodeD1Ev -__ZN3KJS22ReadModifyLocalVarNodeD1Ev -__ZN3KJS10LessEqNodeD1Ev -__ZN3KJS18PostDecResolveNodeD1Ev -__ZN3KJS17DeleteBracketNodeD1Ev -__ZN3KJS18PostIncResolveNodeD1Ev -__ZN3KJS14InstanceOfNodeD1Ev -__ZN3KJS10NegateNodeD1Ev -__ZN3KJS17PreDecResolveNodeD1Ev -__ZN3KJS21ReadModifyBracketNodeD1Ev -__ZN3KJS10BitAndNodeD1Ev -__ZN3KJS9BitOrNodeD1Ev -__ZN3KJS14RightShiftNodeD1Ev -__ZN3KJS13LeftShiftNodeD1Ev -__ZN3KJS13UnaryPlusNodeD1Ev -__ZN3KJS13MathObjectImpD0Ev -__ZN3KJS14NativeErrorImpD0Ev -__ZN3KJS14ErrorObjectImpD0Ev -__ZN3KJS15RegExpObjectImpD0Ev -__ZN3KJS17DateObjectFuncImpD0Ev -__ZN3KJS13DateObjectImpD0Ev -__ZN3KJS15NumberObjectImpD0Ev -__ZN3KJS16BooleanObjectImpD0Ev -__ZN3KJS19StringObjectFuncImpD0Ev -__ZN3KJS15StringObjectImpD0Ev -__ZN3KJS14ArrayObjectImpD0Ev -__ZN3KJS17FunctionObjectImpD0Ev -__ZN3KJS15ObjectObjectImpD0Ev -__ZN3KJS20NativeErrorPrototypeD0Ev -__ZN3KJS15RegExpPrototypeD0Ev -__ZN3KJS15NumberPrototypeD0Ev -__ZN3KJS16BooleanPrototypeD0Ev -__ZN3KJS15StringPrototypeD0Ev -__ZN3KJS15ObjectPrototypeD0Ev -__ZN3KJS17FunctionPrototypeD0Ev -__ZN3KJS13PreIncDotNodeD1Ev -__ZN3KJS17staticValueGetterINS_15RegExpObjectImpEEEPNS_7JSValueEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZNK3KJS15RegExpObjectImp16getValuePropertyEPNS_9ExecStateEi -__ZNK3KJS15RegExpObjectImp10getBackrefEj -__ZN3KJS16mathProtoFuncMaxEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS17staticValueGetterINS_15NumberObjectImpEEEPNS_7JSValueEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZNK3KJS15NumberObjectImp16getValuePropertyEPNS_9ExecStateEi -__ZN3KJS10NegateNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS10NegateNode8evaluateEPNS_9ExecStateE -__ZN3KJS25stringProtoFuncCharCodeAtEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS21arrayProtoFuncUnShiftEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS10LessEqNode8evaluateEPNS_9ExecStateE -__ZN3KJS8JSObject15getPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE -__ZNK3KJS12PropertySlot8getValueEPNS_9ExecStateEPNS_8JSObjectEj -__ZN3KJS16mathProtoFuncMinEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS10Identifier5equalEPKNS_7UString3RepEPKc -__ZN3KJS11addSlowCaseEPNS_9ExecStateEPNS_7JSValueES3_ -__ZN3KJS8LessNode8evaluateEPNS_9ExecStateE -__ZN3KJS7DivNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS10NegateNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS7AddNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS16mathProtoFuncSinEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS16mathProtoFuncLogEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS16mathProtoFuncAbsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3WTF6VectorIPN3KJS9ExecStateELm16EE14expandCapacityEm -__ZN3WTF6VectorIPN3KJS9ExecStateELm16EE15reserveCapacityEm -__ZN3KJS17arrayProtoFuncPopEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS21stringProtoFuncSubstrEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS28globalFuncEncodeURIComponentEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS6encodeEPNS_9ExecStateERKNS_4ListEPKc -__ZN3KJS17PrefixBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS17PreIncBracketNode8evaluateEPNS_9ExecStateE -__ZN3KJS16mathProtoFuncExpEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS17mathProtoFuncATanEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS17mathProtoFuncCeilEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS14AddNumbersNode8evaluateEPNS_9ExecStateE -__ZN3KJS18arrayProtoFuncSortEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS13ArrayInstance4sortEPNS_9ExecStateEPNS_8JSObjectE -__ZN3KJS13ArrayInstance17compactForSortingEv -__ZN3KJS34compareWithCompareFunctionForQSortEPKvS1_ -__ZN3KJS13ArrayInstance4sortEPNS_9ExecStateE -__ZN3KJS16mathProtoFuncPowEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS15NumberObjectImp9constructEPNS_9ExecStateERKNS_4ListE -__ZN3KJS23numberProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS9NumberImp8toObjectEPNS_9ExecStateE -__ZN3KJS16mathProtoFuncCosEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS17mathProtoFuncSqrtEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS17mathProtoFuncASinEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS14ExpressionNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS11DoWhileNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS21stringProtoFuncSearchEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS13PreDecDotNode8evaluateEPNS_9ExecStateE -__ZN3KJS18PostfixBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS18PostIncBracketNode8evaluateEPNS_9ExecStateE -__ZN3KJS13LeftShiftNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE +__ZN3JSC17PrefixResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC10NegateNode8opcodeIDEv +__ZN3JSC10NegateNodeD1Ev +__ZN3JSC11Interpreter13cti_op_negateEPvz +__ZN3JSCL17mathProtoFuncSqrtEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11JSImmediate12toThisObjectENS_10JSValuePtrEPNS_9ExecStateE +__ZN3JSCL16mathProtoFuncAbsEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL18mathProtoFuncRoundEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL16mathProtoFuncCosEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL16mathProtoFuncSinEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter12cti_op_jlessEPvz +__ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE +__ZN3JSC16ArrayConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL20callArrayConstructorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC12JSNumberCell18getPrimitiveNumberEPNS_9ExecStateERdRNS_10JSValuePtrE +__ZN3JSC11Interpreter10cti_op_modEPvz +__ZL17makeLeftShiftNodePvPN3JSC14ExpressionNodeES2_b +__ZNK3JSC13LeftShiftNode8opcodeIDEv +__ZN3JSC13LeftShiftNodeD1Ev +__ZN3JSC3JIT26compileFastArith_op_lshiftEjjj +__ZN3JSC3JIT30compileFastArithSlow_op_lshiftEjjjRPNS_13SlowCaseEntryE +__ZN3JSCL16mathProtoFuncMaxEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC10BitAndNode8opcodeIDEv +__ZN3JSC10BitAndNodeD1Ev +__ZN3JSC3JIT26compileFastArith_op_bitandEjjj +__ZN3JSC3JIT30compileFastArithSlow_op_bitandEjjjRPNS_13SlowCaseEntryE +__ZN3JSC11Interpreter13cti_op_bitandEPvz +__ZNK3JSC14BitwiseNotNode8opcodeIDEv +__ZN3JSC14BitwiseNotNodeD1Ev +__ZN3JSC11Interpreter13cti_op_lshiftEPvz +__ZN3JSC11Interpreter13cti_op_bitnotEPvz +__ZNK3JSC22UnsignedRightShiftNode8opcodeIDEv +__ZNK3JSC10BitXOrNode8opcodeIDEv +__ZN3JSC22UnsignedRightShiftNodeD1Ev +__ZN3JSC10BitXOrNodeD1Ev +__ZN3JSCL25stringProtoFuncCharCodeAtEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter14cti_op_urshiftEPvz +__ZNK3JSC12JSNumberCell18getTruncatedUInt32ERj +__ZN3JSC16toUInt32SlowCaseEdRb +__ZN3JSCL17mathProtoFuncCeilEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC6JSCell18getTruncatedUInt32ERj +__ZN3JSC11Interpreter12cti_op_bitorEPvz +__ZNK3JSC12JSNumberCell17getTruncatedInt32ERi +__ZNK3JSC9BitOrNode8opcodeIDEv +__ZN3JSC9BitOrNodeD1Ev +__ZN3JSC11Interpreter13cti_op_rshiftEPvz +__ZN3JSC11Interpreter13cti_op_bitxorEPvz +__ZN3JSC9parseDateERKNS_7UStringE +__ZNK3JSC12JSActivation12toThisObjectEPNS_9ExecStateE +__ZN3JSC11Interpreter19cti_op_resolve_skipEPvz +__ZN3JSCL24dateProtoFuncGetFullYearEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC17StringConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL30constructWithStringConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSC5equalEPKNS_7UString3RepES3_ +__ZN3JSC10SwitchNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC13CaseBlockNode20emitBytecodeForBlockERNS_17BytecodeGeneratorEPNS_10RegisterIDES4_ +__ZN3JSC13CaseBlockNode18tryOptimizedSwitchERN3WTF6VectorIPNS_14ExpressionNodeELm8EEERiS7_ +__ZN3JSCL17processClauseListEPNS_14ClauseListNodeERN3WTF6VectorIPNS_14ExpressionNodeELm8EEERNS_10SwitchKindERbRiSB_ +__ZNK3JSC10StringNode8isStringEv +__ZN3WTF6VectorIPN3JSC14ExpressionNodeELm8EE14expandCapacityEm +__ZN3WTF6VectorINS_6RefPtrIN3JSC5LabelEEELm8EE14expandCapacityEm +__ZN3JSC17BytecodeGenerator11beginSwitchEPNS_10RegisterIDENS_10SwitchInfo10SwitchTypeE +__ZN3WTF6VectorIN3JSC10SwitchInfoELm0EE14expandCapacityEm +__ZN3JSC17BytecodeGenerator9endSwitchEjPN3WTF6RefPtrINS_5LabelEEEPPNS_14ExpressionNodeEPS3_ii +__ZN3WTF6VectorIN3JSC15SimpleJumpTableELm0EE14expandCapacityEm +__ZN3WTF6VectorIiLm0EE15reserveCapacityEm +__ZN3JSC10SwitchNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13CaseBlockNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC14ClauseListNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC14CaseClauseNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC10SwitchNodeD1Ev +__ZN3JSC13CaseBlockNodeD1Ev +__ZN3JSC14ClauseListNodeD1Ev +__ZN3JSC14CaseClauseNodeD1Ev +__ZN3WTF6VectorIN3JSC12SwitchRecordELm0EE14expandCapacityEm +__ZN3WTF6VectorIPvLm0EE15reserveCapacityEm +__ZN3JSC11Interpreter18cti_op_switch_charEPvz +__ZN3JSC8EvalNodeD1Ev +__ZN3JSCL16mathProtoFuncPowEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3WTF6VectorIcLm0EE14expandCapacityEm +__ZN3WTF6VectorIN3JSC7UString5RangeELm16EE14expandCapacityEm +__ZN3WTF6VectorIN3JSC7UStringELm16EE14expandCapacityEm +__ZN3WTF17TCMalloc_PageHeap3NewEm +__ZN3JSC7JSArray16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE +__ZN3JSC9ExecState10arrayTableEPS0_ +__ZN3JSCL18regExpObjectSourceEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSC7ArgList10slowAppendENS_10JSValuePtrE +__ZN3WTF7HashSetIPN3JSC7ArgListENS_7PtrHashIS3_EENS_10HashTraitsIS3_EEE3addERKS3_ +__ZN3WTF9HashTableIPN3JSC7ArgListES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E6rehashEi +__ZN3WTF6VectorIN3JSC8RegisterELm8EE15reserveCapacityEm +__ZN3JSC22JSPropertyNameIterator4markEv +__ZN3JSCL16mathProtoFuncLogEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL29objectProtoFuncHasOwnPropertyEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL18arrayProtoFuncSortEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC7JSArray4sortEPNS_9ExecStateENS_10JSValuePtrENS_8CallTypeERKNS_8CallDataE +__ZN3WTF7AVLTreeIN3JSC32AVLTreeAbstractorForArrayCompareELj44ENS_18AVLTreeDefaultBSetILj44EEEE6insertEi +__ZN3JSCltERKNS_7UStringES2_ +__ZN3WTF7AVLTreeIN3JSC32AVLTreeAbstractorForArrayCompareELj44ENS_18AVLTreeDefaultBSetILj44EEEE7balanceEi +__ZN3JSC4WREC9Generator29generateAssertionWordBoundaryERNS_14MacroAssembler8JumpListEb +__ZN3JSC12X86Assembler23X86InstructionFormatter11memoryModRMEiNS_3X8610RegisterIDES3_ii +__ZN3JSCL21stringProtoFuncConcatEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC19globalFuncEncodeURIEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC19globalFuncDecodeURIEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL6decodeEPNS_9ExecStateERKNS_7ArgListEPKcb __ZN3WTF7Unicode18UTF8SequenceLengthEc __ZN3WTF7Unicode18decodeUTF8SequenceEPKc -__ZN3KJS9StringImp18getPrimitiveNumberEPNS_9ExecStateERdRPNS_7JSValueE -__ZN3KJSltERKNS_7UStringES2_ -__ZN3KJS15ConditionalNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS10BitAndNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS10BitAndNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS15DotAccessorNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS19ImmediateNumberNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS13ArrayInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE -__ZN3KJS18LocalVarAccessNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS13LeftShiftNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS19BracketAccessorNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS14RightShiftNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS14RightShiftNode8evaluateEPNS_9ExecStateE -__ZN3KJS7AddNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS19ImmediateNumberNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS13LeftShiftNode8evaluateEPNS_9ExecStateE -__ZN3KJS18LocalVarAccessNode16evaluateToUInt32EPNS_9ExecStateE -__ZNK3KJS9NumberImp17getTruncatedInt32ERi -__ZN3KJS19BracketAccessorNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS16BooleanObjectImp9constructEPNS_9ExecStateERKNS_4ListE -__ZN3KJS24booleanProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS14BitwiseNotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS9BitOrNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS9BitOrNode8evaluateEPNS_9ExecStateE -__ZN3KJS10BitAndNode8evaluateEPNS_9ExecStateE -__ZN3KJS14BitwiseNotNode8evaluateEPNS_9ExecStateE -__ZN3KJS15NumberObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS8Bindings8Instance32createBindingForLanguageInstanceENS1_15BindingLanguageEPvN3WTF10PassRefPtrINS0_10RootObjectEEE -__ZN3KJS8Bindings9CInstanceC2EP8NPObjectN3WTF10PassRefPtrINS0_10RootObjectEEE -__ZN3KJS8Bindings8InstanceC2EN3WTF10PassRefPtrINS0_10RootObjectEEE -__ZNK3KJS8Bindings8Instance10rootObjectEv -__ZN3KJS8Bindings8Instance19createRuntimeObjectEPS1_ -__ZN3KJS16RuntimeObjectImpC2EPNS_8Bindings8InstanceE -__ZN3KJS8Bindings10RootObject16addRuntimeObjectEPNS_16RuntimeObjectImpE -__ZN3KJS16RuntimeObjectImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS8Bindings9CInstance5beginEv -__ZNK3KJS8Bindings9CInstance8getClassEv -__ZN3KJS8Bindings6CClass11classForIsAEP7NPClass -__ZN3KJS8Bindings6CClassC2EP7NPClass -__ZNK3KJS8Bindings6CClass10fieldNamedERKNS_10IdentifierEPNS0_8InstanceE -__ZNK3KJS7UString5asciiEv -__ZNK3KJS8Bindings6CClass12methodsNamedERKNS_10IdentifierEPNS0_8InstanceE -__NPN_UTF8FromIdentifier -__ZN3KJS8Bindings5Class14fallbackObjectEPNS_9ExecStateEPNS0_8InstanceERKNS_10IdentifierE -__ZN3KJS8Bindings9CInstance3endEv -__ZN3WTF6VectorIPN3KJS8Bindings6MethodELm0EE14expandCapacityEmPKS4_ -__ZN3WTF6VectorIPN3KJS8Bindings6MethodELm0EE14expandCapacityEm -__ZN3WTF6VectorIPN3KJS8Bindings6MethodELm0EE15reserveCapacityEm -__ZN3KJS16RuntimeObjectImp12methodGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS13RuntimeMethodC2EPNS_9ExecStateERKNS_10IdentifierERN3WTF6VectorIPNS_8Bindings6MethodELm0EEE -__ZN3WTF6VectorIPN3KJS8Bindings6MethodELm0EEC2ERKS5_ -__ZN3KJS13RuntimeMethod14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS16RuntimeObjectImp9classInfoEv -__ZN3KJS8Bindings9CInstance12invokeMethodEPNS_9ExecStateERKN3WTF6VectorIPNS0_6MethodELm0EEERKNS_4ListE -__ZNK3KJS8Bindings7CMethod4nameEv -__ZN3KJS8Bindings23convertNPVariantToValueEPNS_9ExecStateEPK10_NPVariantPNS0_10RootObjectE -__ZN3KJS16RuntimeObjectImpD2Ev -__ZN3KJS8Bindings10RootObject19removeRuntimeObjectEPNS_16RuntimeObjectImpE -__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcPNS_7JSValueEPS0_RKNS_10IdentifierE -__ZN3KJS10substituteERNS_7UStringERKS0_ -__ZN3KJS4Node16rethrowExceptionEPNS_9ExecStateE -__ZN3KJS4Node15handleExceptionEPNS_9ExecStateEPNS_7JSValueE -__ZN3KJS16RuntimeObjectImp10invalidateEv -__ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS14JSGlobalObjectD2Ev -__ZN3KJS15GlobalExecStateD1Ev -__ZN3KJS14BitwiseNotNodeD1Ev -__ZN3KJSplERKNS_7UStringES2_ -__ZN3KJS5Lexer14convertUnicodeEiiii -__ZN3KJS14ArrayObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS9Arguments3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZN3WTF9HashTableIjSt4pairIjiENS_18PairFirstExtractorIS2_EENS_7IntHashIjEENS_14PairHashTraitsINS_10HashTraitsIjEENS8_IiEEEES9_E3addIjS2_NS_22IdentityHashTranslatorIjS2_S6_EEEES1_INS_17HashTableIteratorIjS2_S4_S6_SB_S9_EEbERKT_RKT0_ -__ZN3WTF9HashTableIjSt4pairIjiENS_18PairFirstExtractorIS2_EENS_7IntHashIjEENS_14PairHashTraitsINS_10HashTraitsIjEENS8_IiEEEES9_EC2ERKSC_ -__ZN3KJS23stringProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3WTF9HashTableIjSt4pairIjiENS_18PairFirstExtractorIS2_EENS_7IntHashIjEENS_14PairHashTraitsINS_10HashTraitsIjEENS8_IiEEEES9_E4findIjNS_22IdentityHashTranslatorIjS2_S6_EEEENS_17HashTableIteratorIjS2_S4_S6_SB_S9_EERKT_ -__ZN3KJS10BitXOrNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS10BitXOrNode8evaluateEPNS_9ExecStateE -__ZN3KJS14RightShiftNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS10BitXOrNodeD1Ev -__ZN3KJS17DateObjectFuncImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS9parseDateERKNS_7UStringE -__ZN3KJS6RegExp6createERKNS_7UStringE -__ZN3KJS7ModNode16evaluateToNumberEPNS_9ExecStateE -__ZNK3KJS16RuntimeObjectImp14implementsCallEv -__ZNK3KJS8Bindings9CInstance14implementsCallEv -__ZN3KJS11Interpreter21shouldPrintExceptionsEv -__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcRKNS_10IdentifierE -__ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_ -__ZN3KJS15SavedPropertiesD1Ev -__ZN3KJS8JSObject18isActivationObjectEv -__ZN3KJS19globalFuncDecodeURIEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS14JSGlobalObject15restoreBuiltinsERKNS_13SavedBuiltinsE -__ZN3KJS11PropertyMap7restoreERKNS_15SavedPropertiesE -__ZN3KJS16JSVariableObject19restoreLocalStorageERKNS_15SavedPropertiesE -__ZN3WTF6VectorIN3KJS17LocalStorageEntryELm32EE6resizeEm -__ZNK3KJS23FunctionCallBracketNode8streamToERNS_12SourceStreamE -__ZNK3KJS17TypeOfResolveNode10precedenceEv -__ZNK3KJS17TypeOfResolveNode8streamToERNS_12SourceStreamE -__ZNK3KJS13AssignDotNode10precedenceEv -__ZNK3KJS12ContinueNode8streamToERNS_12SourceStreamE -__ZN3KJS11FunctionImp12callerGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS9BreakNodeC1ERKNS_10IdentifierE -__ZN3KJS13StatementNode9pushLabelERKNS_10IdentifierE -__ZN3KJS10LabelStack4pushERKNS_10IdentifierE -__ZN3KJS9ThrowNode7executeEPNS_9ExecStateE -__ZNK3KJS15NumberObjectImp19implementsConstructEv -__ZN3KJS22numberProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS8VoidNodeD1Ev -__ZN3KJS14ErrorObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS18globalFuncIsFiniteEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS21ReadModifyResolveNode8evaluateEPNS_9ExecStateE -__ZN3KJS15StrictEqualNode8evaluateEPNS_9ExecStateE -__ZN3KJS27compareByStringPairForQSortEPKvS1_ -__ZN3KJS7compareERKNS_7UStringES2_ -__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcPNS_7JSValueEPS0_S8_ -__ZN3KJS21arrayProtoFuncReverseEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS20stringProtoFuncSliceEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS15StringObjectImp19implementsConstructEv -__ZN3KJS15StringObjectImp9constructEPNS_9ExecStateERKNS_4ListE -__ZN3KJS18PostDecResolveNode8evaluateEPNS_9ExecStateE -__ZN3KJS21dateProtoFuncSetMonthEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS23setNewValueFromDateArgsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListEib -__ZN3KJS20dateProtoFuncSetDateEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS21dateProtoFuncSetHoursEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS23setNewValueFromTimeArgsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListEib -__ZN3KJS23dateProtoFuncSetMinutesEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS24dateProtoFuncSetFullYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRPNS_7JSValueE -__ZN3KJS20dateProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS27dateProtoFuncGetUTCFullYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS27dateProtoFuncSetUTCFullYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS24dateProtoFuncGetUTCMonthEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS24dateProtoFuncSetUTCMonthEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS23dateProtoFuncGetUTCDateEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS23dateProtoFuncSetUTCDateEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS24dateProtoFuncGetUTCHoursEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS24dateProtoFuncSetUTCHoursEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS26dateProtoFuncGetUTCMinutesEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS26dateProtoFuncSetUTCMinutesEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS26dateProtoFuncGetUTCSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS26dateProtoFuncSetUTCSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS22numberProtoFuncToFixedEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS18integer_part_noexpEd -__ZN3KJS14AddNumbersNode16evaluateToNumberEPNS_9ExecStateE -__ZNK3KJS14InstanceOfNode10precedenceEv -__ZNK3KJS14InstanceOfNode8streamToERNS_12SourceStreamE -__ZNK3KJS8JSObject8toNumberEPNS_9ExecStateE -__Z15kjs_pcre_xclassiPKh -__ZN3KJS10NumberNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS18PostDecBracketNodeD1Ev -__ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE -__ZN3KJS22errorProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS13LeftShiftNode15evaluateToInt32EPNS_9ExecStateE -__ZNK3KJS9RegExpImp14implementsCallEv -__ZN3KJS22stringProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS15ConditionalNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE -__ZN3KJS11DoWhileNode7executeEPNS_9ExecStateE -__ZN3KJS8Bindings23convertObjcValueToValueEPNS_9ExecStateEPvNS0_13ObjcValueTypeEPNS0_10RootObjectE -__ZN3KJS8Bindings17webUndefinedClassEv -__ZN3KJS8Bindings20webScriptObjectClassEv -__ZN3KJS8Bindings8Instance19createRuntimeObjectENS1_15BindingLanguageEPvN3WTF10PassRefPtrINS0_10RootObjectEEE -__ZN3KJS8Bindings12ObjcInstanceC2EP11objc_objectN3WTF10PassRefPtrINS0_10RootObjectEEE -__ZN3KJS8Bindings8Instance18didExecuteFunctionEv -__ZN3KJS8Bindings12ObjcInstance5beginEv -__ZNK3KJS8Bindings12ObjcInstance8getClassEv -__ZN3KJS8Bindings9ObjcClass11classForIsAEP10objc_class -__ZN3KJS8Bindings9ObjcClassC2EP10objc_class -__ZNK3KJS8Bindings9ObjcClass10fieldNamedERKNS_10IdentifierEPNS0_8InstanceE -__ZNK3KJS8Bindings9ObjcClass12methodsNamedERKNS_10IdentifierEPNS0_8InstanceE -__ZN3KJS8Bindings25convertJSMethodNameToObjcEPKcPcm -__ZN3KJS8Bindings10ObjcMethodC2EP10objc_classPKc -__ZN3KJS8Bindings12ObjcInstance3endEv -__ZN3KJS8Bindings12ObjcInstance12invokeMethodEPNS_9ExecStateERKN3WTF6VectorIPNS0_6MethodELm0EEERKNS_4ListE -__ZNK3KJS8Bindings10ObjcMethod18getMethodSignatureEv -__ZNK3KJS8Bindings10ObjcMethod4nameEv -__ZN3KJS8Bindings20objcValueTypeForTypeEPKc -__ZN3KJS8Bindings23convertValueToObjcValueEPNS_9ExecStateEPNS_7JSValueENS0_13ObjcValueTypeE -__ZNK3KJS6JSCell9getStringEv -__ZN3KJS8Bindings23convertNSStringToStringEP8NSString -__ZN3KJS8Bindings12ObjcInstanceD1Ev -__ZN3KJS9LabelNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS9LabelNode7executeEPNS_9ExecStateE -__ZN3KJS12ContinueNodeC1ERKNS_10IdentifierE -__ZN3KJS11FunctionImp12lengthGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS9BitOrNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS18EmptyStatementNode7executeEPNS_9ExecStateE -__ZN3KJS22UnsignedRightShiftNodeD1Ev -__ZN3KJS7ModNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS20arrayProtoFuncFilterEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS6InNode8evaluateEPNS_9ExecStateE -__ZN3KJS17arrayProtoFuncMapEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS10LessEqNode10precedenceEv -__ZNK3KJS10LessEqNode8streamToERNS_12SourceStreamE -__ZNK3KJS18NotStrictEqualNode10precedenceEv -__ZNK3KJS18NotStrictEqualNode8streamToERNS_12SourceStreamE -__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE -__ZN3KJS7UString4fromEi -__ZN3KJS14StringInstance11indexGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS21stringProtoFuncConcatEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS22UnsignedRightShiftNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS11ResolveNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS19FunctionCallDotNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS22UnsignedRightShiftNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS11ResolveNode16evaluateToUInt32EPNS_9ExecStateE -__ZNK3KJS9NumberImp18getTruncatedUInt32ERj -__ZN3KJS10NumberNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS7SubNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS14BitwiseNotNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS10BitAndNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS7AddNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS7SubNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS8VoidNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS8VoidNode8evaluateEPNS_9ExecStateE -__ZN3KJS17DeleteResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS18LocalVarDeleteNodeD1Ev -__ZN3KJS11FunctionImp15argumentsGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS18LocalVarDeleteNode8evaluateEPNS_9ExecStateE -__ZN3KJS17DeleteResolveNode8evaluateEPNS_9ExecStateE -__ZNK3KJS16RuntimeObjectImp6canPutEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS13UnaryPlusNode8evaluateEPNS_9ExecStateE -__ZN3KJS24dateProtoFuncToUTCStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS23booleanProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS11NewExprNode16evaluateToNumberEPNS_9ExecStateE -__Z22kjs_pcre_ucp_othercasej -__ZN3KJS17PreDecResolveNode8evaluateEPNS_9ExecStateE -__ZNK3KJS7JSValue7toFloatEPNS_9ExecStateE -__ZN3KJS14ExpressionNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS4List26markProtectedListsSlowCaseEv -__ZNK3KJS6JSCell9getStringERNS_7UStringE -__ZN3KJS8TrueNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS9RegExpImp3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -__ZNK3KJS9NumberImp9getUInt32ERj -__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcPNS_7JSValueEPS0_ -__ZN3KJS23FunctionCallResolveNode15evaluateToInt32EPNS_9ExecStateE -__ZNK3KJS6JSCell18getTruncatedUInt32ERj -__ZNK3KJS9LabelNode8streamToERNS_12SourceStreamE -__ZNK3KJS17ObjectLiteralNode21needsParensIfLeftmostEv -__ZNK3KJS11DoWhileNode8streamToERNS_12SourceStreamE -__ZNK3KJS17PreDecResolveNode8streamToERNS_12SourceStreamE -__ZNK3KJS13PreIncDotNode8streamToERNS_12SourceStreamE -__ZNK3KJS13PreDecDotNode8streamToERNS_12SourceStreamE -__ZNK3KJS17DeleteResolveNode8streamToERNS_12SourceStreamE -__ZN3KJS9FalseNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS23dateProtoFuncSetSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS14PostIncDotNode8streamToERNS_12SourceStreamE -__ZNK3KJS8Bindings12ObjcInstance14implementsCallEv -__ZN3KJS8Bindings9ObjcClass14fallbackObjectEPNS_9ExecStateEPNS0_8InstanceERKNS_10IdentifierE -__ZN3KJS16BooleanObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS11jsUndefinedEv -___tcf_2 -___tcf_6 -___tcf_0 -___tcf_5 -___tcf_3 -___tcf_4 +__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZNK3JSC12JSNumberCell8toObjectEPNS_9ExecStateE +__ZN3JSC15constructNumberEPNS_9ExecStateENS_10JSValuePtrE +__ZN3JSCL22numberProtoFuncToFixedEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC12JSNumberCell11getJSNumberEv +__ZN3JSCL16integerPartNoExpEd +__ZN3JSC11Interpreter27cti_op_get_by_id_proto_failEPvz +__ZN3WTF6VectorIPN3JSC10RegisterIDELm32EE14expandCapacityEm +__ZN3JSCL17arrayProtoFuncPopEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC7JSArray3popEv +__ZNK3JSC11DoWhileNode6isLoopEv +__ZN3JSC11DoWhileNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC11DoWhileNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11DoWhileNodeD1Ev +__ZN3JSC11Interpreter17cti_op_switch_immEPvz +__ZN3JSCL16mathProtoFuncMinEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC13UnaryPlusNode14stripUnaryPlusEv +__ZN3JSC13UnaryPlusNodeD1Ev +__ZN3JSCL21stringProtoFuncSubstrEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC15globalFuncIsNaNEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC17NumberConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL21callNumberConstructorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter15cti_op_post_incEPvz +__ZN3JSCL23stringProtoFuncFontsizeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL24dateProtoFuncSetFullYearEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL23setNewValueFromDateArgsEPNS_9ExecStateENS_10JSValuePtrERKNS_7ArgListEib +__ZN3JSCL24dateProtoFuncToUTCStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL19stringProtoFuncLinkEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL9dateParseEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter21cti_op_loop_if_lesseqEPvz +__ZN3JSCL16mathProtoFuncExpEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC6RegExp6createEPNS_12JSGlobalDataERKNS_7UStringE +__ZN3JSCL21dateProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC4WREC9Generator36generateParenthesesInvertedAssertionERNS_14MacroAssembler8JumpListE +__ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_10JSValuePtrE +__ZN3JSC9CodeBlock27lineNumberForBytecodeOffsetEPNS_9ExecStateEj +__ZN3JSCL23regExpProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL18regExpObjectGlobalEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL22regExpObjectIgnoreCaseEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL21regExpObjectMultilineEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSC11Interpreter17cti_op_is_booleanEPvz +__ZNK3JSC12JSNumberCell11toPrimitiveEPNS_9ExecStateENS_22PreferredPrimitiveTypeE +__ZN3JSC4WREC14CharacterClass9nonspacesEv +__ZN3JSC4Heap15recordExtraCostEm +__ZN3WTF6VectorIN3JSC15StringJumpTableELm0EE15reserveCapacityEm +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEESt4pairIS5_NS2_14OffsetLocationEENS_18PairFirstExtractorIS8_EENS_7StrHashIS5_EENS_14PairHashTraitsINS_10HashTraitsIS5_EENSE_IS7_EEEESF_EC2ERKSI_ +__ZN3JSC11Interpreter20cti_op_switch_stringEPvz +__ZNK3JSC12JSNumberCell12toThisObjectEPNS_9ExecStateE +__ZN3JSCL22numberProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC12NumberObject11getJSNumberEv +__ZNK3JSC13UnaryPlusNode8opcodeIDEv +__ZN3WTF12detachThreadEj +__ZN3WTFL26pthreadHandleForIdentifierEj +__ZN3WTFL31clearPthreadHandleForIdentifierEj +__ZN3WTF15ThreadConditionD1Ev +__ZN3WTF23waitForThreadCompletionEjPPv +__ZN3WTF20TCMalloc_ThreadCache18DestroyThreadCacheEPv +__ZN3WTF20TCMalloc_ThreadCache11DeleteCacheEPS0_ +__ZN3WTF14FastMallocZone10statisticsEP14_malloc_zone_tP19malloc_statistics_t +__ZN3JSC4Heap26protectedGlobalObjectCountEv +__ZNK3JSC11ResolveNode10isLocationEv +__ZNK3JSC11ResolveNode13isResolveNodeEv +__ZN3JSC17AssignResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator18findScopedPropertyERKNS_10IdentifierERiRmbRPNS_8JSObjectE +__ZN3JSC17BytecodeGenerator15emitResolveBaseEPNS_10RegisterIDERKNS_10IdentifierE +__ZN3JSC15DotAccessorNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator12newTemporaryEv +__ZN3JSC10StringNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator8emitLoadEPNS_10RegisterIDERKNS_10IdentifierE +__ZN3WTF9HashTableIPN3JSC7UString3RepESt4pairIS4_PNS1_8JSStringEENS_18PairFirstExtractorIS8_EENS1_17IdentifierRepHashENS_14PairHashTraitsINS_10HashTraitsIS4_EENSD_IS7_EEEESE_E6expandEv +__ZN3JSC16ArgumentListNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC10StringNodeD1Ev +__ZN3JSC16ArgumentListNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC16ArgumentListNodeD1Ev +__ZN3JSC11Interpreter19cti_op_resolve_baseEPvz +__ZN3JSC14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZNK3JSC8JSString8toStringEPNS_9ExecStateE +__ZN3JSC13AssignDotNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC10StringNode6isPureERNS_17BytecodeGeneratorE +__ZN3JSC13ParameterNode12releaseNodesERNS_12NodeReleaserE +__ZN3WTF6VectorISt4pairIN3JSC10IdentifierEjELm0EEaSERKS5_ +__ZNK3JSC7UString14toStrictUInt32EPb +__ZN3JSC17BytecodeGenerator8emitMoveEPNS_10RegisterIDES2_ +__ZN3JSC16VarStatementNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZL12makeMultNodePvPN3JSC14ExpressionNodeES2_b +__ZN3JSC14ExpressionNode14stripUnaryPlusEv +__ZN3JSC10NumberNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator8emitLoadEPNS_10RegisterIDEd +__ZN3WTF9HashTableIdSt4pairIdN3JSC10JSValuePtrEENS_18PairFirstExtractorIS4_EENS_9FloatHashIdEENS_14PairHashTraitsINS_10HashTraitsIdEENSA_IS3_EEEESB_E6expandEv +__ZNK3JSC7AddNode8opcodeIDEv +__ZNK3JSC8MultNode8opcodeIDEv +__ZN3JSC10NumberNodeD1Ev +__ZN3JSC8MultNodeD1Ev +__ZN3JSC3JIT23compileFastArith_op_mulEPNS_11InstructionE +__ZN3JSC14MacroAssembler4jz32ENS_3X8610RegisterIDENS0_5Imm32E +__ZN3JSC12X86Assembler7subl_irEiNS_3X8610RegisterIDE +__ZN3JSC3JIT20compileBinaryArithOpENS_8OpcodeIDEjjjNS_12OperandTypesE +__ZN3JSC9CodeBlock19isKnownNotImmediateEi +__ZN3JSC12X86Assembler23X86InstructionFormatter11memoryModRMEiNS_3X8610RegisterIDEi +__ZN3JSC12X86Assembler23X86InstructionFormatter9twoByteOpENS0_15TwoByteOpcodeIDEiNS_3X8610RegisterIDEi +__ZN3JSC12X86Assembler8sarl_i8rEiNS_3X8610RegisterIDE +__ZN3JSC15AssemblerBuffer7putByteEi +__ZN3JSC12X86Assembler23X86InstructionFormatter9twoByteOpENS0_15TwoByteOpcodeIDEiNS_3X8610RegisterIDE +__ZN3JSC3JIT42putDoubleResultToJSNumberCellOrJSImmediateENS_3X8613XMMRegisterIDENS1_10RegisterIDEjPNS_12X86Assembler6JmpSrcES2_S3_S3_ +__ZN3JSC3JIT27compileFastArithSlow_op_mulEPNS_11InstructionERPNS_13SlowCaseEntryE +__ZN3JSC3JIT27compileFastArithSlow_op_addEPNS_11InstructionERPNS_13SlowCaseEntryE +__ZN3JSC3JIT28compileBinaryArithOpSlowCaseENS_8OpcodeIDERPNS_13SlowCaseEntryEjjjNS_12OperandTypesE +__ZN3JSC11Interpreter31cti_op_construct_NotJSConstructEPvz +__ZN3JSC15DateConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL28constructWithDateConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSC13constructDateEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSC13DatePrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL20dateProtoFuncGetTimeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC12DateInstance9classInfoEv +__ZN3JSC11Interpreter10cti_op_addEPvz +__ZN3JSC12jsNumberCellEPNS_12JSGlobalDataEd +__ZNK3JSC12JSNumberCell8toNumberEPNS_9ExecStateE +__ZN3JSC11BooleanNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC6IfNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC9BlockNode7isBlockEv +__ZN3JSC9BlockNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC9BlockNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC10JSFunction4markEv +__ZN3JSC16FunctionBodyNode4markEv +__ZN3JSC23FunctionCallResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator19emitResolveFunctionEPNS_10RegisterIDES2_RKNS_10IdentifierE +__ZNK3JSC12NotEqualNode8opcodeIDEv +__ZNK3JSC8LessNode8opcodeIDEv +__ZN3JSC23FunctionCallResolveNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC23FunctionCallResolveNodeD1Ev +__ZN3JSC12NotEqualNodeD1Ev +__ZN3JSC8LessNodeD1Ev +__ZN3JSC11Interpreter19cti_op_resolve_funcEPvz +__ZN3JSC11Interpreter22cti_op_call_JSFunctionEPvz +__ZN3JSC16FunctionBodyNode16generateBytecodeEPNS_14ScopeChainNodeE +__ZN3JSC6Parser14reparseInPlaceEPNS_12JSGlobalDataEPNS_16FunctionBodyNodeE +__ZN3JSC17BytecodeGeneratorC2EPNS_16FunctionBodyNodeEPKNS_8DebuggerERKNS_10ScopeChainEPN3WTF7HashMapINS9_6RefPtrINS_7UString3RepEEENS_16SymbolTableEntryENS_17IdentifierRepHashENS9_10HashTraitsISE_EENS_26SymbolTableIndexHashTraitsEEEPNS_9CodeBlockE +__ZN3JSC16FunctionBodyNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC16JSVariableObject16isVariableObjectEv +__ZN3JSC17BytecodeGenerator16emitGetScopedVarEPNS_10RegisterIDEmiNS_10JSValuePtrE +__ZNK3JSC13StatementNode12isReturnNodeEv +__ZN3JSC17BytecodeGenerator10emitReturnEPNS_10RegisterIDE +__ZN3JSC11Interpreter23cti_vm_dontLazyLinkCallEPvz +__ZN3JSC11Interpreter23cti_register_file_checkEPvz +__ZN3JSC17BytecodeGenerator12addParameterERKNS_10IdentifierE +__ZNK3JSC13StatementNode7isBlockEv +__ZN3JSC10ReturnNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC14JSGlobalObject14isDynamicScopeEv +__ZN3JSC10ReturnNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC10ReturnNodeD1Ev +__ZN3JSC11concatenateEPNS_7UString3RepES2_ +__ZN3JSC11Interpreter23cti_op_get_by_id_secondEPvz +__ZN3JSC11Interpreter18tryCTICacheGetByIDEPNS_9ExecStateEPNS_9CodeBlockEPvNS_10JSValuePtrERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSC3JIT26privateCompileGetByIdProtoEPNS_17StructureStubInfoEPNS_9StructureES4_mPvPNS_9ExecStateE +__ZN3JSC12X86Assembler23X86InstructionFormatter9oneByteOpENS0_15OneByteOpcodeIDEiPv +__ZNK3JSC11ResolveNode6isPureERNS_17BytecodeGeneratorE +__ZN3JSC9CodeBlock4markEv +__ZN3JSC19BracketAccessorNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator12emitGetByValEPNS_10RegisterIDES2_S2_ +__ZN3JSC10JSFunction18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC11Interpreter28cti_op_construct_JSConstructEPvz +__ZN3JSC8JSObject17createInheritorIDEv +__ZL15makePostfixNodePvPN3JSC14ExpressionNodeENS0_8OperatorEiii +__ZNK3JSC7ForNode6isLoopEv +__ZN3JSC7ForNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator13newLabelScopeENS_10LabelScope4TypeEPKNS_10IdentifierE +__ZN3JSC17BytecodeGenerator8emitJumpEPNS_5LabelE +__ZN3JSC17AssignBracketNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC8ThisNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator12emitPutByValEPNS_10RegisterIDES2_S2_ +__ZN3JSC18PostfixResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator14emitJumpIfTrueEPNS_10RegisterIDEPNS_5LabelE +__ZN3JSC7ForNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC7ForNodeD1Ev +__ZN3JSC18PostfixResolveNodeD1Ev +__ZN3JSC17AssignBracketNodeD1Ev +__ZN3JSC17AssignBracketNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC8ThisNodeD1Ev +__ZN3JSC3JIT27compileFastArith_op_pre_incEj +__ZN3JSC12X86Assembler2joEv +__ZN3JSC3JIT19emitSlowScriptCheckEv +__ZN3JSC3JIT31compileFastArithSlow_op_pre_incEjRPNS_13SlowCaseEntryE +__ZN3JSC11Interpreter22cti_op_call_arityCheckEPvz +__ZN3JSC10JSFunction15argumentsGetterEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZNK3JSC11Interpreter17retrieveArgumentsEPNS_9ExecStateEPNS_10JSFunctionE +__ZN3JSC9Arguments18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC11Interpreter17cti_op_get_by_valEPvz +__ZN3JSC9Arguments18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC11Interpreter17cti_op_put_by_valEPvz +__ZN3JSC8JSObject3putEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3JSC11Interpreter24cti_op_get_by_id_genericEPvz +__ZN3JSCL21dateProtoFuncGetMonthEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC12DateInstance21msToGregorianDateTimeEdbRNS_17GregorianDateTimeE +__ZN3JSC21msToGregorianDateTimeEdbRNS_17GregorianDateTimeE +__ZN3JSCL12getDSTOffsetEdd +__ZN3JSC8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC8JSObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL20dateProtoFuncGetDateEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11concatenateEPNS_7UString3RepEi +__ZN3JSC21ReadModifyResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC21ReadModifyResolveNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSCL20dateProtoFuncGetYearEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZL11makeSubNodePvPN3JSC14ExpressionNodeES2_b +__ZN3JSC10IfElseNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC10LessEqNode8opcodeIDEv +__ZNK3JSC7SubNode8opcodeIDEv +__ZN3JSC10LessEqNodeD1Ev +__ZN3JSC7SubNodeD1Ev +__ZN3JSC3JIT23compileFastArith_op_subEPNS_11InstructionE +__ZN3JSC3JIT27compileFastArithSlow_op_subEPNS_11InstructionERPNS_13SlowCaseEntryE +__ZN3JSCL21dateProtoFuncGetHoursEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter13cti_op_lesseqEPvz +__ZN3JSCL23dateProtoFuncGetMinutesEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC13GreaterEqNode8opcodeIDEv +__ZN3JSC13GreaterEqNodeD1Ev +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEESt4pairIS5_NS2_16SymbolTableEntryEENS_18PairFirstExtractorIS8_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS_10HashTraitsIS5_EENS2_26SymbolTableIndexHashTraitsEEESE_E4findIS5_NS_22IdentityHashTranslatorIS5_S8_SB_EEEENS_17HashTableIteratorIS5_S8_SA_SB_SG_SE_EERKT_ +__ZN3JSC8WithNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator13emitPushScopeEPNS_10RegisterIDE +__ZN3WTF6VectorIN3JSC18ControlFlowContextELm0EE14expandCapacityEm +__ZN3JSC11Interpreter9cti_op_eqEPvz +__ZN3JSCeqERKNS_7UStringES2_ +__ZN3JSC11Interpreter17cti_op_push_scopeEPvz +__ZN3JSC11Interpreter14cti_op_resolveEPvz +__ZN3JSC11Interpreter16cti_op_pop_scopeEPvz +__ZN3JSC8NullNodeD1Ev +__ZN3JSC8NullNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator20emitNextPropertyNameEPNS_10RegisterIDES2_PNS_5LabelE +__ZN3JSC9ForInNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11Interpreter17cti_op_get_pnamesEPvz +__ZN3JSC22JSPropertyNameIterator6createEPNS_9ExecStateENS_10JSValuePtrE +__ZN3JSC8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE +__ZN3JSC9Structure26getEnumerablePropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayEPNS_8JSObjectE +__ZN3JSC9Structure34getEnumerablePropertyNamesInternalERNS_17PropertyNameArrayE +__ZNK3JSC6JSCell9classInfoEv +__ZN3JSC9Structure26createCachedPrototypeChainEv +__ZN3JSC14StructureChainC1EPNS_9StructureE +__ZN3JSC11Interpreter17cti_op_next_pnameEPvz +__ZN3JSC23structureChainsAreEqualEPNS_14StructureChainES1_ +__ZN3JSC13jsOwnedStringEPNS_12JSGlobalDataERKNS_7UStringE +__ZN3JSC11Interpreter10cti_op_neqEPvz +__ZN3JSC16globalFuncEscapeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11JSImmediate8toStringENS_10JSValuePtrE +__ZN3JSC7UString4fromEi +__ZN3JSC7UString6appendERKS0_ +__ZN3JSC22JSPropertyNameIterator10invalidateEv +__ZN3JSCL21dateProtoFuncSetMonthEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL20dateProtoFuncSetDateEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCplERKNS_7UStringES2_ +__ZN3JSC14ExecutablePool13systemReleaseERKNS0_10AllocationE +__ZNK3JSC8JSString11toPrimitiveEPNS_9ExecStateENS_22PreferredPrimitiveTypeE +__ZN3JSC16ArrayConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL29constructWithArrayConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSCL27constructArrayWithSizeQuirkEPNS_9ExecStateERKNS_7ArgListE +__ZL14makePrefixNodePvPN3JSC14ExpressionNodeENS0_8OperatorEiii +__ZN3JSC13PrefixDotNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC9WhileNode6isLoopEv +__ZN3JSC9WhileNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC9WhileNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13PrefixDotNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13PrefixDotNodeD1Ev +__ZN3JSC9WhileNodeD1Ev +__ZN3JSC3JIT28compileFastArith_op_post_incEjj +__ZN3JSC3JIT32compileFastArithSlow_op_post_incEjjRPNS_13SlowCaseEntryE +__ZN3JSC11Interpreter22cti_op_push_activationEPvz +__ZN3JSC12JSActivationC1EPNS_9ExecStateEN3WTF10PassRefPtrINS_16FunctionBodyNodeEEE +__ZN3JSC12JSActivation18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZL11makeDivNodePvPN3JSC14ExpressionNodeES2_b +__ZN3JSC15ConditionalNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC7DivNode8opcodeIDEv +__ZN3JSC15ConditionalNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC15ConditionalNodeD1Ev +__ZN3JSC7DivNodeD1Ev +__ZN3JSC7JSArrayC2EN3WTF10PassRefPtrINS_9StructureEEEj +__ZN3JSC11Interpreter23cti_op_put_by_val_arrayEPvz +__ZN3JSC7JSArray3putEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3JSC7JSArray3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC12StringObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC7JSArray18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC11Interpreter10cti_op_divEPvz +__ZN3JSC3JIT16patchGetByIdSelfEPNS_17StructureStubInfoEPNS_9StructureEmPv +__ZN3JSC3JIT33privateCompilePatchGetArrayLengthEPv +__ZN3JSC11Interpreter23cti_op_put_by_id_secondEPvz +__ZN3JSC11Interpreter18tryCTICachePutByIDEPNS_9ExecStateEPNS_9CodeBlockEPvNS_10JSValuePtrERKNS_15PutPropertySlotE +__ZN3JSCL19cachePrototypeChainEPNS_9ExecStateEPNS_9StructureE +__ZN3JSC3JIT31privateCompilePutByIdTransitionEPNS_17StructureStubInfoEPNS_9StructureES4_mPNS_14StructureChainEPv +__ZN3JSC9Structure22materializePropertyMapEv +__ZN3JSC3JIT19patchPutByIdReplaceEPNS_17StructureStubInfoEPNS_9StructureEmPv +__ZN3JSCL21resizePropertyStorageEPNS_8JSObjectEii +__ZN3JSC8JSObject23allocatePropertyStorageEmm +__ZN3JSC11Interpreter14cti_op_pre_incEPvz +__ZN3JSCL21stringProtoFuncCharAtEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC12StringObject12toThisStringEPNS_9ExecStateE +__ZN3JSC11Interpreter26cti_op_tear_off_activationEPvz +__ZN3JSC11Interpreter21cti_op_ret_scopeChainEPvz +__ZN3JSC11Interpreter27cti_op_get_by_id_proto_listEPvz +__ZN3JSC3JIT30privateCompileGetByIdProtoListEPNS_17StructureStubInfoEPNS_30PolymorphicAccessStructureListEiPNS_9StructureES6_mPNS_9ExecStateE +__ZN3JSC12JSActivationD0Ev +__ZN3JSCL26stringProtoFuncToLowerCaseEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC8JSString14toThisJSStringEPNS_9ExecStateE +__ZN3JSC7JSArray11putSlowCaseEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3WTF11fastReallocILb0EEEPvS1_m +__ZN3JSCL24stringProtoFuncSubstringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11jsSubstringEPNS_12JSGlobalDataERKNS_7UStringEjj +__ZN3JSCL20stringProtoFuncSplitEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC19constructEmptyArrayEPNS_9ExecStateE +__ZNK3JSC11BooleanNode6isPureERNS_17BytecodeGeneratorE +__ZNK3JSC7ModNode8opcodeIDEv +__ZN3JSC7ModNodeD1Ev +__ZN3JSC3JIT23compileFastArith_op_modEjjj +__ZN3JSC3JIT27compileFastArithSlow_op_modEjjjRPNS_13SlowCaseEntryE +__ZN3JSCL23dateProtoFuncGetSecondsEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC17BytecodeGenerator16emitPutScopedVarEmiPNS_10RegisterIDENS_10JSValuePtrE +__ZN3JSC18globalFuncUnescapeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC7UString6appendEt +__ZN3JSC11Interpreter19cti_vm_lazyLinkCallEPvz +__ZN3JSC3JIT8linkCallEPNS_10JSFunctionEPNS_9CodeBlockEPvPNS_12CallLinkInfoEi +__ZN3WTF6VectorIPN3JSC12CallLinkInfoELm0EE14expandCapacityEm +__ZN3JSC12X86Assembler7cmpl_imEiiNS_3X8610RegisterIDE +__ZN3JSC9CodeBlock13unlinkCallersEv +__ZNK3JSC8JSString9toBooleanEPNS_9ExecStateE +__ZN3JSC11Interpreter10cti_op_mulEPvz +__ZN3JSC11Interpreter18cti_op_to_jsnumberEPvz +__ZN3JSCL30dateProtoFuncGetTimezoneOffsetEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL18mathProtoFuncFloorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL13jsAddSlowCaseEPNS_9ExecStateENS_10JSValuePtrES2_ +__ZN3JSC20globalFuncParseFloatEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC7UString4fromEj +__ZN3JSC10Identifier11addSlowCaseEPNS_9ExecStateEPNS_7UString3RepE +__ZN3JSC7UString17expandPreCapacityEi +__ZN3JSC9CommaNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC9CommaNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC16VarDeclCommaNodeD1Ev +__ZN3JSC7UStringC1EPtib +__ZN3JSC5Error6createEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringEilS6_ +__ZN3JSC22NativeErrorConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL35constructWithNativeErrorConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSC22NativeErrorConstructor9constructEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrEj +__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE +__ZNK3JSC8JSObject11toPrimitiveEPNS_9ExecStateENS_22PreferredPrimitiveTypeE +__ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE +__ZN3JSCL22errorProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE +__ZN3JSC7UString6appendEPKc +__ZN3JSC3JIT10unlinkCallEPNS_12CallLinkInfoE +__ZN3JSC11Interpreter24cti_op_put_by_id_genericEPvz +__ZN3JSC21FunctionCallValueNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC12FuncExprNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator25emitNewFunctionExpressionEPNS_10RegisterIDEPNS_12FuncExprNodeE +__ZN3WTF6VectorINS_6RefPtrIN3JSC12FuncExprNodeEEELm0EE15reserveCapacityEm +__ZN3WTF7HashSetINS_6RefPtrIN3JSC7UString3RepEEENS2_17IdentifierRepHashENS_10HashTraitsIS5_EEE3addERKS5_ +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEES5_NS_17IdentityExtractorIS5_EENS2_17IdentifierRepHashENS_10HashTraitsIS5_EESA_E6expandEv +__ZL14compileBracketiPiPPhPPKtS3_P9ErrorCodeiS_S_R11CompileData +__ZN3JSC4WREC9Generator20generateAssertionEOLERNS_14MacroAssembler8JumpListE +__ZN3JSC17ObjectLiteralNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC4WREC31GeneratePatternCharacterFunctor12generateAtomEPNS0_9GeneratorERNS_14MacroAssembler8JumpListE +__ZN3JSC4WREC31GeneratePatternCharacterFunctor9backtrackEPNS0_9GeneratorE +__ZL20branchNeedsLineStartPKhjj +__ZN3JSC9ArrayNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator12emitNewArrayEPNS_10RegisterIDEPNS_11ElementNodeE +__ZL17bracketIsAnchoredPKh +__ZL32branchFindFirstAssertedCharacterPKhb +__ZN3JSC10JSFunction3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC11concatenateEPNS_7UString3RepEd +__ZNK3JSC12JSActivation14isDynamicScopeEv +__ZN3JSC17TypeOfResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC15StrictEqualNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC12ContinueNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator14continueTargetERKNS_10IdentifierE +__ZN3JSC17BytecodeGenerator14emitJumpScopesEPNS_5LabelEi +__ZN3JSC15TypeOfValueNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC15TypeOfValueNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC17TypeOfResolveNodeD1Ev +__ZN3JSC15StrictEqualNodeD1Ev +__ZN3JSC12ContinueNodeD1Ev +__ZN3JSC15TypeOfValueNodeD1Ev +__ZN3JSC11Interpreter33cti_op_create_arguments_no_paramsEPvz +__ZN3JSC11Interpreter13cti_op_typeofEPvz +__ZN3JSCL20jsTypeStringForValueEPNS_9ExecStateENS_10JSValuePtrE +__ZN3JSC6JSCell11getCallDataERNS_8CallDataE +__ZN3JSCL30comparePropertyMapEntryIndicesEPKvS1_ +__ZN3WTF6VectorIN3JSC10IdentifierELm20EE15reserveCapacityEm +__ZN3JSCL22objectProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC14ArrayPrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL22functionProtoFuncApplyEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC7JSArray9classInfoEv +__ZN3JSCL18arrayProtoFuncPushEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter27cti_op_get_by_id_array_failEPvz +__ZN3JSC14PostfixDotNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC14PostfixDotNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11Interpreter32cti_op_get_by_id_proto_list_fullEPvz +__ZN3JSC12FuncExprNodeD1Ev +__ZN3JSC12FuncExprNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11Interpreter26cti_op_get_by_id_self_failEPvz +__ZN3JSC3JIT29privateCompileGetByIdSelfListEPNS_17StructureStubInfoEPNS_30PolymorphicAccessStructureListEiPNS_9StructureEm +__ZN3JSCL19arrayProtoFuncSliceEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter25cti_op_tear_off_argumentsEPvz +__ZN3WTF6VectorIPN3JSC9StructureELm8EE14expandCapacityEm +__ZN3JSCL44countPrototypeChainEntriesAndCheckForProxiesEPNS_9ExecStateENS_10JSValuePtrERKNS_12PropertySlotE +__ZN3JSC17DeleteBracketNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17DeleteBracketNodeD1Ev +__ZN3JSC17DeleteBracketNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11Interpreter17cti_op_del_by_valEPvz +__ZN3JSC8JSObject14deletePropertyEPNS_9ExecStateEj +__ZN3JSC8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZNK3JSC6JSCell9getUInt32ERj +__ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSCL11getPropertyEPNS_9ExecStateEPNS_8JSObjectEj +__ZN3JSC17ReadModifyDotNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17ReadModifyDotNodeD1Ev +__ZN3JSC17ReadModifyDotNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11JSImmediate9prototypeENS_10JSValuePtrEPNS_9ExecStateE +__ZN3JSC9CodeBlock34reparseForExceptionInfoIfNecessaryEPNS_9ExecStateE +__ZNK3JSC10ScopeChain10localDepthEv +__ZNK3JSC12JSActivation9classInfoEv +__ZN3JSC6Parser7reparseINS_16FunctionBodyNodeEEEN3WTF10PassRefPtrIT_EEPNS_12JSGlobalDataEPS5_ +__ZN3JSC16FunctionBodyNode6createEPNS_12JSGlobalDataEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm0EEEPNS6_INS5_6RefPtrINS_12FuncDeclNodeEEELm0EEERKNS_10SourceCodeEji +__ZN3JSC13StatementNode6setLocEii +__ZN3JSC16FunctionBodyNode14copyParametersEv +__ZN3JSC16FunctionBodyNode13finishParsingEPNS_10IdentifierEm +__ZN3JSC16FunctionBodyNode31bytecodeForExceptionInfoReparseEPNS_14ScopeChainNodeEPNS_9CodeBlockE +__ZN3JSC9CodeBlock36hasGlobalResolveInfoAtBytecodeOffsetEj +__ZN3JSC6RegExpD1Ev __Z12jsRegExpFreeP8JSRegExp -__ZN3KJS25CollectorHeapIntrospector4sizeEP14_malloc_zone_tPKv -__ZN3WTF9HashTableINS_6RefPtrIN3KJS7UString3RepEEESt4pairIS5_mENS_18PairFirstExtractorIS7_EENS2_17IdentifierRepHashENS_14PairHashTraitsINS2_23IdentifierRepHashTraitsENS2_26SymbolTableIndexHashTraitsEEESC_E4findIS5_NS_22IdentityHashTranslatorIS5_S7_SA_EEEENS_17HashTableIteratorIS5_S7_S9_SA_SE_SC_EERKT_ -__ZN3KJS18AssignLocalVarNodeD1Ev -__ZN3KJS8TrueNodeD1Ev -__ZN3KJS11NewExprNodeD1Ev -__ZN3KJS19ImmediateNumberNodeD1Ev -__ZN3KJS17AssignBracketNodeD1Ev -__ZN3KJS18LocalVarAccessNodeD1Ev -__ZN3KJS16ParserRefCounted8refcountEv -__ZN3KJS14JSGlobalObject16stopTimeoutCheckEv -__ZN3KJS11GreaterNodeD1Ev -__ZN3KJS16ArgumentListNodeD1Ev -__ZN3KJS17FunctionObjectImp9constructEPNS_9ExecStateERKNS_4ListERKNS_10IdentifierERKNS_7UStringEi -__ZN3KJS6Parser5parseINS_16FunctionBodyNodeEEEN3WTF10PassRefPtrIT_EERKNS_7UStringEiPKNS_5UCharEjPiSD_PS7_ -__ZN3KJS8JSObject4callEPNS_9ExecStateEPS0_RKNS_4ListE -__ZN3KJS18AddStringRightNode8evaluateEPNS_9ExecStateE -__ZN3KJS16globalFuncEscapeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS13DateObjectImp19implementsConstructEv -__ZN3KJS13DateObjectImp9constructEPNS_9ExecStateERKNS_4ListE -__ZN3KJS13DatePrototype18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS20dateProtoFuncGetTimeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS12DateInstance9classInfoEv -__ZNK3KJS9NumberImp8toNumberEPNS_9ExecStateE -__ZNK3KJS9NumberImp8toStringEPNS_9ExecStateE -__ZN3KJS9BlockNodeD1Ev -__ZN3KJS21dateProtoFuncGetMonthEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS21msToGregorianDateTimeEdbRNS_17GregorianDateTimeE -__ZN3KJS12getUTCOffsetEv -__ZN3KJS12getDSTOffsetEdd -__ZN3KJS15ConditionalNodeD1Ev -__ZN3KJS7DivNodeD1Ev -__ZN3KJS9EqualNodeD1Ev -__ZN3KJS8NullNodeD1Ev -__ZN3KJS9FalseNodeD1Ev -__ZN3KJS12NotEqualNodeD1Ev -__ZN3KJS7SubNodeD1Ev -__ZN3KJS7SubNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS24LocalVarFunctionCallNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS21ReadModifyResolveNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS14StringInstance12lengthGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS18globalFuncUnescapeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS7DivNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS7DivNode8evaluateEPNS_9ExecStateE -__ZN3KJS18LocalVarAccessNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS8MultNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS8MultNode8evaluateEPNS_9ExecStateE -__ZN3KJS19FunctionCallDotNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS7SubNode8evaluateEPNS_9ExecStateE -__ZNK3KJS9NumberImp11toPrimitiveEPNS_9ExecStateENS_6JSTypeE -__ZN3KJS18AddStringRightNodeD1Ev -__ZN3KJS7AddNodeD1Ev -__ZN3KJS13LogicalOrNodeD1Ev -__ZN3KJS17PreIncResolveNodeD1Ev -__ZN3KJS8MultNodeD1Ev -__ZN3KJS8LessNodeD1Ev -__ZN3KJS14LogicalAndNodeD1Ev -__ZN3KJS10NumberNodeD1Ev -__ZN3KJS13GreaterEqNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS14LogicalNotNodeD1Ev -__ZN3KJS7ModNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS14JSGlobalObject12checkTimeoutEv -__ZN3KJS7ModNode8evaluateEPNS_9ExecStateE -__ZN3KJS15LessNumbersNode8evaluateEPNS_9ExecStateE -__ZN3KJS20dateProtoFuncGetYearEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS8ThisNodeD1Ev -__ZN3KJS19mathProtoFuncRandomEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS20globalFuncParseFloatEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS13GreaterEqNode8evaluateEPNS_9ExecStateE -__ZN3KJS20dateProtoFuncGetDateEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS18mathProtoFuncFloorEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS23stringProtoFuncFontsizeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS11ResolveNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS13GreaterEqNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS9NumberImp18getPrimitiveNumberEPNS_9ExecStateERdRPNS_7JSValueE -__ZN3KJS19stringProtoFuncLinkEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS19dateProtoFuncGetDayEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS21dateProtoFuncGetHoursEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS23dateProtoFuncGetMinutesEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS23dateProtoFuncGetSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS9ArrayNodeD1Ev -__ZN3KJS11ElementNodeD1Ev -__ZN3KJS17ObjectLiteralNodeD1Ev -__ZN3KJS14PostfixDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS14PostIncDotNode8evaluateEPNS_9ExecStateE -__ZN3KJS19PlaceholderTrueNodeD1Ev -__ZN3KJS19PostDecLocalVarNode8evaluateEPNS_9ExecStateE -__ZN3KJS17ReadModifyDotNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS17ReadModifyDotNode8evaluateEPNS_9ExecStateE -__ZN3KJS21FunctionCallValueNodeD1Ev -__ZN3KJS10BitAndNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS14AddNumbersNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS10BitXOrNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS22UnsignedRightShiftNode8evaluateEPNS_9ExecStateE -__ZN3KJS8MultNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS7DivNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS19StringObjectFuncImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS7ModNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS10BitAndNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS14RightShiftNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS14AddNumbersNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS14globalFuncEvalEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS6Parser5parseINS_8EvalNodeEEEN3WTF10PassRefPtrIT_EERKNS_7UStringEiPKNS_5UCharEjPiSD_PS7_ -__ZN3KJS13EvalExecStateC1EPNS_14JSGlobalObjectEPNS_8EvalNodeEPNS_9ExecStateE -__ZN3KJS8EvalNode7executeEPNS_9ExecStateE -__ZN3KJS8EvalNodeD1Ev -__ZN3KJS23FunctionCallBracketNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS23FunctionCallBracketNode8evaluateEPNS_9ExecStateE -__ZN3KJS16PropertyListNodeD1Ev -__ZN3KJS12PropertyNodeD1Ev -__ZN3KJS13CaseBlockNodeD1Ev -__ZN3KJS14CaseClauseNodeD1Ev -__ZN3KJS14ClauseListNodeD1Ev -__ZN3KJS9RegExpImp18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS17staticValueGetterINS_9RegExpImpEEEPNS_7JSValueEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKNS_12PropertySlotE -__ZNK3KJS9RegExpImp16getValuePropertyEPNS_9ExecStateEi -__ZN3KJS9ThrowNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS15StrictEqualNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS19regExpProtoFuncTestEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS9RegExpImp5matchEPNS_9ExecStateERKNS_4ListE -__ZN3KJS15StrictEqualNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS18NotStrictEqualNodeD1Ev -__ZN3KJS15StrictEqualNodeD1Ev -__ZN3KJS18LocalVarTypeOfNodeD1Ev -__ZN3KJS19globalFuncEncodeURIEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS17TypeOfResolveNode8evaluateEPNS_9ExecStateE -__ZN3KJS26stringProtoFuncLastIndexOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS7JSValue20toIntegerPreserveNaNEPNS_9ExecStateE -__ZNK3KJS7UString5rfindERKS0_i -__ZN3KJS15TypeOfValueNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS15TypeOfValueNode8evaluateEPNS_9ExecStateE -__ZNK3KJS17FunctionObjectImp19implementsConstructEv -__ZN3KJS17FunctionObjectImp9constructEPNS_9ExecStateERKNS_4ListE -__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS30dateProtoFuncGetTimezoneOffsetEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS8JSObject3putEPNS_9ExecStateEjPNS_7JSValueEi -__ZN3KJS6InNodeD1Ev -__ZNK3KJS9Arguments9classInfoEv -__ZN3KJS10BitXOrNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS19addSlowCaseToNumberEPNS_9ExecStateEPNS_7JSValueES3_ -__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj -__ZNK3KJS9WhileNode8streamToERNS_12SourceStreamE -__ZNK3KJS9FalseNode8streamToERNS_12SourceStreamE -__ZNK3KJS7DivNode8streamToERNS_12SourceStreamE -__ZNK3KJS7DivNode10precedenceEv -__ZNK3KJS15StrictEqualNode8streamToERNS_12SourceStreamE -__ZNK3KJS15StrictEqualNode10precedenceEv -__ZNK3KJS16VarDeclCommaNode10precedenceEv -__ZNK3KJS17PreIncResolveNode8streamToERNS_12SourceStreamE -__ZNK3KJS9FalseNode10precedenceEv -__ZN3KJS14InstanceOfNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv -__ZN3KJS8JSObject11hasInstanceEPNS_9ExecStateEPNS_7JSValueE -__ZN3WTF14FastMallocZone9forceLockEP14_malloc_zone_t -__ZN3KJS25CollectorHeapIntrospector9forceLockEP14_malloc_zone_t -__ZN3WTF14FastMallocZone11forceUnlockEP14_malloc_zone_t -__ZN3KJS25CollectorHeapIntrospector11forceUnlockEP14_malloc_zone_t -__ZNK3KJS23FunctionCallBracketNode10precedenceEv -__ZN3KJS14InstanceOfNode8evaluateEPNS_9ExecStateE -__ZNK3KJS9ThrowNode8streamToERNS_12SourceStreamE -__ZNK3KJS7SubNode10precedenceEv -__ZNK3KJS7SubNode8streamToERNS_12SourceStreamE -__ZNK3KJS10NegateNode10precedenceEv -__ZNK3KJS10NegateNode8streamToERNS_12SourceStreamE -__ZNK3KJS12FuncDeclNode8streamToERNS_12SourceStreamE -__ZNK3KJS18PostDecResolveNode8streamToERNS_12SourceStreamE -__ZNK3KJS9BreakNode8streamToERNS_12SourceStreamE -__ZNK3KJS6InNode10precedenceEv -__ZNK3KJS6InNode8streamToERNS_12SourceStreamE -__ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE -__ZN3KJS18PostDecBracketNode8evaluateEPNS_9ExecStateE -__ZN3KJS28dateProtoFuncGetMilliSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS18PostIncResolveNode8streamToERNS_12SourceStreamE -__ZN3KJS13ArrayInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS15AssignErrorNodeD1Ev -__ZN3WTF6VectorIcLm0EE14expandCapacityEmPKc -__ZN3WTF6VectorIcLm0EE14expandCapacityEm -_JSContextGetGlobalObject -_JSClassCreate +__ZN3JSC12JSActivation4markEv +__ZN3JSC9ThrowNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC9ThrowNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC9ThrowNodeD1Ev +__ZNK3JSC21UStringSourceProvider6lengthEv +__ZNK3JSC21UStringSourceProvider4dataEv +__ZN3JSC21UStringSourceProviderD1Ev +__ZN3JSC3JIT26privateCompileGetByIdChainEPNS_17StructureStubInfoEPNS_9StructureEPNS_14StructureChainEmmPvPNS_9ExecStateE +__ZN3JSCL18arrayProtoFuncJoinEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3WTF7HashSetIPN3JSC8JSObjectENS_7PtrHashIS3_EENS_10HashTraitsIS3_EEE3addERKS3_ +__ZN3WTF9HashTableIPN3JSC8JSObjectES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E6rehashEi +__ZN3WTF6VectorItLm256EE14expandCapacityEm +__ZN3WTF9HashTableIPN3JSC8JSObjectES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E4findIS3_NS_22IdentityHashTranslatorIS3_S3_S7_EEEENS_17HashTableIteratorIS3_S3_S5_S7_S9_S9_EERKT_ +__ZN3JSC3JIT28compileFastArith_op_post_decEjj +__ZN3JSC3JIT27compileFastArith_op_pre_decEj +__ZN3JSC3JIT32compileFastArithSlow_op_post_decEjjRPNS_13SlowCaseEntryE +__ZN3JSC3JIT31compileFastArithSlow_op_pre_decEjRPNS_13SlowCaseEntryE +__ZN3JSCL26stringProtoFuncToUpperCaseEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC9Arguments4markEv +__ZN3JSC11Interpreter17cti_timeout_checkEPvz +__ZN3JSCL18stringFromCharCodeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC17ObjectConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL30constructWithObjectConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSC19JSStaticScopeObject4markEv +__ZN3JSC17NumberConstructor18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC21ThrowableBinaryOpNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZNK3JSC6InNode8opcodeIDEv +__ZN3JSC11Interpreter9cti_op_inEPvz +__ZN3JSC11Interpreter21cti_op_put_by_id_failEPvz +__ZN3JSC17RegExpConstructor3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC11Interpreter18cti_op_is_functionEPvz +__ZN3JSC18globalFuncIsFiniteEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL21arrayProtoFuncForEachEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL17arrayProtoFuncMapEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC12StringObject14toThisJSStringEPNS_9ExecStateE +__ZNK3JSC8JSString12toThisObjectEPNS_9ExecStateE +__ZN3JSCL21arrayProtoFuncIndexOfEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC13DeleteDotNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator14emitDeleteByIdEPNS_10RegisterIDES2_RKNS_10IdentifierE +__ZN3JSC13DeleteDotNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11Interpreter16cti_op_del_by_idEPvz +__ZN3JSC10JSFunction14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC10JSFunction12callerGetterEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_16InternalFunctionE +__ZN3JSCL22arrayProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC16ErrorConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL29constructWithErrorConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSC14constructErrorEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSC12JSActivation3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3WTF6VectorIN3JSC14MacroAssembler4JumpELm16EE14expandCapacityEm +__ZN3JSC14InstanceOfNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator14emitInstanceOfEPNS_10RegisterIDES2_S2_S2_ +__ZN3JSC14InstanceOfNodeD1Ev +__ZN3JSC11JSImmediate8toObjectENS_10JSValuePtrEPNS_9ExecStateE +__ZNK3JSC12NumberObject9classInfoEv +__ZN3JSC11Interpreter17cti_op_instanceofEPvz +__ZNK3JSC7UString6substrEii +__ZN3JSCL20arrayProtoFuncSpliceEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC19FunctionConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL32constructWithFunctionConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSC17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi +__ZNK3JSC17ExprStatementNode15isExprStatementEv +__ZNK3JSC12FuncExprNode14isFuncExprNodeEv +__ZN3JSC7ArgList9markListsERN3WTF7HashSetIPS0_NS1_7PtrHashIS3_EENS1_10HashTraitsIS3_EEEE +__ZN3JSC9CommaNodeD1Ev +__ZN3JSC11Interpreter12cti_op_throwEPvz +__ZN3JSC11Interpreter14throwExceptionERPNS_9ExecStateERNS_10JSValuePtrEjb +__ZNK3JSC8JSObject22isNotAnObjectErrorStubEv +__ZN3JSC9CodeBlock32expressionRangeForBytecodeOffsetEPNS_9ExecStateEjRiS3_S3_ +__ZNK3JSC8JSObject19isWatchdogExceptionEv +__ZN3JSC9CodeBlock24handlerForBytecodeOffsetEj +__ZN3JSC11Interpreter15unwindCallFrameERPNS_9ExecStateENS_10JSValuePtrERjRPNS_9CodeBlockE +__ZN3JSCL23returnToThrowTrampolineEPNS_12JSGlobalDataEPvRS2_ +__ZN3JSC19ctiSetReturnAddressEPPvS0_ +ctiVMThrowTrampoline +__ZN3JSC11Interpreter12cti_vm_throwEPvz +__ZN3JSC11Interpreter21cti_op_push_new_scopeEPvz +__ZN3JSC19JSStaticScopeObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC9Arguments3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC4WREC9Generator27generateNonGreedyQuantifierERNS_14MacroAssembler8JumpListERNS0_19GenerateAtomFunctorEjj +__ZN3JSCL21arrayProtoFuncReverseEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC7UString6appendEPKti +__ZN3JSCL26stringProtoFuncLastIndexOfEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC10JSValuePtr20toIntegerPreserveNaNEPNS_9ExecStateE +__Z22jsc_pcre_ucp_othercasej +__ZN3JSCL24regExpConstructorDollar1EPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL24regExpConstructorDollar2EPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL24regExpConstructorDollar3EPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL24regExpConstructorDollar4EPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL19dateProtoFuncGetDayEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC19JSStaticScopeObject14isDynamicScopeEv +__ZN3JSCL35objectProtoFuncPropertyIsEnumerableEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC8JSObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj +__ZN3WTF9HashTableIjSt4pairIjN3JSC10JSValuePtrEENS_18PairFirstExtractorIS4_EENS_7IntHashIjEENS_14PairHashTraitsINS_10HashTraitsIjEENSA_IS3_EEEESB_EC2ERKSE_ +__ZN3JSC11Interpreter14cti_op_pre_decEPvz +__ZN3JSC11Interpreter16cti_op_new_arrayEPvz +__ZN3JSC14constructArrayEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSC10JSFunction11getCallDataERNS_8CallDataE +__ZN3JSC4callEPNS_9ExecStateENS_10JSValuePtrENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE +__ZN3JSC11Interpreter7executeEPNS_16FunctionBodyNodeEPNS_9ExecStateEPNS_10JSFunctionEPNS_8JSObjectERKNS_7ArgListEPNS_14ScopeChainNodeEPNS_10JSValuePtrE +__ZN3JSC9LabelNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC9LabelNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11Interpreter15cti_op_stricteqEPvz +__Z15jsRegExpExecutePK8JSRegExpPKtiiPii +__ZL5matchPKtPKhiR9MatchData +__ZN3JSC18RegExpMatchesArrayC2EPNS_9ExecStateEPNS_24RegExpConstructorPrivateE +__ZN3JSC18RegExpMatchesArray18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC18RegExpMatchesArray17fillArrayInstanceEPNS_9ExecStateE +__ZN3JSC7JSArray18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC12RegExpObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSCL19regExpProtoFuncTestEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC12RegExpObject5matchEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSCL21functionProtoFuncCallEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC8JSString8toObjectEPNS_9ExecStateE +__ZNK3JSC7ArgList8getSliceEiRS0_ +__ZN3JSC17RegExpConstructor18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC23FunctionCallBracketNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC23FunctionCallBracketNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC23FunctionCallBracketNodeD1Ev +__ZN3JSC11Interpreter16cti_op_is_stringEPvz +__ZN3JSC7TryNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17BytecodeGenerator9emitCatchEPNS_10RegisterIDEPNS_5LabelES4_ +__ZN3WTF6VectorIN3JSC11HandlerInfoELm0EE14expandCapacityEm +__ZN3JSC17BytecodeGenerator16emitPushNewScopeEPNS_10RegisterIDERNS_10IdentifierES2_ +__ZN3JSC7TryNode12releaseNodesERNS_12NodeReleaserE +__ZN3WTF6VectorIN3JSC14ExecutablePool10AllocationELm2EE14expandCapacityEm +__ZN3JSC11Interpreter19cti_op_loop_if_lessEPvz +__ZN3JSCL22stringProtoFuncReplaceEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC7UString30spliceSubstringsWithSeparatorsEPKNS0_5RangeEiPKS0_i +__Z15jsc_pcre_xclassiPKh +__ZN3JSC18RegExpMatchesArray3putEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3JSC7JSArray9setLengthEj +__ZN3JSCL21arrayProtoFuncUnShiftEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL19arrayProtoFuncShiftEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC7JSArray14deletePropertyEPNS_9ExecStateEj +__ZN3JSC11Interpreter19cti_op_is_undefinedEPvz +__ZNK3JSC9Arguments9classInfoEv +__ZN3JSC9Arguments11fillArgListEPNS_9ExecStateERNS_7ArgListE +__ZN3JSC11Interpreter23cti_op_create_argumentsEPvz +__ZN3JSC17PropertyNameArray3addEPNS_7UString3RepE +__ZN3WTF7HashSetIPN3JSC7UString3RepENS_7PtrHashIS4_EENS_10HashTraitsIS4_EEE3addERKS4_ +__ZN3WTF9HashTableIPN3JSC7UString3RepES4_NS_17IdentityExtractorIS4_EENS_7PtrHashIS4_EENS_10HashTraitsIS4_EESA_E6expandEv +__ZN3WTF6VectorIN3JSC10IdentifierELm20EE14expandCapacityEm +__ZN3JSC11Interpreter19cti_op_convert_thisEPvz +__ZN3JSC17PrefixBracketNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC17PrefixBracketNodeD1Ev +__ZN3JSC17PrefixBracketNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSCL25functionProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC10JSFunction9classInfoEv +__ZN3JSC7CStringD1Ev +__ZN3JSC6JSLock12DropAllLocksC1Eb +__ZN3JSCL17createJSLockCountEv +__ZN3JSC6JSLock12DropAllLocksD1Ev +__ZN3JSC26createNotAnObjectErrorStubEPNS_9ExecStateEb +__ZN3JSC13JSNotAnObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZNK3JSC22JSNotAnObjectErrorStub22isNotAnObjectErrorStubEv +__ZN3JSC22createNotAnObjectErrorEPNS_9ExecStateEPNS_22JSNotAnObjectErrorStubEjPNS_9CodeBlockE +__ZN3JSC9CodeBlock37getByIdExceptionInfoForBytecodeOffsetEPNS_9ExecStateEjRNS_8OpcodeIDE +__ZN3JSCL18createErrorMessageEPNS_9ExecStateEPNS_9CodeBlockEiiiNS_10JSValuePtrENS_7UStringE +__ZNK3JSC7UString5asciiEv +__ZN3JSC16InternalFunctionC2EPNS_12JSGlobalDataEN3WTF10PassRefPtrINS_9StructureEEERKNS_10IdentifierE +__ZN3WTF13tryFastCallocEmm +__ZN3JSC13JSNotAnObjectD0Ev +__ZN3JSCL31dateProtoFuncToLocaleTimeStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL16formatLocaleDateEPNS_9ExecStateEPNS_12DateInstanceEdNS_20LocaleDateTimeFormatERKNS_7ArgListE +__ZN3JSC16InternalFunction4nameEPNS_12JSGlobalDataE +__ZNK3JSC6JSCell9getStringERNS_7UStringE +__ZN3JSC28globalFuncDecodeURIComponentEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC14ExpressionNode8isStringEv +__ZN3JSC17RegExpConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL21callRegExpConstructorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC23createNotAFunctionErrorEPNS_9ExecStateENS_10JSValuePtrEjPNS_9CodeBlockE +__ZN3JSC11Interpreter17cti_op_jmp_scopesEPvz +__ZN3JSC17BytecodeGenerator18emitJumpSubroutineEPNS_10RegisterIDEPNS_5LabelE +__ZN3WTF6VectorIN3JSC3JIT7JSRInfoELm0EE14expandCapacityEm +__ZN3JSC18RegExpMatchesArray16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE +__ZN3JSC28createUndefinedVariableErrorEPNS_9ExecStateERKNS_10IdentifierEjPNS_9CodeBlockE +__ZN3JSC17DeleteResolveNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSCL21stringProtoFuncSearchEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL27objectProtoFuncDefineGetterEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC8JSObject12defineGetterEPNS_9ExecStateERKNS_10IdentifierEPS0_ +__ZN3JSC9Structure22getterSetterTransitionEPS0_ +__ZN3JSCL27objectProtoFuncLookupGetterEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC8JSObject12lookupGetterEPNS_9ExecStateERKNS_10IdentifierE +__ZNK3JSC6JSCell14isGetterSetterEv +__ZN3JSCL27objectProtoFuncLookupSetterEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC8JSObject12lookupSetterEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC10JSFunction12lengthGetterEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL27objectProtoFuncDefineSetterEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC8JSObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPS0_ +__ZNK3JSC12GetterSetter14isGetterSetterEv +__ZN3JSC12GetterSetter4markEv +__ZN3JSC16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateEj +__ZN3JSC17BytecodeGenerator21emitComplexJumpScopesEPNS_5LabelEPNS_18ControlFlowContextES4_ +__ZN3JSC8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPNS_10JSValuePtrE +__ZN3JSC12PropertySlot14functionGetterEPNS_9ExecStateERKNS_10IdentifierERKS0_ +__ZN3JSC7JSArray4sortEPNS_9ExecStateE +__ZN3JSC7JSArray17compactForSortingEv +__ZN3JSCL24booleanProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC8VoidNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC8VoidNodeD1Ev +__ZN3JSC8VoidNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13JSNotAnObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC12StringObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSCL27compareByStringPairForQSortEPKvS1_ +__ZN3JSC6Parser7reparseINS_8EvalNodeEEEN3WTF10PassRefPtrIT_EEPNS_12JSGlobalDataEPS5_ +__ZN3JSC8EvalNode6createEPNS_12JSGlobalDataEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm0EEEPNS6_INS5_6RefPtrINS_12FuncDeclNodeEEELm0EEERKNS_10SourceCodeEji +__ZN3JSC8EvalNode31bytecodeForExceptionInfoReparseEPNS_14ScopeChainNodeEPNS_9CodeBlockE +__ZN3JSC17NumberConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL30constructWithNumberConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZNK3JSC8JSObject16isVariableObjectEv +__ZN3JSC36constructBooleanFromImmediateBooleanEPNS_9ExecStateENS_10JSValuePtrE +__ZN3JSC13BooleanObjectD0Ev +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEESt4pairIS5_NS2_14OffsetLocationEENS_18PairFirstExtractorIS8_EENS_7StrHashIS5_EENS_14PairHashTraitsINS_10HashTraitsIS5_EENSE_IS7_EEEESF_E4findIPS4_NS_29RefPtrHashMapRawKeyTranslatorISK_S8_SH_SC_EEEENS_17HashTableIteratorIS5_S8_SA_SC_SH_SF_EERKT_ +__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeE +__ZN3JSC14globalFuncEvalEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter7executeEPNS_8EvalNodeEPNS_9ExecStateEPNS_8JSObjectEPNS_14ScopeChainNodeEPNS_10JSValuePtrE +__ZN3JSC11Interpreter19cti_op_put_by_indexEPvz +__ZN3JSCL25numberConstructorMaxValueEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL28numberConstructorPosInfinityEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL28numberConstructorNegInfinityEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL17mathProtoFuncATanEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC18RegExpMatchesArray14deletePropertyEPNS_9ExecStateEj +__ZN3JSC18RegExpMatchesArray3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC7JSArray14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC18EmptyStatementNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSCL17mathProtoFuncASinEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL18mathProtoFuncATan2EPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC16ErrorConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL20callErrorConstructorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL7dateNowEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC18BooleanConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL22callBooleanConstructorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL20arrayProtoFuncFilterEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC4WREC9Generator28generateParenthesesAssertionERNS_14MacroAssembler8JumpListE +__ZN3JSCL21regExpObjectLastIndexEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL18arrayProtoFuncSomeEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC12RegExpObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSCL24setRegExpObjectLastIndexEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrE +__ZN3JSC26createNotAConstructorErrorEPNS_9ExecStateENS_10JSValuePtrEjPNS_9CodeBlockE +__ZN3JSC15isStrWhiteSpaceEt +__ZN3JSCL27dateProtoFuncGetUTCFullYearEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL24dateProtoFuncGetUTCMonthEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL23dateProtoFuncGetUTCDateEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL24dateProtoFuncGetUTCHoursEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL26dateProtoFuncGetUTCMinutesEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL7dateUTCEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL21dateProtoFuncSetHoursEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL23setNewValueFromTimeArgsEPNS_9ExecStateENS_10JSValuePtrERKNS_7ArgListEib +__ZN3JSCL23dateProtoFuncSetMinutesEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL23dateProtoFuncSetSecondsEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL28dateProtoFuncSetMilliSecondsEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC7CStringaSERKS0_ +__ZN3JSCL22dateProtoFuncGetUTCDayEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC7UString8toUInt32EPb +__ZN3JSC12RegExpObject11getCallDataERNS_8CallDataE +__ZNK3JSC8JSObject14isGlobalObjectEv +__ZN3JSC8JSString18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRNS_10JSValuePtrE +__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc +__ZN3JSC16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE +__ZN3JSC17BytecodeGenerator18emitUnexpectedLoadEPNS_10RegisterIDEb +__ZN3WTF6VectorIN3JSC10JSValuePtrELm0EE14expandCapacityEm +__ZN3JSC18BooleanConstructor16getConstructDataERNS_13ConstructDataE +__ZN3JSCL31constructWithBooleanConstructorEPNS_9ExecStateEPNS_8JSObjectERKNS_7ArgListE +__ZN3JSC16constructBooleanEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSCL26stringFromCharCodeSlowCaseEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSCL27dateProtoFuncSetUTCFullYearEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL26dateProtoFuncGetUTCSecondsEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL31dateProtoFuncGetUTCMillisecondsEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL28dateProtoFuncGetMilliSecondsEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZNK3JSC12JSNumberCell9getUInt32ERj +__ZN3JSC13JSNotAnObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSCL23booleanProtoFuncValueOfEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL27dateProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC9Arguments14deletePropertyEPNS_9ExecStateEj +__ZNK3JSC21UStringSourceProvider8getRangeEii +__ZN3JSC22NativeErrorConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL23dateProtoFuncSetUTCDateEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +JSClassCreate __ZN13OpaqueJSClass6createEPK17JSClassDefinition __ZN13OpaqueJSClassC2EPK17JSClassDefinitionPS_ -_JSClassRetain -_JSObjectMake -__ZN13OpaqueJSClass9prototypeEPK15OpaqueJSContext -__ZN3KJS16JSCallbackObjectINS_8JSObjectEE4initEPNS_9ExecStateE -_JSStringCreateWithUTF8CString -_JSObjectSetProperty -_JSStringRelease -__Z30makeGetterOrSetterPropertyNodeRKN3KJS10IdentifierES2_PNS_13ParameterNodeEPNS_16FunctionBodyNodeE -__ZN3KJS8JSObject12defineGetterEPNS_9ExecStateERKNS_10IdentifierEPS0_ -__ZN3KJS8JSObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPS0_ -__ZNK3KJS15GetterSetterImp4typeEv -__ZNK3KJS8JSObject6canPutEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS13ConstDeclNodeC1ERKNS_10IdentifierEPNS_14ExpressionNodeE -__Z26appendToVarDeclarationListRPN3KJS20ParserRefCountedDataIN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEEEPNS_13ConstDeclNodeE -__ZN3KJS18ConstStatementNodeC1EPNS_13ConstDeclNodeE -__ZN3KJS16JSCallbackObjectINS_8JSObjectEE18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE -__ZN3KJS16JSCallbackObjectINS_8JSObjectEE20staticFunctionGetterEPNS_9ExecStateEPS1_RKNS_10IdentifierERKNS_12PropertySlotE -__ZN3KJS18JSCallbackFunctionC1EPNS_9ExecStateEPFPK13OpaqueJSValuePK15OpaqueJSContextPS3_S9_mPKS5_PS5_ERKNS_10IdentifierE -__ZN3KJS18JSCallbackFunction14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -_JSObjectGetPrivate -__ZNK3KJS16JSCallbackObjectINS_8JSObjectEE9classInfoEv -_JSStringCreateWithCharacters -_JSValueMakeString -__ZN3KJS12PropertySlot14functionGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_ -__ZN3WTF10fastCallocEmm -_JSObjectGetProperty -_JSValueToObject -_JSValueProtect -_JSObjectCallAsFunction -_JSValueMakeNumber -_JSValueMakeBoolean -_JSObjectCallAsConstructor -__ZN3KJS15GetterSetterImp4markEv -_JSValueMakeUndefined -_JSValueUnprotect -_JSValueIsNumber -_JSValueToNumber -__ZN3KJS16JSCallbackObjectINS_8JSObjectEED0Ev -__Z25clearReferenceToPrototypeP13OpaqueJSValue -_JSClassRelease -_JSStringIsEqualToUTF8CString -_JSStringIsEqual -__ZN3KJSeqERKNS_7UStringES2_ -__ZN3KJS16JSCallbackObjectINS_8JSObjectEE14callbackGetterEPNS_9ExecStateEPS1_RKNS_10IdentifierERKNS_12PropertySlotE -_JSStringCreateWithCFString -__ZN3KJS7UStringC2EPNS_5UCharEib -__ZN3KJS16JSCallbackObjectINS_8JSObjectEE3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi -_JSObjectSetPrivate -__ZN3KJS15GetterSetterImpD0Ev -__ZN3KJS27objectProtoFuncLookupGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS17PreIncResolveNode10precedenceEv -__ZNK3KJS10SwitchNode8streamToERNS_12SourceStreamE -__ZNK3KJS13CaseBlockNode8streamToERNS_12SourceStreamE -__ZNK3KJS14CaseClauseNode8streamToERNS_12SourceStreamE -__ZN3KJS18ConstStatementNodeD1Ev -__ZN3KJS17PreDecBracketNodeD1Ev -__ZN3KJS11Interpreter24setShouldPrintExceptionsEb -__ZN3KJS9Collector26protectedGlobalObjectCountEv -__ZN3KJS9Collector4sizeEv -__ZN3KJS9Collector17globalObjectCountEv -__ZN3KJS9Collector20protectedObjectCountEv -__ZN3KJS9Collector25protectedObjectTypeCountsEv -__ZNK3KJS15NumberObjectImp9classInfoEv -__ZNK3KJS15RegExpPrototype9classInfoEv -__ZNK3KJS15RegExpObjectImp9classInfoEv -__ZNK3KJS14NativeErrorImp9classInfoEv -__ZNK3KJS13MathObjectImp9classInfoEv -__ZN3WTF6VectorIPN3KJS7JSValueELm8EE14expandCapacityEmPKS3_ -__ZN3WTF6VectorIPN3KJS7JSValueELm8EE14expandCapacityEm -__ZN3KJS15ConditionalNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS9Arguments14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZNK3KJS17DeleteBracketNode8streamToERNS_12SourceStreamE -__ZNK3KJS9BitOrNode10precedenceEv -__ZNK3KJS9BitOrNode8streamToERNS_12SourceStreamE -__ZNK3KJS7ModNode10precedenceEv -__ZNK3KJS7ModNode8streamToERNS_12SourceStreamE -__ZN3KJS31dateProtoFuncToLocaleTimeStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS16formatLocaleDateEPNS_9ExecStateEdbbRKNS_4ListE -__ZN3KJS31dateProtoFuncToLocaleDateStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS9BitOrNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS7DivNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS14BitwiseNotNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS13ActivationImp14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE -__ZN3KJS27objectProtoFuncDefineGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS17PreDecBracketNode8evaluateEPNS_9ExecStateE -__ZNK3KJS16BooleanObjectImp19implementsConstructEv -__ZN3KJS27objectProtoFuncDefineSetterEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPPNS_7JSValueE -__ZN3KJS10StringNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS13UnaryPlusNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS31dateProtoFuncGetUTCMillisecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS17FunctionObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS15DeleteValueNodeD1Ev -__ZN3KJS15RegExpObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS22dateProtoFuncGetUTCDayEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS8MultNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS4Node18setErrorCompletionEPNS_9ExecStateENS_9ErrorTypeEPKc -__ZN3KJS10StringNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS27dateProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS22UnsignedRightShiftNode16evaluateToNumberEPNS_9ExecStateE -__ZNK3KJS18PostIncResolveNode10precedenceEv -__ZNK3KJS21ReadModifyResolveNode10precedenceEv -__ZNK3KJS21FunctionCallValueNode10precedenceEv -__ZN3KJS4Node15handleExceptionEPNS_9ExecStateE -__ZNK3KJS13UnaryPlusNode10precedenceEv -__ZNK3KJS13UnaryPlusNode8streamToERNS_12SourceStreamE -__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcPNS_7JSValueERKNS_10IdentifierE -__ZNK3KJS15DotAccessorNode17isDotAccessorNodeEv -__ZNK3KJS14PostfixDotNode10precedenceEv -__ZN3KJS23regExpProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS14PostDecDotNode8streamToERNS_12SourceStreamE -__ZNK3KJS9CommaNode10precedenceEv -__ZNK3KJS17ReadModifyDotNode10precedenceEv -__ZNK3KJS13DeleteDotNode8streamToERNS_12SourceStreamE -__ZNK3KJS19PlaceholderTrueNode8streamToERNS_12SourceStreamE -__ZNK3KJS17AssignBracketNode10precedenceEv -__ZNK3KJS8WithNode8streamToERNS_12SourceStreamE -__ZNK3KJS17DeleteBracketNode10precedenceEv -__ZN3KJS15ObjectObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -_KJS_JSCreateNativeJSObject -__ZN3KJS8Bindings12JavaJSObject6invokeEPNS0_19JSObjectCallContextE -__ZN3KJS8Bindings12JavaJSObject12createNativeEx -__ZN3KJS8Bindings24findProtectingRootObjectEPNS_8JSObjectE -_KJS_JSObject_JSObjectEval -__ZN3KJS8Bindings12JavaJSObjectC1Ex -__ZNK3KJS8Bindings12JavaJSObject4evalEP8_jstring -__ZN3KJS8Bindings9getJNIEnvEv -__ZN3KJS8Bindings9getJavaVMEv -__ZN3KJS8Bindings30getUCharactersFromJStringInEnvEP7JNIEnv_P8_jstring -__ZN3KJS8Bindings33releaseUCharactersForJStringInEnvEP7JNIEnv_P8_jstringPKt -__ZNK3KJS8Bindings12JavaJSObject21convertValueToJObjectEPNS_7JSValueE -__ZN7JNIEnv_9NewObjectEP7_jclassP10_jmethodIDz -_KJS_JSObject_JSFinalize -__ZN3KJS19stringProtoFuncBoldEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS15RegExpObjectImp15getRightContextEv -__ZNK3KJS15RegExpObjectImp14getLeftContextEv -__ZN3KJS13LeftShiftNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS7ModNode15evaluateToInt32EPNS_9ExecStateE -__ZNK3KJS18PostDecResolveNode10precedenceEv -__ZN3KJS28dateProtoFuncSetMilliSecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS32stringProtoFuncToLocaleLowerCaseEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__NPN_SetException -__ZN3KJS18mathProtoFuncATan2EPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS8Bindings12JavaInstanceC2EP8_jobjectN3WTF10PassRefPtrINS0_10RootObjectEEE -__ZN3KJS8Bindings12JavaInstance5beginEv -__ZNK3KJS8Bindings12JavaInstance8getClassEv -__ZN3KJS8Bindings9JavaClassC2EP8_jobject -__ZN3KJS8Bindings19callJNIObjectMethodEP8_jobjectPKcS4_z -__ZN3KJS8Bindings13callJNIMethodE7JNITypeP8_jobjectPKcS5_Pc -__ZN3KJS8Bindings24getCharactersFromJStringEP8_jstring -__ZN3KJS8Bindings27releaseCharactersForJStringEP8_jstringPKc -__ZN3KJS8Bindings9JavaFieldC2EP7JNIEnv_P8_jobject -__ZN3KJS7CStringaSERKS0_ -__ZN3KJS8Bindings20JNITypeFromClassNameEPKc -__ZN3KJS8Bindings14JObjectWrapperC1EP8_jobject -__ZNK3KJS8Bindings9JavaField4nameEv -__ZN3KJS8Bindings10JavaMethodC2EP7JNIEnv_P8_jobject -__ZN3KJS8Bindings16callJNIIntMethodEP8_jobjectPKcS4_z -__ZN3KJS8Bindings26callJNIStaticBooleanMethodEP7_jclassPKcS4_z -__ZN3KJS8Bindings19callJNIStaticMethodE7JNITypeP7_jclassPKcS5_Pc -__ZNK3KJS8Bindings10JavaMethod4nameEv -__ZN3KJS8Bindings13JavaParameterC2EP7JNIEnv_P8_jstring -__ZNK3KJS8Bindings9JavaClass10fieldNamedERKNS_10IdentifierEPNS0_8InstanceE -__ZNK3KJS8Bindings9JavaClass12methodsNamedERKNS_10IdentifierEPNS0_8InstanceE -__ZN3KJS8Bindings12JavaInstance3endEv -__ZN3KJS8Bindings12JavaInstanceD1Ev -__ZN3KJS8Bindings9JavaClassD1Ev -__ZN3WTF20deleteAllPairSecondsIPN3KJS8Bindings5FieldEKNS_7HashMapINS_6RefPtrINS1_7UString3RepEEES4_NS_7PtrHashIS9_EENS_10HashTraitsIS9_EENSC_IS4_EEEEEEvRT0_ -__ZN3KJS8Bindings14JObjectWrapperD1Ev -__ZN3KJS35objectProtoFuncPropertyIsEnumerableEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS31dateProtoFuncSetUTCMillisecondsEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS12FuncExprNode21needsParensIfLeftmostEv -__ZN3KJS13DateObjectImp14callAsFunctionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS11NewExprNode17evaluateToBooleanEPNS_9ExecStateE -__ZN3KJS29numberProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS25dateProtoFuncToDateStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS9BitOrNode16evaluateToNumberEPNS_9ExecStateE -__ZNK3KJS7JSValue8toUInt32EPNS_9ExecStateE -__ZNK3KJS8JSObject3getEPNS_9ExecStateEj -__ZNK3KJS7JSValue16toUInt32SlowCaseEPNS_9ExecStateERb -__ZN3KJS9Collector29markOtherThreadConservativelyEPNS0_6ThreadE -__ZN3WTF20TCMalloc_ThreadCache18DestroyThreadCacheEPv -__ZN3WTF20TCMalloc_ThreadCache11DeleteCacheEPS0_ -__ZN3KJS23destroyRegisteredThreadEPv -__ZN3KJS28numberProtoFuncToExponentialEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS26numberProtoFuncToPrecisionEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS15RegExpObjectImp16putValuePropertyEPNS_9ExecStateEiPNS_7JSValueEi -__ZNK3KJS15RegExpObjectImp12getLastParenEv -__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeE -__ZN3KJS18arrayProtoFuncSomeEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS9LabelNode9pushLabelERKNS_10IdentifierE -__ZN3KJS9Collector32reportOutOfMemoryToAllExecStatesEv -__ZN3KJS5Error6createEPNS_9ExecStateENS_9ErrorTypeEPKc -__ZNK3KJS17PreDecResolveNode10precedenceEv -__ZN3KJS17mathProtoFuncACosEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS16mathProtoFuncTanEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS16PostfixErrorNode8streamToERNS_12SourceStreamE -__ZNK3KJS15PrefixErrorNode8streamToERNS_12SourceStreamE -__ZNK3KJS15AssignErrorNode8streamToERNS_12SourceStreamE -__ZN3KJS16PostfixErrorNode8evaluateEPNS_9ExecStateE -__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKcS5_ -__ZN3KJS16PostfixErrorNodeD1Ev -__ZNK3KJS13LeftShiftNode8streamToERNS_12SourceStreamE -__ZNK3KJS13LeftShiftNode10precedenceEv -__ZNK3KJS14RightShiftNode8streamToERNS_12SourceStreamE -__ZNK3KJS14RightShiftNode10precedenceEv -__ZNK3KJS22UnsignedRightShiftNode8streamToERNS_12SourceStreamE -__ZNK3KJS22UnsignedRightShiftNode10precedenceEv -__ZNK3KJS10BitAndNode8streamToERNS_12SourceStreamE -__ZNK3KJS10BitAndNode10precedenceEv -__ZNK3KJS10BitXOrNode8streamToERNS_12SourceStreamE -__ZNK3KJS10BitXOrNode10precedenceEv -__ZN3KJS15AssignErrorNode8evaluateEPNS_9ExecStateE -__ZN3KJS4Node10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc -__ZN3KJS13char_sequenceEci -__ZN3KJS15LessStringsNode8evaluateEPNS_9ExecStateE -__ZN3KJS15LessStringsNodeD1Ev -__ZN3KJS15DeleteValueNode8evaluateEPNS_9ExecStateE -__ZN3KJS22regExpProtoFuncCompileEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS15PrefixErrorNode8evaluateEPNS_9ExecStateE -__ZN3KJS28objectProtoFuncIsPrototypeOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS15PrefixErrorNodeD1Ev -__ZN3KJS19arrayProtoFuncEveryEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS29objectProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS25arrayProtoFuncLastIndexOfEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3WTF6VectorItLm0EE6resizeEm -__ZN3WTF6VectorItLm0EE14expandCapacityEm -__ZN3WTF6VectorItLm0EE15reserveCapacityEm -__ZN3KJS28arrayProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS18ConstStatementNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS13ConstDeclNode22optimizeVariableAccessERKN3WTF7HashMapINS1_6RefPtrINS_7UString3RepEEEmNS_17IdentifierRepHashENS_23IdentifierRepHashTraitsENS_26SymbolTableIndexHashTraitsEEERKNS1_6VectorINS_17LocalStorageEntryELm32EEERNSD_IPNS_4NodeELm16EEE -__ZN3KJS18ConstStatementNode7executeEPNS_9ExecStateE -__ZN3KJS13ConstDeclNode8evaluateEPNS_9ExecStateE -__ZN3KJS15AssignConstNode8evaluateEPNS_9ExecStateE -__ZN3KJS16PostIncConstNode8evaluateEPNS_9ExecStateE -__ZN3KJS16PostDecConstNode8evaluateEPNS_9ExecStateE -__ZN3KJS15PreIncConstNode8evaluateEPNS_9ExecStateE -__ZN3KJS15PreDecConstNode8evaluateEPNS_9ExecStateE -__ZN3KJS19ReadModifyConstNode8evaluateEPNS_9ExecStateE -__ZNK3KJS13ActivationImp9classInfoEv -__ZN3KJS16PostIncConstNodeD1Ev -__ZN3KJS15PreIncConstNodeD1Ev -__ZN3KJS15PreDecConstNodeD1Ev -__ZNK3KJS13DeleteDotNode10precedenceEv -__ZN3KJS28stringProtoFuncLocaleCompareEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZN3KJS10NumberNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS19FunctionCallDotNode16evaluateToUInt32EPNS_9ExecStateE -__ZNK3KJS21ReadModifyBracketNode8streamToERNS_12SourceStreamE -__ZN3KJS10BitXOrNode16evaluateToNumberEPNS_9ExecStateE -___tcf_1 -__ZNK3KJS7UString6is8BitEv -__ZN3KJS15DotAccessorNode16evaluateToUInt32EPNS_9ExecStateE -__ZN3KJS24stringProtoFuncFontcolorEPNS_9ExecStateEPNS_8JSObjectERKNS_4ListE -__ZNK3KJS14NativeErrorImp19implementsConstructEv -__ZN3KJS19PostDecLocalVarNode16evaluateToNumberEPNS_9ExecStateE -__ZN3KJS19PostDecLocalVarNode15evaluateToInt32EPNS_9ExecStateE -__ZN3KJS13UnaryPlusNode17evaluateToBooleanEPNS_9ExecStateE +__ZN3JSC7UString3Rep14createFromUTF8EPKc +__ZN3WTF7Unicode18convertUTF8ToUTF16EPPKcS2_PPtS4_b +__ZN3WTF7HashMapINS_6RefPtrIN3JSC7UString3RepEEEP19StaticFunctionEntryNS_7StrHashIS5_EENS_10HashTraitsIS5_EENSA_IS7_EEE3addERKS5_RKS7_ +__ZN3WTF9HashTableINS_6RefPtrIN3JSC7UString3RepEEESt4pairIS5_P19StaticFunctionEntryENS_18PairFirstExtractorIS9_EENS_7StrHashIS5_EENS_14PairHashTraitsINS_10HashTraitsIS5_EENSF_IS8_EEEESG_E6expandEv +JSClassRetain +JSObjectMake +__ZN3JSC4Heap14registerThreadEv +__ZN3JSC6JSLockC1EPNS_9ExecStateE +__ZN3JSC16JSCallbackObjectINS_8JSObjectEE4initEPNS_9ExecStateE +__ZN13OpaqueJSClass9prototypeEPN3JSC9ExecStateE +__ZN13OpaqueJSClass11contextDataEPN3JSC9ExecStateE +__ZN3WTF9HashTableIP13OpaqueJSClassSt4pairIS2_P24OpaqueJSClassContextDataENS_18PairFirstExtractorIS6_EENS_7PtrHashIS2_EENS_14PairHashTraitsINS_10HashTraitsIS2_EENSC_IS5_EEEESD_E6expandEv +__ZN24OpaqueJSClassContextDataC2EP13OpaqueJSClass +JSStringCreateWithCFString +JSObjectSetProperty +__ZNK14OpaqueJSString10identifierEPN3JSC12JSGlobalDataE +JSStringRelease +__ZL30makeGetterOrSetterPropertyNodePvRKN3JSC10IdentifierES3_PNS0_13ParameterNodeEPNS0_16FunctionBodyNodeERKNS0_10SourceCodeE +__ZN3JSC18ConstStatementNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC13ConstDeclNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC13ConstDeclNode14emitCodeSingleERNS_17BytecodeGeneratorE +__ZN3JSC17BytecodeGenerator13emitPutGetterEPNS_10RegisterIDERKNS_10IdentifierES2_ +__ZN3JSC17BytecodeGenerator13emitPutSetterEPNS_10RegisterIDERKNS_10IdentifierES2_ +__ZN3JSC18ConstStatementNodeD1Ev +__ZN3JSC18ConstStatementNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC13ConstDeclNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC11Interpreter17cti_op_put_getterEPvz +__ZN3JSC11Interpreter17cti_op_put_setterEPvz +__ZN3JSC16JSCallbackObjectINS_8JSObjectEE18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC7UString3Rep13createCopyingEPKti +__ZN3JSC16JSCallbackObjectINS_8JSObjectEE20staticFunctionGetterEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSC18JSCallbackFunctionC1EPNS_9ExecStateEPFPK13OpaqueJSValuePK15OpaqueJSContextPS3_S9_mPKS5_PS5_ERKNS_10IdentifierE +__ZN3JSC18JSCallbackFunction11getCallDataERNS_8CallDataE +__ZN3JSC18JSCallbackFunction4callEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC6JSLock12DropAllLocksC1EPNS_9ExecStateE +JSValueIsObjectOfClass +__ZN3JSC6JSCell9getObjectEv +__ZNK3JSC16JSCallbackObjectINS_8JSObjectEE9classInfoEv +JSObjectGetPrivate +JSValueMakeString +__ZNK14OpaqueJSString7ustringEv +JSValueMakeBoolean +JSContextGetGlobalObject +JSStringCreateWithUTF8CString +JSObjectGetProperty +JSValueToObject +JSObjectIsFunction +JSObjectCallAsFunction +JSValueMakeUndefined +__ZN3JSC18JSCallbackFunctionD0Ev +__ZN3JSC16JSCallbackObjectINS_8JSObjectEED0Ev +__ZL25clearReferenceToPrototypeP13OpaqueJSValue +JSClassRelease +__ZN3JSC15AssignErrorNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC23ThrowableExpressionData14emitThrowErrorERNS_17BytecodeGeneratorENS_9ErrorTypeEPKc +__ZN3JSC17BytecodeGenerator12emitNewErrorEPNS_10RegisterIDENS_9ErrorTypeENS_10JSValuePtrE +__ZN3JSC15AssignErrorNodeD1Ev +__ZN3JSC15AssignErrorNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC12StringObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSC12StringObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE +__ZN3JSC9ExecState11stringTableEPS0_ +__ZN3JSCL24dateProtoFuncSetUTCHoursEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN14OpaqueJSString6createERKN3JSC7UStringE +JSStringIsEqualToUTF8CString +__ZN3JSC16JSCallbackObjectINS_8JSObjectEE14callbackGetterEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +JSValueToStringCopy +JSStringCopyCFString +JSValueMakeNumber +__ZN3JSC16JSCallbackObjectINS_8JSObjectEE3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +JSValueToNumber +JSObjectSetPrivate +__ZN3JSC8Profiler8profilerEv +__ZN3JSC8Profiler13stopProfilingEPNS_9ExecStateERKNS_7UStringE +__ZN3JSC8JSObject15unwrappedObjectEv +JSStringCreateWithCharacters +__ZN3JSC9Structure18startIgnoringLeaksEv +__ZN3JSC9Structure17stopIgnoringLeaksEv +JSValueProtect +JSObjectCallAsConstructor +__ZN3JSC10JSFunction16getConstructDataERNS_13ConstructDataE +__ZN3JSC9constructEPNS_9ExecStateENS_10JSValuePtrENS_13ConstructTypeERKNS_13ConstructDataERKNS_7ArgListE +__ZN3JSC10JSFunction9constructEPNS_9ExecStateERKNS_7ArgListE +__ZN3JSCL28stringProtoFuncLocaleCompareEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3WTF8Collator11userDefaultEv +__ZNK3WTF8Collator7collateEPKtmS2_m +__ZNK3WTF8Collator14createCollatorEv +__ZN3WTF8CollatorD1Ev +__ZN3WTF8Collator15releaseCollatorEv +__ZNK3JSC22NativeErrorConstructor9classInfoEv +JSValueUnprotect +JSValueIsNumber +__ZN3JSC8Debugger6attachEPNS_14JSGlobalObjectE +__ZN3WTF7HashSetIPN3JSC14JSGlobalObjectENS_7PtrHashIS3_EENS_10HashTraitsIS3_EEE3addERKS3_ +__ZN3WTF9HashTableIPN3JSC14JSGlobalObjectES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E6rehashEi +__ZN3JSC4Heap14primaryHeapEndEv +__ZN3JSC4Heap16primaryHeapBeginEv +__ZNK3JSC15RegExpPrototype9classInfoEv +__ZNK3JSC17NumberConstructor9classInfoEv +__ZNK3JSC17RegExpConstructor9classInfoEv +__ZNK3JSC10MathObject9classInfoEv +__ZNK3JSC18JSCallbackFunction9classInfoEv +JSValueIsString +JSStringGetLength +JSStringGetCharactersPtr +__ZN3JSC11Interpreter12cti_op_debugEPvz +__ZN3JSC11Interpreter5debugEPNS_9ExecStateENS_11DebugHookIDEii +__ZNK3JSC17DebuggerCallFrame4typeEv +__ZNK3JSC17DebuggerCallFrame12functionNameEv +__ZNK3JSC17DebuggerCallFrame10thisObjectEv +__ZN3WTF28setMainThreadCallbacksPausedEb +__ZN3JSC8Debugger6detachEPNS_14JSGlobalObjectE +__ZN3WTF9HashTableIPN3JSC14JSGlobalObjectES3_NS_17IdentityExtractorIS3_EENS_7PtrHashIS3_EENS_10HashTraitsIS3_EES9_E4findIS3_NS_22IdentityHashTranslatorIS3_S3_S7_EEEENS_17HashTableIteratorIS3_S3_S5_S7_S9_S9_EERKT_ +__ZN3WTF6VectorIN3JSC20FunctionRegisterInfoELm0EE14expandCapacityEm +__ZN3JSC8Profiler14startProfilingEPNS_9ExecStateERKNS_7UStringE +__ZN3JSC16ProfileGenerator6createERKNS_7UStringEPNS_9ExecStateEj +__ZN3JSC16ProfileGeneratorC2ERKNS_7UStringEPNS_9ExecStateEj +__ZN3JSC7Profile6createERKNS_7UStringEj +__ZN3JSC11TreeProfile6createERKNS_7UStringEj +__ZN3JSC7ProfileC2ERKNS_7UStringEj +__ZN3JSC11ProfileNodeC1ERKNS_14CallIdentifierEPS0_S4_ +__ZN3JSC33getCurrentUTCTimeWithMicrosecondsEv +__ZN3JSC16ProfileGenerator24addParentForConsoleStartEPNS_9ExecStateE +__ZN3JSC8Profiler20createCallIdentifierEPNS_12JSGlobalDataENS_10JSValuePtrERKNS_7UStringEi +__ZN3JSC11ProfileNode10insertNodeEN3WTF10PassRefPtrIS0_EE +__ZN3WTF6VectorINS_6RefPtrIN3JSC16ProfileGeneratorEEELm0EE14expandCapacityEm +__ZN3WTF10RefCountedIN3JSC16ProfileGeneratorEE5derefEv +__ZN3JSC8Profiler11willExecuteEPNS_9ExecStateENS_10JSValuePtrE +__ZN3JSC8Profiler10didExecuteEPNS_9ExecStateENS_10JSValuePtrE +__ZN3JSC16ProfileGenerator11willExecuteERKNS_14CallIdentifierE +__ZN3JSC11ProfileNode11willExecuteERKNS_14CallIdentifierE +__ZN3JSC11Interpreter24cti_op_profile_will_callEPvz +__ZN3JSC11Interpreter23cti_op_profile_did_callEPvz +__ZN3JSC16ProfileGenerator10didExecuteERKNS_14CallIdentifierE +__ZN3JSC11ProfileNode10didExecuteEv +__ZN3JSCL28numberProtoFuncToExponentialEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL26numberProtoFuncToPrecisionEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter16cti_op_new_errorEPvz +__ZN3JSC19JSStaticScopeObject3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC4WREC14CharacterClass11nonwordcharEv +__ZN3JSC19FunctionConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL23callFunctionConstructorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC17ObjectConstructor11getCallDataERNS_8CallDataE +__ZN3JSCL21callObjectConstructorEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC12JSActivation14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE +__ZN3JSCL26dateProtoFuncSetUTCMinutesEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL26dateProtoFuncSetUTCSecondsEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC15PrefixErrorNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC15PrefixErrorNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC15PrefixErrorNodeD1Ev +__ZN3JSCL19stringProtoFuncBoldEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3WTF6VectorIPNS0_IN3JSC10RegisterIDELm512EEELm32EE15reserveCapacityEm +__ZN3JSC12StringObjectC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEERKNS_7UStringE +__ZN3JSCL24regExpConstructorDollar5EPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE +__ZN3JSC6JSCell3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +JSValueIsEqual +__ZN3JSC10JSValuePtr13equalSlowCaseEPNS_9ExecStateES0_S0_ +__ZN3JSCL16mathProtoFuncTanEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC11Interpreter15cti_op_post_decEPvz +__ZN3JSCL28regExpConstructorLeftContextEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL31dateProtoFuncToLocaleDateStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC21DebuggerStatementNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC21DebuggerStatementNodeD1Ev +__ZN3JSCL12charSequenceEci +__ZN3JSCL17mathProtoFuncACosEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC4Heap24setGCProtectNeedsLockingEv +__ZNK3JSC7UString6is8BitEv +__ZN3WTF9ByteArray6createEm +__ZN3JSC11JSByteArrayC1EPNS_9ExecStateEN3WTF10PassRefPtrINS_9StructureEEEPNS3_9ByteArrayEPKNS_9ClassInfoE +__ZN3JSC11JSByteArray18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE +__ZN3JSC11Interpreter28cti_op_get_by_val_byte_arrayEPvz +__ZN3JSC11JSByteArray3putEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3JSC11JSByteArray3putEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrERNS_15PutPropertySlotE +__ZN3JSC11JSByteArray18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE +__ZN3JSC11Interpreter28cti_op_put_by_val_byte_arrayEPvz +__ZN3JSCL28objectProtoFuncIsPrototypeOfEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC14JSGlobalObject12defineGetterEPNS_9ExecStateERKNS_10IdentifierEPNS_8JSObjectE +__ZN3JSC14JSGlobalObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPNS_8JSObjectE +__ZN3JSC6JSCell16getConstructDataERNS_13ConstructDataE +__ZN3JSCL25numberConstructorNaNValueEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL23throwStackOverflowErrorEPNS_9ExecStateEPNS_12JSGlobalDataEPvRS4_ +__ZN3JSCL24regExpConstructorDollar6EPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL24regExpConstructorDollar7EPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSC9ExecState9mathTableEPS0_ +__ZN3JSC9ExecState22regExpConstructorTableEPS0_ +__ZN3JSCL24regExpConstructorDollar8EPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL24regExpConstructorDollar9EPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL22regExpConstructorInputEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL25setRegExpConstructorInputEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrE +__ZN3JSCL26regExpConstructorLastMatchEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL26regExpConstructorLastParenEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL26regExpConstructorMultilineEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL29setRegExpConstructorMultilineEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrE +__ZN3JSCL29regExpConstructorRightContextEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSC16PostfixErrorNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC16PostfixErrorNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC16PostfixErrorNodeD1Ev +__ZN3JSC6JSCell11getJSNumberEv +__ZN3JSC14JSGlobalObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_10JSValuePtrEj +__ZN3JSCL25arrayProtoFuncLastIndexOfEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL25numberConstructorMinValueEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSCL22regExpProtoFuncCompileEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL19arrayProtoFuncEveryEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL29objectProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC6JSCell14toThisJSStringEPNS_9ExecStateE +__ZNK3JSC6JSCell12toThisStringEPNS_9ExecStateE +__ZN3JSCL31dateProtoFuncSetUTCMillisecondsEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL24dateProtoFuncSetUTCMonthEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL28arrayProtoFuncToLocaleStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC12JSActivation18getArgumentsGetterEv +__ZN3JSC12JSActivation15argumentsGetterEPNS_9ExecStateERKNS_10IdentifierERKNS_12PropertySlotE +__ZN3JSC9ExecState9dateTableEPS0_ +__ZN3JSC23createInvalidParamErrorEPNS_9ExecStateEPKcNS_10JSValuePtrEjPNS_9CodeBlockE +__ZNK3JSC15DotAccessorNode17isDotAccessorNodeEv +__ZNK3JSC14ExpressionNode17isDotAccessorNodeEv +__ZN3JSC13JSNotAnObject3putEPNS_9ExecStateEjNS_10JSValuePtrE +__ZN3JSC15DeleteValueNode12emitBytecodeERNS_17BytecodeGeneratorEPNS_10RegisterIDE +__ZN3JSC15DeleteValueNodeD1Ev +__ZN3JSC15DeleteValueNode12releaseNodesERNS_12NodeReleaserE +__ZN3JSC17BytecodeGenerator18emitUnexpectedLoadEPNS_10RegisterIDEd +__ZN3JSC4WREC14CharacterClass9nondigitsEv +__ZNK3JSC19JSStaticScopeObject12toThisObjectEPNS_9ExecStateE +__ZNK3JSC16JSVariableObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj +__ZN3JSCL25dateProtoFuncToDateStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSCL25dateProtoFuncToTimeStringEPNS_9ExecStateEPNS_8JSObjectENS_10JSValuePtrERKNS_7ArgListE +__ZN3JSC17BytecodeGenerator35emitThrowExpressionTooDeepExceptionEv +__ZN3JSC12JSGlobalData6createEv +__ZN3WTF12isMainThreadEv +__ZN3JSC4Heap7destroyEv +__ZN3JSC12JSGlobalDataD1Ev +__ZN3JSC11InterpreterD1Ev +__ZN3JSC12RegisterFileD1Ev +__ZNK3JSC9HashTable11deleteTableEv +__ZN3JSC5LexerD1Ev +__ZN3WTF20deleteAllPairSecondsIP24OpaqueJSClassContextDataKNS_7HashMapIP13OpaqueJSClassS2_NS_7PtrHashIS5_EENS_10HashTraitsIS5_EENS8_IS2_EEEEEEvRT0_ +__ZN3JSC17CommonIdentifiersD2Ev +__ZN3JSC21deleteIdentifierTableEPNS_15IdentifierTableE +__ZN3JSC4HeapD1Ev +__ZN3JSC12SmallStringsD1Ev +__ZN3JSC12JSGlobalData10ClientDataD2Ev +__ZN3WTF8CollatorC1EPKc +__ZN3WTF8Collator18setOrderLowerFirstEb +__ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE +__ZNK3JSC25InterruptedExecutionError19isWatchdogExceptionEv diff --git a/JavaScriptCore.pri b/JavaScriptCore.pri index d7cbc6a..6aee0aa 100644 --- a/JavaScriptCore.pri +++ b/JavaScriptCore.pri @@ -2,52 +2,58 @@ VPATH += $$PWD INCLUDEPATH += tmp -INCLUDEPATH += $$PWD $$PWD/kjs $$PWD/bindings $$PWD/bindings/c $$PWD/wtf -DEPENDPATH += $$PWD $$PWD/kjs $$PWD/bindings $$PWD/bindings/c $$PWD/wtf -DEFINES -= KJS_IDENTIFIER_HIDE_GLOBALS -qt-port:INCLUDEPATH += $$PWD/bindings/qt -qt-port:DEFINES += BUILDING_QT__ -gtk-port:DEFINES += BUILDING_GTK__ - -# http://bugs.webkit.org/show_bug.cgi?id=16406 -# [Gtk] JavaScriptCore needs -lpthread -gtk-port:!win32-*:LIBS += -lpthread - -win32-msvc*: INCLUDEPATH += $$PWD/os-win32 +INCLUDEPATH += $$PWD $$PWD/parser $$PWD/bytecompiler $$PWD/debugger $$PWD/runtime $$PWD/wtf $$PWD/wtf/unicode $$PWD/interpreter $$PWD/jit $$PWD/profiler $$PWD/wrec $$PWD/API $$PWD/.. \ + $$PWD/ForwardingHeaders $$PWD/bytecode $$PWD/assembler +DEFINES += BUILDING_QT__ isEmpty(GENERATED_SOURCES_DIR):GENERATED_SOURCES_DIR = tmp +GENERATED_SOURCES_DIR_SLASH = $$GENERATED_SOURCES_DIR/ +win32-* { + GENERATED_SOURCES_DIR_SLASH ~= s|/|\| + LIBS += -lwinmm +} + +# Disable the JIT due to numerous observed miscompilations :( +#CONFIG(release):isEqual(QT_ARCH,i386) { +# JIT_DEFINES = ENABLE_JIT ENABLE_WREC ENABLE_JIT_OPTIMIZE_CALL ENABLE_JIT_OPTIMIZE_PROPERTY_ACCESS ENABLE_JIT_OPTIMIZE_ARITHMETIC +# # gcc <= 4.1 is known to miscompile, so require >= 4.2, written as major > 3 and minor > 1 +# linux-g++*:greaterThan(QT_GCC_MAJOR_VERSION,3):greaterThan(QT_GCC_MINOR_VERSION,1) { +# DEFINES += $$JIT_DEFINES +# SOURCES += wtf/TCSystemAlloc.cpp +# DEFINES -= USE_SYSTEM_MALLOC +# } +# win32-msvc* { +# DEFINES += $$JIT_DEFINES +# } +#} include(pcre/pcre.pri) LUT_FILES += \ - kjs/date_object.cpp \ - kjs/number_object.cpp \ - kjs/string_object.cpp \ - kjs/array_object.cpp \ - kjs/math_object.cpp \ - kjs/regexp_object.cpp + runtime/DatePrototype.cpp \ + runtime/NumberConstructor.cpp \ + runtime/StringPrototype.cpp \ + runtime/ArrayPrototype.cpp \ + runtime/MathObject.cpp \ + runtime/RegExpConstructor.cpp \ + runtime/RegExpObject.cpp KEYWORDLUT_FILES += \ - kjs/keywords.table + parser/Keywords.table -KJSBISON += \ - kjs/grammar.y +JSCBISON += \ + parser/Grammar.y SOURCES += \ wtf/Assertions.cpp \ + wtf/ByteArray.cpp \ wtf/HashTable.cpp \ + wtf/MainThread.cpp \ + wtf/RandomNumber.cpp \ + wtf/RefCountedLeakCounter.cpp \ + wtf/unicode/CollatorDefault.cpp \ + wtf/unicode/icu/CollatorICU.cpp \ wtf/unicode/UTF8.cpp \ - bindings/NP_jsobject.cpp \ - bindings/npruntime.cpp \ - bindings/runtime_array.cpp \ - bindings/runtime.cpp \ - bindings/runtime_method.cpp \ - bindings/runtime_object.cpp \ - bindings/runtime_root.cpp \ - bindings/c/c_class.cpp \ - bindings/c/c_instance.cpp \ - bindings/c/c_runtime.cpp \ - bindings/c/c_utility.cpp \ API/JSBase.cpp \ API/JSCallbackConstructor.cpp \ API/JSCallbackFunction.cpp \ @@ -57,99 +63,148 @@ SOURCES += \ API/JSObjectRef.cpp \ API/JSStringRef.cpp \ API/JSValueRef.cpp \ - kjs/JSGlobalObject.cpp \ - kjs/JSVariableObject.cpp + API/OpaqueJSString.cpp \ + runtime/InitializeThreading.cpp \ + runtime/JSGlobalData.cpp \ + runtime/JSGlobalObject.cpp \ + runtime/JSStaticScopeObject.cpp \ + runtime/JSVariableObject.cpp \ + runtime/JSActivation.cpp \ + runtime/JSNotAnObject.cpp \ + bytecode/CodeBlock.cpp \ + bytecode/StructureStubInfo.cpp \ + bytecode/JumpTable.cpp \ + jit/JIT.cpp \ + jit/JITCall.cpp \ + jit/JITArithmetic.cpp \ + jit/JITPropertyAccess.cpp \ + jit/ExecutableAllocator.cpp \ + bytecompiler/BytecodeGenerator.cpp \ + runtime/ExceptionHelpers.cpp \ + runtime/JSPropertyNameIterator.cpp \ + interpreter/Interpreter.cpp \ + bytecode/Opcode.cpp \ + bytecode/SamplingTool.cpp \ + wrec/CharacterClass.cpp \ + wrec/CharacterClassConstructor.cpp \ + wrec/WREC.cpp \ + wrec/WRECFunctors.cpp \ + wrec/WRECGenerator.cpp \ + wrec/WRECParser.cpp \ + interpreter/RegisterFile.cpp + +win32-*: SOURCES += jit/ExecutableAllocatorWin.cpp +else: SOURCES += jit/ExecutableAllocatorPosix.cpp # AllInOneFile.cpp helps gcc analize and optimize code # Other compilers may be able to do this at link time -gtk-port:CONFIG(release) { -SOURCES += \ - kjs/AllInOneFile.cpp -} else { SOURCES += \ - kjs/function.cpp \ - kjs/debugger.cpp \ - kjs/array_instance.cpp \ - kjs/array_object.cpp \ - kjs/bool_object.cpp \ - kjs/collector.cpp \ - kjs/CommonIdentifiers.cpp \ - kjs/date_object.cpp \ - kjs/DateMath.cpp \ - kjs/dtoa.cpp \ - kjs/error_object.cpp \ - kjs/ExecState.cpp \ - kjs/function_object.cpp \ - kjs/identifier.cpp \ - kjs/internal.cpp \ - kjs/interpreter.cpp \ - kjs/JSImmediate.cpp \ - kjs/JSLock.cpp \ - kjs/JSWrapperObject.cpp \ - kjs/lexer.cpp \ - kjs/list.cpp \ - kjs/lookup.cpp \ - kjs/math_object.cpp \ - kjs/nodes.cpp \ - kjs/nodes2string.cpp \ - kjs/number_object.cpp \ - kjs/object.cpp \ - kjs/object_object.cpp \ - kjs/operations.cpp \ - kjs/Parser.cpp \ - kjs/property_map.cpp \ - kjs/property_slot.cpp \ - kjs/PropertyNameArray.cpp \ - kjs/regexp.cpp \ - kjs/regexp_object.cpp \ - kjs/scope_chain.cpp \ - kjs/string_object.cpp \ - kjs/ustring.cpp \ - kjs/value.cpp \ - wtf/FastMalloc.cpp - -!qt-port:SOURCES += \ - wtf/TCSystemAlloc.cpp -} - -qt-port:SOURCES += \ - bindings/qt/qt_class.cpp \ - bindings/qt/qt_instance.cpp \ - bindings/qt/qt_runtime.cpp - -!CONFIG(QTDIR_build) { - defineTest(addExtraCompiler) { - QMAKE_EXTRA_COMPILERS += $$1 - generated_files.depends += compiler_$${1}_make_all - export(QMAKE_EXTRA_COMPILERS) - export(generated_files.depends) - return(true) - } -} + runtime/ArgList.cpp \ + runtime/Arguments.cpp \ + runtime/ArrayConstructor.cpp \ + runtime/ArrayPrototype.cpp \ + runtime/BooleanConstructor.cpp \ + runtime/BooleanObject.cpp \ + runtime/BooleanPrototype.cpp \ + runtime/CallData.cpp \ + runtime/Collector.cpp \ + runtime/CommonIdentifiers.cpp \ + runtime/ConstructData.cpp \ + wtf/CurrentTime.cpp \ + runtime/DateConstructor.cpp \ + runtime/DateInstance.cpp \ + runtime/DateMath.cpp \ + runtime/DatePrototype.cpp \ + debugger/Debugger.cpp \ + debugger/DebuggerCallFrame.cpp \ + debugger/DebuggerActivation.cpp \ + wtf/dtoa.cpp \ + runtime/Error.cpp \ + runtime/ErrorConstructor.cpp \ + runtime/ErrorInstance.cpp \ + runtime/ErrorPrototype.cpp \ + interpreter/CallFrame.cpp \ + runtime/FunctionConstructor.cpp \ + runtime/FunctionPrototype.cpp \ + runtime/GetterSetter.cpp \ + runtime/GlobalEvalFunction.cpp \ + runtime/Identifier.cpp \ + runtime/InternalFunction.cpp \ + runtime/Completion.cpp \ + runtime/JSArray.cpp \ + runtime/JSByteArray.cpp \ + runtime/JSCell.cpp \ + runtime/JSFunction.cpp \ + runtime/JSGlobalObjectFunctions.cpp \ + runtime/JSImmediate.cpp \ + runtime/JSLock.cpp \ + runtime/JSNumberCell.cpp \ + runtime/JSObject.cpp \ + runtime/JSString.cpp \ + runtime/JSValue.cpp \ + runtime/JSWrapperObject.cpp \ + parser/Lexer.cpp \ + runtime/Lookup.cpp \ + runtime/MathObject.cpp \ + runtime/NativeErrorConstructor.cpp \ + runtime/NativeErrorPrototype.cpp \ + parser/Nodes.cpp \ + runtime/NumberConstructor.cpp \ + runtime/NumberObject.cpp \ + runtime/NumberPrototype.cpp \ + runtime/ObjectConstructor.cpp \ + runtime/ObjectPrototype.cpp \ + runtime/Operations.cpp \ + parser/Parser.cpp \ + runtime/PropertyNameArray.cpp \ + runtime/PropertySlot.cpp \ + runtime/PrototypeFunction.cpp \ + runtime/RegExp.cpp \ + runtime/RegExpConstructor.cpp \ + runtime/RegExpObject.cpp \ + runtime/RegExpPrototype.cpp \ + runtime/ScopeChain.cpp \ + runtime/SmallStrings.cpp \ + runtime/StringConstructor.cpp \ + runtime/StringObject.cpp \ + runtime/StringPrototype.cpp \ + runtime/Structure.cpp \ + runtime/StructureChain.cpp \ + runtime/UString.cpp \ + profiler/HeavyProfile.cpp \ + profiler/Profile.cpp \ + profiler/ProfileGenerator.cpp \ + profiler/ProfileNode.cpp \ + profiler/Profiler.cpp \ + profiler/TreeProfile.cpp \ + wtf/FastMalloc.cpp \ + wtf/Threading.cpp \ + wtf/ThreadingQt.cpp \ + wtf/qt/MainThreadQt.cpp # GENERATOR 1-A: LUT creator lut.output = $$GENERATED_SOURCES_DIR/${QMAKE_FILE_BASE}.lut.h -lut.commands = perl $$PWD/kjs/create_hash_table ${QMAKE_FILE_NAME} -i > ${QMAKE_FILE_OUT} +lut.commands = perl $$PWD/create_hash_table ${QMAKE_FILE_NAME} -i > ${QMAKE_FILE_OUT} lut.depend = ${QMAKE_FILE_NAME} lut.input = LUT_FILES lut.CONFIG += no_link addExtraCompiler(lut) # GENERATOR 1-B: particular LUT creator (for 1 file only) -keywordlut.output = $$GENERATED_SOURCES_DIR/lexer.lut.h -keywordlut.commands = perl $$PWD/kjs/create_hash_table ${QMAKE_FILE_NAME} -i > ${QMAKE_FILE_OUT} +keywordlut.output = $$GENERATED_SOURCES_DIR/Lexer.lut.h +keywordlut.commands = perl $$PWD/create_hash_table ${QMAKE_FILE_NAME} -i > ${QMAKE_FILE_OUT} keywordlut.depend = ${QMAKE_FILE_NAME} keywordlut.input = KEYWORDLUT_FILES keywordlut.CONFIG += no_link addExtraCompiler(keywordlut) # GENERATOR 2: bison grammar -kjsbison.output = $$GENERATED_SOURCES_DIR/${QMAKE_FILE_BASE}.cpp -kjsbison.commands = bison -d -p kjsyy ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_BASE}.tab.c && $(MOVE) ${QMAKE_FILE_BASE}.tab.c ${QMAKE_FILE_OUT} && $(MOVE) ${QMAKE_FILE_BASE}.tab.h $$GENERATED_SOURCES_DIR/${QMAKE_FILE_BASE}.h -kjsbison.depend = ${QMAKE_FILE_NAME} -kjsbison.input = KJSBISON -kjsbison.variable_out = GENERATED_SOURCES -kjsbison.dependency_type = TYPE_C -kjsbison.CONFIG = target_predeps -kjsbison.clean = ${QMAKE_FILE_OUT} ${QMAKE_VAR_GENERATED_SOURCES_DIR}${QMAKE_FILE_BASE}.h -addExtraCompiler(kjsbison) +jscbison.output = $$GENERATED_SOURCES_DIR/${QMAKE_FILE_BASE}.cpp +jscbison.commands = bison -d -p jscyy ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_BASE}.tab.c && $(MOVE) ${QMAKE_FILE_BASE}.tab.c ${QMAKE_FILE_OUT} && $(MOVE) ${QMAKE_FILE_BASE}.tab.h $$GENERATED_SOURCES_DIR/${QMAKE_FILE_BASE}.h +jscbison.depend = ${QMAKE_FILE_NAME} +jscbison.input = JSCBISON +jscbison.variable_out = GENERATED_SOURCES +jscbison.dependency_type = TYPE_C +jscbison.CONFIG = target_predeps +addExtraCompilerWithHeader(jscbison) + diff --git a/JavaScriptCore.pro b/JavaScriptCore.pro new file mode 100644 index 0000000..56dae05 --- /dev/null +++ b/JavaScriptCore.pro @@ -0,0 +1,72 @@ +# JavaScriptCore - qmake build info +CONFIG += building-libs +include($$PWD/../WebKit.pri) + +TEMPLATE = lib +CONFIG += staticlib +TARGET = JavaScriptCore + +CONFIG += depend_includepath + +contains(QT_CONFIG, embedded):CONFIG += embedded + +CONFIG(QTDIR_build) { + GENERATED_SOURCES_DIR = $$PWD/generated + OLDDESTDIR = $$DESTDIR + include($$QT_SOURCE_TREE/src/qbase.pri) + INSTALLS = + DESTDIR = $$OLDDESTDIR + PRECOMPILED_HEADER = $$PWD/../WebKit/qt/WebKit_pch.h + DEFINES *= NDEBUG +} + +isEmpty(GENERATED_SOURCES_DIR):GENERATED_SOURCES_DIR = tmp +GENERATED_SOURCES_DIR_SLASH = $$GENERATED_SOURCES_DIR/ +win32-*: GENERATED_SOURCES_DIR_SLASH ~= s|/|\| + +INCLUDEPATH += $$GENERATED_SOURCES_DIR + +!CONFIG(QTDIR_build) { + OBJECTS_DIR = tmp +} + +include($$OUTPUT_DIR/config.pri) + +CONFIG -= warn_on +*-g++*:QMAKE_CXXFLAGS += -Wreturn-type -fno-strict-aliasing +#QMAKE_CXXFLAGS += -Wall -Wno-undef -Wno-unused-parameter + +CONFIG(release):!CONFIG(QTDIR_build) { + contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols + unix:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions +} + +linux-*: DEFINES += HAVE_STDINT_H +freebsd-*: DEFINES += HAVE_PTHREAD_NP_H + +DEFINES += BUILD_WEBKIT + +win32-*: DEFINES += _HAS_TR1=0 + +# Pick up 3rdparty libraries from INCLUDE/LIB just like with MSVC +win32-g++ { + TMPPATH = $$quote($$(INCLUDE)) + QMAKE_INCDIR_POST += $$split(TMPPATH,";") + TMPPATH = $$quote($$(LIB)) + QMAKE_LIBDIR_POST += $$split(TMPPATH,";") +} + +DEFINES += WTF_USE_JAVASCRIPTCORE_BINDINGS=1 + +DEFINES += WTF_CHANGES=1 + +include(JavaScriptCore.pri) + +QMAKE_EXTRA_TARGETS += generated_files + +qt-port: lessThan(QT_MINOR_VERSION, 4) { + DEFINES += QT_BEGIN_NAMESPACE="" QT_END_NAMESPACE="" +} + +*-g++*:QMAKE_CXXFLAGS_RELEASE -= -O2 +*-g++*:QMAKE_CXXFLAGS_RELEASE += -O3 diff --git a/JavaScriptCore.scons b/JavaScriptCore.scons new file mode 100644 index 0000000..24e5003 --- /dev/null +++ b/JavaScriptCore.scons @@ -0,0 +1,307 @@ +# The keys in sources are the paths to the directories +# the values are an array of source files in those directories to compile +sources = {} +sources['API'] = [ + 'API/JSBase.cpp', + 'API/JSCallbackConstructor.cpp', + 'API/JSCallbackFunction.cpp', + 'API/JSCallbackObject.cpp', + 'API/JSClassRef.cpp', + 'API/JSContextRef.cpp', + 'API/JSObjectRef.cpp', + 'API/JSProfilerPrivate.cpp', + 'API/JSStringRef.cpp', + 'API/JSValueRef.cpp', + 'API/OpaqueJSString.cpp', +] +sources['bytecompiler'] = [ + 'bytecompiler/BytecodeGenerator.cpp', +] +sources['debugger'] = [ + 'debugger/Debugger.cpp', + 'debugger/DebuggerActivation.cpp', + 'debugger/DebuggerCallFrame.cpp', +] +sources['parser'] = [ + 'parser/Lexer.cpp', + 'parser/Nodes.cpp', + 'parser/Parser.cpp', +] +sources['pcre'] = [ + 'pcre/pcre_compile.cpp', + 'pcre/pcre_exec.cpp', + 'pcre/pcre_tables.cpp', + 'pcre/pcre_ucp_searchfuncs.cpp', + 'pcre/pcre_xclass.cpp', +] +sources['profiler'] = [ + 'profiler/HeavyProfile.cpp', + 'profiler/Profile.cpp', + 'profiler/ProfileGenerator.cpp', + 'profiler/ProfileNode.cpp', + 'profiler/Profiler.cpp', + 'profiler/TreeProfile.cpp', +] +sources['runtime'] = [ + 'runtime/ArgList.cpp', + 'runtime/Arguments.cpp', + 'runtime/ArrayConstructor.cpp', + 'runtime/ArrayPrototype.cpp', + 'runtime/BooleanConstructor.cpp', + 'runtime/BooleanObject.cpp', + 'runtime/BooleanPrototype.cpp', + 'runtime/CallData.cpp', + 'runtime/Collector.cpp', + 'runtime/Completion.cpp', + 'runtime/CommonIdentifiers.cpp', + 'runtime/ConstructData.cpp', + 'runtime/DateConstructor.cpp', + 'runtime/DateInstance.cpp', + 'runtime/DateMath.cpp', + 'runtime/DatePrototype.cpp', + 'runtime/Error.cpp', + 'runtime/ErrorConstructor.cpp', + 'runtime/ErrorInstance.cpp', + 'runtime/ErrorPrototype.cpp', + 'runtime/ExceptionHelpers.cpp', + 'runtime/FunctionConstructor.cpp', + 'runtime/FunctionPrototype.cpp', + 'runtime/GetterSetter.cpp', + 'runtime/GlobalEvalFunction.cpp', + 'runtime/Identifier.cpp', + 'runtime/InitializeThreading.cpp', + 'runtime/InternalFunction.cpp', + 'runtime/JSActivation.cpp', + 'runtime/JSArray.cpp', + 'runtime/JSByteArray.cpp', + 'runtime/JSCell.cpp', + 'runtime/JSFunction.cpp', + 'runtime/JSGlobalData.cpp', + 'runtime/JSGlobalObject.cpp', + 'runtime/JSGlobalObjectFunctions.cpp', + 'runtime/JSImmediate.cpp', + 'runtime/JSLock.cpp', + 'runtime/JSNotAnObject.cpp', + 'runtime/JSNumberCell.cpp', + 'runtime/JSObject.cpp', + 'runtime/JSPropertyNameIterator.cpp', + 'runtime/JSStaticScopeObject.cpp', + 'runtime/JSString.cpp', + 'runtime/JSValue.cpp', + 'runtime/JSVariableObject.cpp', + 'runtime/JSWrapperObject.cpp', + 'runtime/Lookup.cpp', + 'runtime/MathObject.cpp', + 'runtime/NativeErrorConstructor.cpp', + 'runtime/NativeErrorPrototype.cpp', + 'runtime/NumberConstructor.cpp', + 'runtime/NumberObject.cpp', + 'runtime/NumberPrototype.cpp', + 'runtime/ObjectConstructor.cpp', + 'runtime/ObjectPrototype.cpp', + 'runtime/Operations.cpp', + 'runtime/PropertyNameArray.cpp', + 'runtime/PropertySlot.cpp', + 'runtime/PrototypeFunction.cpp', + 'runtime/RegExp.cpp', + 'runtime/RegExpConstructor.cpp', + 'runtime/RegExpObject.cpp', + 'runtime/RegExpPrototype.cpp', + 'runtime/ScopeChain.cpp', + 'runtime/SmallStrings.cpp', + 'runtime/StringConstructor.cpp', + 'runtime/StringObject.cpp', + 'runtime/StringPrototype.cpp', + 'runtime/Structure.cpp', + 'runtime/StructureChain.cpp', + 'runtime/UString.cpp', +] +sources['bytecode'] = [ + 'bytecode/CodeBlock.cpp', + 'bytecode/StructureStubInfo.cpp', + 'bytecode/JumpTable.cpp', + 'bytecode/Opcode.cpp', + 'bytecode/SamplingTool.cpp', +] +sources['interpreter'] = [ + 'interpreter/CallFrame.cpp', + 'interpreter/Interpreter.cpp', + 'interpreter/RegisterFile.cpp', +] +sources['jit'] = [ + 'jit/ExecutableAllocator.cpp', + 'jit/JIT.cpp', +] +sources['wrec'] = [ + 'wrec/CharacterClass.cpp', + 'wrec/CharacterClassConstructor.cpp', + 'wrec/WREC.cpp', + 'wrec/WRECFunctors.cpp', + 'wrec/WRECGenerator.cpp', + 'wrec/WRECParser.cpp', +] +sources['wtf'] = [ + 'wtf/Assertions.cpp', + 'wtf/ByteArray.cpp', + 'wtf/CurrentTime.cpp', + 'wtf/FastMalloc.cpp', + 'wtf/HashTable.cpp', + 'wtf/RandomNumber.cpp', + 'wtf/RefCountedLeakCounter.cpp', + 'wtf/Threading.cpp', + 'wtf/dtoa.cpp', +] +sources['wtf/unicode'] = [ + 'wtf/unicode/CollatorDefault.cpp', + 'wtf/unicode/UTF8.cpp', +] +sources['wtf/unicode/icu'] = [ + 'wtf/unicode/icu/CollatorICU.cpp', +] + +env = Environment() + +building_on_win32 = env['PLATFORM'] == 'win32' or env['PLATFORM'] == 'cygwin' + +# Scons uses gcc when building under cygwin by default +# We also have to manually force 8.0 or Scons will try and +# look up what version to use using the registry and fail +# due to lack of cygwin-python registry support +if env['PLATFORM'] == 'cygwin': + env['MSVS_VERSION'] = '8.0' + # Some systems have PROGRAMFILES, some have ProgramFiles + # Scons msvc tool only expects 'ProgramFiles' + import os + if os.getenv('PROGRAMFILES') and not os.getenv('ProgramFiles'): + os.environ['ProgramFiles'] = os.getenv('PROGRAMFILES') + + env.Tool('msvc') + env.Tool('mslink') + env.Tool('mslib') + +# Scons is failing to carry the %PATH% value through correctly +# Hack IncrediBuild into our path so cl.exe doesn't crash +if env['PLATFORM'] == 'win32': + env.AppendENVPath('PATH', 'c:/Program Files/Xoreax/IncrediBuild') + +if env['PLATFORM'] == 'darwin': + sources['API'].append('API/JSStringRefCF.cpp') + sources['profiler'].append('profiler/ProfilerServer.mm') + sources['wtf'].append('wtf/ThreadingPthreads.cpp') + sources['wtf'].append('wtf/MainThread.cpp') + sources['wtf/mac'] = ['wtf/mac/MainThreadMac.mm'] + sources['wtf'].append('wtf/TCSystemAlloc.cpp') + sources['jit'].append('jit/ExecutableAllocatorPosix.cpp') +elif building_on_win32: + sources['wtf'].append('wtf/ThreadingNone.cpp') + sources['jit'].append('jit/ExecutableAllocatorWin.cpp') + env.Append(CPPDEFINES = ['ENABLE_JSC_MULTIPLE_THREADS=0']) + +derived_sources_path = 'DerivedSources/JavaScriptCore/' +def DerivedSources(path): + return derived_sources_path + path + +derived_sources_results = map(DerivedSources, [ + 'ArrayPrototype.lut.h', + 'DatePrototype.lut.h', + 'MathObject.lut.h', + 'NumberConstructor.lut.h', + 'RegExpConstructor.lut.h', + 'RegExpObject.lut.h', + 'StringPrototype.lut.h' + 'chartables.c', + 'grammar.cpp', + 'grammar.h', + 'lexer.lut.h', +]) + +derived_sources_sources = [ + 'runtime/ArrayPrototype.cpp', + 'runtime/DatePrototype.cpp', + 'runtime/MathObject.cpp', + 'runtime/NumberConstructor.cpp', + 'runtime/RegExpConstructor.cpp', + 'runtime/RegExpObject.cpp', + 'runtime/StringPrototype.cpp', + 'parser/Grammar.y', + 'parser/Lexer.cpp', +] + +# Generate DerivedSources +# Make sure Windows knows where bash (and all the other cygwin commands) live +if env['PLATFORM'] == 'win32': + env.AppendENVPath('PATH', 'C:/cygwin/bin') +env.Command(derived_sources_results, derived_sources_sources, 'bash make-generated-sources.sh') +sources[derived_sources_path] = [DerivedSources('Grammar.cpp')] + +# Handle os-version specific build settings +if env['PLATFORM'] == 'darwin': + from subprocess import Popen, PIPE + version_pieces = Popen(["sw_vers", "-productVersion"], stdout = PIPE).communicate()[0].split('.') + if map(int, version_pieces)[:2] > (10, 5): + # Dtrace doesn't exist in Tiger, and was broken in Leopard + env.Command(DerivedSources('TracingDtrace.h'), 'runtime/Tracing.d', '/usr/sbin/dtrace -h -o $TARGET -s $SOURCE') + +# This build file builds the Chromium port for now, support for +# others could be added later. +env.Append(CPPDEFINES = ['BUILDING_CHROMIUM__']) + +# I'm not certain how many of these windows defines are actually required. +if building_on_win32: + env.Append(CPPDEFINES = ['_WIN32_WINNT=0x0600', 'WINVER=0x0600', 'WIN32', '_WINDOWS', 'NOMINMAX', 'UNICODE', '_UNICODE', '__STD_C', '_HAS_EXCEPTIONS=0']) + +# Scons out-of-the-box only supports precompiled headers for MSVC +# remove this when we fix Scons to understand GCC precompiled headers +if env['CC'] == 'gcc': + env['CCFLAGS'] = '-include JavaScriptCorePrefix.h' +# Turns out the MSVC PCH support is badly broken +# env['PCH'] = 'JavaScriptCorePrefix.h' +# env['PCHSTOP'] = 'JavaScriptCorePrefix.h' + +if env['PLATFORM'] == 'darwin': + env['FRAMEWORKS'] = ['CoreFoundation', 'Foundation'] + env['LIBS'] = ['icucore'] + # Apple does not ship the ICU headers with Mac OS X, so WebKit includes a copy of 3.2 headers + env.Append(CPPPATH = 'icu') + +webkit_libraries_path = "../WebKitLibraries/win/" +def WebKitLibraries(path): + return webkit_libraries_path + path + +include_paths = ['.', '..', 'ForwardingHeaders'] + sources.keys() +env.Append(CPPPATH = include_paths) +if building_on_win32: + env.Append(CPPPATH = ['os-win32', WebKitLibraries('include')]) + env.Prepend(LIBPATH = [WebKitLibraries('lib')]) + env.Append(LIBS = ['icuin', 'icuuc', 'user32', 'winmm']) + +# Save off a copy of the environment for use with jsc +jsc_env = env.Clone() + +if building_on_win32: + env.StaticLibrary("JavaScriptCore", sources.values()) +else: + env.SharedLibrary("JavaScriptCore", sources.values()) + + +env = jsc_env + +# Build the jsc testing shell +shell_sources = ['jsc.cpp'] +build_directory = '.' # This should be changed to point to wherever JavaScriptCore gets built to + +# It's hacky to re-use the same environment from JavaScriptCore +# but it makes building on windows easier for now +env['CPPPATH'] = include_paths +env['LIBS'] = ['JavaScriptCore'] +env['LIBPATH'] = [build_directory] + +if env['PLATFORM'] == 'darwin': + env.Append(LIBS = ['edit']) + env.Append(CPPPATH = 'icu') +elif building_on_win32: + env.Append(CPPPATH = ['os-win32', WebKitLibraries('include')]) + env.Prepend(LIBPATH = [WebKitLibraries('lib')]) + env.Append(LIBS = ['icuin', 'icuuc', 'user32', 'winmm']) + +env.Program('jsc', shell_sources) diff --git a/JavaScriptCorePrefix.h b/JavaScriptCorePrefix.h index 13b21bb..e71c8a8 100644 --- a/JavaScriptCorePrefix.h +++ b/JavaScriptCorePrefix.h @@ -25,6 +25,15 @@ #endif +#if defined(__APPLE__) +#import +#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 +#define BUILDING_ON_TIGER 1 +#elif MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 +#define BUILDING_ON_LEOPARD 1 +#endif +#endif + #ifdef __cplusplus #define new ("if you use new/delete make sure to include config.h at the top of the file"()) #define delete ("if you use new/delete make sure to include config.h at the top of the file"()) diff --git a/JavaScriptCoreSources.bkl b/JavaScriptCoreSources.bkl index 2a1312b..7ba3e09 100644 --- a/JavaScriptCoreSources.bkl +++ b/JavaScriptCoreSources.bkl @@ -29,7 +29,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Source files for JSCore. --> - + API/JSBase.cpp API/JSCallbackConstructor.cpp API/JSCallbackFunction.cpp @@ -39,80 +39,139 @@ Source files for JSCore. API/JSObjectRef.cpp API/JSStringRef.cpp API/JSValueRef.cpp + API/OpaqueJSString.cpp - - - bindings/c/c_class.cpp - bindings/c/c_instance.cpp - bindings/c/c_runtime.cpp - bindings/c/c_utility.cpp - bindings/NP_jsobject.cpp - bindings/npruntime.cpp - bindings/runtime.cpp - bindings/runtime_array.cpp - bindings/runtime_method.cpp - bindings/runtime_object.cpp - bindings/runtime_root.cpp + + bytecompiler/BytecodeGenerator.cpp - - - DerivedSources/JavaScriptCore/grammar.cpp - kjs/array_instance.cpp - kjs/array_object.cpp - kjs/bool_object.cpp - kjs/collector.cpp - kjs/CommonIdentifiers.cpp - kjs/date_object.cpp - kjs/DateMath.cpp - kjs/debugger.cpp - kjs/dtoa.cpp - kjs/error_object.cpp - kjs/ExecState.cpp - kjs/function.cpp - kjs/function_object.cpp - kjs/identifier.cpp - kjs/internal.cpp - kjs/interpreter.cpp - kjs/JSGlobalObject.cpp - kjs/JSVariableObject.cpp - kjs/JSImmediate.cpp - kjs/JSLock.cpp - kjs/JSWrapperObject.cpp - kjs/lexer.cpp - kjs/list.cpp - kjs/lookup.cpp - kjs/math_object.cpp - kjs/nodes.cpp - kjs/nodes2string.cpp - kjs/number_object.cpp - kjs/object.cpp - kjs/object_object.cpp - kjs/operations.cpp - kjs/Parser.cpp - kjs/property_map.cpp - kjs/property_slot.cpp - kjs/PropertyNameArray.cpp - kjs/regexp.cpp - kjs/regexp_object.cpp - kjs/scope_chain.cpp - kjs/string_object.cpp - kjs/ustring.cpp - kjs/value.cpp - + + debugger/Debugger.cpp + debugger/DebuggerActivation.cpp + debugger/DebuggerCallFrame.cpp - + + DerivedSources/JavaScriptCore/Grammar.cpp + wtf/dtoa.cpp + + pcre/pcre_compile.cpp pcre/pcre_exec.cpp pcre/pcre_tables.cpp pcre/pcre_ucp_searchfuncs.cpp pcre/pcre_xclass.cpp - - + + parser/Lexer.cpp + parser/Nodes.cpp + parser/Parser.cpp + + + profiler/HeavyProfile.cpp + profiler/ProfileGenerator.cpp + profiler/ProfileNode.cpp + profiler/Profile.cpp + profiler/Profiler.cpp + profiler/TreeProfile.cpp + + + runtime/ArgList.cpp + runtime/Arguments.cpp + runtime/ArrayConstructor.cpp + runtime/ArrayPrototype.cpp + runtime/BooleanConstructor.cpp + runtime/BooleanObject.cpp + runtime/BooleanPrototype.cpp + runtime/CallData.cpp + runtime/Collector.cpp + runtime/CommonIdentifiers.cpp + runtime/ConstructData.cpp + runtime/DateConstructor.cpp + runtime/DateInstance.cpp + runtime/DateMath.cpp + runtime/DatePrototype.cpp + runtime/Error.cpp + runtime/ErrorConstructor.cpp + runtime/ErrorInstance.cpp + runtime/ErrorPrototype.cpp + interpreter/CallFrame.cpp + runtime/FunctionConstructor.cpp + runtime/FunctionPrototype.cpp + runtime/GetterSetter.cpp + runtime/GlobalEvalFunction.cpp + runtime/Identifier.cpp + runtime/InitializeThreading.cpp + runtime/InternalFunction.cpp + runtime/Completion.cpp + runtime/JSActivation.cpp + runtime/JSArray.cpp + runtime/JSByteArray.cpp + runtime/JSCell.cpp + runtime/JSFunction.cpp + runtime/JSGlobalData.cpp + runtime/JSGlobalObject.cpp + runtime/JSGlobalObjectFunctions.cpp + runtime/JSImmediate.cpp + runtime/JSLock.cpp + runtime/JSNotAnObject.cpp + runtime/JSNumberCell.cpp + runtime/JSObject.cpp + runtime/JSPropertyNameIterator.cpp + runtime/JSStaticScopeObject.cpp + runtime/JSString.cpp + runtime/JSValue.cpp + runtime/JSVariableObject.cpp + runtime/JSWrapperObject.cpp + runtime/Lookup.cpp + runtime/MathObject.cpp + runtime/NativeErrorConstructor.cpp + runtime/NativeErrorPrototype.cpp + runtime/NumberConstructor.cpp + runtime/NumberObject.cpp + runtime/NumberPrototype.cpp + runtime/ObjectConstructor.cpp + runtime/ObjectPrototype.cpp + runtime/Operations.cpp + runtime/PropertyNameArray.cpp + runtime/PropertySlot.cpp + runtime/PrototypeFunction.cpp + runtime/RegExp.cpp + runtime/RegExpConstructor.cpp + runtime/RegExpObject.cpp + runtime/RegExpPrototype.cpp + runtime/ScopeChain.cpp + runtime/SmallStrings.cpp + runtime/StringConstructor.cpp + runtime/StringObject.cpp + runtime/StringPrototype.cpp + runtime/Structure.cpp + runtime/StructureChain.cpp + runtime/UString.cpp + + + bytecode/CodeBlock.cpp + bytecode/StructureStubInfo.cpp + bytecode/JumpTable.cpp + runtime/ExceptionHelpers.cpp + interpreter/Interpreter.cpp + bytecode/Opcode.cpp + bytecode/SamplingTool.cpp + interpreter/RegisterFile.cpp + + wtf/Assertions.cpp + wtf/ByteArray.cpp + wtf/CurrentTime.cpp wtf/FastMalloc.cpp wtf/HashTable.cpp + wtf/MainThread.cpp + wtf/RandomNumber.cpp + wtf/RefCountedLeakCounter.cpp wtf/TCSystemAlloc.cpp + wtf/Threading.cpp + wtf/ThreadingNone.cpp + wtf/wx/MainThreadWx.cpp + wtf/unicode/CollatorDefault.cpp + wtf/unicode/icu/CollatorICU.cpp wtf/unicode/UTF8.cpp diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000..b77d202 --- /dev/null +++ b/SConstruct @@ -0,0 +1 @@ +SConscript(['JavaScriptCore.scons']) diff --git a/assembler/AssemblerBuffer.h b/assembler/AssemblerBuffer.h new file mode 100644 index 0000000..e1f53d8 --- /dev/null +++ b/assembler/AssemblerBuffer.h @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef AssemblerBuffer_h +#define AssemblerBuffer_h + +#include + +#if ENABLE(ASSEMBLER) + +#include "stdint.h" +#include +#include +#include +#include + +namespace JSC { + + class AssemblerBuffer { + static const int inlineCapacity = 256; + public: + AssemblerBuffer() + : m_buffer(m_inlineBuffer) + , m_capacity(inlineCapacity) + , m_size(0) + { + } + + ~AssemblerBuffer() + { + if (m_buffer != m_inlineBuffer) + fastFree(m_buffer); + } + + void ensureSpace(int space) + { + if (m_size > m_capacity - space) + grow(); + } + + bool isAligned(int alignment) const + { + return !(m_size & (alignment - 1)); + } + + void putByteUnchecked(int value) + { + ASSERT(!(m_size > m_capacity - 4)); + m_buffer[m_size] = value; + m_size++; + } + + void putByte(int value) + { + if (m_size > m_capacity - 4) + grow(); + putByteUnchecked(value); + } + + void putShortUnchecked(int value) + { + ASSERT(!(m_size > m_capacity - 4)); + *reinterpret_cast(&m_buffer[m_size]) = value; + m_size += 2; + } + + void putShort(int value) + { + if (m_size > m_capacity - 4) + grow(); + putShortUnchecked(value); + } + + void putIntUnchecked(int value) + { + *reinterpret_cast(&m_buffer[m_size]) = value; + m_size += 4; + } + + void putInt64Unchecked(int64_t value) + { + *reinterpret_cast(&m_buffer[m_size]) = value; + m_size += 8; + } + + void putInt(int value) + { + if (m_size > m_capacity - 4) + grow(); + putIntUnchecked(value); + } + + void* data() const + { + return m_buffer; + } + + int size() const + { + return m_size; + } + + void* executableCopy(ExecutablePool* allocator) + { + if (!m_size) + return 0; + + void* result = allocator->alloc(m_size); + + if (!result) + return 0; + + return memcpy(result, m_buffer, m_size); + } + + private: + void grow() + { + m_capacity += m_capacity / 2; + + if (m_buffer == m_inlineBuffer) { + char* newBuffer = static_cast(fastMalloc(m_capacity)); + m_buffer = static_cast(memcpy(newBuffer, m_buffer, m_size)); + } else + m_buffer = static_cast(fastRealloc(m_buffer, m_capacity)); + } + + char m_inlineBuffer[inlineCapacity]; + char* m_buffer; + int m_capacity; + int m_size; + }; + +} // namespace JSC + +#endif // ENABLE(ASSEMBLER) + +#endif // AssemblerBuffer_h diff --git a/assembler/MacroAssembler.h b/assembler/MacroAssembler.h new file mode 100644 index 0000000..9d24653 --- /dev/null +++ b/assembler/MacroAssembler.h @@ -0,0 +1,2019 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef MacroAssembler_h +#define MacroAssembler_h + +#include + +#if ENABLE(ASSEMBLER) + +#include "X86Assembler.h" + +namespace JSC { + +class MacroAssembler { +protected: + X86Assembler m_assembler; + +#if PLATFORM(X86_64) + static const X86::RegisterID scratchRegister = X86::r11; +#endif + +public: + typedef X86::RegisterID RegisterID; + + // Note: do not rely on values in this enum, these will change (to 0..3). + enum Scale { + TimesOne = 1, + TimesTwo = 2, + TimesFour = 4, + TimesEight = 8, +#if PLATFORM(X86) + ScalePtr = TimesFour +#endif +#if PLATFORM(X86_64) + ScalePtr = TimesEight +#endif + }; + + MacroAssembler() + { + } + + size_t size() { return m_assembler.size(); } + void* copyCode(ExecutablePool* allocator) + { + return m_assembler.executableCopy(allocator); + } + + + // Address: + // + // Describes a simple base-offset address. + struct Address { + explicit Address(RegisterID base, int32_t offset = 0) + : base(base) + , offset(offset) + { + } + + RegisterID base; + int32_t offset; + }; + + // ImplicitAddress: + // + // This class is used for explicit 'load' and 'store' operations + // (as opposed to situations in which a memory operand is provided + // to a generic operation, such as an integer arithmetic instruction). + // + // In the case of a load (or store) operation we want to permit + // addresses to be implicitly constructed, e.g. the two calls: + // + // load32(Address(addrReg), destReg); + // load32(addrReg, destReg); + // + // Are equivalent, and the explicit wrapping of the Address in the former + // is unnecessary. + struct ImplicitAddress { + ImplicitAddress(RegisterID base) + : base(base) + , offset(0) + { + } + + ImplicitAddress(Address address) + : base(address.base) + , offset(address.offset) + { + } + + RegisterID base; + int32_t offset; + }; + + // BaseIndex: + // + // Describes a complex addressing mode. + struct BaseIndex { + BaseIndex(RegisterID base, RegisterID index, Scale scale, int32_t offset = 0) + : base(base) + , index(index) + , scale(scale) + , offset(offset) + { + } + + RegisterID base; + RegisterID index; + Scale scale; + int32_t offset; + }; + + // AbsoluteAddress: + // + // Describes an memory operand given by a pointer. For regular load & store + // operations an unwrapped void* will be used, rather than using this. + struct AbsoluteAddress { + explicit AbsoluteAddress(void* ptr) + : m_ptr(ptr) + { + } + + void* m_ptr; + }; + + + class Jump; + class PatchBuffer; + + // DataLabelPtr: + // + // A DataLabelPtr is used to refer to a location in the code containing a pointer to be + // patched after the code has been generated. + class DataLabelPtr { + friend class MacroAssembler; + friend class PatchBuffer; + + public: + DataLabelPtr() + { + } + + DataLabelPtr(MacroAssembler* masm) + : m_label(masm->m_assembler.label()) + { + } + + static void patch(void* address, void* value) + { + X86Assembler::patchPointer(reinterpret_cast(address), reinterpret_cast(value)); + } + + private: + X86Assembler::JmpDst m_label; + }; + + // DataLabel32: + // + // A DataLabelPtr is used to refer to a location in the code containing a pointer to be + // patched after the code has been generated. + class DataLabel32 { + friend class MacroAssembler; + friend class PatchBuffer; + + public: + DataLabel32() + { + } + + DataLabel32(MacroAssembler* masm) + : m_label(masm->m_assembler.label()) + { + } + + static void patch(void* address, int32_t value) + { + X86Assembler::patchImmediate(reinterpret_cast(address), value); + } + + private: + X86Assembler::JmpDst m_label; + }; + + // Label: + // + // A Label records a point in the generated instruction stream, typically such that + // it may be used as a destination for a jump. + class Label { + friend class Jump; + friend class MacroAssembler; + friend class PatchBuffer; + + public: + Label() + { + } + + Label(MacroAssembler* masm) + : m_label(masm->m_assembler.label()) + { + } + + // FIXME: transitionary method, while we replace JmpSrces with Jumps. + operator X86Assembler::JmpDst() + { + return m_label; + } + + private: + X86Assembler::JmpDst m_label; + }; + + + // Jump: + // + // A jump object is a reference to a jump instruction that has been planted + // into the code buffer - it is typically used to link the jump, setting the + // relative offset such that when executed it will jump to the desired + // destination. + // + // Jump objects retain a pointer to the assembler for syntactic purposes - + // to allow the jump object to be able to link itself, e.g.: + // + // Jump forwardsBranch = jne32(Imm32(0), reg1); + // // ... + // forwardsBranch.link(); + // + // Jumps may also be linked to a Label. + class Jump { + friend class PatchBuffer; + friend class MacroAssembler; + + public: + Jump() + { + } + + // FIXME: transitionary method, while we replace JmpSrces with Jumps. + Jump(X86Assembler::JmpSrc jmp) + : m_jmp(jmp) + { + } + + void link(MacroAssembler* masm) + { + masm->m_assembler.link(m_jmp, masm->m_assembler.label()); + } + + void linkTo(Label label, MacroAssembler* masm) + { + masm->m_assembler.link(m_jmp, label.m_label); + } + + // FIXME: transitionary method, while we replace JmpSrces with Jumps. + operator X86Assembler::JmpSrc() + { + return m_jmp; + } + + static void patch(void* address, void* destination) + { + X86Assembler::patchBranchOffset(reinterpret_cast(address), destination); + } + + private: + X86Assembler::JmpSrc m_jmp; + }; + + // JumpList: + // + // A JumpList is a set of Jump objects. + // All jumps in the set will be linked to the same destination. + class JumpList { + friend class PatchBuffer; + + public: + void link(MacroAssembler* masm) + { + size_t size = m_jumps.size(); + for (size_t i = 0; i < size; ++i) + m_jumps[i].link(masm); + m_jumps.clear(); + } + + void linkTo(Label label, MacroAssembler* masm) + { + size_t size = m_jumps.size(); + for (size_t i = 0; i < size; ++i) + m_jumps[i].linkTo(label, masm); + m_jumps.clear(); + } + + void append(Jump jump) + { + m_jumps.append(jump); + } + + void append(JumpList& other) + { + m_jumps.append(other.m_jumps.begin(), other.m_jumps.size()); + } + + bool empty() + { + return !m_jumps.size(); + } + + private: + Vector m_jumps; + }; + + + // PatchBuffer: + // + // This class assists in linking code generated by the macro assembler, once code generation + // has been completed, and the code has been copied to is final location in memory. At this + // time pointers to labels within the code may be resolved, and relative offsets to external + // addresses may be fixed. + // + // Specifically: + // * Jump objects may be linked to external targets, + // * The address of Jump objects may taken, such that it can later be relinked. + // * The return address of a Jump object representing a call may be acquired. + // * The address of a Label pointing into the code may be resolved. + // * The value referenced by a DataLabel may be fixed. + // + // FIXME: distinguish between Calls & Jumps (make a specific call to obtain the return + // address of calls, as opposed to a point that can be used to later relink a Jump - + // possibly wrap the later up in an object that can do just that). + class PatchBuffer { + public: + PatchBuffer(void* code) + : m_code(code) + { + } + + void link(Jump jump, void* target) + { + X86Assembler::link(m_code, jump.m_jmp, target); + } + + void link(JumpList list, void* target) + { + for (unsigned i = 0; i < list.m_jumps.size(); ++i) + X86Assembler::link(m_code, list.m_jumps[i], target); + } + + void* addressOf(Jump jump) + { + return X86Assembler::getRelocatedAddress(m_code, jump.m_jmp); + } + + void* addressOf(Label label) + { + return X86Assembler::getRelocatedAddress(m_code, label.m_label); + } + + void* addressOf(DataLabelPtr label) + { + return X86Assembler::getRelocatedAddress(m_code, label.m_label); + } + + void* addressOf(DataLabel32 label) + { + return X86Assembler::getRelocatedAddress(m_code, label.m_label); + } + + void setPtr(DataLabelPtr label, void* value) + { + X86Assembler::patchAddress(m_code, label.m_label, value); + } + + private: + void* m_code; + }; + + + // ImmPtr: + // + // A pointer sized immediate operand to an instruction - this is wrapped + // in a class requiring explicit construction in order to differentiate + // from pointers used as absolute addresses to memory operations + struct ImmPtr { + explicit ImmPtr(void* value) + : m_value(value) + { + } + + intptr_t asIntptr() + { + return reinterpret_cast(m_value); + } + + void* m_value; + }; + + + // Imm32: + // + // A 32bit immediate operand to an instruction - this is wrapped in a + // class requiring explicit construction in order to prevent RegisterIDs + // (which are implemented as an enum) from accidentally being passed as + // immediate values. + struct Imm32 { + explicit Imm32(int32_t value) + : m_value(value) + { + } + +#if PLATFORM(X86) + explicit Imm32(ImmPtr ptr) + : m_value(ptr.asIntptr()) + { + } +#endif + + int32_t m_value; + }; + + // Integer arithmetic operations: + // + // Operations are typically two operand - operation(source, srcDst) + // For many operations the source may be an Imm32, the srcDst operand + // may often be a memory location (explictly described using an Address + // object). + + void addPtr(RegisterID src, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.addq_rr(src, dest); +#else + add32(src, dest); +#endif + } + + void addPtr(Imm32 imm, RegisterID srcDest) + { +#if PLATFORM(X86_64) + m_assembler.addq_ir(imm.m_value, srcDest); +#else + add32(imm, srcDest); +#endif + } + + void addPtr(ImmPtr imm, RegisterID dest) + { +#if PLATFORM(X86_64) + move(imm, scratchRegister); + m_assembler.addq_rr(scratchRegister, dest); +#else + add32(Imm32(imm), dest); +#endif + } + + void addPtr(Imm32 imm, RegisterID src, RegisterID dest) + { + m_assembler.leal_mr(imm.m_value, src, dest); + } + + void add32(RegisterID src, RegisterID dest) + { + m_assembler.addl_rr(src, dest); + } + + void add32(Imm32 imm, Address address) + { + m_assembler.addl_im(imm.m_value, address.offset, address.base); + } + + void add32(Imm32 imm, RegisterID dest) + { + m_assembler.addl_ir(imm.m_value, dest); + } + + void add32(Imm32 imm, AbsoluteAddress address) + { +#if PLATFORM(X86_64) + move(ImmPtr(address.m_ptr), scratchRegister); + add32(imm, Address(scratchRegister)); +#else + m_assembler.addl_im(imm.m_value, address.m_ptr); +#endif + } + + void add32(Address src, RegisterID dest) + { + m_assembler.addl_mr(src.offset, src.base, dest); + } + + void andPtr(RegisterID src, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.andq_rr(src, dest); +#else + and32(src, dest); +#endif + } + + void andPtr(Imm32 imm, RegisterID srcDest) + { +#if PLATFORM(X86_64) + m_assembler.andq_ir(imm.m_value, srcDest); +#else + and32(imm, srcDest); +#endif + } + + void and32(RegisterID src, RegisterID dest) + { + m_assembler.andl_rr(src, dest); + } + + void and32(Imm32 imm, RegisterID dest) + { + m_assembler.andl_ir(imm.m_value, dest); + } + + void lshift32(Imm32 imm, RegisterID dest) + { + m_assembler.shll_i8r(imm.m_value, dest); + } + + void lshift32(RegisterID shift_amount, RegisterID dest) + { + // On x86 we can only shift by ecx; if asked to shift by another register we'll + // need rejig the shift amount into ecx first, and restore the registers afterwards. + if (shift_amount != X86::ecx) { + swap(shift_amount, X86::ecx); + + // E.g. transform "shll %eax, %eax" -> "xchgl %eax, %ecx; shll %ecx, %ecx; xchgl %eax, %ecx" + if (dest == shift_amount) + m_assembler.shll_CLr(X86::ecx); + // E.g. transform "shll %eax, %ecx" -> "xchgl %eax, %ecx; shll %ecx, %eax; xchgl %eax, %ecx" + else if (dest == X86::ecx) + m_assembler.shll_CLr(shift_amount); + // E.g. transform "shll %eax, %ebx" -> "xchgl %eax, %ecx; shll %ecx, %ebx; xchgl %eax, %ecx" + else + m_assembler.shll_CLr(dest); + + swap(shift_amount, X86::ecx); + } else + m_assembler.shll_CLr(dest); + } + + // Take the value from dividend, divide it by divisor, and put the remainder in remainder. + // For now, this operation has specific register requirements, and the three register must + // be unique. It is unfortunate to expose this in the MacroAssembler interface, however + // given the complexity to fix, the fact that it is not uncommmon for processors to have + // specific register requirements on this operation (e.g. Mips result in 'hi'), or to not + // support a hardware divide at all, it may not be + void mod32(RegisterID divisor, RegisterID dividend, RegisterID remainder) + { +#ifdef NDEBUG +#pragma unused(dividend,remainder) +#else + ASSERT((dividend == X86::eax) && (remainder == X86::edx)); + ASSERT((dividend != divisor) && (remainder != divisor)); +#endif + + m_assembler.cdq(); + m_assembler.idivl_r(divisor); + } + + void mul32(RegisterID src, RegisterID dest) + { + m_assembler.imull_rr(src, dest); + } + + void mul32(Imm32 imm, RegisterID src, RegisterID dest) + { + m_assembler.imull_i32r(src, imm.m_value, dest); + } + + void not32(RegisterID srcDest) + { + m_assembler.notl_r(srcDest); + } + + void orPtr(RegisterID src, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.orq_rr(src, dest); +#else + or32(src, dest); +#endif + } + + void orPtr(ImmPtr imm, RegisterID dest) + { +#if PLATFORM(X86_64) + move(imm, scratchRegister); + m_assembler.orq_rr(scratchRegister, dest); +#else + or32(Imm32(imm), dest); +#endif + } + + void orPtr(Imm32 imm, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.orq_ir(imm.m_value, dest); +#else + or32(imm, dest); +#endif + } + + void or32(RegisterID src, RegisterID dest) + { + m_assembler.orl_rr(src, dest); + } + + void or32(Imm32 imm, RegisterID dest) + { + m_assembler.orl_ir(imm.m_value, dest); + } + + void rshiftPtr(RegisterID shift_amount, RegisterID dest) + { +#if PLATFORM(X86_64) + // On x86 we can only shift by ecx; if asked to shift by another register we'll + // need rejig the shift amount into ecx first, and restore the registers afterwards. + if (shift_amount != X86::ecx) { + swap(shift_amount, X86::ecx); + + // E.g. transform "shll %eax, %eax" -> "xchgl %eax, %ecx; shll %ecx, %ecx; xchgl %eax, %ecx" + if (dest == shift_amount) + m_assembler.sarq_CLr(X86::ecx); + // E.g. transform "shll %eax, %ecx" -> "xchgl %eax, %ecx; shll %ecx, %eax; xchgl %eax, %ecx" + else if (dest == X86::ecx) + m_assembler.sarq_CLr(shift_amount); + // E.g. transform "shll %eax, %ebx" -> "xchgl %eax, %ecx; shll %ecx, %ebx; xchgl %eax, %ecx" + else + m_assembler.sarq_CLr(dest); + + swap(shift_amount, X86::ecx); + } else + m_assembler.sarq_CLr(dest); +#else + rshift32(shift_amount, dest); +#endif + } + + void rshiftPtr(Imm32 imm, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.sarq_i8r(imm.m_value, dest); +#else + rshift32(imm, dest); +#endif + } + + void rshift32(RegisterID shift_amount, RegisterID dest) + { + // On x86 we can only shift by ecx; if asked to shift by another register we'll + // need rejig the shift amount into ecx first, and restore the registers afterwards. + if (shift_amount != X86::ecx) { + swap(shift_amount, X86::ecx); + + // E.g. transform "shll %eax, %eax" -> "xchgl %eax, %ecx; shll %ecx, %ecx; xchgl %eax, %ecx" + if (dest == shift_amount) + m_assembler.sarl_CLr(X86::ecx); + // E.g. transform "shll %eax, %ecx" -> "xchgl %eax, %ecx; shll %ecx, %eax; xchgl %eax, %ecx" + else if (dest == X86::ecx) + m_assembler.sarl_CLr(shift_amount); + // E.g. transform "shll %eax, %ebx" -> "xchgl %eax, %ecx; shll %ecx, %ebx; xchgl %eax, %ecx" + else + m_assembler.sarl_CLr(dest); + + swap(shift_amount, X86::ecx); + } else + m_assembler.sarl_CLr(dest); + } + + void rshift32(Imm32 imm, RegisterID dest) + { + m_assembler.sarl_i8r(imm.m_value, dest); + } + + void subPtr(RegisterID src, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.subq_rr(src, dest); +#else + sub32(src, dest); +#endif + } + + void subPtr(Imm32 imm, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.subq_ir(imm.m_value, dest); +#else + sub32(imm, dest); +#endif + } + + void subPtr(ImmPtr imm, RegisterID dest) + { +#if PLATFORM(X86_64) + move(imm, scratchRegister); + m_assembler.subq_rr(scratchRegister, dest); +#else + sub32(Imm32(imm), dest); +#endif + } + + void sub32(RegisterID src, RegisterID dest) + { + m_assembler.subl_rr(src, dest); + } + + void sub32(Imm32 imm, RegisterID dest) + { + m_assembler.subl_ir(imm.m_value, dest); + } + + void sub32(Imm32 imm, Address address) + { + m_assembler.subl_im(imm.m_value, address.offset, address.base); + } + + void sub32(Imm32 imm, AbsoluteAddress address) + { +#if PLATFORM(X86_64) + move(ImmPtr(address.m_ptr), scratchRegister); + sub32(imm, Address(scratchRegister)); +#else + m_assembler.subl_im(imm.m_value, address.m_ptr); +#endif + } + + void sub32(Address src, RegisterID dest) + { + m_assembler.subl_mr(src.offset, src.base, dest); + } + + void xorPtr(RegisterID src, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.xorq_rr(src, dest); +#else + xor32(src, dest); +#endif + } + + void xorPtr(Imm32 imm, RegisterID srcDest) + { +#if PLATFORM(X86_64) + m_assembler.xorq_ir(imm.m_value, srcDest); +#else + xor32(imm, srcDest); +#endif + } + + void xor32(RegisterID src, RegisterID dest) + { + m_assembler.xorl_rr(src, dest); + } + + void xor32(Imm32 imm, RegisterID srcDest) + { + m_assembler.xorl_ir(imm.m_value, srcDest); + } + + + // Memory access operations: + // + // Loads are of the form load(address, destination) and stores of the form + // store(source, address). The source for a store may be an Imm32. Address + // operand objects to loads and store will be implicitly constructed if a + // register is passed. + + void loadPtr(ImplicitAddress address, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.movq_mr(address.offset, address.base, dest); +#else + load32(address, dest); +#endif + } + + DataLabel32 loadPtrWithAddressOffsetPatch(Address address, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.movq_mr_disp32(address.offset, address.base, dest); + return DataLabel32(this); +#else + m_assembler.movl_mr_disp32(address.offset, address.base, dest); + return DataLabel32(this); +#endif + } + + void loadPtr(BaseIndex address, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.movq_mr(address.offset, address.base, address.index, address.scale, dest); +#else + load32(address, dest); +#endif + } + + void loadPtr(void* address, RegisterID dest) + { +#if PLATFORM(X86_64) + if (dest == X86::eax) + m_assembler.movq_mEAX(address); + else { + move(X86::eax, dest); + m_assembler.movq_mEAX(address); + swap(X86::eax, dest); + } +#else + load32(address, dest); +#endif + } + + void load32(ImplicitAddress address, RegisterID dest) + { + m_assembler.movl_mr(address.offset, address.base, dest); + } + + void load32(BaseIndex address, RegisterID dest) + { + m_assembler.movl_mr(address.offset, address.base, address.index, address.scale, dest); + } + + void load32(void* address, RegisterID dest) + { +#if PLATFORM(X86_64) + if (dest == X86::eax) + m_assembler.movl_mEAX(address); + else { + move(X86::eax, dest); + m_assembler.movl_mEAX(address); + swap(X86::eax, dest); + } +#else + m_assembler.movl_mr(address, dest); +#endif + } + + void load16(BaseIndex address, RegisterID dest) + { + m_assembler.movzwl_mr(address.offset, address.base, address.index, address.scale, dest); + } + + void storePtr(RegisterID src, ImplicitAddress address) + { +#if PLATFORM(X86_64) + m_assembler.movq_rm(src, address.offset, address.base); +#else + store32(src, address); +#endif + } + + DataLabel32 storePtrWithAddressOffsetPatch(RegisterID src, Address address) + { +#if PLATFORM(X86_64) + m_assembler.movq_rm_disp32(src, address.offset, address.base); + return DataLabel32(this); +#else + m_assembler.movl_rm_disp32(src, address.offset, address.base); + return DataLabel32(this); +#endif + } + + void storePtr(RegisterID src, BaseIndex address) + { +#if PLATFORM(X86_64) + m_assembler.movq_rm(src, address.offset, address.base, address.index, address.scale); +#else + store32(src, address); +#endif + } + + void storePtr(ImmPtr imm, ImplicitAddress address) + { +#if PLATFORM(X86_64) + move(imm, scratchRegister); + storePtr(scratchRegister, address); +#else + m_assembler.movl_i32m(imm.asIntptr(), address.offset, address.base); +#endif + } + +#if !PLATFORM(X86_64) + void storePtr(ImmPtr imm, void* address) + { + store32(Imm32(imm), address); + } +#endif + + DataLabelPtr storePtrWithPatch(Address address) + { +#if PLATFORM(X86_64) + m_assembler.movq_i64r(0, scratchRegister); + DataLabelPtr label(this); + storePtr(scratchRegister, address); + return label; +#else + m_assembler.movl_i32m(0, address.offset, address.base); + return DataLabelPtr(this); +#endif + } + + void store32(RegisterID src, ImplicitAddress address) + { + m_assembler.movl_rm(src, address.offset, address.base); + } + + void store32(RegisterID src, BaseIndex address) + { + m_assembler.movl_rm(src, address.offset, address.base, address.index, address.scale); + } + + void store32(Imm32 imm, ImplicitAddress address) + { + m_assembler.movl_i32m(imm.m_value, address.offset, address.base); + } + + void store32(Imm32 imm, void* address) + { +#if PLATFORM(X86_64) + move(X86::eax, scratchRegister); + move(imm, X86::eax); + m_assembler.movl_EAXm(address); + move(scratchRegister, X86::eax); +#else + m_assembler.movl_i32m(imm.m_value, address); +#endif + } + + + // Stack manipulation operations: + // + // The ABI is assumed to provide a stack abstraction to memory, + // containing machine word sized units of data. Push and pop + // operations add and remove a single register sized unit of data + // to or from the stack. Peek and poke operations read or write + // values on the stack, without moving the current stack position. + + void pop(RegisterID dest) + { + m_assembler.pop_r(dest); + } + + void push(RegisterID src) + { + m_assembler.push_r(src); + } + + void push(Address address) + { + m_assembler.push_m(address.offset, address.base); + } + + void push(Imm32 imm) + { + m_assembler.push_i32(imm.m_value); + } + + void pop() + { + addPtr(Imm32(sizeof(void*)), X86::esp); + } + + void peek(RegisterID dest, int index = 0) + { + loadPtr(Address(X86::esp, (index * sizeof(void *))), dest); + } + + void poke(RegisterID src, int index = 0) + { + storePtr(src, Address(X86::esp, (index * sizeof(void *)))); + } + + void poke(Imm32 value, int index = 0) + { + store32(value, Address(X86::esp, (index * sizeof(void *)))); + } + + void poke(ImmPtr imm, int index = 0) + { + storePtr(imm, Address(X86::esp, (index * sizeof(void *)))); + } + + // Register move operations: + // + // Move values in registers. + + void move(Imm32 imm, RegisterID dest) + { + // Note: on 64-bit the Imm32 value is zero extended into the register, it + // may be useful to have a separate version that sign extends the value? + if (!imm.m_value) + m_assembler.xorl_rr(dest, dest); + else + m_assembler.movl_i32r(imm.m_value, dest); + } + + void move(RegisterID src, RegisterID dest) + { + // Note: on 64-bit this is is a full register move; perhaps it would be + // useful to have separate move32 & movePtr, with move32 zero extending? +#if PLATFORM(X86_64) + m_assembler.movq_rr(src, dest); +#else + m_assembler.movl_rr(src, dest); +#endif + } + + void move(ImmPtr imm, RegisterID dest) + { +#if PLATFORM(X86_64) + if (CAN_SIGN_EXTEND_U32_64(imm.asIntptr())) + m_assembler.movl_i32r(static_cast(imm.asIntptr()), dest); + else + m_assembler.movq_i64r(imm.asIntptr(), dest); +#else + m_assembler.movl_i32r(imm.asIntptr(), dest); +#endif + } + + void swap(RegisterID reg1, RegisterID reg2) + { +#if PLATFORM(X86_64) + m_assembler.xchgq_rr(reg1, reg2); +#else + m_assembler.xchgl_rr(reg1, reg2); +#endif + } + + void signExtend32ToPtr(RegisterID src, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.movsxd_rr(src, dest); +#else + if (src != dest) + move(src, dest); +#endif + } + + void zeroExtend32ToPtr(RegisterID src, RegisterID dest) + { +#if PLATFORM(X86_64) + m_assembler.movl_rr(src, dest); +#else + if (src != dest) + move(src, dest); +#endif + } + + + // Forwards / external control flow operations: + // + // This set of jump and conditional branch operations return a Jump + // object which may linked at a later point, allow forwards jump, + // or jumps that will require external linkage (after the code has been + // relocated). + // + // For branches, signed <, >, <= and >= are denoted as l, g, le, and ge + // respecitvely, for unsigned comparisons the names b, a, be, and ae are + // used (representing the names 'below' and 'above'). + // + // Operands to the comparision are provided in the expected order, e.g. + // jle32(reg1, Imm32(5)) will branch if the value held in reg1, when + // treated as a signed 32bit value, is less than or equal to 5. + // + // jz and jnz test whether the first operand is equal to zero, and take + // an optional second operand of a mask under which to perform the test. + +private: + void compareImm32ForBranch(RegisterID left, int32_t right) + { + m_assembler.cmpl_ir(right, left); + } + + void compareImm32ForBranchEquality(RegisterID reg, int32_t imm) + { + if (!imm) + m_assembler.testl_rr(reg, reg); + else + m_assembler.cmpl_ir(imm, reg); + } + + void compareImm32ForBranchEquality(Address address, int32_t imm) + { + m_assembler.cmpl_im(imm, address.offset, address.base); + } + + void testImm32(RegisterID reg, Imm32 mask) + { + // if we are only interested in the low seven bits, this can be tested with a testb + if (mask.m_value == -1) + m_assembler.testl_rr(reg, reg); + else if ((mask.m_value & ~0x7f) == 0) + m_assembler.testb_i8r(mask.m_value, reg); + else + m_assembler.testl_i32r(mask.m_value, reg); + } + + void testImm32(Address address, Imm32 mask) + { + if (mask.m_value == -1) + m_assembler.cmpl_im(0, address.offset, address.base); + else + m_assembler.testl_i32m(mask.m_value, address.offset, address.base); + } + + void testImm32(BaseIndex address, Imm32 mask) + { + if (mask.m_value == -1) + m_assembler.cmpl_im(0, address.offset, address.base, address.index, address.scale); + else + m_assembler.testl_i32m(mask.m_value, address.offset, address.base, address.index, address.scale); + } + +#if PLATFORM(X86_64) + void compareImm64ForBranch(RegisterID left, int32_t right) + { + m_assembler.cmpq_ir(right, left); + } + + void compareImm64ForBranchEquality(RegisterID reg, int32_t imm) + { + if (!imm) + m_assembler.testq_rr(reg, reg); + else + m_assembler.cmpq_ir(imm, reg); + } + + void testImm64(RegisterID reg, Imm32 mask) + { + // if we are only interested in the low seven bits, this can be tested with a testb + if (mask.m_value == -1) + m_assembler.testq_rr(reg, reg); + else if ((mask.m_value & ~0x7f) == 0) + m_assembler.testb_i8r(mask.m_value, reg); + else + m_assembler.testq_i32r(mask.m_value, reg); + } + + void testImm64(Address address, Imm32 mask) + { + if (mask.m_value == -1) + m_assembler.cmpq_im(0, address.offset, address.base); + else + m_assembler.testq_i32m(mask.m_value, address.offset, address.base); + } + + void testImm64(BaseIndex address, Imm32 mask) + { + if (mask.m_value == -1) + m_assembler.cmpq_im(0, address.offset, address.base, address.index, address.scale); + else + m_assembler.testq_i32m(mask.m_value, address.offset, address.base, address.index, address.scale); + } +#endif + +public: + Jump ja32(RegisterID left, Imm32 right) + { + compareImm32ForBranch(left, right.m_value); + return Jump(m_assembler.ja()); + } + + Jump jaePtr(RegisterID left, RegisterID right) + { +#if PLATFORM(X86_64) + m_assembler.cmpq_rr(right, left); + return Jump(m_assembler.jae()); +#else + return jae32(left, right); +#endif + } + + Jump jaePtr(RegisterID reg, ImmPtr ptr) + { +#if PLATFORM(X86_64) + intptr_t imm = ptr.asIntptr(); + if (CAN_SIGN_EXTEND_32_64(imm)) { + compareImm64ForBranch(reg, imm); + return Jump(m_assembler.jae()); + } else { + move(ptr, scratchRegister); + return jaePtr(reg, scratchRegister); + } +#else + return jae32(reg, Imm32(ptr)); +#endif + } + + Jump jae32(RegisterID left, RegisterID right) + { + m_assembler.cmpl_rr(right, left); + return Jump(m_assembler.jae()); + } + + Jump jae32(RegisterID left, Imm32 right) + { + compareImm32ForBranch(left, right.m_value); + return Jump(m_assembler.jae()); + } + + Jump jae32(RegisterID left, Address right) + { + m_assembler.cmpl_mr(right.offset, right.base, left); + return Jump(m_assembler.jae()); + } + + Jump jae32(Address left, RegisterID right) + { + m_assembler.cmpl_rm(right, left.offset, left.base); + return Jump(m_assembler.jae()); + } + + Jump jbPtr(RegisterID left, RegisterID right) + { +#if PLATFORM(X86_64) + m_assembler.cmpq_rr(right, left); + return Jump(m_assembler.jb()); +#else + return jb32(left, right); +#endif + } + + Jump jbPtr(RegisterID reg, ImmPtr ptr) + { +#if PLATFORM(X86_64) + intptr_t imm = ptr.asIntptr(); + if (CAN_SIGN_EXTEND_32_64(imm)) { + compareImm64ForBranch(reg, imm); + return Jump(m_assembler.jb()); + } else { + move(ptr, scratchRegister); + return jbPtr(reg, scratchRegister); + } +#else + return jb32(reg, Imm32(ptr)); +#endif + } + + Jump jb32(RegisterID left, RegisterID right) + { + m_assembler.cmpl_rr(right, left); + return Jump(m_assembler.jb()); + } + + Jump jb32(RegisterID left, Imm32 right) + { + compareImm32ForBranch(left, right.m_value); + return Jump(m_assembler.jb()); + } + + Jump jb32(RegisterID left, Address right) + { + m_assembler.cmpl_mr(right.offset, right.base, left); + return Jump(m_assembler.jb()); + } + + Jump jePtr(RegisterID op1, RegisterID op2) + { +#if PLATFORM(X86_64) + m_assembler.cmpq_rr(op1, op2); + return Jump(m_assembler.je()); +#else + return je32(op1, op2); +#endif + } + + Jump jePtr(RegisterID reg, Address address) + { +#if PLATFORM(X86_64) + m_assembler.cmpq_rm(reg, address.offset, address.base); +#else + m_assembler.cmpl_rm(reg, address.offset, address.base); +#endif + return Jump(m_assembler.je()); + } + + Jump jePtr(RegisterID reg, ImmPtr ptr) + { +#if PLATFORM(X86_64) + intptr_t imm = ptr.asIntptr(); + if (CAN_SIGN_EXTEND_32_64(imm)) { + compareImm64ForBranchEquality(reg, imm); + return Jump(m_assembler.je()); + } else { + move(ptr, scratchRegister); + return jePtr(scratchRegister, reg); + } +#else + return je32(reg, Imm32(ptr)); +#endif + } + + Jump jePtr(Address address, ImmPtr imm) + { +#if PLATFORM(X86_64) + move(imm, scratchRegister); + return jePtr(scratchRegister, address); +#else + return je32(address, Imm32(imm)); +#endif + } + + Jump je32(RegisterID op1, RegisterID op2) + { + m_assembler.cmpl_rr(op1, op2); + return Jump(m_assembler.je()); + } + + Jump je32(Address op1, RegisterID op2) + { + m_assembler.cmpl_mr(op1.offset, op1.base, op2); + return Jump(m_assembler.je()); + } + + Jump je32(RegisterID reg, Imm32 imm) + { + compareImm32ForBranchEquality(reg, imm.m_value); + return Jump(m_assembler.je()); + } + + Jump je32(Address address, Imm32 imm) + { + compareImm32ForBranchEquality(address, imm.m_value); + return Jump(m_assembler.je()); + } + + Jump je16(RegisterID op1, BaseIndex op2) + { + m_assembler.cmpw_rm(op1, op2.offset, op2.base, op2.index, op2.scale); + return Jump(m_assembler.je()); + } + + Jump jg32(RegisterID left, RegisterID right) + { + m_assembler.cmpl_rr(right, left); + return Jump(m_assembler.jg()); + } + + Jump jg32(RegisterID reg, Address address) + { + m_assembler.cmpl_mr(address.offset, address.base, reg); + return Jump(m_assembler.jg()); + } + + Jump jgePtr(RegisterID left, RegisterID right) + { +#if PLATFORM(X86_64) + m_assembler.cmpq_rr(right, left); + return Jump(m_assembler.jge()); +#else + return jge32(left, right); +#endif + } + + Jump jgePtr(RegisterID reg, ImmPtr ptr) + { +#if PLATFORM(X86_64) + intptr_t imm = ptr.asIntptr(); + if (CAN_SIGN_EXTEND_32_64(imm)) { + compareImm64ForBranch(reg, imm); + return Jump(m_assembler.jge()); + } else { + move(ptr, scratchRegister); + return jgePtr(reg, scratchRegister); + } +#else + return jge32(reg, Imm32(ptr)); +#endif + } + + Jump jge32(RegisterID left, RegisterID right) + { + m_assembler.cmpl_rr(right, left); + return Jump(m_assembler.jge()); + } + + Jump jge32(RegisterID left, Imm32 right) + { + compareImm32ForBranch(left, right.m_value); + return Jump(m_assembler.jge()); + } + + Jump jlPtr(RegisterID left, RegisterID right) + { +#if PLATFORM(X86_64) + m_assembler.cmpq_rr(right, left); + return Jump(m_assembler.jl()); +#else + return jl32(left, right); +#endif + } + + Jump jlPtr(RegisterID reg, ImmPtr ptr) + { +#if PLATFORM(X86_64) + intptr_t imm = ptr.asIntptr(); + if (CAN_SIGN_EXTEND_32_64(imm)) { + compareImm64ForBranch(reg, imm); + return Jump(m_assembler.jl()); + } else { + move(ptr, scratchRegister); + return jlPtr(reg, scratchRegister); + } +#else + return jl32(reg, Imm32(ptr)); +#endif + } + + Jump jl32(RegisterID left, RegisterID right) + { + m_assembler.cmpl_rr(right, left); + return Jump(m_assembler.jl()); + } + + Jump jl32(RegisterID left, Imm32 right) + { + compareImm32ForBranch(left, right.m_value); + return Jump(m_assembler.jl()); + } + + Jump jlePtr(RegisterID left, RegisterID right) + { +#if PLATFORM(X86_64) + m_assembler.cmpq_rr(right, left); + return Jump(m_assembler.jle()); +#else + return jle32(left, right); +#endif + } + + Jump jlePtr(RegisterID reg, ImmPtr ptr) + { +#if PLATFORM(X86_64) + intptr_t imm = ptr.asIntptr(); + if (CAN_SIGN_EXTEND_32_64(imm)) { + compareImm64ForBranch(reg, imm); + return Jump(m_assembler.jle()); + } else { + move(ptr, scratchRegister); + return jlePtr(reg, scratchRegister); + } +#else + return jle32(reg, Imm32(ptr)); +#endif + } + + Jump jle32(RegisterID left, RegisterID right) + { + m_assembler.cmpl_rr(right, left); + return Jump(m_assembler.jle()); + } + + Jump jle32(RegisterID left, Imm32 right) + { + compareImm32ForBranch(left, right.m_value); + return Jump(m_assembler.jle()); + } + + Jump jnePtr(RegisterID op1, RegisterID op2) + { +#if PLATFORM(X86_64) + m_assembler.cmpq_rr(op1, op2); + return Jump(m_assembler.jne()); +#else + return jne32(op1, op2); +#endif + } + + Jump jnePtr(RegisterID reg, Address address) + { +#if PLATFORM(X86_64) + m_assembler.cmpq_rm(reg, address.offset, address.base); +#else + m_assembler.cmpl_rm(reg, address.offset, address.base); +#endif + return Jump(m_assembler.jne()); + } + + Jump jnePtr(RegisterID reg, AbsoluteAddress address) + { +#if PLATFORM(X86_64) + move(ImmPtr(address.m_ptr), scratchRegister); + return jnePtr(reg, Address(scratchRegister)); +#else + m_assembler.cmpl_rm(reg, address.m_ptr); + return Jump(m_assembler.jne()); +#endif + } + + Jump jnePtr(RegisterID reg, ImmPtr ptr) + { +#if PLATFORM(X86_64) + intptr_t imm = ptr.asIntptr(); + if (CAN_SIGN_EXTEND_32_64(imm)) { + compareImm64ForBranchEquality(reg, imm); + return Jump(m_assembler.jne()); + } else { + move(ptr, scratchRegister); + return jnePtr(scratchRegister, reg); + } +#else + return jne32(reg, Imm32(ptr)); +#endif + } + + Jump jnePtr(Address address, ImmPtr imm) + { +#if PLATFORM(X86_64) + move(imm, scratchRegister); + return jnePtr(scratchRegister, address); +#else + return jne32(address, Imm32(imm)); +#endif + } + +#if !PLATFORM(X86_64) + Jump jnePtr(AbsoluteAddress address, ImmPtr imm) + { + m_assembler.cmpl_im(imm.asIntptr(), address.m_ptr); + return Jump(m_assembler.jne()); + } +#endif + + Jump jnePtrWithPatch(RegisterID reg, DataLabelPtr& dataLabel, ImmPtr initialValue = ImmPtr(0)) + { +#if PLATFORM(X86_64) + m_assembler.movq_i64r(initialValue.asIntptr(), scratchRegister); + dataLabel = DataLabelPtr(this); + return jnePtr(scratchRegister, reg); +#else + m_assembler.cmpl_ir_force32(initialValue.asIntptr(), reg); + dataLabel = DataLabelPtr(this); + return Jump(m_assembler.jne()); +#endif + } + + Jump jnePtrWithPatch(Address address, DataLabelPtr& dataLabel, ImmPtr initialValue = ImmPtr(0)) + { +#if PLATFORM(X86_64) + m_assembler.movq_i64r(initialValue.asIntptr(), scratchRegister); + dataLabel = DataLabelPtr(this); + return jnePtr(scratchRegister, address); +#else + m_assembler.cmpl_im_force32(initialValue.asIntptr(), address.offset, address.base); + dataLabel = DataLabelPtr(this); + return Jump(m_assembler.jne()); +#endif + } + + Jump jne32(RegisterID op1, RegisterID op2) + { + m_assembler.cmpl_rr(op1, op2); + return Jump(m_assembler.jne()); + } + + Jump jne32(RegisterID reg, Imm32 imm) + { + compareImm32ForBranchEquality(reg, imm.m_value); + return Jump(m_assembler.jne()); + } + + Jump jne32(Address address, Imm32 imm) + { + compareImm32ForBranchEquality(address, imm.m_value); + return Jump(m_assembler.jne()); + } + + Jump jne32(Address address, RegisterID reg) + { + m_assembler.cmpl_rm(reg, address.offset, address.base); + return Jump(m_assembler.jne()); + } + + Jump jnzPtr(RegisterID reg, RegisterID mask) + { +#if PLATFORM(X86_64) + m_assembler.testq_rr(reg, mask); + return Jump(m_assembler.jne()); +#else + return jnz32(reg, mask); +#endif + } + + Jump jnzPtr(RegisterID reg, Imm32 mask = Imm32(-1)) + { +#if PLATFORM(X86_64) + testImm64(reg, mask); + return Jump(m_assembler.jne()); +#else + return jnz32(reg, mask); +#endif + } + + Jump jnzPtr(RegisterID reg, ImmPtr mask) + { +#if PLATFORM(X86_64) + move(mask, scratchRegister); + m_assembler.testq_rr(scratchRegister, reg); + return Jump(m_assembler.jne()); +#else + return jnz32(reg, Imm32(mask)); +#endif + } + + Jump jnzPtr(Address address, Imm32 mask = Imm32(-1)) + { +#if PLATFORM(X86_64) + testImm64(address, mask); + return Jump(m_assembler.jne()); +#else + return jnz32(address, mask); +#endif + } + + Jump jnz32(RegisterID reg, RegisterID mask) + { + m_assembler.testl_rr(reg, mask); + return Jump(m_assembler.jne()); + } + + Jump jnz32(RegisterID reg, Imm32 mask = Imm32(-1)) + { + testImm32(reg, mask); + return Jump(m_assembler.jne()); + } + + Jump jnz32(Address address, Imm32 mask = Imm32(-1)) + { + testImm32(address, mask); + return Jump(m_assembler.jne()); + } + + Jump jzPtr(RegisterID reg, RegisterID mask) + { +#if PLATFORM(X86_64) + m_assembler.testq_rr(reg, mask); + return Jump(m_assembler.je()); +#else + return jz32(reg, mask); +#endif + } + + Jump jzPtr(RegisterID reg, Imm32 mask = Imm32(-1)) + { +#if PLATFORM(X86_64) + testImm64(reg, mask); + return Jump(m_assembler.je()); +#else + return jz32(reg, mask); +#endif + } + + Jump jzPtr(RegisterID reg, ImmPtr mask) + { +#if PLATFORM(X86_64) + move(mask, scratchRegister); + m_assembler.testq_rr(scratchRegister, reg); + return Jump(m_assembler.je()); +#else + return jz32(reg, Imm32(mask)); +#endif + } + + Jump jzPtr(Address address, Imm32 mask = Imm32(-1)) + { +#if PLATFORM(X86_64) + testImm64(address, mask); + return Jump(m_assembler.je()); +#else + return jz32(address, mask); +#endif + } + + Jump jzPtr(BaseIndex address, Imm32 mask = Imm32(-1)) + { +#if PLATFORM(X86_64) + testImm64(address, mask); + return Jump(m_assembler.je()); +#else + return jz32(address, mask); +#endif + } + + Jump jz32(RegisterID reg, RegisterID mask) + { + m_assembler.testl_rr(reg, mask); + return Jump(m_assembler.je()); + } + + Jump jz32(RegisterID reg, Imm32 mask = Imm32(-1)) + { + testImm32(reg, mask); + return Jump(m_assembler.je()); + } + + Jump jz32(Address address, Imm32 mask = Imm32(-1)) + { + testImm32(address, mask); + return Jump(m_assembler.je()); + } + + Jump jz32(BaseIndex address, Imm32 mask = Imm32(-1)) + { + testImm32(address, mask); + return Jump(m_assembler.je()); + } + + Jump jump() + { + return Jump(m_assembler.jmp()); + } + + + // Backwards, local control flow operations: + // + // These operations provide a shorter notation for local + // backwards branches, which may be both more convenient + // for the user, and for the programmer, and for the + // assembler (allowing shorter values to be used in + // relative offsets). + // + // The code sequence: + // + // Label topOfLoop(this); + // // ... + // jne32(reg1, reg2, topOfLoop); + // + // Is equivalent to the longer, potentially less efficient form: + // + // Label topOfLoop(this); + // // ... + // jne32(reg1, reg2).linkTo(topOfLoop); + + void jae32(RegisterID left, Address right, Label target) + { + jae32(left, right).linkTo(target, this); + } + + void je32(RegisterID op1, Imm32 imm, Label target) + { + je32(op1, imm).linkTo(target, this); + } + + void je16(RegisterID op1, BaseIndex op2, Label target) + { + je16(op1, op2).linkTo(target, this); + } + + void jl32(RegisterID left, Imm32 right, Label target) + { + jl32(left, right).linkTo(target, this); + } + + void jle32(RegisterID left, RegisterID right, Label target) + { + jle32(left, right).linkTo(target, this); + } + + void jnePtr(RegisterID op1, ImmPtr imm, Label target) + { + jnePtr(op1, imm).linkTo(target, this); + } + + void jne32(RegisterID op1, RegisterID op2, Label target) + { + jne32(op1, op2).linkTo(target, this); + } + + void jne32(RegisterID op1, Imm32 imm, Label target) + { + jne32(op1, imm).linkTo(target, this); + } + + void jzPtr(RegisterID reg, Label target) + { + jzPtr(reg).linkTo(target, this); + } + + void jump(Label target) + { + m_assembler.link(m_assembler.jmp(), target.m_label); + } + + void jump(RegisterID target) + { + m_assembler.jmp_r(target); + } + + // Address is a memory location containing the address to jump to + void jump(Address address) + { + m_assembler.jmp_m(address.offset, address.base); + } + + + // Arithmetic control flow operations: + // + // This set of conditional branch operations branch based + // on the result of an arithmetic operation. The operation + // is performed as normal, storing the result. + // + // * jz operations branch if the result is zero. + // * jo operations branch if the (signed) arithmetic + // operation caused an overflow to occur. + + Jump jnzSubPtr(Imm32 imm, RegisterID dest) + { + subPtr(imm, dest); + return Jump(m_assembler.jne()); + } + + Jump jnzSub32(Imm32 imm, RegisterID dest) + { + sub32(imm, dest); + return Jump(m_assembler.jne()); + } + + Jump joAddPtr(RegisterID src, RegisterID dest) + { + addPtr(src, dest); + return Jump(m_assembler.jo()); + } + + Jump joAdd32(RegisterID src, RegisterID dest) + { + add32(src, dest); + return Jump(m_assembler.jo()); + } + + Jump joAdd32(Imm32 imm, RegisterID dest) + { + add32(imm, dest); + return Jump(m_assembler.jo()); + } + + Jump joMul32(RegisterID src, RegisterID dest) + { + mul32(src, dest); + return Jump(m_assembler.jo()); + } + + Jump joMul32(Imm32 imm, RegisterID src, RegisterID dest) + { + mul32(imm, src, dest); + return Jump(m_assembler.jo()); + } + + Jump joSub32(RegisterID src, RegisterID dest) + { + sub32(src, dest); + return Jump(m_assembler.jo()); + } + + Jump joSub32(Imm32 imm, RegisterID dest) + { + sub32(imm, dest); + return Jump(m_assembler.jo()); + } + + Jump jzSubPtr(Imm32 imm, RegisterID dest) + { + subPtr(imm, dest); + return Jump(m_assembler.je()); + } + + Jump jzSub32(Imm32 imm, RegisterID dest) + { + sub32(imm, dest); + return Jump(m_assembler.je()); + } + + + // Miscellaneous operations: + + void breakpoint() + { + m_assembler.int3(); + } + + Jump call() + { + return Jump(m_assembler.call()); + } + + // FIXME: why does this return a Jump object? - it can't be linked. + // This may be to get a reference to the return address of the call. + // + // This should probably be handled by a separate label type to a regular + // jump. Todo: add a CallLabel type, for the regular call - can be linked + // like a jump (possibly a subclass of jump?, or possibly casts to a Jump). + // Also add a CallReturnLabel type for this to return (just a more JmpDsty + // form of label, can get the void* after the code has been linked, but can't + // try to link it like a Jump object), and let the CallLabel be cast into a + // CallReturnLabel. + Jump call(RegisterID target) + { + return Jump(m_assembler.call(target)); + } + + Label label() + { + return Label(this); + } + + Label align() + { + m_assembler.align(16); + return Label(this); + } + + ptrdiff_t differenceBetween(Label from, Jump to) + { + return X86Assembler::getDifferenceBetweenLabels(from.m_label, to.m_jmp); + } + + ptrdiff_t differenceBetween(Label from, Label to) + { + return X86Assembler::getDifferenceBetweenLabels(from.m_label, to.m_label); + } + + ptrdiff_t differenceBetween(Label from, DataLabelPtr to) + { + return X86Assembler::getDifferenceBetweenLabels(from.m_label, to.m_label); + } + + ptrdiff_t differenceBetween(Label from, DataLabel32 to) + { + return X86Assembler::getDifferenceBetweenLabels(from.m_label, to.m_label); + } + + ptrdiff_t differenceBetween(DataLabelPtr from, Jump to) + { + return X86Assembler::getDifferenceBetweenLabels(from.m_label, to.m_jmp); + } + + void ret() + { + m_assembler.ret(); + } + + void sete32(RegisterID src, RegisterID srcDest) + { + m_assembler.cmpl_rr(srcDest, src); + m_assembler.sete_r(srcDest); + m_assembler.movzbl_rr(srcDest, srcDest); + } + + void sete32(Imm32 imm, RegisterID srcDest) + { + compareImm32ForBranchEquality(srcDest, imm.m_value); + m_assembler.sete_r(srcDest); + m_assembler.movzbl_rr(srcDest, srcDest); + } + + void setne32(RegisterID src, RegisterID srcDest) + { + m_assembler.cmpl_rr(srcDest, src); + m_assembler.setne_r(srcDest); + m_assembler.movzbl_rr(srcDest, srcDest); + } + + void setne32(Imm32 imm, RegisterID srcDest) + { + compareImm32ForBranchEquality(srcDest, imm.m_value); + m_assembler.setne_r(srcDest); + m_assembler.movzbl_rr(srcDest, srcDest); + } + + // FIXME: + // The mask should be optional... paerhaps the argument order should be + // dest-src, operations always have a dest? ... possibly not true, considering + // asm ops like test, or pseudo ops like pop(). + void setnz32(Address address, Imm32 mask, RegisterID dest) + { + testImm32(address, mask); + m_assembler.setnz_r(dest); + m_assembler.movzbl_rr(dest, dest); + } + + void setz32(Address address, Imm32 mask, RegisterID dest) + { + testImm32(address, mask); + m_assembler.setz_r(dest); + m_assembler.movzbl_rr(dest, dest); + } +}; + +} // namespace JSC + +#endif // ENABLE(ASSEMBLER) + +#endif // MacroAssembler_h diff --git a/assembler/X86Assembler.h b/assembler/X86Assembler.h new file mode 100644 index 0000000..de23e45 --- /dev/null +++ b/assembler/X86Assembler.h @@ -0,0 +1,1704 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef X86Assembler_h +#define X86Assembler_h + +#include + +#if ENABLE(ASSEMBLER) && (PLATFORM(X86) || PLATFORM(X86_64)) + +#include "AssemblerBuffer.h" +#include +#include +#include + +namespace JSC { + +inline bool CAN_SIGN_EXTEND_8_32(int32_t value) { return value == (int32_t)(signed char)value; } +#if PLATFORM(X86_64) +inline bool CAN_SIGN_EXTEND_32_64(intptr_t value) { return value == (intptr_t)(int32_t)value; } +inline bool CAN_SIGN_EXTEND_U32_64(intptr_t value) { return value == (intptr_t)(uint32_t)value; } +#endif + +namespace X86 { + typedef enum { + eax, + ecx, + edx, + ebx, + esp, + ebp, + esi, + edi, + +#if PLATFORM(X86_64) + r8, + r9, + r10, + r11, + r12, + r13, + r14, + r15, +#endif + } RegisterID; + + typedef enum { + xmm0, + xmm1, + xmm2, + xmm3, + xmm4, + xmm5, + xmm6, + xmm7, + } XMMRegisterID; +} + +class X86Assembler { +public: + typedef X86::RegisterID RegisterID; + typedef X86::XMMRegisterID XMMRegisterID; + + typedef enum { + OP_ADD_EvGv = 0x01, + OP_ADD_GvEv = 0x03, + OP_OR_EvGv = 0x09, + OP_OR_GvEv = 0x0B, + OP_2BYTE_ESCAPE = 0x0F, + OP_AND_EvGv = 0x21, + OP_SUB_EvGv = 0x29, + OP_SUB_GvEv = 0x2B, + PRE_PREDICT_BRANCH_NOT_TAKEN = 0x2E, + OP_XOR_EvGv = 0x31, + OP_CMP_EvGv = 0x39, + OP_CMP_GvEv = 0x3B, +#if PLATFORM(X86_64) + PRE_REX = 0x40, +#endif + OP_PUSH_EAX = 0x50, + OP_POP_EAX = 0x58, +#if PLATFORM(X86_64) + OP_MOVSXD_GvEv = 0x63, +#endif + PRE_OPERAND_SIZE = 0x66, + PRE_SSE_66 = 0x66, + OP_PUSH_Iz = 0x68, + OP_IMUL_GvEvIz = 0x69, + OP_GROUP1_EvIz = 0x81, + OP_GROUP1_EvIb = 0x83, + OP_TEST_EvGv = 0x85, + OP_XCHG_EvGv = 0x87, + OP_MOV_EvGv = 0x89, + OP_MOV_GvEv = 0x8B, + OP_LEA = 0x8D, + OP_GROUP1A_Ev = 0x8F, + OP_CDQ = 0x99, + OP_MOV_EAXOv = 0xA1, + OP_MOV_OvEAX = 0xA3, + OP_MOV_EAXIv = 0xB8, + OP_GROUP2_EvIb = 0xC1, + OP_RET = 0xC3, + OP_GROUP11_EvIz = 0xC7, + OP_INT3 = 0xCC, + OP_GROUP2_Ev1 = 0xD1, + OP_GROUP2_EvCL = 0xD3, + OP_CALL_rel32 = 0xE8, + OP_JMP_rel32 = 0xE9, + PRE_SSE_F2 = 0xF2, + OP_HLT = 0xF4, + OP_GROUP3_EbIb = 0xF6, + OP_GROUP3_Ev = 0xF7, + OP_GROUP3_EvIz = 0xF7, // OP_GROUP3_Ev has an immediate, when instruction is a test. + OP_GROUP5_Ev = 0xFF, + } OneByteOpcodeID; + + typedef enum { + OP2_MOVSD_VsdWsd = 0x10, + OP2_MOVSD_WsdVsd = 0x11, + OP2_CVTSI2SD_VsdEd = 0x2A, + OP2_CVTTSD2SI_GdWsd = 0x2C, + OP2_UCOMISD_VsdWsd = 0x2E, + OP2_ADDSD_VsdWsd = 0x58, + OP2_MULSD_VsdWsd = 0x59, + OP2_SUBSD_VsdWsd = 0x5C, + OP2_MOVD_VdEd = 0x6E, + OP2_MOVD_EdVd = 0x7E, + OP2_JO_rel32 = 0x80, + OP2_JB_rel32 = 0x82, + OP2_JAE_rel32 = 0x83, + OP2_JE_rel32 = 0x84, + OP2_JNE_rel32 = 0x85, + OP2_JBE_rel32 = 0x86, + OP2_JA_rel32 = 0x87, + OP2_JS_rel32 = 0x88, + OP2_JP_rel32 = 0x8A, + OP2_JL_rel32 = 0x8C, + OP2_JGE_rel32 = 0x8D, + OP2_JLE_rel32 = 0x8E, + OP2_JG_rel32 = 0x8F, + OP_SETE = 0x94, + OP_SETNE = 0x95, + OP2_IMUL_GvEv = 0xAF, + OP2_MOVZX_GvEb = 0xB6, + OP2_MOVZX_GvEw = 0xB7, + OP2_PEXTRW_GdUdIb = 0xC5, + } TwoByteOpcodeID; + + typedef enum { + GROUP1_OP_ADD = 0, + GROUP1_OP_OR = 1, + GROUP1_OP_AND = 4, + GROUP1_OP_SUB = 5, + GROUP1_OP_XOR = 6, + GROUP1_OP_CMP = 7, + + GROUP1A_OP_POP = 0, + + GROUP2_OP_SHL = 4, + GROUP2_OP_SAR = 7, + + GROUP3_OP_TEST = 0, + GROUP3_OP_NOT = 2, + GROUP3_OP_IDIV = 7, + + GROUP5_OP_CALLN = 2, + GROUP5_OP_JMPN = 4, + GROUP5_OP_PUSH = 6, + + GROUP11_MOV = 0, + } GroupOpcodeID; + + // Opaque label types + +private: + class X86InstructionFormatter; +public: + + class JmpSrc { + friend class X86Assembler; + friend class X86InstructionFormatter; + public: + JmpSrc() + : m_offset(-1) + { + } + + private: + JmpSrc(int offset) + : m_offset(offset) + { + } + + int m_offset; + }; + + class JmpDst { + friend class X86Assembler; + friend class X86InstructionFormatter; + public: + JmpDst() + : m_offset(-1) + { + } + + private: + JmpDst(int offset) + : m_offset(offset) + { + } + + int m_offset; + }; + + X86Assembler() + { + } + + size_t size() const { return m_formatter.size(); } + + // Stack operations: + + void push_r(RegisterID reg) + { + m_formatter.oneByteOp(OP_PUSH_EAX, reg); + } + + void pop_r(RegisterID reg) + { + m_formatter.oneByteOp(OP_POP_EAX, reg); + } + + void push_i32(int imm) + { + m_formatter.oneByteOp(OP_PUSH_Iz); + m_formatter.immediate32(imm); + } + + void push_m(int offset, RegisterID base) + { + m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_PUSH, base, offset); + } + + void pop_m(int offset, RegisterID base) + { + m_formatter.oneByteOp(OP_GROUP1A_Ev, GROUP1A_OP_POP, base, offset); + } + + // Arithmetic operations: + + void addl_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp(OP_ADD_EvGv, src, dst); + } + + void addl_mr(int offset, RegisterID base, RegisterID dst) + { + m_formatter.oneByteOp(OP_ADD_GvEv, dst, base, offset); + } + + void addl_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_ADD, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_ADD, dst); + m_formatter.immediate32(imm); + } + } + + void addl_im(int imm, int offset, RegisterID base) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_ADD, base, offset); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_ADD, base, offset); + m_formatter.immediate32(imm); + } + } + +#if PLATFORM(X86_64) + void addq_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp64(OP_ADD_EvGv, src, dst); + } + + void addq_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_ADD, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_ADD, dst); + m_formatter.immediate32(imm); + } + } +#else + void addl_im(int imm, void* addr) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_ADD, addr); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_ADD, addr); + m_formatter.immediate32(imm); + } + } +#endif + + void andl_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp(OP_AND_EvGv, src, dst); + } + + void andl_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_AND, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_AND, dst); + m_formatter.immediate32(imm); + } + } + +#if PLATFORM(X86_64) + void andq_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp64(OP_AND_EvGv, src, dst); + } + + void andq_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_AND, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_AND, dst); + m_formatter.immediate32(imm); + } + } +#endif + + void notl_r(RegisterID dst) + { + m_formatter.oneByteOp(OP_GROUP3_Ev, GROUP3_OP_NOT, dst); + } + + void orl_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp(OP_OR_EvGv, src, dst); + } + + void orl_mr(int offset, RegisterID base, RegisterID dst) + { + m_formatter.oneByteOp(OP_OR_GvEv, dst, base, offset); + } + + void orl_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_OR, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_OR, dst); + m_formatter.immediate32(imm); + } + } + +#if PLATFORM(X86_64) + void orq_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp64(OP_OR_EvGv, src, dst); + } + + void orq_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_OR, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_OR, dst); + m_formatter.immediate32(imm); + } + } +#endif + + void subl_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp(OP_SUB_EvGv, src, dst); + } + + void subl_mr(int offset, RegisterID base, RegisterID dst) + { + m_formatter.oneByteOp(OP_SUB_GvEv, dst, base, offset); + } + + void subl_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_SUB, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_SUB, dst); + m_formatter.immediate32(imm); + } + } + + void subl_im(int imm, int offset, RegisterID base) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_SUB, base, offset); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_SUB, base, offset); + m_formatter.immediate32(imm); + } + } + +#if PLATFORM(X86_64) + void subq_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp64(OP_SUB_EvGv, src, dst); + } + + void subq_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_SUB, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_SUB, dst); + m_formatter.immediate32(imm); + } + } +#else + void subl_im(int imm, void* addr) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_SUB, addr); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_SUB, addr); + m_formatter.immediate32(imm); + } + } +#endif + + void xorl_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp(OP_XOR_EvGv, src, dst); + } + + void xorl_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_XOR, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_XOR, dst); + m_formatter.immediate32(imm); + } + } + +#if PLATFORM(X86_64) + void xorq_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp64(OP_XOR_EvGv, src, dst); + } + + void xorq_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_XOR, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_XOR, dst); + m_formatter.immediate32(imm); + } + } +#endif + + void sarl_i8r(int imm, RegisterID dst) + { + if (imm == 1) + m_formatter.oneByteOp(OP_GROUP2_Ev1, GROUP2_OP_SAR, dst); + else { + m_formatter.oneByteOp(OP_GROUP2_EvIb, GROUP2_OP_SAR, dst); + m_formatter.immediate8(imm); + } + } + + void sarl_CLr(RegisterID dst) + { + m_formatter.oneByteOp(OP_GROUP2_EvCL, GROUP2_OP_SAR, dst); + } + + void shll_i8r(int imm, RegisterID dst) + { + if (imm == 1) + m_formatter.oneByteOp(OP_GROUP2_Ev1, GROUP2_OP_SHL, dst); + else { + m_formatter.oneByteOp(OP_GROUP2_EvIb, GROUP2_OP_SHL, dst); + m_formatter.immediate8(imm); + } + } + + void shll_CLr(RegisterID dst) + { + m_formatter.oneByteOp(OP_GROUP2_EvCL, GROUP2_OP_SHL, dst); + } + +#if PLATFORM(X86_64) + void sarq_CLr(RegisterID dst) + { + m_formatter.oneByteOp64(OP_GROUP2_EvCL, GROUP2_OP_SAR, dst); + } + + void sarq_i8r(int imm, RegisterID dst) + { + if (imm == 1) + m_formatter.oneByteOp64(OP_GROUP2_Ev1, GROUP2_OP_SAR, dst); + else { + m_formatter.oneByteOp64(OP_GROUP2_EvIb, GROUP2_OP_SAR, dst); + m_formatter.immediate8(imm); + } + } +#endif + + void imull_rr(RegisterID src, RegisterID dst) + { + m_formatter.twoByteOp(OP2_IMUL_GvEv, dst, src); + } + + void imull_i32r(RegisterID src, int32_t value, RegisterID dst) + { + m_formatter.oneByteOp(OP_IMUL_GvEvIz, dst, src); + m_formatter.immediate32(value); + } + + void idivl_r(RegisterID dst) + { + m_formatter.oneByteOp(OP_GROUP3_Ev, GROUP3_OP_IDIV, dst); + } + + // Comparisons: + + void cmpl_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp(OP_CMP_EvGv, src, dst); + } + + void cmpl_rm(RegisterID src, int offset, RegisterID base) + { + m_formatter.oneByteOp(OP_CMP_EvGv, src, base, offset); + } + + void cmpl_mr(int offset, RegisterID base, RegisterID src) + { + m_formatter.oneByteOp(OP_CMP_GvEv, src, base, offset); + } + + void cmpl_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_CMP, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, dst); + m_formatter.immediate32(imm); + } + } + + void cmpl_ir_force32(int imm, RegisterID dst) + { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, dst); + m_formatter.immediate32(imm); + } + + void cmpl_im(int imm, int offset, RegisterID base) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_CMP, base, offset); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, offset); + m_formatter.immediate32(imm); + } + } + + void cmpl_im(int imm, int offset, RegisterID base, RegisterID index, int scale) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_CMP, base, index, scale, offset); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, index, scale, offset); + m_formatter.immediate32(imm); + } + } + + void cmpl_im_force32(int imm, int offset, RegisterID base) + { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, offset); + m_formatter.immediate32(imm); + } + +#if PLATFORM(X86_64) + void cmpq_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp64(OP_CMP_EvGv, src, dst); + } + + void cmpq_rm(RegisterID src, int offset, RegisterID base) + { + m_formatter.oneByteOp64(OP_CMP_EvGv, src, base, offset); + } + + void cmpq_ir(int imm, RegisterID dst) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_CMP, dst); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_CMP, dst); + m_formatter.immediate32(imm); + } + } + + void cmpq_im(int imm, int offset, RegisterID base) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_CMP, base, offset); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, offset); + m_formatter.immediate32(imm); + } + } + + void cmpq_im(int imm, int offset, RegisterID base, RegisterID index, int scale) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_CMP, base, index, scale, offset); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, index, scale, offset); + m_formatter.immediate32(imm); + } + } +#else + void cmpl_rm(RegisterID reg, void* addr) + { + m_formatter.oneByteOp(OP_CMP_EvGv, reg, addr); + } + + void cmpl_im(int imm, void* addr) + { + if (CAN_SIGN_EXTEND_8_32(imm)) { + m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_CMP, addr); + m_formatter.immediate8(imm); + } else { + m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, addr); + m_formatter.immediate32(imm); + } + } +#endif + + void cmpw_rm(RegisterID src, int offset, RegisterID base, RegisterID index, int scale) + { + m_formatter.prefix(PRE_OPERAND_SIZE); + m_formatter.oneByteOp(OP_CMP_EvGv, src, base, index, scale, offset); + } + + void testl_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp(OP_TEST_EvGv, src, dst); + } + + void testl_i32r(int imm, RegisterID dst) + { + m_formatter.oneByteOp(OP_GROUP3_EvIz, GROUP3_OP_TEST, dst); + m_formatter.immediate32(imm); + } + + void testl_i32m(int imm, int offset, RegisterID base) + { + m_formatter.oneByteOp(OP_GROUP3_EvIz, GROUP3_OP_TEST, base, offset); + m_formatter.immediate32(imm); + } + + void testl_i32m(int imm, int offset, RegisterID base, RegisterID index, int scale) + { + m_formatter.oneByteOp(OP_GROUP3_EvIz, GROUP3_OP_TEST, base, index, scale, offset); + m_formatter.immediate32(imm); + } + +#if PLATFORM(X86_64) + void testq_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp64(OP_TEST_EvGv, src, dst); + } + + void testq_i32r(int imm, RegisterID dst) + { + m_formatter.oneByteOp64(OP_GROUP3_EvIz, GROUP3_OP_TEST, dst); + m_formatter.immediate32(imm); + } + + void testq_i32m(int imm, int offset, RegisterID base) + { + m_formatter.oneByteOp64(OP_GROUP3_EvIz, GROUP3_OP_TEST, base, offset); + m_formatter.immediate32(imm); + } + + void testq_i32m(int imm, int offset, RegisterID base, RegisterID index, int scale) + { + m_formatter.oneByteOp64(OP_GROUP3_EvIz, GROUP3_OP_TEST, base, index, scale, offset); + m_formatter.immediate32(imm); + } +#endif + + void testb_i8r(int imm, RegisterID dst) + { + m_formatter.oneByteOp8(OP_GROUP3_EbIb, GROUP3_OP_TEST, dst); + m_formatter.immediate8(imm); + } + + void sete_r(RegisterID dst) + { + m_formatter.twoByteOp8(OP_SETE, (GroupOpcodeID)0, dst); + } + + void setz_r(RegisterID dst) + { + sete_r(dst); + } + + void setne_r(RegisterID dst) + { + m_formatter.twoByteOp8(OP_SETNE, (GroupOpcodeID)0, dst); + } + + void setnz_r(RegisterID dst) + { + setne_r(dst); + } + + // Various move ops: + + void cdq() + { + m_formatter.oneByteOp(OP_CDQ); + } + + void xchgl_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp(OP_XCHG_EvGv, src, dst); + } + +#if PLATFORM(X86_64) + void xchgq_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp64(OP_XCHG_EvGv, src, dst); + } +#endif + + void movl_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp(OP_MOV_EvGv, src, dst); + } + + void movl_rm(RegisterID src, int offset, RegisterID base) + { + m_formatter.oneByteOp(OP_MOV_EvGv, src, base, offset); + } + + void movl_rm_disp32(RegisterID src, int offset, RegisterID base) + { + m_formatter.oneByteOp_disp32(OP_MOV_EvGv, src, base, offset); + } + + void movl_rm(RegisterID src, int offset, RegisterID base, RegisterID index, int scale) + { + m_formatter.oneByteOp(OP_MOV_EvGv, src, base, index, scale, offset); + } + + void movl_mEAX(void* addr) + { + m_formatter.oneByteOp(OP_MOV_EAXOv); +#if PLATFORM(X86_64) + m_formatter.immediate64(reinterpret_cast(addr)); +#else + m_formatter.immediate32(reinterpret_cast(addr)); +#endif + } + + void movl_mr(int offset, RegisterID base, RegisterID dst) + { + m_formatter.oneByteOp(OP_MOV_GvEv, dst, base, offset); + } + + void movl_mr_disp32(int offset, RegisterID base, RegisterID dst) + { + m_formatter.oneByteOp_disp32(OP_MOV_GvEv, dst, base, offset); + } + + void movl_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst) + { + m_formatter.oneByteOp(OP_MOV_GvEv, dst, base, index, scale, offset); + } + + void movl_i32r(int imm, RegisterID dst) + { + m_formatter.oneByteOp(OP_MOV_EAXIv, dst); + m_formatter.immediate32(imm); + } + + void movl_i32m(int imm, int offset, RegisterID base) + { + m_formatter.oneByteOp(OP_GROUP11_EvIz, GROUP11_MOV, base, offset); + m_formatter.immediate32(imm); + } + + void movl_EAXm(void* addr) + { + m_formatter.oneByteOp(OP_MOV_OvEAX); +#if PLATFORM(X86_64) + m_formatter.immediate64(reinterpret_cast(addr)); +#else + m_formatter.immediate32(reinterpret_cast(addr)); +#endif + } + +#if PLATFORM(X86_64) + void movq_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp64(OP_MOV_EvGv, src, dst); + } + + void movq_rm(RegisterID src, int offset, RegisterID base) + { + m_formatter.oneByteOp64(OP_MOV_EvGv, src, base, offset); + } + + void movq_rm_disp32(RegisterID src, int offset, RegisterID base) + { + m_formatter.oneByteOp64_disp32(OP_MOV_EvGv, src, base, offset); + } + + void movq_rm(RegisterID src, int offset, RegisterID base, RegisterID index, int scale) + { + m_formatter.oneByteOp64(OP_MOV_EvGv, src, base, index, scale, offset); + } + + void movq_mEAX(void* addr) + { + m_formatter.oneByteOp64(OP_MOV_EAXOv); + m_formatter.immediate64(reinterpret_cast(addr)); + } + + void movq_mr(int offset, RegisterID base, RegisterID dst) + { + m_formatter.oneByteOp64(OP_MOV_GvEv, dst, base, offset); + } + + void movq_mr_disp32(int offset, RegisterID base, RegisterID dst) + { + m_formatter.oneByteOp64_disp32(OP_MOV_GvEv, dst, base, offset); + } + + void movq_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst) + { + m_formatter.oneByteOp64(OP_MOV_GvEv, dst, base, index, scale, offset); + } + + void movq_i64r(int64_t imm, RegisterID dst) + { + m_formatter.oneByteOp64(OP_MOV_EAXIv, dst); + m_formatter.immediate64(imm); + } + + void movsxd_rr(RegisterID src, RegisterID dst) + { + m_formatter.oneByteOp64(OP_MOVSXD_GvEv, dst, src); + } + + +#else + void movl_mr(void* addr, RegisterID dst) + { + if (dst == X86::eax) + movl_mEAX(addr); + else + m_formatter.oneByteOp(OP_MOV_GvEv, dst, addr); + } + + void movl_i32m(int imm, void* addr) + { + m_formatter.oneByteOp(OP_GROUP11_EvIz, GROUP11_MOV, addr); + m_formatter.immediate32(imm); + } +#endif + + void movzwl_mr(int offset, RegisterID base, RegisterID dst) + { + m_formatter.twoByteOp(OP2_MOVZX_GvEw, dst, base, offset); + } + + void movzwl_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst) + { + m_formatter.twoByteOp(OP2_MOVZX_GvEw, dst, base, index, scale, offset); + } + + void movzbl_rr(RegisterID src, RegisterID dst) + { + // In 64-bit, this may cause an unnecessary REX to be planted (if the dst register + // is in the range ESP-EDI, and the src would not have required a REX). Unneeded + // REX prefixes are defined to be silently ignored by the processor. + m_formatter.twoByteOp8(OP2_MOVZX_GvEb, dst, src); + } + + void leal_mr(int offset, RegisterID base, RegisterID dst) + { + m_formatter.oneByteOp(OP_LEA, dst, base, offset); + } + + // Flow control: + + JmpSrc call() + { + m_formatter.oneByteOp(OP_CALL_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc call(RegisterID dst) + { + m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_CALLN, dst); + return JmpSrc(m_formatter.size()); + } + + JmpSrc jmp() + { + m_formatter.oneByteOp(OP_JMP_rel32); + return m_formatter.immediateRel32(); + } + + void jmp_r(RegisterID dst) + { + m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_JMPN, dst); + } + + void jmp_m(int offset, RegisterID base) + { + m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_JMPN, base, offset); + } + + JmpSrc jne() + { + m_formatter.twoByteOp(OP2_JNE_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc jnz() + { + return jne(); + } + + JmpSrc je() + { + m_formatter.twoByteOp(OP2_JE_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc jl() + { + m_formatter.twoByteOp(OP2_JL_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc jb() + { + m_formatter.twoByteOp(OP2_JB_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc jle() + { + m_formatter.twoByteOp(OP2_JLE_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc jbe() + { + m_formatter.twoByteOp(OP2_JBE_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc jge() + { + m_formatter.twoByteOp(OP2_JGE_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc jg() + { + m_formatter.twoByteOp(OP2_JG_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc ja() + { + m_formatter.twoByteOp(OP2_JA_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc jae() + { + m_formatter.twoByteOp(OP2_JAE_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc jo() + { + m_formatter.twoByteOp(OP2_JO_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc jp() + { + m_formatter.twoByteOp(OP2_JP_rel32); + return m_formatter.immediateRel32(); + } + + JmpSrc js() + { + m_formatter.twoByteOp(OP2_JS_rel32); + return m_formatter.immediateRel32(); + } + + // SSE operations: + + void addsd_rr(XMMRegisterID src, XMMRegisterID dst) + { + m_formatter.prefix(PRE_SSE_F2); + m_formatter.twoByteOp(OP2_ADDSD_VsdWsd, (RegisterID)dst, (RegisterID)src); + } + + void addsd_mr(int offset, RegisterID base, XMMRegisterID dst) + { + m_formatter.prefix(PRE_SSE_F2); + m_formatter.twoByteOp(OP2_ADDSD_VsdWsd, (RegisterID)dst, base, offset); + } + + void cvtsi2sd_rr(RegisterID src, XMMRegisterID dst) + { + m_formatter.prefix(PRE_SSE_F2); + m_formatter.twoByteOp(OP2_CVTSI2SD_VsdEd, (RegisterID)dst, src); + } + + void cvttsd2si_rr(XMMRegisterID src, RegisterID dst) + { + m_formatter.prefix(PRE_SSE_F2); + m_formatter.twoByteOp(OP2_CVTTSD2SI_GdWsd, dst, (RegisterID)src); + } + + void movd_rr(XMMRegisterID src, RegisterID dst) + { + m_formatter.prefix(PRE_SSE_66); + m_formatter.twoByteOp(OP2_MOVD_EdVd, (RegisterID)src, dst); + } + +#if PLATFORM(X86_64) + void movq_rr(XMMRegisterID src, RegisterID dst) + { + m_formatter.prefix(PRE_SSE_66); + m_formatter.twoByteOp64(OP2_MOVD_EdVd, (RegisterID)src, dst); + } + + void movq_rr(RegisterID src, XMMRegisterID dst) + { + m_formatter.prefix(PRE_SSE_66); + m_formatter.twoByteOp64(OP2_MOVD_VdEd, (RegisterID)dst, src); + } +#endif + + void movsd_rm(XMMRegisterID src, int offset, RegisterID base) + { + m_formatter.prefix(PRE_SSE_F2); + m_formatter.twoByteOp(OP2_MOVSD_WsdVsd, (RegisterID)src, base, offset); + } + + void movsd_mr(int offset, RegisterID base, XMMRegisterID dst) + { + m_formatter.prefix(PRE_SSE_F2); + m_formatter.twoByteOp(OP2_MOVSD_VsdWsd, (RegisterID)dst, base, offset); + } + + void mulsd_rr(XMMRegisterID src, XMMRegisterID dst) + { + m_formatter.prefix(PRE_SSE_F2); + m_formatter.twoByteOp(OP2_MULSD_VsdWsd, (RegisterID)dst, (RegisterID)src); + } + + void mulsd_mr(int offset, RegisterID base, XMMRegisterID dst) + { + m_formatter.prefix(PRE_SSE_F2); + m_formatter.twoByteOp(OP2_MULSD_VsdWsd, (RegisterID)dst, base, offset); + } + + void pextrw_irr(int whichWord, XMMRegisterID src, RegisterID dst) + { + m_formatter.prefix(PRE_SSE_66); + m_formatter.twoByteOp(OP2_PEXTRW_GdUdIb, (RegisterID)dst, (RegisterID)src); + m_formatter.immediate8(whichWord); + } + + void subsd_rr(XMMRegisterID src, XMMRegisterID dst) + { + m_formatter.prefix(PRE_SSE_F2); + m_formatter.twoByteOp(OP2_SUBSD_VsdWsd, (RegisterID)dst, (RegisterID)src); + } + + void subsd_mr(int offset, RegisterID base, XMMRegisterID dst) + { + m_formatter.prefix(PRE_SSE_F2); + m_formatter.twoByteOp(OP2_SUBSD_VsdWsd, (RegisterID)dst, base, offset); + } + + void ucomisd_rr(XMMRegisterID src, XMMRegisterID dst) + { + m_formatter.prefix(PRE_SSE_66); + m_formatter.twoByteOp(OP2_UCOMISD_VsdWsd, (RegisterID)dst, (RegisterID)src); + } + + // Misc instructions: + + void int3() + { + m_formatter.oneByteOp(OP_INT3); + } + + void ret() + { + m_formatter.oneByteOp(OP_RET); + } + + void predictNotTaken() + { + m_formatter.prefix(PRE_PREDICT_BRANCH_NOT_TAKEN); + } + + // Assembler admin methods: + + JmpDst label() + { + return JmpDst(m_formatter.size()); + } + + JmpDst align(int alignment) + { + while (!m_formatter.isAligned(alignment)) + m_formatter.oneByteOp(OP_HLT); + + return label(); + } + + // Linking & patching: + + void link(JmpSrc from, JmpDst to) + { + ASSERT(to.m_offset != -1); + ASSERT(from.m_offset != -1); + + reinterpret_cast(reinterpret_cast(m_formatter.data()) + from.m_offset)[-1] = to.m_offset - from.m_offset; + } + + static void patchAddress(void* code, JmpDst position, void* value) + { + ASSERT(position.m_offset != -1); + + reinterpret_cast(reinterpret_cast(code) + position.m_offset)[-1] = value; + } + + static void link(void* code, JmpSrc from, void* to) + { + ASSERT(from.m_offset != -1); + + reinterpret_cast(reinterpret_cast(code) + from.m_offset)[-1] = reinterpret_cast(to) - (reinterpret_cast(code) + from.m_offset); + } + + static void* getRelocatedAddress(void* code, JmpSrc jump) + { + return reinterpret_cast(reinterpret_cast(code) + jump.m_offset); + } + + static void* getRelocatedAddress(void* code, JmpDst destination) + { + ASSERT(destination.m_offset != -1); + + return reinterpret_cast(reinterpret_cast(code) + destination.m_offset); + } + + static int getDifferenceBetweenLabels(JmpDst src, JmpDst dst) + { + return dst.m_offset - src.m_offset; + } + + static int getDifferenceBetweenLabels(JmpDst src, JmpSrc dst) + { + return dst.m_offset - src.m_offset; + } + + static int getDifferenceBetweenLabels(JmpSrc src, JmpDst dst) + { + return dst.m_offset - src.m_offset; + } + + static void patchImmediate(intptr_t where, int32_t value) + { + reinterpret_cast(where)[-1] = value; + } + + static void patchPointer(intptr_t where, intptr_t value) + { + reinterpret_cast(where)[-1] = value; + } + + static void patchBranchOffset(intptr_t where, void* destination) + { + intptr_t offset = reinterpret_cast(destination) - where; + ASSERT(offset == static_cast(offset)); + reinterpret_cast(where)[-1] = static_cast(offset); + } + + void* executableCopy(ExecutablePool* allocator) + { + void* copy = m_formatter.executableCopy(allocator); + ASSERT(copy); + return copy; + } + +private: + + class X86InstructionFormatter { + + static const int maxInstructionSize = 16; + + public: + + // Legacy prefix bytes: + // + // These are emmitted prior to the instruction. + + void prefix(OneByteOpcodeID pre) + { + m_buffer.putByte(pre); + } + + // Word-sized operands / no operand instruction formatters. + // + // In addition to the opcode, the following operand permutations are supported: + // * None - instruction takes no operands. + // * One register - the low three bits of the RegisterID are added into the opcode. + // * Two registers - encode a register form ModRm (for all ModRm formats, the reg field is passed first, and a GroupOpcodeID may be passed in its place). + // * Three argument ModRM - a register, and a register and an offset describing a memory operand. + // * Five argument ModRM - a register, and a base register, an index, scale, and offset describing a memory operand. + // + // For 32-bit x86 targets, the address operand may also be provided as a void*. + // On 64-bit targets REX prefixes will be planted as necessary, where high numbered registers are used. + // + // The twoByteOp methods plant two-byte Intel instructions sequences (first opcode byte 0x0F). + + void oneByteOp(OneByteOpcodeID opcode) + { + m_buffer.ensureSpace(maxInstructionSize); + m_buffer.putByteUnchecked(opcode); + } + + void oneByteOp(OneByteOpcodeID opcode, RegisterID reg) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIfNeeded(0, 0, reg); + m_buffer.putByteUnchecked(opcode + (reg & 7)); + } + + void oneByteOp(OneByteOpcodeID opcode, int reg, RegisterID rm) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIfNeeded(reg, 0, rm); + m_buffer.putByteUnchecked(opcode); + registerModRM(reg, rm); + } + + void oneByteOp(OneByteOpcodeID opcode, int reg, RegisterID base, int offset) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIfNeeded(reg, 0, base); + m_buffer.putByteUnchecked(opcode); + memoryModRM(reg, base, offset); + } + + void oneByteOp_disp32(OneByteOpcodeID opcode, int reg, RegisterID base, int offset) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIfNeeded(reg, 0, base); + m_buffer.putByteUnchecked(opcode); + memoryModRM_disp32(reg, base, offset); + } + + void oneByteOp(OneByteOpcodeID opcode, int reg, RegisterID base, RegisterID index, int scale, int offset) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIfNeeded(reg, index, base); + m_buffer.putByteUnchecked(opcode); + memoryModRM(reg, base, index, scale, offset); + } + +#if !PLATFORM(X86_64) + void oneByteOp(OneByteOpcodeID opcode, int reg, void* address) + { + m_buffer.ensureSpace(maxInstructionSize); + m_buffer.putByteUnchecked(opcode); + memoryModRM(reg, address); + } +#endif + + void twoByteOp(TwoByteOpcodeID opcode) + { + m_buffer.ensureSpace(maxInstructionSize); + m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE); + m_buffer.putByteUnchecked(opcode); + } + + void twoByteOp(TwoByteOpcodeID opcode, int reg, RegisterID rm) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIfNeeded(reg, 0, rm); + m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE); + m_buffer.putByteUnchecked(opcode); + registerModRM(reg, rm); + } + + void twoByteOp(TwoByteOpcodeID opcode, int reg, RegisterID base, int offset) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIfNeeded(reg, 0, base); + m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE); + m_buffer.putByteUnchecked(opcode); + memoryModRM(reg, base, offset); + } + + void twoByteOp(TwoByteOpcodeID opcode, int reg, RegisterID base, RegisterID index, int scale, int offset) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIfNeeded(reg, index, base); + m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE); + m_buffer.putByteUnchecked(opcode); + memoryModRM(reg, base, index, scale, offset); + } + +#if PLATFORM(X86_64) + // Quad-word-sized operands: + // + // Used to format 64-bit operantions, planting a REX.w prefix. + // When planting d64 or f64 instructions, not requiring a REX.w prefix, + // the normal (non-'64'-postfixed) formatters should be used. + + void oneByteOp64(OneByteOpcodeID opcode) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexW(0, 0, 0); + m_buffer.putByteUnchecked(opcode); + } + + void oneByteOp64(OneByteOpcodeID opcode, RegisterID reg) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexW(0, 0, reg); + m_buffer.putByteUnchecked(opcode + (reg & 7)); + } + + void oneByteOp64(OneByteOpcodeID opcode, int reg, RegisterID rm) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexW(reg, 0, rm); + m_buffer.putByteUnchecked(opcode); + registerModRM(reg, rm); + } + + void oneByteOp64(OneByteOpcodeID opcode, int reg, RegisterID base, int offset) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexW(reg, 0, base); + m_buffer.putByteUnchecked(opcode); + memoryModRM(reg, base, offset); + } + + void oneByteOp64_disp32(OneByteOpcodeID opcode, int reg, RegisterID base, int offset) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexW(reg, 0, base); + m_buffer.putByteUnchecked(opcode); + memoryModRM_disp32(reg, base, offset); + } + + void oneByteOp64(OneByteOpcodeID opcode, int reg, RegisterID base, RegisterID index, int scale, int offset) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexW(reg, index, base); + m_buffer.putByteUnchecked(opcode); + memoryModRM(reg, base, index, scale, offset); + } + + void twoByteOp64(TwoByteOpcodeID opcode, int reg, RegisterID rm) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexW(reg, 0, rm); + m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE); + m_buffer.putByteUnchecked(opcode); + registerModRM(reg, rm); + } +#endif + + // Byte-operands: + // + // These methods format byte operations. Byte operations differ from the normal + // formatters in the circumstances under which they will decide to emit REX prefixes. + // These should be used where any register operand signifies a byte register. + // + // The disctinction is due to the handling of register numbers in the range 4..7 on + // x86-64. These register numbers may either represent the second byte of the first + // four registers (ah..bh) or the first byte of the second four registers (spl..dil). + // + // Since ah..bh cannot be used in all permutations of operands (specifically cannot + // be accessed where a REX prefix is present), these are likely best treated as + // deprecated. In order to ensure the correct registers spl..dil are selected a + // REX prefix will be emitted for any byte register operand in the range 4..15. + // + // These formatters may be used in instructions where a mix of operand sizes, in which + // case an unnecessary REX will be emitted, for example: + // movzbl %al, %edi + // In this case a REX will be planted since edi is 7 (and were this a byte operand + // a REX would be required to specify dil instead of bh). Unneeded REX prefixes will + // be silently ignored by the processor. + // + // Address operands should still be checked using regRequiresRex(), while byteRegRequiresRex() + // is provided to check byte register operands. + + void oneByteOp8(OneByteOpcodeID opcode, GroupOpcodeID groupOp, RegisterID rm) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIf(byteRegRequiresRex(rm), 0, 0, rm); + m_buffer.putByteUnchecked(opcode); + registerModRM(groupOp, rm); + } + + void twoByteOp8(TwoByteOpcodeID opcode, RegisterID reg, RegisterID rm) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIf(byteRegRequiresRex(reg)|byteRegRequiresRex(rm), reg, 0, rm); + m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE); + m_buffer.putByteUnchecked(opcode); + registerModRM(reg, rm); + } + + void twoByteOp8(TwoByteOpcodeID opcode, GroupOpcodeID groupOp, RegisterID rm) + { + m_buffer.ensureSpace(maxInstructionSize); + emitRexIf(byteRegRequiresRex(rm), 0, 0, rm); + m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE); + m_buffer.putByteUnchecked(opcode); + registerModRM(groupOp, rm); + } + + // Immediates: + // + // An immedaite should be appended where appropriate after an op has been emitted. + // The writes are unchecked since the opcode formatters above will have ensured space. + + void immediate8(int imm) + { + m_buffer.putByteUnchecked(imm); + } + + void immediate32(int imm) + { + m_buffer.putIntUnchecked(imm); + } + + void immediate64(int64_t imm) + { + m_buffer.putInt64Unchecked(imm); + } + + JmpSrc immediateRel32() + { + m_buffer.putIntUnchecked(0); + return JmpSrc(m_buffer.size()); + } + + // Administrative methods: + + size_t size() const { return m_buffer.size(); } + bool isAligned(int alignment) const { return m_buffer.isAligned(alignment); } + void* data() const { return m_buffer.data(); } + void* executableCopy(ExecutablePool* allocator) { return m_buffer.executableCopy(allocator); } + + private: + + // Internals; ModRm and REX formatters. + + static const RegisterID noBase = X86::ebp; + static const RegisterID hasSib = X86::esp; + static const RegisterID noIndex = X86::esp; +#if PLATFORM(X86_64) + static const RegisterID noBase2 = X86::r13; + static const RegisterID hasSib2 = X86::r12; + + // Registers r8 & above require a REX prefixe. + inline bool regRequiresRex(int reg) + { + return (reg >= X86::r8); + } + + // Byte operand register spl & above require a REX prefix (to prevent the 'H' registers be accessed). + inline bool byteRegRequiresRex(int reg) + { + return (reg >= X86::esp); + } + + // Format a REX prefix byte. + inline void emitRex(bool w, int r, int x, int b) + { + m_buffer.putByteUnchecked(PRE_REX | ((int)w << 3) | ((r>>3)<<2) | ((x>>3)<<1) | (b>>3)); + } + + // Used to plant a REX byte with REX.w set (for 64-bit operations). + inline void emitRexW(int r, int x, int b) + { + emitRex(true, r, x, b); + } + + // Used for operations with byte operands - use byteRegRequiresRex() to check register operands, + // regRequiresRex() to check other registers (i.e. address base & index). + inline void emitRexIf(bool condition, int r, int x, int b) + { + if (condition) emitRex(false, r, x, b); + } + + // Used for word sized operations, will plant a REX prefix if necessary (if any register is r8 or above). + inline void emitRexIfNeeded(int r, int x, int b) + { + emitRexIf(regRequiresRex(r) || regRequiresRex(x) || regRequiresRex(b), r, x, b); + } +#else + // No REX prefix bytes on 32-bit x86. + inline bool regRequiresRex(int) { return false; } + inline bool byteRegRequiresRex(int) { return false; } + inline void emitRexIf(bool, int, int, int) {} + inline void emitRexIfNeeded(int, int, int) {} +#endif + + enum ModRmMode { + ModRmMemoryNoDisp, + ModRmMemoryDisp8, + ModRmMemoryDisp32, + ModRmRegister, + }; + + void putModRm(ModRmMode mode, int reg, RegisterID rm) + { + m_buffer.putByteUnchecked((mode << 6) | ((reg & 7) << 3) | (rm & 7)); + } + + void putModRmSib(ModRmMode mode, int reg, RegisterID base, RegisterID index, int scale) + { + ASSERT(mode != ModRmRegister); + + // Encode sacle of (1,2,4,8) -> (0,1,2,3) + int shift = 0; + while (scale >>= 1) + shift++; + + putModRm(mode, reg, hasSib); + m_buffer.putByteUnchecked((shift << 6) | ((index & 7) << 3) | (base & 7)); + } + + void registerModRM(int reg, RegisterID rm) + { + putModRm(ModRmRegister, reg, rm); + } + + void memoryModRM(int reg, RegisterID base, int offset) + { + // A base of esp or r12 would be interpreted as a sib, so force a sib with no index & put the base in there. +#if PLATFORM(X86_64) + if ((base == hasSib) || (base == hasSib2)) { +#else + if (base == hasSib) { +#endif + if (!offset) // No need to check if the base is noBase, since we know it is hasSib! + putModRmSib(ModRmMemoryNoDisp, reg, base, noIndex, 0); + else if (CAN_SIGN_EXTEND_8_32(offset)) { + putModRmSib(ModRmMemoryDisp8, reg, base, noIndex, 0); + m_buffer.putByteUnchecked(offset); + } else { + putModRmSib(ModRmMemoryDisp32, reg, base, noIndex, 0); + m_buffer.putIntUnchecked(offset); + } + } else { +#if PLATFORM(X86_64) + if (!offset && (base != noBase) && (base != noBase2)) +#else + if (!offset && (base != noBase)) +#endif + putModRm(ModRmMemoryNoDisp, reg, base); + else if (CAN_SIGN_EXTEND_8_32(offset)) { + putModRm(ModRmMemoryDisp8, reg, base); + m_buffer.putByteUnchecked(offset); + } else { + putModRm(ModRmMemoryDisp32, reg, base); + m_buffer.putIntUnchecked(offset); + } + } + } + + void memoryModRM_disp32(int reg, RegisterID base, int offset) + { + // A base of esp or r12 would be interpreted as a sib, so force a sib with no index & put the base in there. +#if PLATFORM(X86_64) + if ((base == hasSib) || (base == hasSib2)) { +#else + if (base == hasSib) { +#endif + putModRmSib(ModRmMemoryDisp32, reg, base, noIndex, 0); + m_buffer.putIntUnchecked(offset); + } else { + putModRm(ModRmMemoryDisp32, reg, base); + m_buffer.putIntUnchecked(offset); + } + } + + void memoryModRM(int reg, RegisterID base, RegisterID index, int scale, int offset) + { + ASSERT(index != noIndex); + +#if PLATFORM(X86_64) + if (!offset && (base != noBase) && (base != noBase2)) +#else + if (!offset && (base != noBase)) +#endif + putModRmSib(ModRmMemoryNoDisp, reg, base, index, scale); + else if (CAN_SIGN_EXTEND_8_32(offset)) { + putModRmSib(ModRmMemoryDisp8, reg, base, index, scale); + m_buffer.putByteUnchecked(offset); + } else { + putModRmSib(ModRmMemoryDisp32, reg, base, index, scale); + m_buffer.putIntUnchecked(offset); + } + } + +#if !PLATFORM(X86_64) + void memoryModRM(int reg, void* address) + { + // noBase + ModRmMemoryNoDisp means noBase + ModRmMemoryDisp32! + putModRm(ModRmMemoryNoDisp, reg, noBase); + m_buffer.putIntUnchecked(reinterpret_cast(address)); + } +#endif + + AssemblerBuffer m_buffer; + } m_formatter; +}; + +} // namespace JSC + +#endif // ENABLE(ASSEMBLER) && PLATFORM(X86) + +#endif // X86Assembler_h diff --git a/bindings/NP_jsobject.cpp b/bindings/NP_jsobject.cpp deleted file mode 100644 index f334624..0000000 --- a/bindings/NP_jsobject.cpp +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(NETSCAPE_API) - -#include "NP_jsobject.h" - -#include "JSGlobalObject.h" -#include "PropertyNameArray.h" -#include "SourceCode.h" -#include "c_utility.h" -#include "interpreter.h" -#include "npruntime_impl.h" -#include "npruntime_priv.h" -#include "object.h" -#include "runtime_root.h" - -using namespace KJS; -using namespace KJS::Bindings; - -static void getListFromVariantArgs(ExecState* exec, const NPVariant* args, unsigned argCount, RootObject* rootObject, List& aList) -{ - for (unsigned i = 0; i < argCount; i++) - aList.append(convertNPVariantToValue(exec, &args[i], rootObject)); -} - -static NPObject* jsAllocate(NPP, NPClass*) -{ - return (NPObject*)malloc(sizeof(JavaScriptObject)); -} - -static void jsDeallocate(NPObject* npObj) -{ - JavaScriptObject* obj = (JavaScriptObject*)npObj; - - if (obj->rootObject && obj->rootObject->isValid()) - obj->rootObject->gcUnprotect(obj->imp); - - if (obj->rootObject) - obj->rootObject->deref(); - - free(obj); -} - -static NPClass javascriptClass = { 1, jsAllocate, jsDeallocate, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -static NPClass noScriptClass = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -NPClass* NPScriptObjectClass = &javascriptClass; -static NPClass* NPNoScriptObjectClass = &noScriptClass; - -NPObject* _NPN_CreateScriptObject(NPP npp, JSObject* imp, PassRefPtr rootObject) -{ - JavaScriptObject* obj = (JavaScriptObject*)_NPN_CreateObject(npp, NPScriptObjectClass); - - obj->rootObject = rootObject.releaseRef(); - - if (obj->rootObject) - obj->rootObject->gcProtect(imp); - obj->imp = imp; - - return (NPObject*)obj; -} - -NPObject *_NPN_CreateNoScriptObject(void) -{ - return _NPN_CreateObject(0, NPNoScriptObjectClass); -} - -bool _NPN_InvokeDefault(NPP, NPObject* o, const NPVariant* args, uint32_t argCount, NPVariant* result) -{ - if (o->_class == NPScriptObjectClass) { - JavaScriptObject* obj = (JavaScriptObject*)o; - - VOID_TO_NPVARIANT(*result); - - // Lookup the function object. - RootObject* rootObject = obj->rootObject; - if (!rootObject || !rootObject->isValid()) - return false; - - ExecState* exec = rootObject->globalObject()->globalExec(); - JSLock lock; - - // Call the function object. - JSObject *funcImp = static_cast(obj->imp); - if (!funcImp->implementsCall()) - return false; - - List argList; - getListFromVariantArgs(exec, args, argCount, rootObject, argList); - rootObject->globalObject()->startTimeoutCheck(); - JSValue *resultV = funcImp->call (exec, funcImp, argList); - rootObject->globalObject()->stopTimeoutCheck(); - - // Convert and return the result of the function call. - convertValueToNPVariant(exec, resultV, result); - return true; - } - - if (o->_class->invokeDefault) - return o->_class->invokeDefault(o, args, argCount, result); - VOID_TO_NPVARIANT(*result); - return true; -} - -bool _NPN_Invoke(NPP npp, NPObject* o, NPIdentifier methodName, const NPVariant* args, uint32_t argCount, NPVariant* result) -{ - if (o->_class == NPScriptObjectClass) { - JavaScriptObject* obj = (JavaScriptObject*)o; - - PrivateIdentifier* i = (PrivateIdentifier*)methodName; - if (!i->isString) - return false; - - // Special case the "eval" method. - if (methodName == _NPN_GetStringIdentifier("eval")) { - if (argCount != 1) - return false; - if (args[0].type != NPVariantType_String) - return false; - return _NPN_Evaluate(npp, o, (NPString *)&args[0].value.stringValue, result); - } - - // Lookup the function object. - RootObject* rootObject = obj->rootObject; - if (!rootObject || !rootObject->isValid()) - return false; - - ExecState* exec = rootObject->globalObject()->globalExec(); - JSLock lock; - JSValue* func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string)); - if (func->isNull()) { - NULL_TO_NPVARIANT(*result); - return false; - } - if (func->isUndefined()) { - VOID_TO_NPVARIANT(*result); - return false; - } - // Call the function object. - JSObject *funcImp = static_cast(func); - JSObject *thisObj = const_cast(obj->imp); - List argList; - getListFromVariantArgs(exec, args, argCount, rootObject, argList); - rootObject->globalObject()->startTimeoutCheck(); - JSValue *resultV = funcImp->call (exec, thisObj, argList); - rootObject->globalObject()->stopTimeoutCheck(); - - // Convert and return the result of the function call. - convertValueToNPVariant(exec, resultV, result); - return true; - } - - if (o->_class->invoke) - return o->_class->invoke(o, methodName, args, argCount, result); - - VOID_TO_NPVARIANT(*result); - return true; -} - -bool _NPN_Evaluate(NPP, NPObject* o, NPString* s, NPVariant* variant) -{ - if (o->_class == NPScriptObjectClass) { - JavaScriptObject* obj = (JavaScriptObject*)o; - - RootObject* rootObject = obj->rootObject; - if (!rootObject || !rootObject->isValid()) - return false; - - ExecState* exec = rootObject->globalObject()->globalExec(); - - JSLock lock; - NPUTF16* scriptString; - unsigned int UTF16Length; - convertNPStringToUTF16(s, &scriptString, &UTF16Length); // requires free() of returned memory - rootObject->globalObject()->startTimeoutCheck(); - - SourceCode source = makeSource(UString(reinterpret_cast(scriptString), UTF16Length), UString()); - Completion completion = Interpreter::evaluate(rootObject->globalObject()->globalExec(), source); - rootObject->globalObject()->stopTimeoutCheck(); - ComplType type = completion.complType(); - - JSValue* result; - if (type == Normal) { - result = completion.value(); - if (!result) - result = jsUndefined(); - } else - result = jsUndefined(); - - free(scriptString); - - convertValueToNPVariant(exec, result, variant); - - return true; - } - - VOID_TO_NPVARIANT(*variant); - return false; -} - -bool _NPN_GetProperty(NPP, NPObject* o, NPIdentifier propertyName, NPVariant* variant) -{ - if (o->_class == NPScriptObjectClass) { - JavaScriptObject* obj = (JavaScriptObject*)o; - - RootObject* rootObject = obj->rootObject; - if (!rootObject || !rootObject->isValid()) - return false; - - ExecState* exec = rootObject->globalObject()->globalExec(); - PrivateIdentifier* i = (PrivateIdentifier*)propertyName; - - JSLock lock; - JSValue *result; - if (i->isString) - result = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string)); - else - result = obj->imp->get(exec, i->value.number); - - convertValueToNPVariant(exec, result, variant); - return true; - } - - if (o->_class->hasProperty && o->_class->getProperty) { - if (o->_class->hasProperty(o, propertyName)) - return o->_class->getProperty(o, propertyName, variant); - return false; - } - - VOID_TO_NPVARIANT(*variant); - return false; -} - -bool _NPN_SetProperty(NPP, NPObject* o, NPIdentifier propertyName, const NPVariant* variant) -{ - if (o->_class == NPScriptObjectClass) { - JavaScriptObject* obj = (JavaScriptObject*)o; - - RootObject* rootObject = obj->rootObject; - if (!rootObject || !rootObject->isValid()) - return false; - - ExecState* exec = rootObject->globalObject()->globalExec(); - JSLock lock; - PrivateIdentifier* i = (PrivateIdentifier*)propertyName; - if (i->isString) - obj->imp->put(exec, identifierFromNPIdentifier(i->value.string), convertNPVariantToValue(exec, variant, rootObject)); - else - obj->imp->put(exec, i->value.number, convertNPVariantToValue(exec, variant, rootObject)); - return true; - } - - if (o->_class->setProperty) - return o->_class->setProperty(o, propertyName, variant); - - return false; -} - -bool _NPN_RemoveProperty(NPP, NPObject* o, NPIdentifier propertyName) -{ - if (o->_class == NPScriptObjectClass) { - JavaScriptObject* obj = (JavaScriptObject*)o; - - RootObject* rootObject = obj->rootObject; - if (!rootObject || !rootObject->isValid()) - return false; - - ExecState* exec = rootObject->globalObject()->globalExec(); - PrivateIdentifier* i = (PrivateIdentifier*)propertyName; - if (i->isString) { - if (!obj->imp->hasProperty(exec, identifierFromNPIdentifier(i->value.string))) - return false; - } else { - if (!obj->imp->hasProperty(exec, i->value.number)) - return false; - } - - JSLock lock; - if (i->isString) - obj->imp->deleteProperty(exec, identifierFromNPIdentifier(i->value.string)); - else - obj->imp->deleteProperty(exec, i->value.number); - - return true; - } - return false; -} - -bool _NPN_HasProperty(NPP, NPObject* o, NPIdentifier propertyName) -{ - if (o->_class == NPScriptObjectClass) { - JavaScriptObject* obj = (JavaScriptObject*)o; - - RootObject* rootObject = obj->rootObject; - if (!rootObject || !rootObject->isValid()) - return false; - - ExecState* exec = rootObject->globalObject()->globalExec(); - PrivateIdentifier* i = (PrivateIdentifier*)propertyName; - JSLock lock; - if (i->isString) - return obj->imp->hasProperty(exec, identifierFromNPIdentifier(i->value.string)); - return obj->imp->hasProperty(exec, i->value.number); - } - - if (o->_class->hasProperty) - return o->_class->hasProperty(o, propertyName); - - return false; -} - -bool _NPN_HasMethod(NPP, NPObject* o, NPIdentifier methodName) -{ - if (o->_class == NPScriptObjectClass) { - JavaScriptObject* obj = (JavaScriptObject*)o; - - PrivateIdentifier* i = (PrivateIdentifier*)methodName; - if (!i->isString) - return false; - - RootObject* rootObject = obj->rootObject; - if (!rootObject || !rootObject->isValid()) - return false; - - ExecState* exec = rootObject->globalObject()->globalExec(); - JSLock lock; - JSValue* func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string)); - return !func->isUndefined(); - } - - if (o->_class->hasMethod) - return o->_class->hasMethod(o, methodName); - - return false; -} - -void _NPN_SetException(NPObject* o, const NPUTF8* message) -{ - if (o->_class == NPScriptObjectClass) { - JavaScriptObject* obj = (JavaScriptObject*)o; - RootObject* rootObject = obj->rootObject; - if (!rootObject || !rootObject->isValid()) - return; - - ExecState* exec = rootObject->globalObject()->globalExec(); - JSLock lock; - throwError(exec, GeneralError, message); - } -} - -bool _NPN_Enumerate(NPP, NPObject *o, NPIdentifier **identifier, uint32_t *count) -{ - if (o->_class == NPScriptObjectClass) { - JavaScriptObject* obj = (JavaScriptObject*)o; - - RootObject* rootObject = obj->rootObject; - if (!rootObject || !rootObject->isValid()) - return false; - - ExecState* exec = rootObject->globalObject()->globalExec(); - JSLock lock; - PropertyNameArray propertyNames; - - obj->imp->getPropertyNames(exec, propertyNames); - unsigned size = static_cast(propertyNames.size()); - // FIXME: This should really call NPN_MemAlloc but that's in WebKit - NPIdentifier *identifiers = static_cast(malloc(sizeof(NPIdentifier) * size)); - - for (unsigned i = 0; i < size; i++) - identifiers[i] = _NPN_GetStringIdentifier(propertyNames[i].ustring().UTF8String().c_str()); - - *identifier = identifiers; - *count = size; - - return true; - } - - if (NP_CLASS_STRUCT_VERSION_HAS_ENUM(o->_class) && o->_class->enumerate) - return o->_class->enumerate(o, identifier, count); - - return false; -} - -#endif // ENABLE(NETSCAPE_API) diff --git a/bindings/c/c_class.cpp b/bindings/c/c_class.cpp deleted file mode 100644 index af8a36b..0000000 --- a/bindings/c/c_class.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(NETSCAPE_API) - -#include "c_class.h" - -#include "c_instance.h" -#include "c_runtime.h" -#include "identifier.h" -#include "npruntime_impl.h" - -namespace KJS { namespace Bindings { - -CClass::CClass(NPClass* aClass) -{ - _isa = aClass; -} - -CClass::~CClass() -{ - JSLock lock; - - deleteAllValues(_methods); - _methods.clear(); - - deleteAllValues(_fields); - _fields.clear(); -} - -typedef HashMap ClassesByIsAMap; -static ClassesByIsAMap* classesByIsA = 0; - -CClass* CClass::classForIsA(NPClass* isa) -{ - if (!classesByIsA) - classesByIsA = new ClassesByIsAMap; - - CClass* aClass = classesByIsA->get(isa); - if (!aClass) { - aClass = new CClass(isa); - classesByIsA->set(isa, aClass); - } - - return aClass; -} - -const char* CClass::name() const -{ - return ""; -} - -MethodList CClass::methodsNamed(const Identifier& identifier, Instance* instance) const -{ - MethodList methodList; - - Method* method = _methods.get(identifier.ustring().rep()); - if (method) { - methodList.append(method); - return methodList; - } - - NPIdentifier ident = _NPN_GetStringIdentifier(identifier.ascii()); - const CInstance* inst = static_cast(instance); - NPObject* obj = inst->getObject(); - if (_isa->hasMethod && _isa->hasMethod(obj, ident)){ - Method* aMethod = new CMethod(ident); // deleted in the CClass destructor - { - JSLock lock; - _methods.set(identifier.ustring().rep(), aMethod); - } - methodList.append(aMethod); - } - - return methodList; -} - -Field* CClass::fieldNamed(const Identifier& identifier, Instance* instance) const -{ - Field* aField = _fields.get(identifier.ustring().rep()); - if (aField) - return aField; - - NPIdentifier ident = _NPN_GetStringIdentifier(identifier.ascii()); - const CInstance* inst = static_cast(instance); - NPObject* obj = inst->getObject(); - if (_isa->hasProperty && _isa->hasProperty(obj, ident)){ - aField = new CField(ident); // deleted in the CClass destructor - { - JSLock lock; - _fields.set(identifier.ustring().rep(), aField); - } - } - return aField; -} - -} } // namespace KJS::Bindings - -#endif // ENABLE(NETSCAPE_API) diff --git a/bindings/c/c_instance.cpp b/bindings/c/c_instance.cpp deleted file mode 100644 index dd33253..0000000 --- a/bindings/c/c_instance.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(NETSCAPE_API) - -#include "c_instance.h" - -#include "c_class.h" -#include "c_runtime.h" -#include "c_utility.h" -#include "list.h" -#include "npruntime_impl.h" -#include "PropertyNameArray.h" -#include "runtime_root.h" -#include -#include -#include - -namespace KJS { -namespace Bindings { - -CInstance::CInstance(NPObject* o, PassRefPtr rootObject) - : Instance(rootObject) -{ - _object = _NPN_RetainObject(o); - _class = 0; -} - -CInstance::~CInstance() -{ - _NPN_ReleaseObject(_object); -} - -Class *CInstance::getClass() const -{ - if (!_class) - _class = CClass::classForIsA(_object->_class); - return _class; -} - -void CInstance::begin() -{ - // Do nothing. -} - -void CInstance::end() -{ - // Do nothing. -} - -bool CInstance::implementsCall() const -{ - return (_object->_class->invokeDefault != 0); -} - -JSValue* CInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const List& args) -{ - // Overloading methods are not allowed by NPObjects. Should only be one - // name match for a particular method. - ASSERT(methodList.size() == 1); - - CMethod* method = static_cast(methodList[0]); - - NPIdentifier ident = _NPN_GetStringIdentifier(method->name()); - if (!_object->_class->hasMethod(_object, ident)) - return jsUndefined(); - - unsigned count = args.size(); - Vector cArgs(count); - - unsigned i; - for (i = 0; i < count; i++) - convertValueToNPVariant(exec, args.at(i), &cArgs[i]); - - // Invoke the 'C' method. - NPVariant resultVariant; - VOID_TO_NPVARIANT(resultVariant); - - { - JSLock::DropAllLocks dropAllLocks; - _object->_class->invoke(_object, ident, cArgs.data(), count, &resultVariant); - } - - for (i = 0; i < count; i++) - _NPN_ReleaseVariantValue(&cArgs[i]); - - JSValue* resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get()); - _NPN_ReleaseVariantValue(&resultVariant); - return resultValue; -} - - -JSValue* CInstance::invokeDefaultMethod(ExecState* exec, const List& args) -{ - if (!_object->_class->invokeDefault) - return jsUndefined(); - - unsigned count = args.size(); - Vector cArgs(count); - - unsigned i; - for (i = 0; i < count; i++) - convertValueToNPVariant(exec, args.at(i), &cArgs[i]); - - // Invoke the 'C' method. - NPVariant resultVariant; - VOID_TO_NPVARIANT(resultVariant); - { - JSLock::DropAllLocks dropAllLocks; - _object->_class->invokeDefault(_object, cArgs.data(), count, &resultVariant); - } - - for (i = 0; i < count; i++) - _NPN_ReleaseVariantValue(&cArgs[i]); - - JSValue* resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get()); - _NPN_ReleaseVariantValue(&resultVariant); - return resultValue; -} - - -JSValue* CInstance::defaultValue(JSType hint) const -{ - if (hint == StringType) - return stringValue(); - if (hint == NumberType) - return numberValue(); - if (hint == BooleanType) - return booleanValue(); - return valueOf(); -} - -JSValue* CInstance::stringValue() const -{ - char buf[1024]; - snprintf(buf, sizeof(buf), "NPObject %p, NPClass %p", _object, _object->_class); - return jsString(buf); -} - -JSValue* CInstance::numberValue() const -{ - // FIXME: Implement something sensible. - return jsNumber(0); -} - -JSValue* CInstance::booleanValue() const -{ - // FIXME: Implement something sensible. - return jsBoolean(false); -} - -JSValue* CInstance::valueOf() const -{ - return stringValue(); -} - -void CInstance::getPropertyNames(ExecState*, PropertyNameArray& nameArray) -{ - if (!NP_CLASS_STRUCT_VERSION_HAS_ENUM(_object->_class) || - !_object->_class->enumerate) - return; - - unsigned count; - NPIdentifier* identifiers; - - { - JSLock::DropAllLocks dropAllLocks; - if (!_object->_class->enumerate(_object, &identifiers, &count)) - return; - } - - for (unsigned i = 0; i < count; i++) { - PrivateIdentifier* identifier = static_cast(identifiers[i]); - - if (identifier->isString) - nameArray.add(identifierFromNPIdentifier(identifier->value.string)); - else - nameArray.add(Identifier::from(identifier->value.number)); - } - - // FIXME: This should really call NPN_MemFree but that's in WebKit - free(identifiers); -} - -} -} - -#endif // ENABLE(NETSCAPE_API) diff --git a/bindings/c/c_runtime.cpp b/bindings/c/c_runtime.cpp deleted file mode 100644 index cf98019..0000000 --- a/bindings/c/c_runtime.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(NETSCAPE_API) - -#include "c_runtime.h" - -#include "c_instance.h" -#include "c_utility.h" -#include "npruntime_impl.h" - -namespace KJS { -namespace Bindings { - -// ---------------------- CMethod ---------------------- - -const char* CMethod::name() const -{ - PrivateIdentifier *i = (PrivateIdentifier *)_methodIdentifier; - return i->isString ? i->value.string : 0; -} - -// ---------------------- CField ---------------------- - -const char* CField::name() const -{ - PrivateIdentifier *i = (PrivateIdentifier *)_fieldIdentifier; - return i->isString ? i->value.string : 0; -} - -JSValue* CField::valueFromInstance(ExecState* exec, const Instance* inst) const -{ - const CInstance* instance = static_cast(inst); - NPObject* obj = instance->getObject(); - if (obj->_class->getProperty) { - NPVariant property; - VOID_TO_NPVARIANT(property); - - bool result; - { - JSLock::DropAllLocks dropAllLocks; - result = obj->_class->getProperty(obj, _fieldIdentifier, &property); - } - if (result) { - JSValue* result = convertNPVariantToValue(exec, &property, instance->rootObject()); - _NPN_ReleaseVariantValue(&property); - return result; - } - } - return jsUndefined(); -} - -void CField::setValueToInstance(ExecState *exec, const Instance *inst, JSValue *aValue) const -{ - const CInstance* instance = static_cast(inst); - NPObject* obj = instance->getObject(); - if (obj->_class->setProperty) { - NPVariant variant; - convertValueToNPVariant(exec, aValue, &variant); - - { - JSLock::DropAllLocks dropAllLocks; - obj->_class->setProperty(obj, _fieldIdentifier, &variant); - } - - _NPN_ReleaseVariantValue(&variant); - } -} - -} } - -#endif // ENABLE(NETSCAPE_API) diff --git a/bindings/c/c_utility.cpp b/bindings/c/c_utility.cpp deleted file mode 100644 index 7951482..0000000 --- a/bindings/c/c_utility.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. - * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(NETSCAPE_API) - -#include "c_utility.h" - -#include "NP_jsobject.h" -#include "c_instance.h" -#include "JSGlobalObject.h" -#include "npruntime_impl.h" -#include "npruntime_priv.h" -#include "runtime_object.h" -#include "runtime_root.h" -#include "Platform.h" -#include -#include - -using namespace WTF::Unicode; - -namespace KJS { namespace Bindings { - -// Requires free() of returned UTF16Chars. -static void convertUTF8ToUTF16WithLatin1Fallback(const NPUTF8* UTF8Chars, int UTF8Length, NPUTF16** UTF16Chars, unsigned int* UTF16Length) -{ - ASSERT(UTF8Chars || UTF8Length == 0); - ASSERT(UTF16Chars); - - if (UTF8Length == -1) - UTF8Length = static_cast(strlen(UTF8Chars)); - - *UTF16Length = UTF8Length; - *UTF16Chars = static_cast(malloc(sizeof(NPUTF16) * (*UTF16Length))); - - const char* sourcestart = UTF8Chars; - const char* sourceend = sourcestart + UTF8Length; - - ::UChar* targetstart = reinterpret_cast< ::UChar*>(*UTF16Chars); - ::UChar* targetend = targetstart + UTF8Length; - - ConversionResult result = convertUTF8ToUTF16(&sourcestart, sourceend, &targetstart, targetend); - - *UTF16Length = targetstart - reinterpret_cast< ::UChar*>(*UTF16Chars); - - // Check to see if the conversion was successful - // Some plugins return invalid UTF-8 in NPVariantType_String, see - // There is no "bad data" for latin1. It is unlikely that the plugin was really sending text in this encoding, - // but it should have used UTF-8, and now we are simply avoiding a crash. - if (result != conversionOK) { - *UTF16Length = UTF8Length; - - if (!*UTF16Chars) // If the memory wasn't allocated, allocate it. - *UTF16Chars = (NPUTF16*)malloc(sizeof(NPUTF16) * (*UTF16Length)); - - for (unsigned i = 0; i < *UTF16Length; i++) - (*UTF16Chars)[i] = UTF8Chars[i] & 0xFF; - } -} - -// Variant value must be released with NPReleaseVariantValue() -void convertValueToNPVariant(ExecState *exec, JSValue *value, NPVariant *result) -{ - JSLock lock; - - JSType type = value->type(); - - VOID_TO_NPVARIANT(*result); - - if (type == StringType) { - UString ustring = value->toString(exec); - CString cstring = ustring.UTF8String(); - NPString string = { (const NPUTF8 *)cstring.c_str(), static_cast(cstring.size()) }; - NPN_InitializeVariantWithStringCopy(result, &string); - } else if (type == NumberType) { - DOUBLE_TO_NPVARIANT(value->toNumber(exec), *result); - } else if (type == BooleanType) { - BOOLEAN_TO_NPVARIANT(value->toBoolean(exec), *result); - } else if (type == UnspecifiedType) { - VOID_TO_NPVARIANT(*result); - } else if (type == NullType) { - NULL_TO_NPVARIANT(*result); - } else if (type == ObjectType) { - JSObject* object = static_cast(value); - if (object->classInfo() == &RuntimeObjectImp::info) { - RuntimeObjectImp* imp = static_cast(value); - CInstance* instance = static_cast(imp->getInternalInstance()); - if (instance) { - NPObject* obj = instance->getObject(); - _NPN_RetainObject(obj); - OBJECT_TO_NPVARIANT(obj, *result); - } - } else { - JSGlobalObject* globalObject = exec->dynamicGlobalObject(); - - RootObject* rootObject = findRootObject(globalObject); - if (rootObject) { - NPObject* npObject = _NPN_CreateScriptObject(0, object, rootObject); - OBJECT_TO_NPVARIANT(npObject, *result); - } - } - } -} - -JSValue *convertNPVariantToValue(ExecState*, const NPVariant* variant, RootObject* rootObject) -{ - JSLock lock; - - NPVariantType type = variant->type; - - if (type == NPVariantType_Bool) - return jsBoolean(NPVARIANT_TO_BOOLEAN(*variant)); - if (type == NPVariantType_Null) - return jsNull(); - if (type == NPVariantType_Void) - return jsUndefined(); - if (type == NPVariantType_Int32) - return jsNumber(NPVARIANT_TO_INT32(*variant)); - if (type == NPVariantType_Double) - return jsNumber(NPVARIANT_TO_DOUBLE(*variant)); - if (type == NPVariantType_String) { - NPUTF16 *stringValue; - unsigned int UTF16Length; - convertNPStringToUTF16(&variant->value.stringValue, &stringValue, &UTF16Length); // requires free() of returned memory - UString resultString((const UChar *)stringValue,UTF16Length); - free(stringValue); - return jsString(resultString); - } - if (type == NPVariantType_Object) { - NPObject *obj = variant->value.objectValue; - - if (obj->_class == NPScriptObjectClass) - // Get JSObject from NP_JavaScriptObject. - return ((JavaScriptObject *)obj)->imp; - - // Wrap NPObject in a CInstance. - return Instance::createRuntimeObject(Instance::CLanguage, obj, rootObject); - } - - return jsUndefined(); -} - -// Requires free() of returned UTF16Chars. -void convertNPStringToUTF16(const NPString *string, NPUTF16 **UTF16Chars, unsigned int *UTF16Length) -{ - convertUTF8ToUTF16WithLatin1Fallback(string->UTF8Characters, string->UTF8Length, UTF16Chars, UTF16Length); -} - -Identifier identifierFromNPIdentifier(const NPUTF8* name) -{ - NPUTF16 *methodName; - unsigned UTF16Length; - convertUTF8ToUTF16WithLatin1Fallback(name, -1, &methodName, &UTF16Length); // requires free() of returned memory. - Identifier identifier((const KJS::UChar*)methodName, UTF16Length); - free(methodName); - return identifier; -} - -} } - -#endif // ENABLE(NETSCAPE_API) diff --git a/bindings/jni/jni_class.cpp b/bindings/jni/jni_class.cpp deleted file mode 100644 index 38606b9..0000000 --- a/bindings/jni/jni_class.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(JAVA_BINDINGS) - -#include - -#include "identifier.h" -#include -#include - -using namespace KJS::Bindings; - -JavaClass::JavaClass(jobject anInstance) -{ - jobject aClass = callJNIObjectMethod(anInstance, "getClass", "()Ljava/lang/Class;"); - - if (!aClass) { - fprintf(stderr, "%s: unable to call getClass on instance %p\n", __PRETTY_FUNCTION__, anInstance); - return; - } - - jstring className = (jstring)callJNIObjectMethod(aClass, "getName", "()Ljava/lang/String;"); - const char *classNameC = getCharactersFromJString(className); - _name = strdup(classNameC); - releaseCharactersForJString(className, classNameC); - - int i; - JNIEnv *env = getJNIEnv(); - - // Get the fields - jarray fields = (jarray)callJNIObjectMethod(aClass, "getFields", "()[Ljava/lang/reflect/Field;"); - int numFields = env->GetArrayLength(fields); - for (i = 0; i < numFields; i++) { - jobject aJField = env->GetObjectArrayElement((jobjectArray)fields, i); - Field *aField = new JavaField(env, aJField); // deleted in the JavaClass destructor - { - JSLock lock; - _fields.set(Identifier(aField->name()).ustring().rep(), aField); - } - env->DeleteLocalRef(aJField); - } - - // Get the methods - jarray methods = (jarray)callJNIObjectMethod(aClass, "getMethods", "()[Ljava/lang/reflect/Method;"); - int numMethods = env->GetArrayLength(methods); - for (i = 0; i < numMethods; i++) { - jobject aJMethod = env->GetObjectArrayElement((jobjectArray)methods, i); - Method *aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor - MethodList* methodList; - { - JSLock lock; - - methodList = _methods.get(Identifier(aMethod->name()).ustring().rep()); - if (!methodList) { - methodList = new MethodList(); - _methods.set(Identifier(aMethod->name()).ustring().rep(), methodList); - } - } - methodList->append(aMethod); - env->DeleteLocalRef(aJMethod); - } -} - -JavaClass::~JavaClass() { - free((void *)_name); - - JSLock lock; - - deleteAllValues(_fields); - _fields.clear(); - - MethodListMap::const_iterator end = _methods.end(); - for (MethodListMap::const_iterator it = _methods.begin(); it != end; ++it) { - const MethodList* methodList = it->second; - deleteAllValues(*methodList); - delete methodList; - } - _methods.clear(); -} - -MethodList JavaClass::methodsNamed(const Identifier& identifier, Instance*) const -{ - MethodList *methodList = _methods.get(identifier.ustring().rep()); - - if (methodList) - return *methodList; - return MethodList(); -} - -Field *JavaClass::fieldNamed(const Identifier& identifier, Instance*) const -{ - return _fields.get(identifier.ustring().rep()); -} - -bool JavaClass::isNumberClass() const -{ - return ((strcmp(_name, "java.lang.Byte") == 0 || - strcmp(_name, "java.lang.Short") == 0 || - strcmp(_name, "java.lang.Integer") == 0 || - strcmp(_name, "java.lang.Long") == 0 || - strcmp(_name, "java.lang.Float") == 0 || - strcmp(_name, "java.lang.Double") == 0) ); -} - -bool JavaClass::isBooleanClass() const -{ - return strcmp(_name, "java.lang.Boolean") == 0; -} - -bool JavaClass::isStringClass() const -{ - return strcmp(_name, "java.lang.String") == 0; -} - -#endif // ENABLE(JAVA_BINDINGS) diff --git a/bindings/jni/jni_instance.cpp b/bindings/jni/jni_instance.cpp deleted file mode 100644 index f97da15..0000000 --- a/bindings/jni/jni_instance.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(JAVA_BINDINGS) - -#include "jni_class.h" -#include "jni_instance.h" -#include "jni_runtime.h" -#include "jni_utility.h" -#include "runtime_object.h" -#include "runtime_root.h" - -#ifdef NDEBUG -#define JS_LOG(formatAndArgs...) ((void)0) -#else -#define JS_LOG(formatAndArgs...) { \ - fprintf (stderr, "%s:%d -- %s: ", __FILE__, __LINE__, __FUNCTION__); \ - fprintf(stderr, formatAndArgs); \ -} -#endif - -using namespace KJS::Bindings; -using namespace KJS; - -JavaInstance::JavaInstance (jobject instance, PassRefPtr rootObject) - : Instance(rootObject) -{ - _instance = new JObjectWrapper (instance); - _class = 0; -} - -JavaInstance::~JavaInstance () -{ - delete _class; -} - -#define NUM_LOCAL_REFS 64 - -void JavaInstance::begin() -{ - getJNIEnv()->PushLocalFrame (NUM_LOCAL_REFS); -} - -void JavaInstance::end() -{ - getJNIEnv()->PopLocalFrame (NULL); -} - -Class *JavaInstance::getClass() const -{ - if (_class == 0) - _class = new JavaClass (_instance->_instance); - return _class; -} - -JSValue *JavaInstance::stringValue() const -{ - JSLock lock; - - jstring stringValue = (jstring)callJNIObjectMethod (_instance->_instance, "toString", "()Ljava/lang/String;"); - JNIEnv *env = getJNIEnv(); - const jchar *c = getUCharactersFromJStringInEnv(env, stringValue); - UString u((const UChar *)c, (int)env->GetStringLength(stringValue)); - releaseUCharactersForJStringInEnv(env, stringValue, c); - return jsString(u); -} - -JSValue *JavaInstance::numberValue() const -{ - jdouble doubleValue = callJNIDoubleMethod (_instance->_instance, "doubleValue", "()D"); - return jsNumber(doubleValue); -} - -JSValue *JavaInstance::booleanValue() const -{ - jboolean booleanValue = callJNIBooleanMethod (_instance->_instance, "booleanValue", "()Z"); - return jsBoolean(booleanValue); -} - -JSValue *JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const List &args) -{ - int i, count = args.size(); - jvalue *jArgs; - JSValue *resultValue; - Method *method = 0; - size_t numMethods = methodList.size(); - - // Try to find a good match for the overloaded method. The - // fundamental problem is that JavaScript doesn have the - // notion of method overloading and Java does. We could - // get a bit more sophisticated and attempt to does some - // type checking as we as checking the number of parameters. - Method *aMethod; - for (size_t methodIndex = 0; methodIndex < numMethods; methodIndex++) { - aMethod = methodList[methodIndex]; - if (aMethod->numParameters() == count) { - method = aMethod; - break; - } - } - if (method == 0) { - JS_LOG ("unable to find an appropiate method\n"); - return jsUndefined(); - } - - const JavaMethod *jMethod = static_cast(method); - JS_LOG ("call %s %s on %p\n", method->name(), jMethod->signature(), _instance->_instance); - - if (count > 0) { - jArgs = (jvalue *)malloc (count * sizeof(jvalue)); - } - else - jArgs = 0; - - for (i = 0; i < count; i++) { - JavaParameter* aParameter = jMethod->parameterAt(i); - jArgs[i] = convertValueToJValue (exec, args.at(i), aParameter->getJNIType(), aParameter->type()); - JS_LOG("arg[%d] = %s\n", i, args.at(i)->toString(exec).ascii()); - } - - jvalue result; - - // Try to use the JNI abstraction first, otherwise fall back to - // nornmal JNI. The JNI dispatch abstraction allows the Java plugin - // to dispatch the call on the appropriate internal VM thread. - RootObject* rootObject = this->rootObject(); - if (!rootObject) - return jsUndefined(); - - bool handled = false; - if (rootObject->nativeHandle()) { - jobject obj = _instance->_instance; - JSValue *exceptionDescription = NULL; - const char *callingURL = 0; // FIXME, need to propagate calling URL to Java - handled = dispatchJNICall(rootObject->nativeHandle(), obj, jMethod->isStatic(), jMethod->JNIReturnType(), jMethod->methodID(obj), jArgs, result, callingURL, exceptionDescription); - if (exceptionDescription) { - throwError(exec, GeneralError, exceptionDescription->toString(exec)); - free (jArgs); - return jsUndefined(); - } - } - - // The following code can be conditionally removed once we have a Tiger update that - // contains the new Java plugin. It is needed for builds prior to Tiger. - if (!handled) { - jobject obj = _instance->_instance; - switch (jMethod->JNIReturnType()){ - case void_type: { - callJNIVoidMethodIDA (obj, jMethod->methodID(obj), jArgs); - } - break; - - case object_type: { - result.l = callJNIObjectMethodIDA (obj, jMethod->methodID(obj), jArgs); - } - break; - - case boolean_type: { - result.z = callJNIBooleanMethodIDA (obj, jMethod->methodID(obj), jArgs); - } - break; - - case byte_type: { - result.b = callJNIByteMethodIDA (obj, jMethod->methodID(obj), jArgs); - } - break; - - case char_type: { - result.c = callJNICharMethodIDA (obj, jMethod->methodID(obj), jArgs); - } - break; - - case short_type: { - result.s = callJNIShortMethodIDA (obj, jMethod->methodID(obj), jArgs); - } - break; - - case int_type: { - result.i = callJNIIntMethodIDA (obj, jMethod->methodID(obj), jArgs); - } - break; - - case long_type: { - result.j = callJNILongMethodIDA (obj, jMethod->methodID(obj), jArgs); - } - break; - - case float_type: { - result.f = callJNIFloatMethodIDA (obj, jMethod->methodID(obj), jArgs); - } - break; - - case double_type: { - result.d = callJNIDoubleMethodIDA (obj, jMethod->methodID(obj), jArgs); - } - break; - - case invalid_type: - default: { - } - break; - } - } - - switch (jMethod->JNIReturnType()){ - case void_type: { - resultValue = jsUndefined(); - } - break; - - case object_type: { - if (result.l != 0) { - const char *arrayType = jMethod->returnType(); - if (arrayType[0] == '[') { - resultValue = JavaArray::convertJObjectToArray(exec, result.l, arrayType, rootObject); - } - else { - resultValue = Instance::createRuntimeObject(Instance::JavaLanguage, result.l, rootObject); - } - } - else { - resultValue = jsUndefined(); - } - } - break; - - case boolean_type: { - resultValue = jsBoolean(result.z); - } - break; - - case byte_type: { - resultValue = jsNumber(result.b); - } - break; - - case char_type: { - resultValue = jsNumber(result.c); - } - break; - - case short_type: { - resultValue = jsNumber(result.s); - } - break; - - case int_type: { - resultValue = jsNumber(result.i); - } - break; - - case long_type: { - resultValue = jsNumber(result.j); - } - break; - - case float_type: { - resultValue = jsNumber(result.f); - } - break; - - case double_type: { - resultValue = jsNumber(result.d); - } - break; - - case invalid_type: - default: { - resultValue = jsUndefined(); - } - break; - } - - free (jArgs); - - return resultValue; -} - -JSValue *JavaInstance::defaultValue (JSType hint) const -{ - if (hint == StringType) { - return stringValue(); - } - else if (hint == NumberType) { - return numberValue(); - } - else if (hint == BooleanType) { - return booleanValue(); - } - else if (hint == UnspecifiedType) { - JavaClass *aClass = static_cast(getClass()); - if (aClass->isStringClass()) { - return stringValue(); - } - else if (aClass->isNumberClass()) { - return numberValue(); - } - else if (aClass->isBooleanClass()) { - return booleanValue(); - } - } - - return valueOf(); -} - -JSValue *JavaInstance::valueOf() const -{ - return stringValue(); -} - -JObjectWrapper::JObjectWrapper(jobject instance) -: _refCount(0) -{ - assert (instance != 0); - - // Cache the JNIEnv used to get the global ref for this java instanace. - // It'll be used to delete the reference. - _env = getJNIEnv(); - - _instance = _env->NewGlobalRef (instance); - - JS_LOG ("new global ref %p for %p\n", _instance, instance); - - if (_instance == NULL) { - fprintf (stderr, "%s: could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance); - } -} - -JObjectWrapper::~JObjectWrapper() { - JS_LOG ("deleting global ref %p\n", _instance); - _env->DeleteGlobalRef (_instance); -} - -#endif // ENABLE(JAVA_BINDINGS) diff --git a/bindings/jni/jni_instance.h b/bindings/jni/jni_instance.h deleted file mode 100644 index b00e7f1..0000000 --- a/bindings/jni/jni_instance.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _JNI_INSTANCE_H_ -#define _JNI_INSTANCE_H_ - -#if ENABLE(JAVA_BINDINGS) - -#include "runtime.h" - -#include - - -namespace KJS { - -namespace Bindings { - -class JavaClass; - -class JObjectWrapper -{ -friend class RefPtr; -friend class JavaArray; -friend class JavaField; -friend class JavaInstance; -friend class JavaMethod; - -protected: - JObjectWrapper(jobject instance); - ~JObjectWrapper(); - - void ref() { _refCount++; } - void deref() - { - if (--_refCount == 0) - delete this; - } - - jobject _instance; - -private: - JNIEnv *_env; - unsigned int _refCount; -}; - -class JavaInstance : public Instance -{ -public: - JavaInstance(jobject instance, PassRefPtr); - ~JavaInstance(); - - virtual Class *getClass() const; - - virtual void begin(); - virtual void end(); - - virtual JSValue *valueOf() const; - virtual JSValue *defaultValue (JSType hint) const; - - virtual JSValue *invokeMethod (ExecState *exec, const MethodList &method, const List &args); - - jobject javaInstance() const { return _instance->_instance; } - - JSValue *stringValue() const; - JSValue *numberValue() const; - JSValue *booleanValue() const; - - virtual BindingLanguage getBindingLanguage() const { return JavaLanguage; } - -private: - RefPtr _instance; - mutable JavaClass *_class; -}; - -} // namespace Bindings - -} // namespace KJS - -#endif // ENABLE(JAVA_BINDINGS) - -#endif // _JNI_INSTANCE_H_ diff --git a/bindings/jni/jni_jsobject.cpp b/bindings/jni/jni_jsobject.cpp deleted file mode 100644 index a16c640..0000000 --- a/bindings/jni/jni_jsobject.cpp +++ /dev/null @@ -1,594 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(JAVA_BINDINGS) - -#include "SourceCode.h" -#include "identifier.h" -#include "internal.h" -#include "interpreter.h" -#include "jni_jsobject.h" -#include "jni_runtime.h" -#include "jni_utility.h" -#include "JSGlobalObject.h" -#include "list.h" -#include "runtime_object.h" -#include "runtime_root.h" -#include -#include - -using namespace KJS::Bindings; -using namespace KJS; - -#ifdef NDEBUG -#define JS_LOG(formatAndArgs...) ((void)0) -#else -#define JS_LOG(formatAndArgs...) { \ - fprintf (stderr, "%s(%p,%p): ", __PRETTY_FUNCTION__, RootObject::runLoop(), CFRunLoopGetCurrent()); \ - fprintf(stderr, formatAndArgs); \ -} -#endif - -#define UndefinedHandle 1 - -static bool isJavaScriptThread() -{ - return (RootObject::runLoop() == CFRunLoopGetCurrent()); -} - -jvalue JavaJSObject::invoke (JSObjectCallContext *context) -{ - jvalue result; - - bzero ((void *)&result, sizeof(jvalue)); - - if (!isJavaScriptThread()) { - // Send the call context to the thread that is allowed to - // call JavaScript. - RootObject::dispatchToJavaScriptThread(context); - result = context->result; - } - else { - jlong nativeHandle = context->nativeHandle; - if (nativeHandle == UndefinedHandle || nativeHandle == 0) { - return result; - } - - if (context->type == CreateNative) { - result.j = JavaJSObject::createNative(nativeHandle); - } - else { - JSObject *imp = jlong_to_impptr(nativeHandle); - if (!findProtectingRootObject(imp)) { - fprintf (stderr, "%s:%d: Attempt to access JavaScript from destroyed applet, type %d.\n", __FILE__, __LINE__, context->type); - return result; - } - - switch (context->type){ - case Call: { - result.l = JavaJSObject(nativeHandle).call(context->string, context->args); - break; - } - - case Eval: { - result.l = JavaJSObject(nativeHandle).eval(context->string); - break; - } - - case GetMember: { - result.l = JavaJSObject(nativeHandle).getMember(context->string); - break; - } - - case SetMember: { - JavaJSObject(nativeHandle).setMember(context->string, context->value); - break; - } - - case RemoveMember: { - JavaJSObject(nativeHandle).removeMember(context->string); - break; - } - - case GetSlot: { - result.l = JavaJSObject(nativeHandle).getSlot(context->index); - break; - } - - case SetSlot: { - JavaJSObject(nativeHandle).setSlot(context->index, context->value); - break; - } - - case ToString: { - result.l = (jobject) JavaJSObject(nativeHandle).toString(); - break; - } - - case Finalize: { - JavaJSObject(nativeHandle).finalize(); - break; - } - - default: { - fprintf (stderr, "%s: invalid JavaScript call\n", __PRETTY_FUNCTION__); - } - } - } - context->result = result; - } - - return result; -} - - -JavaJSObject::JavaJSObject(jlong nativeJSObject) -{ - _imp = jlong_to_impptr(nativeJSObject); - - ASSERT(_imp); - _rootObject = findProtectingRootObject(_imp); - ASSERT(_rootObject); -} - -RootObject* JavaJSObject::rootObject() const -{ - return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0; -} - -jobject JavaJSObject::call(jstring methodName, jobjectArray args) const -{ - JS_LOG ("methodName = %s\n", JavaString(methodName).UTF8String()); - - RootObject* rootObject = this->rootObject(); - if (!rootObject) - return 0; - - // Lookup the function object. - ExecState* exec = rootObject->globalObject()->globalExec(); - JSLock lock; - - Identifier identifier(JavaString(methodName).ustring()); - JSValue *func = _imp->get (exec, identifier); - if (func->isUndefinedOrNull()) - return 0; - - // Call the function object. - JSObject *funcImp = static_cast(func); - JSObject *thisObj = const_cast(_imp); - List argList; - getListFromJArray(args, argList); - rootObject->globalObject()->startTimeoutCheck(); - JSValue *result = funcImp->call(exec, thisObj, argList); - rootObject->globalObject()->stopTimeoutCheck(); - - return convertValueToJObject(result); -} - -jobject JavaJSObject::eval(jstring script) const -{ - JS_LOG ("script = %s\n", JavaString(script).UTF8String()); - - JSObject *thisObj = const_cast(_imp); - JSValue *result; - - JSLock lock; - - RootObject* rootObject = this->rootObject(); - if (!rootObject) - return 0; - - rootObject->globalObject()->startTimeoutCheck(); - - SourceCode source = makeSource(JavaString(script).ustring(), UString()); - Completion completion = Interpreter::evaluate(rootObject->globalObject()->globalExec(), source, thisObj); - - rootObject->globalObject()->stopTimeoutCheck(); - ComplType type = completion.complType(); - - if (type == Normal) { - result = completion.value(); - if (!result) - result = jsUndefined(); - } else - result = jsUndefined(); - - return convertValueToJObject (result); -} - -jobject JavaJSObject::getMember(jstring memberName) const -{ - JS_LOG ("(%p) memberName = %s\n", _imp, JavaString(memberName).UTF8String()); - - RootObject* rootObject = this->rootObject(); - if (!rootObject) - return 0; - - ExecState* exec = rootObject->globalObject()->globalExec(); - - JSLock lock; - JSValue *result = _imp->get (exec, Identifier (JavaString(memberName).ustring())); - - return convertValueToJObject(result); -} - -void JavaJSObject::setMember(jstring memberName, jobject value) const -{ - JS_LOG ("memberName = %s, value = %p\n", JavaString(memberName).UTF8String(), value); - - RootObject* rootObject = this->rootObject(); - if (!rootObject) - return; - - ExecState* exec = rootObject->globalObject()->globalExec(); - JSLock lock; - _imp->put(exec, Identifier (JavaString(memberName).ustring()), convertJObjectToValue(value)); -} - - -void JavaJSObject::removeMember(jstring memberName) const -{ - JS_LOG ("memberName = %s\n", JavaString(memberName).UTF8String()); - - RootObject* rootObject = this->rootObject(); - if (!rootObject) - return; - - ExecState* exec = rootObject->globalObject()->globalExec(); - JSLock lock; - _imp->deleteProperty(exec, Identifier (JavaString(memberName).ustring())); -} - - -jobject JavaJSObject::getSlot(jint index) const -{ -#ifdef __LP64__ - JS_LOG ("index = %d\n", index); -#else - JS_LOG ("index = %ld\n", index); -#endif - - RootObject* rootObject = this->rootObject(); - if (!rootObject) - return 0; - - ExecState* exec = rootObject->globalObject()->globalExec(); - - JSLock lock; - JSValue *result = _imp->get (exec, (unsigned)index); - - return convertValueToJObject(result); -} - - -void JavaJSObject::setSlot(jint index, jobject value) const -{ -#ifdef __LP64__ - JS_LOG ("index = %d, value = %p\n", index, value); -#else - JS_LOG ("index = %ld, value = %p\n", index, value); -#endif - - RootObject* rootObject = this->rootObject(); - if (!rootObject) - return; - - ExecState* exec = rootObject->globalObject()->globalExec(); - JSLock lock; - _imp->put(exec, (unsigned)index, convertJObjectToValue(value)); -} - - -jstring JavaJSObject::toString() const -{ - JS_LOG ("\n"); - - RootObject* rootObject = this->rootObject(); - if (!rootObject) - return 0; - - JSLock lock; - JSObject *thisObj = const_cast(_imp); - ExecState* exec = rootObject->globalObject()->globalExec(); - - return (jstring)convertValueToJValue (exec, thisObj, object_type, "java.lang.String").l; -} - -void JavaJSObject::finalize() const -{ - if (RootObject* rootObject = this->rootObject()) - rootObject->gcUnprotect(_imp); -} - -// We're either creating a 'Root' object (via a call to JavaJSObject.getWindow()), or -// another JavaJSObject. -jlong JavaJSObject::createNative(jlong nativeHandle) -{ - JS_LOG ("nativeHandle = %d\n", (int)nativeHandle); - - if (nativeHandle == UndefinedHandle) - return nativeHandle; - - if (findProtectingRootObject(jlong_to_impptr(nativeHandle))) - return nativeHandle; - - CreateRootObjectFunction createRootObject = RootObject::createRootObject(); - if (!createRootObject) - return ptr_to_jlong(0); - - RefPtr rootObject = createRootObject(jlong_to_ptr(nativeHandle)); - - // If rootObject is !NULL We must have been called via netscape.javascript.JavaJSObject.getWindow(), - // otherwise we are being called after creating a JavaJSObject in - // JavaJSObject::convertValueToJObject(). - if (rootObject) { - JSObject* globalObject = rootObject->globalObject(); - // We call gcProtect here to get the object into the root object's "protect set" which - // is used to test if a native handle is valid as well as getting the root object given the handle. - rootObject->gcProtect(globalObject); - return ptr_to_jlong(globalObject); - } - - return nativeHandle; -} - -jobject JavaJSObject::convertValueToJObject (JSValue *value) const -{ - JSLock lock; - - RootObject* rootObject = this->rootObject(); - if (!rootObject) - return 0; - - ExecState* exec = rootObject->globalObject()->globalExec(); - JNIEnv *env = getJNIEnv(); - jobject result = 0; - - // See section 22.7 of 'JavaScript: The Definitive Guide, 4th Edition', - // figure 22-5. - // number -> java.lang.Double - // string -> java.lang.String - // boolean -> java.lang.Boolean - // Java instance -> Java instance - // Everything else -> JavaJSObject - - JSType type = value->type(); - if (type == NumberType) { - jclass JSObjectClass = env->FindClass ("java/lang/Double"); - jmethodID constructorID = env->GetMethodID (JSObjectClass, "", "(D)V"); - if (constructorID != NULL) { - result = env->NewObject (JSObjectClass, constructorID, (jdouble)value->toNumber(exec)); - } - } - else if (type == StringType) { - UString stringValue = value->toString(exec); - JNIEnv *env = getJNIEnv(); - result = env->NewString ((const jchar *)stringValue.data(), stringValue.size()); - } - else if (type == BooleanType) { - jclass JSObjectClass = env->FindClass ("java/lang/Boolean"); - jmethodID constructorID = env->GetMethodID (JSObjectClass, "", "(Z)V"); - if (constructorID != NULL) { - result = env->NewObject (JSObjectClass, constructorID, (jboolean)value->toBoolean(exec)); - } - } - else { - // Create a JavaJSObject. - jlong nativeHandle; - - if (type == ObjectType){ - JSObject *imp = static_cast(value); - - // We either have a wrapper around a Java instance or a JavaScript - // object. If we have a wrapper around a Java instance, return that - // instance, otherwise create a new Java JavaJSObject with the JSObject* - // as it's nativeHandle. - if (imp->classInfo() && strcmp(imp->classInfo()->className, "RuntimeObject") == 0) { - RuntimeObjectImp *runtimeImp = static_cast(value); - JavaInstance *runtimeInstance = static_cast(runtimeImp->getInternalInstance()); - if (!runtimeInstance) - return 0; - - return runtimeInstance->javaInstance(); - } - else { - nativeHandle = ptr_to_jlong(imp); - rootObject->gcProtect(imp); - } - } - // All other types will result in an undefined object. - else { - nativeHandle = UndefinedHandle; - } - - // Now create the Java JavaJSObject. Look for the JavaJSObject in it's new (Tiger) - // location and in the original Java 1.4.2 location. - jclass JSObjectClass; - - JSObjectClass = env->FindClass ("sun/plugin/javascript/webkit/JSObject"); - if (!JSObjectClass) { - env->ExceptionDescribe(); - env->ExceptionClear(); - JSObjectClass = env->FindClass ("apple/applet/JSObject"); - } - - jmethodID constructorID = env->GetMethodID (JSObjectClass, "", "(J)V"); - if (constructorID != NULL) { - result = env->NewObject (JSObjectClass, constructorID, nativeHandle); - } - } - - return result; -} - -JSValue *JavaJSObject::convertJObjectToValue (jobject theObject) const -{ - // Instances of netscape.javascript.JSObject get converted back to - // JavaScript objects. All other objects are wrapped. It's not - // possible to pass primitive types from the Java to JavaScript. - // See section 22.7 of 'JavaScript: The Definitive Guide, 4th Edition', - // figure 22-4. - jobject classOfInstance = callJNIObjectMethod(theObject, "getClass", "()Ljava/lang/Class;"); - jstring className = (jstring)callJNIObjectMethod(classOfInstance, "getName", "()Ljava/lang/String;"); - - // Only the sun.plugin.javascript.webkit.JSObject has a member called nativeJSObject. This class is - // created above to wrap internal browser objects. The constructor of this class takes the native - // pointer and stores it in this object, so that it can be retrieved below. - if (strcmp(JavaString(className).UTF8String(), "sun.plugin.javascript.webkit.JSObject") == 0) { - // Pull the nativeJSObject value from the Java instance. This is a - // pointer to the JSObject. - JNIEnv *env = getJNIEnv(); - jfieldID fieldID = env->GetFieldID((jclass)classOfInstance, "nativeJSObject", "J"); - if (fieldID == NULL) { - return jsUndefined(); - } - jlong nativeHandle = env->GetLongField(theObject, fieldID); - if (nativeHandle == UndefinedHandle) { - return jsUndefined(); - } - JSObject *imp = static_cast(jlong_to_impptr(nativeHandle)); - return imp; - } - - JSLock lock; - JavaInstance* javaInstance = new JavaInstance(theObject, _rootObject); - return KJS::Bindings::Instance::createRuntimeObject(javaInstance); -} - -void JavaJSObject::getListFromJArray(jobjectArray jArray, List& list) const -{ - JNIEnv *env = getJNIEnv(); - int i, numObjects = jArray ? env->GetArrayLength (jArray) : 0; - - for (i = 0; i < numObjects; i++) { - jobject anObject = env->GetObjectArrayElement ((jobjectArray)jArray, i); - if (anObject) { - list.append(convertJObjectToValue(anObject)); - env->DeleteLocalRef (anObject); - } - else { - env->ExceptionDescribe(); - env->ExceptionClear(); - } - } -} - -extern "C" { - -jlong KJS_JSCreateNativeJSObject (JNIEnv*, jclass, jstring, jlong nativeHandle, jboolean) -{ - JSObjectCallContext context; - context.type = CreateNative; - context.nativeHandle = nativeHandle; - return JavaJSObject::invoke (&context).j; -} - -void KJS_JSObject_JSFinalize (JNIEnv*, jclass, jlong nativeHandle) -{ - JSObjectCallContext context; - context.type = Finalize; - context.nativeHandle = nativeHandle; - JavaJSObject::invoke (&context); -} - -jobject KJS_JSObject_JSObjectCall (JNIEnv*, jclass, jlong nativeHandle, jstring, jstring methodName, jobjectArray args, jboolean) -{ - JSObjectCallContext context; - context.type = Call; - context.nativeHandle = nativeHandle; - context.string = methodName; - context.args = args; - return JavaJSObject::invoke (&context).l; -} - -jobject KJS_JSObject_JSObjectEval (JNIEnv*, jclass, jlong nativeHandle, jstring, jstring jscript, jboolean) -{ - JSObjectCallContext context; - context.type = Eval; - context.nativeHandle = nativeHandle; - context.string = jscript; - return JavaJSObject::invoke (&context).l; -} - -jobject KJS_JSObject_JSObjectGetMember (JNIEnv*, jclass, jlong nativeHandle, jstring, jstring jname, jboolean) -{ - JSObjectCallContext context; - context.type = GetMember; - context.nativeHandle = nativeHandle; - context.string = jname; - return JavaJSObject::invoke (&context).l; -} - -void KJS_JSObject_JSObjectSetMember (JNIEnv*, jclass, jlong nativeHandle, jstring, jstring jname, jobject value, jboolean) -{ - JSObjectCallContext context; - context.type = SetMember; - context.nativeHandle = nativeHandle; - context.string = jname; - context.value = value; - JavaJSObject::invoke (&context); -} - -void KJS_JSObject_JSObjectRemoveMember (JNIEnv*, jclass, jlong nativeHandle, jstring, jstring jname, jboolean) -{ - JSObjectCallContext context; - context.type = RemoveMember; - context.nativeHandle = nativeHandle; - context.string = jname; - JavaJSObject::invoke (&context); -} - -jobject KJS_JSObject_JSObjectGetSlot (JNIEnv*, jclass, jlong nativeHandle, jstring, jint jindex, jboolean) -{ - JSObjectCallContext context; - context.type = GetSlot; - context.nativeHandle = nativeHandle; - context.index = jindex; - return JavaJSObject::invoke (&context).l; -} - -void KJS_JSObject_JSObjectSetSlot (JNIEnv*, jclass, jlong nativeHandle, jstring, jint jindex, jobject value, jboolean) -{ - JSObjectCallContext context; - context.type = SetSlot; - context.nativeHandle = nativeHandle; - context.index = jindex; - context.value = value; - JavaJSObject::invoke (&context); -} - -jstring KJS_JSObject_JSObjectToString (JNIEnv*, jclass, jlong nativeHandle) -{ - JSObjectCallContext context; - context.type = ToString; - context.nativeHandle = nativeHandle; - return (jstring)JavaJSObject::invoke (&context).l; -} - -} - -#endif // ENABLE(JAVA_BINDINGS) diff --git a/bindings/jni/jni_jsobject.h b/bindings/jni/jni_jsobject.h deleted file mode 100644 index d559fa1..0000000 --- a/bindings/jni/jni_jsobject.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JAVASCRIPTCORE_BINDINGS_JNI_JSOBJECT_H -#define JAVASCRIPTCORE_BINDINGS_JNI_JSOBJECT_H - -#if ENABLE(JAVA_BINDINGS) - -#if PLATFORM(MAC) -#include -#endif - -#include -#include - -#define jlong_to_ptr(a) ((void*)(uintptr_t)(a)) -#define jlong_to_impptr(a) (static_cast(((void*)(uintptr_t)(a)))) -#define ptr_to_jlong(a) ((jlong)(uintptr_t)(a)) - -namespace KJS { - -class List; -class JSObject; -class JSValue; - -namespace Bindings { - -class RootObject; - -enum JSObjectCallType { - CreateNative, - Call, - Eval, - GetMember, - SetMember, - RemoveMember, - GetSlot, - SetSlot, - ToString, - Finalize -}; - -struct JSObjectCallContext -{ - JSObjectCallType type; - jlong nativeHandle; - jstring string; - jobjectArray args; - jint index; - jobject value; - CFRunLoopRef originatingLoop; - jvalue result; -}; - -class JavaJSObject -{ -public: - JavaJSObject(jlong nativeHandle); - - static jlong createNative(jlong nativeHandle); - jobject call(jstring methodName, jobjectArray args) const; - jobject eval(jstring script) const; - jobject getMember(jstring memberName) const; - void setMember(jstring memberName, jobject value) const; - void removeMember(jstring memberName) const; - jobject getSlot(jint index) const; - void setSlot(jint index, jobject value) const; - jstring toString() const; - void finalize() const; - - static jvalue invoke(JSObjectCallContext*); - - jobject convertValueToJObject(JSValue*) const; - JSValue* convertJObjectToValue(jobject) const; - void getListFromJArray(jobjectArray, List&) const; - - RootObject* rootObject() const; - -private: - RefPtr _rootObject; - JSObject* _imp; -}; - - -} // namespace Bindings - -} // namespace KJS - -extern "C" { - -// The Java VM calls these functions to handle calls to methods in Java's JSObject class. -jlong KJS_JSCreateNativeJSObject(JNIEnv*, jclass, jstring jurl, jlong nativeHandle, jboolean ctx); -void KJS_JSObject_JSFinalize(JNIEnv*, jclass, jlong nativeJSObject); -jobject KJS_JSObject_JSObjectCall(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jstring methodName, jobjectArray args, jboolean ctx); -jobject KJS_JSObject_JSObjectEval(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jstring jscript, jboolean ctx); -jobject KJS_JSObject_JSObjectGetMember(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jstring jname, jboolean ctx); -void KJS_JSObject_JSObjectSetMember(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jstring jname, jobject value, jboolean ctx); -void KJS_JSObject_JSObjectRemoveMember(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jstring jname, jboolean ctx); -jobject KJS_JSObject_JSObjectGetSlot(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jint jindex, jboolean ctx); -void KJS_JSObject_JSObjectSetSlot(JNIEnv*, jclass, jlong nativeJSObject, jstring jurl, jint jindex, jobject value, jboolean ctx); -jstring KJS_JSObject_JSObjectToString(JNIEnv*, jclass, jlong nativeJSObject); - -} - -#endif // ENABLE(JAVA_BINDINGS) - -#endif // JAVASCRIPTCORE_BINDINGS_JNI_JSOBJECT_H diff --git a/bindings/jni/jni_objc.mm b/bindings/jni/jni_objc.mm deleted file mode 100644 index c5ba0af..0000000 --- a/bindings/jni/jni_objc.mm +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(JAVA_BINDINGS) - -#import -#import -#import - -using namespace KJS::Bindings; - -@interface NSObject (WebScriptingPrivate) -- (jvalue)webPlugInCallJava:(jobject)object method:(jmethodID)method returnType:(JNIType)returnType arguments:(jvalue*)args; -- (jvalue)webPlugInCallJava:(jobject)object - isStatic:(BOOL)isStatic - returnType:(JNIType)returnType - method:(jmethodID)method - arguments:(jvalue*)args - callingURL:(NSURL *)url - exceptionDescription:(NSString **)exceptionString; -@end - -bool KJS::Bindings::dispatchJNICall (const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char*, JSValue *&exceptionDescription) -{ - id view = (id)targetAppletView; - - // As array_type is not known by the Mac JVM, change it to a compatible type. - if (returnType == array_type) - returnType = object_type; - - if ([view respondsToSelector:@selector(webPlugInCallJava:isStatic:returnType:method:arguments:callingURL:exceptionDescription:)]) { - NSString *_exceptionDescription = 0; - - // Passing nil as the calling URL will cause the Java plugin to use the URL - // of the page that contains the applet. The execution restrictions - // implemented in WebCore will guarantee that only appropriate JavaScript - // can reference the applet. - { - JSLock::DropAllLocks dropAllLocks; - result = [view webPlugInCallJava:obj isStatic:isStatic returnType:returnType method:methodID arguments:args callingURL:nil exceptionDescription:&_exceptionDescription]; - } - - if (_exceptionDescription != 0) { - exceptionDescription = convertNSStringToString(_exceptionDescription); - } - return true; - } - else if ([view respondsToSelector:@selector(webPlugInCallJava:method:returnType:arguments:)]) { - JSLock::DropAllLocks dropAllLocks; - result = [view webPlugInCallJava:obj method:methodID returnType:returnType arguments:args]; - return true; - } - - bzero (&result, sizeof(jvalue)); - return false; -} - -#endif // ENABLE(JAVA_BINDINGS) diff --git a/bindings/jni/jni_runtime.cpp b/bindings/jni/jni_runtime.cpp deleted file mode 100644 index e42ac82..0000000 --- a/bindings/jni/jni_runtime.cpp +++ /dev/null @@ -1,549 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(JAVA_BINDINGS) - -#include -#include -#include - -#include -#include - -#include -#include -#include - -#ifdef NDEBUG -#define JS_LOG(formatAndArgs...) ((void)0) -#else -#define JS_LOG(formatAndArgs...) { \ - fprintf (stderr, "%s:%d -- %s: ", __FILE__, __LINE__, __FUNCTION__); \ - fprintf(stderr, formatAndArgs); \ -} -#endif - -using namespace KJS; -using namespace KJS::Bindings; - - -JavaParameter::JavaParameter (JNIEnv *env, jstring type) -{ - _type = JavaString (env, type); - _JNIType = JNITypeFromClassName (_type.UTF8String()); -} - -JavaField::JavaField (JNIEnv *env, jobject aField) -{ - // Get field type - jobject fieldType = callJNIObjectMethod (aField, "getType", "()Ljava/lang/Class;"); - jstring fieldTypeName = (jstring)callJNIObjectMethod (fieldType, "getName", "()Ljava/lang/String;"); - _type = JavaString(env, fieldTypeName); - _JNIType = JNITypeFromClassName (_type.UTF8String()); - - // Get field name - jstring fieldName = (jstring)callJNIObjectMethod (aField, "getName", "()Ljava/lang/String;"); - _name = JavaString(env, fieldName); - - _field = new JObjectWrapper(aField); -} - -JSValue* JavaArray::convertJObjectToArray(ExecState* exec, jobject anObject, const char* type, PassRefPtr rootObject) -{ - if (type[0] != '[') - return jsUndefined(); - - return new RuntimeArray(exec, new JavaArray((jobject)anObject, type, rootObject)); -} - -jvalue JavaField::dispatchValueFromInstance(ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const -{ - jobject jinstance = instance->javaInstance(); - jobject fieldJInstance = _field->_instance; - JNIEnv *env = getJNIEnv(); - jvalue result; - - bzero (&result, sizeof(jvalue)); - jclass cls = env->GetObjectClass(fieldJInstance); - if ( cls != NULL ) { - jmethodID mid = env->GetMethodID(cls, name, sig); - if ( mid != NULL ) - { - RootObject* rootObject = instance->rootObject(); - if (rootObject && rootObject->nativeHandle()) { - JSValue *exceptionDescription = NULL; - jvalue args[1]; - - args[0].l = jinstance; - dispatchJNICall(rootObject->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription); - if (exceptionDescription) - throwError(exec, GeneralError, exceptionDescription->toString(exec)); - } - } - } - return result; -} - -JSValue *JavaField::valueFromInstance(ExecState *exec, const Instance *i) const -{ - const JavaInstance *instance = static_cast(i); - - JSValue *jsresult = jsUndefined(); - - switch (_JNIType) { - case array_type: - case object_type: { - jvalue result = dispatchValueFromInstance (exec, instance, "get", "(Ljava/lang/Object;)Ljava/lang/Object;", object_type); - jobject anObject = result.l; - - const char *arrayType = type(); - if (arrayType[0] == '[') { - jsresult = JavaArray::convertJObjectToArray(exec, anObject, arrayType, instance->rootObject()); - } - else if (anObject != 0){ - jsresult = Instance::createRuntimeObject(Instance::JavaLanguage, anObject, instance->rootObject()); - } - } - break; - - case boolean_type: - jsresult = jsBoolean(dispatchValueFromInstance(exec, instance, "getBoolean", "(Ljava/lang/Object;)Z", boolean_type).z); - break; - - case byte_type: - case char_type: - case short_type: - - case int_type: { - jint value; - jvalue result = dispatchValueFromInstance (exec, instance, "getInt", "(Ljava/lang/Object;)I", int_type); - value = result.i; - jsresult = jsNumber((int)value); - } - break; - - case long_type: - case float_type: - case double_type: { - jdouble value; - jvalue result = dispatchValueFromInstance (exec, instance, "getDouble", "(Ljava/lang/Object;)D", double_type); - value = result.i; - jsresult = jsNumber((double)value); - } - break; - default: - break; - } - - JS_LOG ("getting %s = %s\n", name(), jsresult->toString(exec).ascii()); - - return jsresult; -} - -void JavaField::dispatchSetValueToInstance(ExecState *exec, const JavaInstance *instance, jvalue javaValue, const char *name, const char *sig) const -{ - jobject jinstance = instance->javaInstance(); - jobject fieldJInstance = _field->_instance; - JNIEnv *env = getJNIEnv(); - - jclass cls = env->GetObjectClass(fieldJInstance); - if ( cls != NULL ) { - jmethodID mid = env->GetMethodID(cls, name, sig); - if ( mid != NULL ) - { - RootObject* rootObject = instance->rootObject(); - if (rootObject && rootObject->nativeHandle()) { - JSValue *exceptionDescription = NULL; - jvalue args[2]; - jvalue result; - - args[0].l = jinstance; - args[1] = javaValue; - dispatchJNICall(rootObject->nativeHandle(), fieldJInstance, false, void_type, mid, args, result, 0, exceptionDescription); - if (exceptionDescription) - throwError(exec, GeneralError, exceptionDescription->toString(exec)); - } - } - } -} - -void JavaField::setValueToInstance(ExecState *exec, const Instance *i, JSValue *aValue) const -{ - const JavaInstance *instance = static_cast(i); - jvalue javaValue = convertValueToJValue (exec, aValue, _JNIType, type()); - - JS_LOG ("setting value %s to %s\n", name(), aValue->toString(exec).ascii()); - - switch (_JNIType) { - case array_type: - case object_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "set", "(Ljava/lang/Object;Ljava/lang/Object;)V"); - } - break; - - case boolean_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setBoolean", "(Ljava/lang/Object;Z)V"); - } - break; - - case byte_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setByte", "(Ljava/lang/Object;B)V"); - } - break; - - case char_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setChar", "(Ljava/lang/Object;C)V"); - } - break; - - case short_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setShort", "(Ljava/lang/Object;S)V"); - } - break; - - case int_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setInt", "(Ljava/lang/Object;I)V"); - } - break; - - case long_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setLong", "(Ljava/lang/Object;J)V"); - } - break; - - case float_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setFloat", "(Ljava/lang/Object;F)V"); - } - break; - - case double_type: { - dispatchSetValueToInstance (exec, instance, javaValue, "setDouble", "(Ljava/lang/Object;D)V"); - } - break; - default: - break; - } -} - -JavaMethod::JavaMethod (JNIEnv *env, jobject aMethod) -{ - // Get return type - jobject returnType = callJNIObjectMethod (aMethod, "getReturnType", "()Ljava/lang/Class;"); - jstring returnTypeName = (jstring)callJNIObjectMethod (returnType, "getName", "()Ljava/lang/String;"); - _returnType =JavaString (env, returnTypeName); - _JNIReturnType = JNITypeFromClassName (_returnType.UTF8String()); - env->DeleteLocalRef (returnType); - env->DeleteLocalRef (returnTypeName); - - // Get method name - jstring methodName = (jstring)callJNIObjectMethod (aMethod, "getName", "()Ljava/lang/String;"); - _name = JavaString (env, methodName); - env->DeleteLocalRef (methodName); - - // Get parameters - jarray jparameters = (jarray)callJNIObjectMethod (aMethod, "getParameterTypes", "()[Ljava/lang/Class;"); - _numParameters = env->GetArrayLength (jparameters); - _parameters = new JavaParameter[_numParameters]; - - int i; - for (i = 0; i < _numParameters; i++) { - jobject aParameter = env->GetObjectArrayElement ((jobjectArray)jparameters, i); - jstring parameterName = (jstring)callJNIObjectMethod (aParameter, "getName", "()Ljava/lang/String;"); - _parameters[i] = JavaParameter(env, parameterName); - env->DeleteLocalRef (aParameter); - env->DeleteLocalRef (parameterName); - } - env->DeleteLocalRef (jparameters); - - // Created lazily. - _signature = 0; - _methodID = 0; - - jclass modifierClass = env->FindClass("java/lang/reflect/Modifier"); - int modifiers = callJNIIntMethod (aMethod, "getModifiers", "()I"); - _isStatic = (bool)callJNIStaticBooleanMethod (modifierClass, "isStatic", "(I)Z", modifiers); -} - -JavaMethod::~JavaMethod() -{ - if (_signature) - free(_signature); - delete [] _parameters; -}; - -// JNI method signatures use '/' between components of a class name, but -// we get '.' between components from the reflection API. -static void appendClassName(UString& aString, const char* className) -{ - ASSERT(JSLock::lockCount() > 0); - - char *result, *cp = strdup(className); - - result = cp; - while (*cp) { - if (*cp == '.') - *cp = '/'; - cp++; - } - - aString.append(result); - - free (result); -} - -const char *JavaMethod::signature() const -{ - if (!_signature) { - JSLock lock; - - UString signatureBuilder("("); - for (int i = 0; i < _numParameters; i++) { - JavaParameter* aParameter = parameterAt(i); - JNIType _JNIType = aParameter->getJNIType(); - if (_JNIType == array_type) - appendClassName(signatureBuilder, aParameter->type()); - else { - signatureBuilder.append(signatureFromPrimitiveType(_JNIType)); - if (_JNIType == object_type) { - appendClassName(signatureBuilder, aParameter->type()); - signatureBuilder.append(";"); - } - } - } - signatureBuilder.append(")"); - - const char *returnType = _returnType.UTF8String(); - if (_JNIReturnType == array_type) { - appendClassName(signatureBuilder, returnType); - } else { - signatureBuilder.append(signatureFromPrimitiveType(_JNIReturnType)); - if (_JNIReturnType == object_type) { - appendClassName(signatureBuilder, returnType); - signatureBuilder.append(";"); - } - } - - _signature = strdup(signatureBuilder.ascii()); - } - - return _signature; -} - -JNIType JavaMethod::JNIReturnType() const -{ - return _JNIReturnType; -} - -jmethodID JavaMethod::methodID (jobject obj) const -{ - if (_methodID == 0) { - _methodID = getMethodID (obj, name(), signature()); - } - return _methodID; -} - - -JavaArray::JavaArray(jobject array, const char* type, PassRefPtr rootObject) - : Array(rootObject) -{ - _array = new JObjectWrapper(array); - // Java array are fixed length, so we can cache length. - JNIEnv *env = getJNIEnv(); - _length = env->GetArrayLength((jarray)_array->_instance); - _type = strdup(type); - _rootObject = rootObject; -} - -JavaArray::~JavaArray () -{ - free ((void *)_type); -} - -RootObject* JavaArray::rootObject() const -{ - return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0; -} - -void JavaArray::setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const -{ - JNIEnv *env = getJNIEnv(); - char *javaClassName = 0; - - JNIType arrayType = JNITypeFromPrimitiveType(_type[1]); - if (_type[1] == 'L'){ - // The type of the array will be something like: - // "[Ljava.lang.string;". This is guaranteed, so no need - // for extra sanity checks. - javaClassName = strdup(&_type[2]); - javaClassName[strchr(javaClassName, ';')-javaClassName] = 0; - } - jvalue aJValue = convertValueToJValue (exec, aValue, arrayType, javaClassName); - - switch (arrayType) { - case object_type: { - env->SetObjectArrayElement((jobjectArray)javaArray(), index, aJValue.l); - break; - } - - case boolean_type: { - env->SetBooleanArrayRegion((jbooleanArray)javaArray(), index, 1, &aJValue.z); - break; - } - - case byte_type: { - env->SetByteArrayRegion((jbyteArray)javaArray(), index, 1, &aJValue.b); - break; - } - - case char_type: { - env->SetCharArrayRegion((jcharArray)javaArray(), index, 1, &aJValue.c); - break; - } - - case short_type: { - env->SetShortArrayRegion((jshortArray)javaArray(), index, 1, &aJValue.s); - break; - } - - case int_type: { - env->SetIntArrayRegion((jintArray)javaArray(), index, 1, &aJValue.i); - break; - } - - case long_type: { - env->SetLongArrayRegion((jlongArray)javaArray(), index, 1, &aJValue.j); - } - - case float_type: { - env->SetFloatArrayRegion((jfloatArray)javaArray(), index, 1, &aJValue.f); - break; - } - - case double_type: { - env->SetDoubleArrayRegion((jdoubleArray)javaArray(), index, 1, &aJValue.d); - break; - } - default: - break; - } - - if (javaClassName) - free ((void *)javaClassName); -} - - -JSValue *JavaArray::valueAt(ExecState *exec, unsigned int index) const -{ - JNIEnv *env = getJNIEnv(); - JNIType arrayType = JNITypeFromPrimitiveType(_type[1]); - switch (arrayType) { - case object_type: { - jobjectArray objectArray = (jobjectArray)javaArray(); - jobject anObject; - anObject = env->GetObjectArrayElement(objectArray, index); - - // No object? - if (!anObject) { - return jsNull(); - } - - // Nested array? - if (_type[1] == '[') { - return JavaArray::convertJObjectToArray(exec, anObject, _type+1, rootObject()); - } - // or array of other object type? - return Instance::createRuntimeObject(Instance::JavaLanguage, anObject, rootObject()); - } - - case boolean_type: { - jbooleanArray booleanArray = (jbooleanArray)javaArray(); - jboolean aBoolean; - env->GetBooleanArrayRegion(booleanArray, index, 1, &aBoolean); - return jsBoolean(aBoolean); - } - - case byte_type: { - jbyteArray byteArray = (jbyteArray)javaArray(); - jbyte aByte; - env->GetByteArrayRegion(byteArray, index, 1, &aByte); - return jsNumber(aByte); - } - - case char_type: { - jcharArray charArray = (jcharArray)javaArray(); - jchar aChar; - env->GetCharArrayRegion(charArray, index, 1, &aChar); - return jsNumber(aChar); - break; - } - - case short_type: { - jshortArray shortArray = (jshortArray)javaArray(); - jshort aShort; - env->GetShortArrayRegion(shortArray, index, 1, &aShort); - return jsNumber(aShort); - } - - case int_type: { - jintArray intArray = (jintArray)javaArray(); - jint anInt; - env->GetIntArrayRegion(intArray, index, 1, &anInt); - return jsNumber(anInt); - } - - case long_type: { - jlongArray longArray = (jlongArray)javaArray(); - jlong aLong; - env->GetLongArrayRegion(longArray, index, 1, &aLong); - return jsNumber(aLong); - } - - case float_type: { - jfloatArray floatArray = (jfloatArray)javaArray(); - jfloat aFloat; - env->GetFloatArrayRegion(floatArray, index, 1, &aFloat); - return jsNumber(aFloat); - } - - case double_type: { - jdoubleArray doubleArray = (jdoubleArray)javaArray(); - jdouble aDouble; - env->GetDoubleArrayRegion(doubleArray, index, 1, &aDouble); - return jsNumber(aDouble); - } - default: - break; - } - return jsUndefined(); -} - -unsigned int JavaArray::getLength() const -{ - return _length; -} - -#endif // ENABLE(JAVA_BINDINGS) diff --git a/bindings/jni/jni_runtime.h b/bindings/jni/jni_runtime.h deleted file mode 100644 index eb6d273..0000000 --- a/bindings/jni/jni_runtime.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _JNI_RUNTIME_H_ -#define _JNI_RUNTIME_H_ - -#if ENABLE(JAVA_BINDINGS) - -#include -#include - - -namespace KJS -{ - -namespace Bindings -{ - -typedef const char* RuntimeType; - -class JavaString -{ -public: - JavaString() - { - JSLock lock; - _rep = UString().rep(); - } - - void _commonInit (JNIEnv *e, jstring s) - { - int _size = e->GetStringLength (s); - const jchar *uc = getUCharactersFromJStringInEnv (e, s); - { - JSLock lock; - _rep = UString((UChar *)uc,_size).rep(); - } - releaseUCharactersForJStringInEnv (e, s, uc); - } - - JavaString (JNIEnv *e, jstring s) { - _commonInit (e, s); - } - - JavaString (jstring s) { - _commonInit (getJNIEnv(), s); - } - - ~JavaString() - { - JSLock lock; - _rep = 0; - } - - const char *UTF8String() const { - if (_utf8String.c_str() == 0) { - JSLock lock; - _utf8String = UString(_rep).UTF8String(); - } - return _utf8String.c_str(); - } - const jchar *uchars() const { return (const jchar *)_rep->data(); } - int length() const { return _rep->size(); } - UString ustring() const { return UString(_rep); } - -private: - RefPtr _rep; - mutable CString _utf8String; -}; - -class JavaParameter -{ -public: - JavaParameter () : _JNIType(invalid_type) {}; - JavaParameter (JNIEnv *env, jstring type); - virtual ~JavaParameter() { } - - RuntimeType type() const { return _type.UTF8String(); } - JNIType getJNIType() const { return _JNIType; } - -private: - JavaString _type; - JNIType _JNIType; -}; - - -class JavaField : public Field -{ -public: - JavaField (JNIEnv *env, jobject aField); - - virtual JSValue *valueFromInstance(ExecState *exec, const Instance *instance) const; - virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue *aValue) const; - - virtual const char *name() const { return _name.UTF8String(); } - virtual RuntimeType type() const { return _type.UTF8String(); } - - JNIType getJNIType() const { return _JNIType; } - -private: - void dispatchSetValueToInstance(ExecState *exec, const JavaInstance *instance, jvalue javaValue, const char *name, const char *sig) const; - jvalue dispatchValueFromInstance(ExecState *exec, const JavaInstance *instance, const char *name, const char *sig, JNIType returnType) const; - - JavaString _name; - JavaString _type; - JNIType _JNIType; - RefPtr _field; -}; - - -class JavaMethod : public Method -{ -public: - JavaMethod(JNIEnv* env, jobject aMethod); - ~JavaMethod(); - - virtual const char *name() const { return _name.UTF8String(); }; - RuntimeType returnType() const { return _returnType.UTF8String(); }; - JavaParameter* parameterAt(int i) const { return &_parameters[i]; }; - int numParameters() const { return _numParameters; }; - - const char *signature() const; - JNIType JNIReturnType() const; - - jmethodID methodID (jobject obj) const; - - bool isStatic() const { return _isStatic; } - -private: - JavaParameter* _parameters; - int _numParameters; - JavaString _name; - mutable char* _signature; - JavaString _returnType; - JNIType _JNIReturnType; - mutable jmethodID _methodID; - bool _isStatic; -}; - -class JavaArray : public Array -{ -public: - JavaArray(jobject array, const char* type, PassRefPtr); - virtual ~JavaArray(); - - RootObject* rootObject() const; - - virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const; - virtual JSValue *valueAt(ExecState *exec, unsigned int index) const; - virtual unsigned int getLength() const; - - jobject javaArray() const { return _array->_instance; } - - static JSValue* convertJObjectToArray (ExecState* exec, jobject anObject, const char* type, PassRefPtr); - -private: - RefPtr _array; - unsigned int _length; - const char *_type; -}; - -} // namespace Bindings - -} // namespace KJS - -#endif // ENABLE(JAVA_BINDINGS) - -#endif // _JNI_RUNTIME_H_ diff --git a/bindings/jni/jni_utility.cpp b/bindings/jni/jni_utility.cpp deleted file mode 100644 index 967aa54..0000000 --- a/bindings/jni/jni_utility.cpp +++ /dev/null @@ -1,992 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(JAVA_BINDINGS) - -#include "jni_utility.h" - -#include "list.h" -#include "jni_runtime.h" -#include "runtime_array.h" -#include "runtime_object.h" -#include - -namespace KJS { - -namespace Bindings { - -static jint KJS_GetCreatedJavaVMs(JavaVM** vmBuf, jsize bufLen, jsize* nVMs) -{ - static void* javaVMFramework = 0; - if (!javaVMFramework) - javaVMFramework = dlopen("/System/Library/Frameworks/JavaVM.framework/JavaVM", RTLD_LAZY); - if (!javaVMFramework) - return JNI_ERR; - - static jint(*functionPointer)(JavaVM**, jsize, jsize *) = 0; - if (!functionPointer) - functionPointer = (jint(*)(JavaVM**, jsize, jsize *))dlsym(javaVMFramework, "JNI_GetCreatedJavaVMs"); - if (!functionPointer) - return JNI_ERR; - return functionPointer(vmBuf, bufLen, nVMs); -} - -static JavaVM *jvm = 0; - -// Provide the ability for an outside component to specify the JavaVM to use -// If the jvm value is set, the getJavaVM function below will just return. -// In getJNIEnv(), if AttachCurrentThread is called to a VM that is already -// attached, the result is a no-op. -void setJavaVM(JavaVM *javaVM) -{ - jvm = javaVM; -} - -JavaVM *getJavaVM() -{ - if (jvm) - return jvm; - - JavaVM *jvmArray[1]; - jsize bufLen = 1; - jsize nJVMs = 0; - jint jniError = 0; - - // Assumes JVM is already running ..., one per process - jniError = KJS_GetCreatedJavaVMs(jvmArray, bufLen, &nJVMs); - if ( jniError == JNI_OK && nJVMs > 0 ) { - jvm = jvmArray[0]; - } - else - fprintf(stderr, "%s: JNI_GetCreatedJavaVMs failed, returned %ld\n", __PRETTY_FUNCTION__, (long)jniError); - - return jvm; -} - -JNIEnv* getJNIEnv() -{ - union { - JNIEnv* env; - void* dummy; - } u; - jint jniError = 0; - - jniError = (getJavaVM())->AttachCurrentThread(&u.dummy, NULL); - if (jniError == JNI_OK) - return u.env; - else - fprintf(stderr, "%s: AttachCurrentThread failed, returned %ld\n", __PRETTY_FUNCTION__, (long)jniError); - return NULL; -} - -static jvalue callJNIMethod (JNIType type, jobject obj, const char *name, const char *sig, va_list args) -{ - JavaVM *jvm = getJavaVM(); - JNIEnv *env = getJNIEnv(); - jvalue result; - - bzero (&result, sizeof(jvalue)); - if ( obj != NULL && jvm != NULL && env != NULL) { - jclass cls = env->GetObjectClass(obj); - if ( cls != NULL ) { - jmethodID mid = env->GetMethodID(cls, name, sig); - if ( mid != NULL ) - { - switch (type) { - case void_type: - env->functions->CallVoidMethodV(env, obj, mid, args); - break; - case array_type: - case object_type: - result.l = env->functions->CallObjectMethodV(env, obj, mid, args); - break; - case boolean_type: - result.z = env->functions->CallBooleanMethodV(env, obj, mid, args); - break; - case byte_type: - result.b = env->functions->CallByteMethodV(env, obj, mid, args); - break; - case char_type: - result.c = env->functions->CallCharMethodV(env, obj, mid, args); - break; - case short_type: - result.s = env->functions->CallShortMethodV(env, obj, mid, args); - break; - case int_type: - result.i = env->functions->CallIntMethodV(env, obj, mid, args); - break; - case long_type: - result.j = env->functions->CallLongMethodV(env, obj, mid, args); - break; - case float_type: - result.f = env->functions->CallFloatMethodV(env, obj, mid, args); - break; - case double_type: - result.d = env->functions->CallDoubleMethodV(env, obj, mid, args); - break; - default: - fprintf(stderr, "%s: invalid function type (%d)\n", __PRETTY_FUNCTION__, (int)type); - } - } - else - { - fprintf(stderr, "%s: Could not find method: %s for %p\n", __PRETTY_FUNCTION__, name, obj); - env->ExceptionDescribe(); - env->ExceptionClear(); - fprintf (stderr, "\n"); - } - - env->DeleteLocalRef(cls); - } - else { - fprintf(stderr, "%s: Could not find class for %p\n", __PRETTY_FUNCTION__, obj); - } - } - - return result; -} - -static jvalue callJNIStaticMethod (JNIType type, jclass cls, const char *name, const char *sig, va_list args) -{ - JavaVM *jvm = getJavaVM(); - JNIEnv *env = getJNIEnv(); - jvalue result; - - bzero (&result, sizeof(jvalue)); - if ( cls != NULL && jvm != NULL && env != NULL) { - jmethodID mid = env->GetStaticMethodID(cls, name, sig); - if ( mid != NULL ) - { - switch (type) { - case void_type: - env->functions->CallStaticVoidMethodV(env, cls, mid, args); - break; - case array_type: - case object_type: - result.l = env->functions->CallStaticObjectMethodV(env, cls, mid, args); - break; - case boolean_type: - result.z = env->functions->CallStaticBooleanMethodV(env, cls, mid, args); - break; - case byte_type: - result.b = env->functions->CallStaticByteMethodV(env, cls, mid, args); - break; - case char_type: - result.c = env->functions->CallStaticCharMethodV(env, cls, mid, args); - break; - case short_type: - result.s = env->functions->CallStaticShortMethodV(env, cls, mid, args); - break; - case int_type: - result.i = env->functions->CallStaticIntMethodV(env, cls, mid, args); - break; - case long_type: - result.j = env->functions->CallStaticLongMethodV(env, cls, mid, args); - break; - case float_type: - result.f = env->functions->CallStaticFloatMethodV(env, cls, mid, args); - break; - case double_type: - result.d = env->functions->CallStaticDoubleMethodV(env, cls, mid, args); - break; - default: - fprintf(stderr, "%s: invalid function type (%d)\n", __PRETTY_FUNCTION__, (int)type); - } - } - else - { - fprintf(stderr, "%s: Could not find method: %s for %p\n", __PRETTY_FUNCTION__, name, cls); - env->ExceptionDescribe(); - env->ExceptionClear(); - fprintf (stderr, "\n"); - } - } - - return result; -} - -static jvalue callJNIMethodIDA (JNIType type, jobject obj, jmethodID mid, jvalue *args) -{ - JNIEnv *env = getJNIEnv(); - jvalue result; - - bzero (&result, sizeof(jvalue)); - if ( obj != NULL && mid != NULL ) - { - switch (type) { - case void_type: - env->functions->CallVoidMethodA(env, obj, mid, args); - break; - case array_type: - case object_type: - result.l = env->functions->CallObjectMethodA(env, obj, mid, args); - break; - case boolean_type: - result.z = env->functions->CallBooleanMethodA(env, obj, mid, args); - break; - case byte_type: - result.b = env->functions->CallByteMethodA(env, obj, mid, args); - break; - case char_type: - result.c = env->functions->CallCharMethodA(env, obj, mid, args); - break; - case short_type: - result.s = env->functions->CallShortMethodA(env, obj, mid, args); - break; - case int_type: - result.i = env->functions->CallIntMethodA(env, obj, mid, args); - break; - case long_type: - result.j = env->functions->CallLongMethodA(env, obj, mid, args); - break; - case float_type: - result.f = env->functions->CallFloatMethodA(env, obj, mid, args); - break; - case double_type: - result.d = env->functions->CallDoubleMethodA(env, obj, mid, args); - break; - default: - fprintf(stderr, "%s: invalid function type (%d)\n", __PRETTY_FUNCTION__, (int)type); - } - } - - return result; -} - -static jvalue callJNIMethodA (JNIType type, jobject obj, const char *name, const char *sig, jvalue *args) -{ - JavaVM *jvm = getJavaVM(); - JNIEnv *env = getJNIEnv(); - jvalue result; - - bzero (&result, sizeof(jvalue)); - if ( obj != NULL && jvm != NULL && env != NULL) { - jclass cls = env->GetObjectClass(obj); - if ( cls != NULL ) { - jmethodID mid = env->GetMethodID(cls, name, sig); - if ( mid != NULL ) { - result = callJNIMethodIDA (type, obj, mid, args); - } - else { - fprintf(stderr, "%s: Could not find method: %s\n", __PRETTY_FUNCTION__, name); - env->ExceptionDescribe(); - env->ExceptionClear(); - fprintf (stderr, "\n"); - } - - env->DeleteLocalRef(cls); - } - else { - fprintf(stderr, "%s: Could not find class for object\n", __PRETTY_FUNCTION__); - } - } - - return result; -} - -jmethodID getMethodID (jobject obj, const char *name, const char *sig) -{ - JNIEnv *env = getJNIEnv(); - jmethodID mid = 0; - - if ( env != NULL) { - jclass cls = env->GetObjectClass(obj); - if ( cls != NULL ) { - mid = env->GetMethodID(cls, name, sig); - if (!mid) { - env->ExceptionClear(); - mid = env->GetStaticMethodID(cls, name, sig); - if (!mid) { - env->ExceptionClear(); - } - } - } - env->DeleteLocalRef(cls); - } - return mid; -} - - -#define CALL_JNI_METHOD(function_type,obj,name,sig) \ - va_list args;\ - va_start (args, sig);\ - \ - jvalue result = callJNIMethod(function_type, obj, name, sig, args);\ - \ - va_end (args); - -#define CALL_JNI_STATIC_METHOD(function_type,cls,name,sig) \ - va_list args;\ - va_start (args, sig);\ - \ - jvalue result = callJNIStaticMethod(function_type, cls, name, sig, args);\ - \ - va_end (args); - -void callJNIVoidMethod (jobject obj, const char *name, const char *sig, ... ) -{ - CALL_JNI_METHOD (void_type, obj, name, sig); -} - -jobject callJNIObjectMethod (jobject obj, const char *name, const char *sig, ... ) -{ - CALL_JNI_METHOD (object_type, obj, name, sig); - return result.l; -} - -jboolean callJNIBooleanMethod( jobject obj, const char *name, const char *sig, ... ) -{ - CALL_JNI_METHOD (boolean_type, obj, name, sig); - return result.z; -} - -jboolean callJNIStaticBooleanMethod (jclass cls, const char *name, const char *sig, ... ) -{ - CALL_JNI_STATIC_METHOD (boolean_type, cls, name, sig); - return result.z; -} - -jbyte callJNIByteMethod( jobject obj, const char *name, const char *sig, ... ) -{ - CALL_JNI_METHOD (byte_type, obj, name, sig); - return result.b; -} - -jchar callJNICharMethod (jobject obj, const char *name, const char *sig, ... ) -{ - CALL_JNI_METHOD (char_type, obj, name, sig); - return result.c; -} - -jshort callJNIShortMethod (jobject obj, const char *name, const char *sig, ... ) -{ - CALL_JNI_METHOD (short_type, obj, name, sig); - return result.s; -} - -jint callJNIIntMethod (jobject obj, const char *name, const char *sig, ... ) -{ - CALL_JNI_METHOD (int_type, obj, name, sig); - return result.i; -} - -jlong callJNILongMethod (jobject obj, const char *name, const char *sig, ... ) -{ - CALL_JNI_METHOD (long_type, obj, name, sig); - return result.j; -} - -jfloat callJNIFloatMethod (jobject obj, const char *name, const char *sig, ... ) -{ - CALL_JNI_METHOD (float_type, obj, name, sig); - return result.f; -} - -jdouble callJNIDoubleMethod (jobject obj, const char *name, const char *sig, ... ) -{ - CALL_JNI_METHOD (double_type, obj, name, sig); - return result.d; -} - -void callJNIVoidMethodA (jobject obj, const char *name, const char *sig, jvalue *args) -{ - jvalue result = callJNIMethodA (void_type, obj, name, sig, args); -} - -jobject callJNIObjectMethodA (jobject obj, const char *name, const char *sig, jvalue *args) -{ - jvalue result = callJNIMethodA (object_type, obj, name, sig, args); - return result.l; -} - -jbyte callJNIByteMethodA ( jobject obj, const char *name, const char *sig, jvalue *args) -{ - jvalue result = callJNIMethodA (byte_type, obj, name, sig, args); - return result.b; -} - -jchar callJNICharMethodA (jobject obj, const char *name, const char *sig, jvalue *args) -{ - jvalue result = callJNIMethodA (char_type, obj, name, sig, args); - return result.c; -} - -jshort callJNIShortMethodA (jobject obj, const char *name, const char *sig, jvalue *args) -{ - jvalue result = callJNIMethodA (short_type, obj, name, sig, args); - return result.s; -} - -jint callJNIIntMethodA (jobject obj, const char *name, const char *sig, jvalue *args) -{ - jvalue result = callJNIMethodA (int_type, obj, name, sig, args); - return result.i; -} - -jlong callJNILongMethodA (jobject obj, const char *name, const char *sig, jvalue *args) -{ - jvalue result = callJNIMethodA (long_type, obj, name, sig, args); - return result.j; -} - -jfloat callJNIFloatMethodA (jobject obj, const char *name, const char *sig, jvalue *args) -{ - jvalue result = callJNIMethodA (float_type, obj, name, sig, args); - return result.f; -} - -jdouble callJNIDoubleMethodA (jobject obj, const char *name, const char *sig, jvalue *args) -{ - jvalue result = callJNIMethodA (double_type, obj, name, sig, args); - return result.d; -} - -jboolean callJNIBooleanMethodA (jobject obj, const char *name, const char *sig, jvalue *args) -{ - jvalue result = callJNIMethodA (boolean_type, obj, name, sig, args); - return result.z; -} - -void callJNIVoidMethodIDA (jobject obj, jmethodID methodID, jvalue *args) -{ - jvalue result = callJNIMethodIDA (void_type, obj, methodID, args); -} - -jobject callJNIObjectMethodIDA (jobject obj, jmethodID methodID, jvalue *args) -{ - jvalue result = callJNIMethodIDA (object_type, obj, methodID, args); - return result.l; -} - -jbyte callJNIByteMethodIDA ( jobject obj, jmethodID methodID, jvalue *args) -{ - jvalue result = callJNIMethodIDA (byte_type, obj, methodID, args); - return result.b; -} - -jchar callJNICharMethodIDA (jobject obj, jmethodID methodID, jvalue *args) -{ - jvalue result = callJNIMethodIDA (char_type, obj, methodID, args); - return result.c; -} - -jshort callJNIShortMethodIDA (jobject obj, jmethodID methodID, jvalue *args) -{ - jvalue result = callJNIMethodIDA (short_type, obj, methodID, args); - return result.s; -} - -jint callJNIIntMethodIDA (jobject obj, jmethodID methodID, jvalue *args) -{ - jvalue result = callJNIMethodIDA (int_type, obj, methodID, args); - return result.i; -} - -jlong callJNILongMethodIDA (jobject obj, jmethodID methodID, jvalue *args) -{ - jvalue result = callJNIMethodIDA (long_type, obj, methodID, args); - return result.j; -} - -jfloat callJNIFloatMethodIDA (jobject obj, jmethodID methodID, jvalue *args) -{ - jvalue result = callJNIMethodIDA (float_type, obj, methodID, args); - return result.f; -} - -jdouble callJNIDoubleMethodIDA (jobject obj, jmethodID methodID, jvalue *args) -{ - jvalue result = callJNIMethodIDA (double_type, obj, methodID, args); - return result.d; -} - -jboolean callJNIBooleanMethodIDA (jobject obj, jmethodID methodID, jvalue *args) -{ - jvalue result = callJNIMethodIDA (boolean_type, obj, methodID, args); - return result.z; -} - -const char *getCharactersFromJString (jstring aJString) -{ - return getCharactersFromJStringInEnv (getJNIEnv(), aJString); -} - -void releaseCharactersForJString (jstring aJString, const char *s) -{ - releaseCharactersForJStringInEnv (getJNIEnv(), aJString, s); -} - -const char *getCharactersFromJStringInEnv (JNIEnv *env, jstring aJString) -{ - jboolean isCopy; - const char *s = env->GetStringUTFChars((jstring)aJString, &isCopy); - if (!s) { - env->ExceptionDescribe(); - env->ExceptionClear(); - fprintf (stderr, "\n"); - } - return s; -} - -void releaseCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const char *s) -{ - env->ReleaseStringUTFChars (aJString, s); -} - -const jchar *getUCharactersFromJStringInEnv (JNIEnv *env, jstring aJString) -{ - jboolean isCopy; - const jchar *s = env->GetStringChars((jstring)aJString, &isCopy); - if (!s) { - env->ExceptionDescribe(); - env->ExceptionClear(); - fprintf (stderr, "\n"); - } - return s; -} - -void releaseUCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const jchar *s) -{ - env->ReleaseStringChars (aJString, s); -} - -JNIType JNITypeFromClassName(const char *name) -{ - JNIType type; - - if (strcmp("byte",name) == 0) - type = byte_type; - else if (strcmp("short",name) == 0) - type = short_type; - else if (strcmp("int",name) == 0) - type = int_type; - else if (strcmp("long",name) == 0) - type = long_type; - else if (strcmp("float",name) == 0) - type = float_type; - else if (strcmp("double",name) == 0) - type = double_type; - else if (strcmp("char",name) == 0) - type = char_type; - else if (strcmp("boolean",name) == 0) - type = boolean_type; - else if (strcmp("void",name) == 0) - type = void_type; - else if ('[' == name[0]) - type = array_type; - else - type = object_type; - - return type; -} - -const char *signatureFromPrimitiveType(JNIType type) -{ - switch (type){ - case void_type: - return "V"; - - case array_type: - return "["; - - case object_type: - return "L"; - - case boolean_type: - return "Z"; - - case byte_type: - return "B"; - - case char_type: - return "C"; - - case short_type: - return "S"; - - case int_type: - return "I"; - - case long_type: - return "J"; - - case float_type: - return "F"; - - case double_type: - return "D"; - - case invalid_type: - default: - break; - } - return ""; -} - -JNIType JNITypeFromPrimitiveType(char type) -{ - switch (type){ - case 'V': - return void_type; - - case 'L': - return object_type; - - case '[': - return array_type; - - case 'Z': - return boolean_type; - - case 'B': - return byte_type; - - case 'C': - return char_type; - - case 'S': - return short_type; - - case 'I': - return int_type; - - case 'J': - return long_type; - - case 'F': - return float_type; - - case 'D': - return double_type; - - default: - break; - } - return invalid_type; -} - -jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *signature) -{ - JavaVM *jvm = getJavaVM(); - JNIEnv *env = getJNIEnv(); - jvalue result; - - bzero (&result, sizeof(jvalue)); - if ( obj != NULL && jvm != NULL && env != NULL) { - jclass cls = env->GetObjectClass(obj); - if ( cls != NULL ) { - jfieldID field = env->GetFieldID(cls, name, signature); - if ( field != NULL ) { - switch (type) { - case array_type: - case object_type: - result.l = env->functions->GetObjectField(env, obj, field); - break; - case boolean_type: - result.z = env->functions->GetBooleanField(env, obj, field); - break; - case byte_type: - result.b = env->functions->GetByteField(env, obj, field); - break; - case char_type: - result.c = env->functions->GetCharField(env, obj, field); - break; - case short_type: - result.s = env->functions->GetShortField(env, obj, field); - break; - case int_type: - result.i = env->functions->GetIntField(env, obj, field); - break; - case long_type: - result.j = env->functions->GetLongField(env, obj, field); - break; - case float_type: - result.f = env->functions->GetFloatField(env, obj, field); - break; - case double_type: - result.d = env->functions->GetDoubleField(env, obj, field); - break; - default: - fprintf(stderr, "%s: invalid field type (%d)\n", __PRETTY_FUNCTION__, (int)type); - } - } - else - { - fprintf(stderr, "%s: Could not find field: %s\n", __PRETTY_FUNCTION__, name); - env->ExceptionDescribe(); - env->ExceptionClear(); - fprintf (stderr, "\n"); - } - - env->DeleteLocalRef(cls); - } - else { - fprintf(stderr, "%s: Could not find class for object\n", __PRETTY_FUNCTION__); - } - } - - return result; -} - -static jobject convertArrayInstanceToJavaArray(ExecState *exec, JSValue *value, const char *javaClassName) { - - ASSERT(JSLock::lockCount() > 0); - - JNIEnv *env = getJNIEnv(); - // As JS Arrays can contain a mixture of objects, assume we can convert to - // the requested Java Array type requested, unless the array type is some object array - // other than a string. - ArrayInstance *jsArray = static_cast(value); - unsigned length = jsArray->getLength(); - jobjectArray jarray = 0; - - // Build the correct array type - switch (JNITypeFromPrimitiveType(javaClassName[1])) { - case object_type: { - // Only support string object types - if (0 == strcmp("[Ljava.lang.String;", javaClassName)) { - jarray = (jobjectArray)env->NewObjectArray(length, - env->FindClass("java/lang/String"), - env->NewStringUTF("")); - for(unsigned i = 0; i < length; i++) { - JSValue* item = jsArray->getItem(i); - UString stringValue = item->toString(exec); - env->SetObjectArrayElement(jarray,i, - env->functions->NewString(env, (const jchar *)stringValue.data(), stringValue.size())); - } - } - break; - } - - case boolean_type: { - jarray = (jobjectArray)env->NewBooleanArray(length); - for(unsigned i = 0; i < length; i++) { - JSValue* item = jsArray->getItem(i); - jboolean value = (jboolean)item->toNumber(exec); - env->SetBooleanArrayRegion((jbooleanArray)jarray, (jsize)i, (jsize)1, &value); - } - break; - } - - case byte_type: { - jarray = (jobjectArray)env->NewByteArray(length); - for(unsigned i = 0; i < length; i++) { - JSValue* item = jsArray->getItem(i); - jbyte value = (jbyte)item->toNumber(exec); - env->SetByteArrayRegion((jbyteArray)jarray, (jsize)i, (jsize)1, &value); - } - break; - } - - case char_type: { - jarray = (jobjectArray)env->NewCharArray(length); - for(unsigned i = 0; i < length; i++) { - JSValue* item = jsArray->getItem(i); - UString stringValue = item->toString(exec); - jchar value = 0; - if (stringValue.size() > 0) - value = ((const jchar*)stringValue.data())[0]; - env->SetCharArrayRegion((jcharArray)jarray, (jsize)i, (jsize)1, &value); - } - break; - } - - case short_type: { - jarray = (jobjectArray)env->NewShortArray(length); - for(unsigned i = 0; i < length; i++) { - JSValue* item = jsArray->getItem(i); - jshort value = (jshort)item->toNumber(exec); - env->SetShortArrayRegion((jshortArray)jarray, (jsize)i, (jsize)1, &value); - } - break; - } - - case int_type: { - jarray = (jobjectArray)env->NewIntArray(length); - for(unsigned i = 0; i < length; i++) { - JSValue* item = jsArray->getItem(i); - jint value = (jint)item->toNumber(exec); - env->SetIntArrayRegion((jintArray)jarray, (jsize)i, (jsize)1, &value); - } - break; - } - - case long_type: { - jarray = (jobjectArray)env->NewLongArray(length); - for(unsigned i = 0; i < length; i++) { - JSValue* item = jsArray->getItem(i); - jlong value = (jlong)item->toNumber(exec); - env->SetLongArrayRegion((jlongArray)jarray, (jsize)i, (jsize)1, &value); - } - break; - } - - case float_type: { - jarray = (jobjectArray)env->NewFloatArray(length); - for(unsigned i = 0; i < length; i++) { - JSValue* item = jsArray->getItem(i); - jfloat value = (jfloat)item->toNumber(exec); - env->SetFloatArrayRegion((jfloatArray)jarray, (jsize)i, (jsize)1, &value); - } - break; - } - - case double_type: { - jarray = (jobjectArray)env->NewDoubleArray(length); - for(unsigned i = 0; i < length; i++) { - JSValue* item = jsArray->getItem(i); - jdouble value = (jdouble)item->toNumber(exec); - env->SetDoubleArrayRegion((jdoubleArray)jarray, (jsize)i, (jsize)1, &value); - } - break; - } - - case array_type: // don't handle embedded arrays - case void_type: // Don't expect arrays of void objects - case invalid_type: // Array of unknown objects - break; - } - - // if it was not one of the cases handled, then null is returned - return jarray; -} - - -jvalue convertValueToJValue (ExecState *exec, JSValue *value, JNIType _JNIType, const char *javaClassName) -{ - JSLock lock; - - jvalue result; - - switch (_JNIType){ - case array_type: - case object_type: { - result.l = (jobject)0; - - // First see if we have a Java instance. - if (value->isObject()){ - JSObject *objectImp = static_cast(value); - if (objectImp->classInfo() == &RuntimeObjectImp::info) { - RuntimeObjectImp *imp = static_cast(value); - JavaInstance *instance = static_cast(imp->getInternalInstance()); - if (instance) - result.l = instance->javaInstance(); - } - else if (objectImp->classInfo() == &RuntimeArray::info) { - // Input is a JavaScript Array that was originally created from a Java Array - RuntimeArray *imp = static_cast(value); - JavaArray *array = static_cast(imp->getConcreteArray()); - result.l = array->javaArray(); - } - else if (objectImp->classInfo() == &ArrayInstance::info) { - // Input is a Javascript Array. We need to create it to a Java Array. - result.l = convertArrayInstanceToJavaArray(exec, value, javaClassName); - } - } - - // Now convert value to a string if the target type is a java.lang.string, and we're not - // converting from a Null. - if (result.l == 0 && strcmp(javaClassName, "java.lang.String") == 0) { -#ifdef CONVERT_NULL_TO_EMPTY_STRING - if (value->isNull()) { - JNIEnv *env = getJNIEnv(); - jchar buf[2]; - jobject javaString = env->functions->NewString (env, buf, 0); - result.l = javaString; - } - else -#else - if (!value->isNull()) -#endif - { - UString stringValue = value->toString(exec); - JNIEnv *env = getJNIEnv(); - jobject javaString = env->functions->NewString (env, (const jchar *)stringValue.data(), stringValue.size()); - result.l = javaString; - } - } else if (result.l == 0) - bzero (&result, sizeof(jvalue)); // Handle it the same as a void case - } - break; - - case boolean_type: { - result.z = (jboolean)value->toNumber(exec); - } - break; - - case byte_type: { - result.b = (jbyte)value->toNumber(exec); - } - break; - - case char_type: { - result.c = (jchar)value->toNumber(exec); - } - break; - - case short_type: { - result.s = (jshort)value->toNumber(exec); - } - break; - - case int_type: { - result.i = (jint)value->toNumber(exec); - } - break; - - case long_type: { - result.j = (jlong)value->toNumber(exec); - } - break; - - case float_type: { - result.f = (jfloat)value->toNumber(exec); - } - break; - - case double_type: { - result.d = (jdouble)value->toNumber(exec); - } - break; - - break; - - case invalid_type: - default: - case void_type: { - bzero (&result, sizeof(jvalue)); - } - break; - } - return result; -} - -} // end of namespace Bindings - -} // end of namespace KJS - -#endif // ENABLE(JAVA_BINDINGS) diff --git a/bindings/jni/jni_utility.h b/bindings/jni/jni_utility.h deleted file mode 100644 index 3b4955f..0000000 --- a/bindings/jni/jni_utility.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _JNI_UTILITY_H_ -#define _JNI_UTILITY_H_ - -#if ENABLE(JAVA_BINDINGS) - -#include - -#include - -// The order of these items can not be modified as they are tightly -// bound with the JVM on Mac OSX. If new types need to be added, they -// should be added to the end. It is used in jni_obc.mm when calling -// through to the JVM. Newly added items need to be made compatible -// in that file. -typedef enum { - invalid_type = 0, - void_type, - object_type, - boolean_type, - byte_type, - char_type, - short_type, - int_type, - long_type, - float_type, - double_type, - array_type -} JNIType; - -namespace KJS { - -namespace Bindings { - -class JavaParameter; - -const char *getCharactersFromJString(jstring aJString); -void releaseCharactersForJString(jstring aJString, const char *s); - -const char *getCharactersFromJStringInEnv(JNIEnv *env, jstring aJString); -void releaseCharactersForJStringInEnv(JNIEnv *env, jstring aJString, const char *s); -const jchar *getUCharactersFromJStringInEnv(JNIEnv *env, jstring aJString); -void releaseUCharactersForJStringInEnv(JNIEnv *env, jstring aJString, const jchar *s); - -JNIType JNITypeFromClassName(const char *name); -JNIType JNITypeFromPrimitiveType(char type); -const char *signatureFromPrimitiveType(JNIType type); - -jvalue convertValueToJValue(ExecState *exec, JSValue *value, JNIType _JNIType, const char *javaClassName); - -jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature); - -jmethodID getMethodID(jobject obj, const char *name, const char *sig); - -jobject callJNIObjectMethod(jobject obj, const char *name, const char *sig, ... ); -void callJNIVoidMethod(jobject obj, const char *name, const char *sig, ... ); -jboolean callJNIBooleanMethod(jobject obj, const char *name, const char *sig, ... ); -jboolean callJNIStaticBooleanMethod(jclass cls, const char *name, const char *sig, ... ); -jbyte callJNIByteMethod(jobject obj, const char *name, const char *sig, ... ); -jchar callJNICharMethod(jobject obj, const char *name, const char *sig, ... ); -jshort callJNIShortMethod(jobject obj, const char *name, const char *sig, ... ); -jint callJNIIntMethod(jobject obj, const char *name, const char *sig, ... ); -jlong callJNILongMethod(jobject obj, const char *name, const char *sig, ... ); -jfloat callJNIFloatMethod(jobject obj, const char *name, const char *sig, ... ); -jdouble callJNIDoubleMethod(jobject obj, const char *name, const char *sig, ... ); - -jobject callJNIObjectMethodA(jobject obj, const char *name, const char *sig, jvalue *args); -void callJNIVoidMethodA(jobject obj, const char *name, const char *sig, jvalue *args); -jboolean callJNIBooleanMethodA(jobject obj, const char *name, const char *sig, jvalue *args); -jbyte callJNIByteMethodA(jobject obj, const char *name, const char *sig, jvalue *args); -jchar callJNICharMethodA(jobject obj, const char *name, const char *sig, jvalue *args); -jshort callJNIShortMethodA(jobject obj, const char *name, const char *sig, jvalue *args); -jint callJNIIntMethodA(jobject obj, const char *name, const char *sig, jvalue *args); -jlong callJNILongMethodA(jobject obj, const char *name, const char *sig, jvalue *args); -jfloat callJNIFloatMethodA(jobject obj, const char *name, const char *sig, jvalue *args); -jdouble callJNIDoubleMethodA(jobject obj, const char *name, const char *sig, jvalue *args); - -jobject callJNIObjectMethodIDA(jobject obj, jmethodID methodID, jvalue *args); -void callJNIVoidMethodIDA(jobject obj, jmethodID methodID, jvalue *args); -jboolean callJNIBooleanMethodIDA(jobject obj, jmethodID methodID, jvalue *args); -jbyte callJNIByteMethodIDA(jobject obj, jmethodID methodID, jvalue *args); -jchar callJNICharMethodIDA(jobject obj, jmethodID methodID, jvalue *args); -jshort callJNIShortMethodIDA(jobject obj, jmethodID methodID, jvalue *args); -jint callJNIIntMethodIDA(jobject obj, jmethodID methodID, jvalue *args); -jlong callJNILongMethodIDA(jobject obj, jmethodID methodID, jvalue *args); -jfloat callJNIFloatMethodIDA(jobject obj, jmethodID methodID, jvalue *args); -jdouble callJNIDoubleMethodIDA(jobject obj, jmethodID methodID, jvalue *args); - -JavaVM *getJavaVM(); -void setJavaVM(JavaVM *javaVM); -JNIEnv *getJNIEnv(); - -bool dispatchJNICall(const void *targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue *args, jvalue &result, const char *callingURL, JSValue *&exceptionDescription); - -} // namespace Bindings - -} // namespace KJS - -#endif // ENABLE(JAVA_BINDINGS) - -#endif // _JNI_UTILITY_H_ diff --git a/bindings/make_testbindings b/bindings/make_testbindings deleted file mode 100755 index 1f528fe..0000000 --- a/bindings/make_testbindings +++ /dev/null @@ -1,2 +0,0 @@ -cc -g -o testbindingsM testbindings.mm -I../kjs -F$SYMROOTS -framework JavaScriptCore -framework Foundation -lstdc++ -cc -g -o testbindingsC testbindings.cpp -I../kjs -F$SYMROOTS -framework JavaScriptCore -framework Foundation -lstdc++ diff --git a/bindings/npapi.h b/bindings/npapi.h deleted file mode 100644 index e7cf503..0000000 --- a/bindings/npapi.h +++ /dev/null @@ -1,720 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - - - /* - * Netscape client plug-in API spec - */ - - -#ifndef _NPAPI_H_ -#define _NPAPI_H_ - -#include - -#if ENABLE(NETSCAPE_API) - -#ifdef INCLUDE_JAVA -#include "jri.h" /* Java Runtime Interface */ -#else -#define jref void * -#define JRIEnv void -#endif - -#ifdef _WIN32 -# ifndef XP_WIN -# define XP_WIN 1 -# endif /* XP_WIN */ -#endif /* _WIN32 */ - -#ifdef __MWERKS__ -# define _declspec __declspec -# ifdef macintosh -# ifndef XP_MAC -# define XP_MAC 1 -# endif /* XP_MAC */ -# endif /* macintosh */ -# ifdef __INTEL__ -# undef NULL -# ifndef XP_WIN -# define XP_WIN 1 -# endif /* __INTEL__ */ -# endif /* XP_PC */ -#endif /* __MWERKS__ */ - -#if defined(__APPLE_CC__) && !defined(__MACOS_CLASSIC__) && !defined(XP_UNIX) -# define XP_MACOSX -#endif - -#ifdef XP_MAC - #include - #include -#endif - -#ifdef XP_MACOSX - #include - #include - #include -#endif - -#ifdef XP_UNIX - #include - #include - #include -#endif - -#ifdef XP_WIN - #include -#endif - -#if defined(XP_MACOSX) && defined(__LP64__) -#error 64-bit Netscape plug-ins are not supported on Mac OS X -#endif - -/*----------------------------------------------------------------------*/ -/* Plugin Version Constants */ -/*----------------------------------------------------------------------*/ - -#define NP_VERSION_MAJOR 0 -#define NP_VERSION_MINOR 18 - - - -/*----------------------------------------------------------------------*/ -/* Definition of Basic Types */ -/*----------------------------------------------------------------------*/ - -#ifndef _UINT16 -#define _UINT16 -typedef unsigned short uint16; -#endif - -#ifndef _UINT32 -#define _UINT32 -#ifdef __LP64__ -typedef unsigned int uint32; -#else /* __LP64__ */ -typedef unsigned long uint32; -#endif /* __LP64__ */ -#endif - -#ifndef _INT16 -#define _INT16 -typedef short int16; -#endif - -#ifndef _INT32 -#define _INT32 -#ifdef __LP64__ -typedef int int32; -#else /* __LP64__ */ -typedef long int32; -#endif /* __LP64__ */ -#endif - -#ifndef FALSE -#define FALSE (0) -#endif -#ifndef TRUE -#define TRUE (1) -#endif -#ifndef NULL -#define NULL (0L) -#endif - -typedef unsigned char NPBool; -typedef int16 NPError; -typedef int16 NPReason; -typedef char* NPMIMEType; - - - -/*----------------------------------------------------------------------*/ -/* Structures and definitions */ -/*----------------------------------------------------------------------*/ - -#if !defined(__LP64__) -#if defined(XP_MAC) || defined(XP_MACOSX) -#pragma options align=mac68k -#endif -#endif /* __LP64__ */ - -/* - * NPP is a plug-in's opaque instance handle - */ -typedef struct _NPP -{ - void* pdata; /* plug-in private data */ - void* ndata; /* netscape private data */ -} NPP_t; - -typedef NPP_t* NPP; - - -typedef struct _NPStream -{ - void* pdata; /* plug-in private data */ - void* ndata; /* netscape private data */ - const char* url; - uint32 end; - uint32 lastmodified; - void* notifyData; - const char* headers; /* Response headers from host. - * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS. - * Used for HTTP only; NULL for non-HTTP. - * Available from NPP_NewStream onwards. - * Plugin should copy this data before storing it. - * Includes HTTP status line and all headers, - * preferably verbatim as received from server, - * headers formatted as in HTTP ("Header: Value"), - * and newlines (\n, NOT \r\n) separating lines. - * Terminated by \n\0 (NOT \n\n\0). */ -} NPStream; - - -typedef struct _NPByteRange -{ - int32 offset; /* negative offset means from the end */ - uint32 length; - struct _NPByteRange* next; -} NPByteRange; - - -typedef struct _NPSavedData -{ - int32 len; - void* buf; -} NPSavedData; - - -typedef struct _NPRect -{ - uint16 top; - uint16 left; - uint16 bottom; - uint16 right; -} NPRect; - - -#ifdef XP_UNIX -/* - * Unix specific structures and definitions - */ - -/* - * Callback Structures. - * - * These are used to pass additional platform specific information. - */ -enum { - NP_SETWINDOW = 1, - NP_PRINT -}; - -typedef struct -{ - int32 type; -} NPAnyCallbackStruct; - -typedef struct -{ - int32 type; - Display* display; - Visual* visual; - Colormap colormap; - unsigned int depth; -} NPSetWindowCallbackStruct; - -typedef struct -{ - int32 type; - FILE* fp; -} NPPrintCallbackStruct; - -#endif /* XP_UNIX */ - -/* - * The following masks are applied on certain platforms to NPNV and - * NPPV selectors that pass around pointers to COM interfaces. Newer - * compilers on some platforms may generate vtables that are not - * compatible with older compilers. To prevent older plugins from - * not understanding a new browser's ABI, these masks change the - * values of those selectors on those platforms. To remain backwards - * compatible with differenet versions of the browser, plugins can - * use these masks to dynamically determine and use the correct C++ - * ABI that the browser is expecting. This does not apply to Windows - * as Microsoft's COM ABI will likely not change. - */ - -#define NP_ABI_GCC3_MASK 0x10000000 -/* - * gcc 3.x generated vtables on UNIX and OSX are incompatible with - * previous compilers. - */ -#if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3)) -#define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK -#else -#define _NP_ABI_MIXIN_FOR_GCC3 0 -#endif - -#define NP_ABI_MACHO_MASK 0x01000000 -/* - * On OSX, the Mach-O executable format is significantly - * different than CFM. In addition to having a different - * C++ ABI, it also has has different C calling convention. - * You must use glue code when calling between CFM and - * Mach-O C functions. - */ -#if (defined(TARGET_RT_MAC_MACHO)) -#define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK -#else -#define _NP_ABI_MIXIN_FOR_MACHO 0 -#endif - - -#define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO) - -/* - * List of variable names for which NPP_GetValue shall be implemented - */ -typedef enum { - NPPVpluginNameString = 1, - NPPVpluginDescriptionString, - NPPVpluginWindowBool, - NPPVpluginTransparentBool, - - NPPVjavaClass, /* Not implemented in WebKit */ - NPPVpluginWindowSize, /* Not implemented in WebKit */ - NPPVpluginTimerInterval, /* Not implemented in WebKit */ - - NPPVpluginScriptableInstance = (10 | NP_ABI_MASK), /* Not implemented in WebKit */ - NPPVpluginScriptableIID = 11, /* Not implemented in WebKit */ - - /* 12 and over are available on Mozilla builds starting with 0.9.9 */ - NPPVjavascriptPushCallerBool = 12, /* Not implemented in WebKit */ - NPPVpluginKeepLibraryInMemory = 13, /* Not implemented in WebKit */ - NPPVpluginNeedsXEmbed = 14, /* Not implemented in WebKit */ - - /* Get the NPObject for scripting the plugin. */ - NPPVpluginScriptableNPObject = 15, - - /* Get the plugin value (as \0-terminated UTF-8 string data) for - * form submission if the plugin is part of a form. Use - * NPN_MemAlloc() to allocate memory for the string data. - */ - NPPVformValue = 16, /* Not implemented in WebKit */ -#ifdef XP_MACOSX - /* Used for negotiating drawing models */ - NPPVpluginDrawingModel = 1000 -#endif -} NPPVariable; - -/* - * List of variable names for which NPN_GetValue is implemented by Mozilla - */ -typedef enum { - NPNVxDisplay = 1, - NPNVxtAppContext, - NPNVnetscapeWindow, - NPNVjavascriptEnabledBool, - NPNVasdEnabledBool, - NPNVisOfflineBool, - - /* 10 and over are available on Mozilla builds starting with 0.9.4 */ - NPNVserviceManager = (10 | NP_ABI_MASK), /* Not implemented in WebKit */ - NPNVDOMElement = (11 | NP_ABI_MASK), /* Not implemented in WebKit */ - NPNVDOMWindow = (12 | NP_ABI_MASK), /* Not implemented in WebKit */ - NPNVToolkit = (13 | NP_ABI_MASK), /* Not implemented in WebKit */ - NPNVSupportsXEmbedBool = 14, /* Not implemented in WebKit */ - - /* Get the NPObject wrapper for the browser window. */ - NPNVWindowNPObject = 15, - - /* Get the NPObject wrapper for the plugins DOM element. */ - NPNVPluginElementNPObject - -#ifdef XP_MACOSX - , NPNVpluginDrawingModel = 1000 /* The NPDrawingModel specified by the plugin */ - -#ifndef NP_NO_QUICKDRAW - , NPNVsupportsQuickDrawBool = 2000 /* TRUE if the browser supports the QuickDraw drawing model */ -#endif - , NPNVsupportsCoreGraphicsBool = 2001 /* TRUE if the browser supports the CoreGraphics drawing model */ - , NPNVsupportsOpenGLBool = 2002 /* TRUE if the browser supports the OpenGL drawing model (CGL on Mac) */ -#endif /* XP_MACOSX */ -} NPNVariable; - -/* - * The type of a NPWindow - it specifies the type of the data structure - * returned in the window field. - */ -typedef enum { - NPWindowTypeWindow = 1, - NPWindowTypeDrawable -} NPWindowType; - -#ifdef XP_MACOSX - -/* - * The drawing model for a Mac OS X plugin. These are the possible values for the NPNVpluginDrawingModel variable. - */ - -typedef enum { -#ifndef NP_NO_QUICKDRAW - NPDrawingModelQuickDraw = 0, -#endif - NPDrawingModelCoreGraphics = 1, - NPDrawingModelOpenGL = 2 -} NPDrawingModel; - -#endif - -typedef struct _NPWindow -{ - void* window; /* Platform specific window handle */ - int32 x; /* Position of top left corner relative */ - int32 y; /* to a netscape page. */ - uint32 width; /* Maximum window size */ - uint32 height; - NPRect clipRect; /* Clipping rectangle in port coordinates */ - /* Used by MAC only. */ -#ifdef XP_UNIX - void * ws_info; /* Platform-dependent additonal data */ -#endif /* XP_UNIX */ - NPWindowType type; /* Is this a window or a drawable? */ -} NPWindow; - - -typedef struct _NPFullPrint -{ - NPBool pluginPrinted; /* Set TRUE if plugin handled fullscreen */ - /* printing */ - NPBool printOne; /* TRUE if plugin should print one copy */ - /* to default printer */ - void* platformPrint; /* Platform-specific printing info */ -} NPFullPrint; - -typedef struct _NPEmbedPrint -{ - NPWindow window; - void* platformPrint; /* Platform-specific printing info */ -} NPEmbedPrint; - -typedef struct _NPPrint -{ - uint16 mode; /* NP_FULL or NP_EMBED */ - union - { - NPFullPrint fullPrint; /* if mode is NP_FULL */ - NPEmbedPrint embedPrint; /* if mode is NP_EMBED */ - } print; -} NPPrint; - -#if defined(XP_MAC) || defined(XP_MACOSX) -typedef EventRecord NPEvent; -#elif defined(XP_WIN) -typedef struct _NPEvent -{ - uint16 event; - uint32 wParam; - uint32 lParam; -} NPEvent; -#elif defined (XP_UNIX) -typedef XEvent NPEvent; -#else -typedef void* NPEvent; -#endif /* XP_MAC */ - -#if defined(XP_MAC) -typedef RgnHandle NPRegion; -#elif defined(XP_MACOSX) -/* - * NPRegion's type depends on the drawing model specified by the plugin (see NPNVpluginDrawingModel). - * NPQDRegion represents a QuickDraw RgnHandle and is used with the QuickDraw drawing model. - * NPCGRegion repesents a graphical region when using any other drawing model. - */ -typedef void *NPRegion; -#ifndef NP_NO_QUICKDRAW -typedef RgnHandle NPQDRegion; -#endif -typedef CGPathRef NPCGRegion; -#elif defined(XP_WIN) -typedef HRGN NPRegion; -#elif defined(XP_UNIX) -typedef Region NPRegion; -#else -typedef void *NPRegion; -#endif /* XP_MAC */ - -#ifdef XP_MACOSX - -/* - * NP_CGContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelCoreGraphics - * as its drawing model. - */ - -typedef struct NP_CGContext -{ - CGContextRef context; - WindowRef window; -} NP_CGContext; - -/* - * NP_GLContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelOpenGL as its - * drawing model. - */ - -typedef struct NP_GLContext -{ - CGLContextObj context; - WindowRef window; -} NP_GLContext; - -#endif /* XP_MACOSX */ - -#if defined(XP_MAC) || defined(XP_MACOSX) - -/* - * Mac-specific structures and definitions. - */ - -#ifndef NP_NO_QUICKDRAW - -/* - * NP_Port is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelQuickDraw as its - * drawing model, or the plugin does not specify a drawing model. - * - * It is not recommended that new plugins use NPDrawingModelQuickDraw or NP_Port, as QuickDraw has been - * deprecated in Mac OS X 10.5. CoreGraphics is the preferred drawing API. - * - * NP_Port is not available in 64-bit. - */ - -typedef struct NP_Port -{ - CGrafPtr port; /* Grafport */ - int32 portx; /* position inside the topmost window */ - int32 porty; -} NP_Port; - -#endif /* NP_NO_QUICKDRAW */ - -/* - * Non-standard event types that can be passed to HandleEvent - */ -#define getFocusEvent (osEvt + 16) -#define loseFocusEvent (osEvt + 17) -#define adjustCursorEvent (osEvt + 18) - -#endif /* XP_MAC */ - - -/* - * Values for mode passed to NPP_New: - */ -#define NP_EMBED 1 -#define NP_FULL 2 - -/* - * Values for stream type passed to NPP_NewStream: - */ -#define NP_NORMAL 1 -#define NP_SEEK 2 -#define NP_ASFILE 3 -#define NP_ASFILEONLY 4 - -#define NP_MAXREADY (((unsigned)(~0)<<1)>>1) - -#if !defined(__LP64__) -#if defined(XP_MAC) || defined(XP_MACOSX) -#pragma options align=reset -#endif -#endif /* __LP64__ */ - - -/*----------------------------------------------------------------------*/ -/* Error and Reason Code definitions */ -/*----------------------------------------------------------------------*/ - -/* - * Values of type NPError: - */ -#define NPERR_BASE 0 -#define NPERR_NO_ERROR (NPERR_BASE + 0) -#define NPERR_GENERIC_ERROR (NPERR_BASE + 1) -#define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2) -#define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3) -#define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4) -#define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5) -#define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6) -#define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7) -#define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8) -#define NPERR_INVALID_PARAM (NPERR_BASE + 9) -#define NPERR_INVALID_URL (NPERR_BASE + 10) -#define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11) -#define NPERR_NO_DATA (NPERR_BASE + 12) -#define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13) - -/* - * Values of type NPReason: - */ -#define NPRES_BASE 0 -#define NPRES_DONE (NPRES_BASE + 0) -#define NPRES_NETWORK_ERR (NPRES_BASE + 1) -#define NPRES_USER_BREAK (NPRES_BASE + 2) - -/* - * Don't use these obsolete error codes any more. - */ -#define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR -#define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR -#define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK - -/* - * Version feature information - */ -#define NPVERS_HAS_STREAMOUTPUT 8 -#define NPVERS_HAS_NOTIFICATION 9 -#define NPVERS_HAS_LIVECONNECT 9 -#define NPVERS_WIN16_HAS_LIVECONNECT 9 -#define NPVERS_68K_HAS_LIVECONNECT 11 -#define NPVERS_HAS_WINDOWLESS 11 -#define NPVERS_HAS_XPCONNECT_SCRIPTING 13 /* Not implemented in WebKit */ -#define NPVERS_HAS_NPRUNTIME_SCRIPTING 14 -#define NPVERS_HAS_FORM_VALUES 15 /* Not implemented in WebKit; see bug 13061 */ -#define NPVERS_HAS_POPUPS_ENABLED_STATE 16 /* Not implemented in WebKit */ -#define NPVERS_HAS_RESPONSE_HEADERS 17 -#define NPVERS_HAS_NPOBJECT_ENUM 18 - - -/*----------------------------------------------------------------------*/ -/* Function Prototypes */ -/*----------------------------------------------------------------------*/ - -#if defined(_WINDOWS) && !defined(WIN32) -#define NP_LOADDS _loadds -#else -#define NP_LOADDS -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * NPP_* functions are provided by the plugin and called by the navigator. - */ - -#ifdef XP_UNIX -char* NPP_GetMIMEDescription(void); -#endif /* XP_UNIX */ - -NPError NPP_Initialize(void); -void NPP_Shutdown(void); -NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance, - uint16 mode, int16 argc, char* argn[], - char* argv[], NPSavedData* saved); -NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save); -NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window); -NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type, - NPStream* stream, NPBool seekable, - uint16* stype); -NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream, - NPReason reason); -int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream); -int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset, - int32 len, void* buffer); -void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream, - const char* fname); -void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint); -int16 NPP_HandleEvent(NPP instance, void* event); -void NP_LOADDS NPP_URLNotify(NPP instance, const char* url, - NPReason reason, void* notifyData); -jref NP_LOADDS NPP_GetJavaClass(void); -NPError NPP_GetValue(NPP instance, NPPVariable variable, - void *value); -NPError NPP_SetValue(NPP instance, NPNVariable variable, - void *value); - -/* - * NPN_* functions are provided by the navigator and called by the plugin. - */ - -void NPN_Version(int* plugin_major, int* plugin_minor, - int* netscape_major, int* netscape_minor); -NPError NPN_GetURLNotify(NPP instance, const char* url, - const char* target, void* notifyData); -NPError NPN_GetURL(NPP instance, const char* url, - const char* target); -NPError NPN_PostURLNotify(NPP instance, const char* url, - const char* target, uint32 len, - const char* buf, NPBool file, - void* notifyData); -NPError NPN_PostURL(NPP instance, const char* url, - const char* target, uint32 len, - const char* buf, NPBool file); -NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList); -NPError NPN_NewStream(NPP instance, NPMIMEType type, - const char* target, NPStream** stream); -int32 NPN_Write(NPP instance, NPStream* stream, int32 len, - void* buffer); -NPError NPN_DestroyStream(NPP instance, NPStream* stream, - NPReason reason); -void NPN_Status(NPP instance, const char* message); -const char* NPN_UserAgent(NPP instance); -void* NPN_MemAlloc(uint32 size); -void NPN_MemFree(void* ptr); -uint32 NPN_MemFlush(uint32 size); -void NPN_ReloadPlugins(NPBool reloadPages); -JRIEnv* NPN_GetJavaEnv(void); -jref NPN_GetJavaPeer(NPP instance); -NPError NPN_GetValue(NPP instance, NPNVariable variable, - void *value); -NPError NPN_SetValue(NPP instance, NPPVariable variable, - void *value); -void NPN_InvalidateRect(NPP instance, NPRect *invalidRect); -void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion); -void NPN_ForceRedraw(NPP instance); -void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled); -void NPN_PopPopupsEnabledState(NPP instance); - -#ifdef __cplusplus -} /* end extern "C" */ -#endif - -#endif // ENABLE(NETSCAPE_API) - -#endif /* _NPAPI_H_ */ diff --git a/bindings/npruntime.cpp b/bindings/npruntime.cpp deleted file mode 100644 index 0413879..0000000 --- a/bindings/npruntime.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(NETSCAPE_API) - -#include "npruntime_internal.h" -#include "npruntime_impl.h" -#include "npruntime_priv.h" - -#include "JSLock.h" -#include "c_utility.h" -#include "identifier.h" -#include -#include - -using namespace KJS::Bindings; - -typedef HashMap, PrivateIdentifier*> StringIdentifierMap; - -static StringIdentifierMap* getStringIdentifierMap() -{ - static StringIdentifierMap* stringIdentifierMap = 0; - if (!stringIdentifierMap) - stringIdentifierMap = new StringIdentifierMap; - return stringIdentifierMap; -} - -typedef HashMap IntIdentifierMap; - -static IntIdentifierMap* getIntIdentifierMap() -{ - static IntIdentifierMap* intIdentifierMap = 0; - if (!intIdentifierMap) - intIdentifierMap = new IntIdentifierMap; - return intIdentifierMap; -} - -NPIdentifier _NPN_GetStringIdentifier(const NPUTF8* name) -{ - ASSERT(name); - - if (name) { - PrivateIdentifier* identifier = 0; - - KJS::JSLock lock; - - identifier = getStringIdentifierMap()->get(identifierFromNPIdentifier(name).ustring().rep()); - if (identifier == 0) { - identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier)); - // We never release identifier names, so this dictionary will grow, as will - // the memory for the identifier name strings. - identifier->isString = true; - identifier->value.string = strdup(name); - - getStringIdentifierMap()->set(identifierFromNPIdentifier(name).ustring().rep(), identifier); - } - return (NPIdentifier)identifier; - } - - return 0; -} - -void _NPN_GetStringIdentifiers(const NPUTF8** names, int32_t nameCount, NPIdentifier* identifiers) -{ - ASSERT(names); - ASSERT(identifiers); - - if (names && identifiers) - for (int i = 0; i < nameCount; i++) - identifiers[i] = _NPN_GetStringIdentifier(names[i]); -} - -NPIdentifier _NPN_GetIntIdentifier(int32_t intid) -{ - PrivateIdentifier* identifier; - - if (intid == 0 || intid == -1) { - static PrivateIdentifier* negativeOneAndZeroIdentifiers[2]; - - identifier = negativeOneAndZeroIdentifiers[intid + 1]; - if (!identifier) { - identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier)); - identifier->isString = false; - identifier->value.number = intid; - - negativeOneAndZeroIdentifiers[intid + 1] = identifier; - } - } else { - identifier = getIntIdentifierMap()->get(intid); - if (!identifier) { - identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier)); - // We never release identifier names, so this dictionary will grow. - identifier->isString = false; - identifier->value.number = intid; - - getIntIdentifierMap()->set(intid, identifier); - } - } - return (NPIdentifier)identifier; -} - -bool _NPN_IdentifierIsString(NPIdentifier identifier) -{ - PrivateIdentifier* i = (PrivateIdentifier*)identifier; - return i->isString; -} - -NPUTF8 *_NPN_UTF8FromIdentifier(NPIdentifier identifier) -{ - PrivateIdentifier* i = (PrivateIdentifier*)identifier; - if (!i->isString || !i->value.string) - return NULL; - - return (NPUTF8 *)strdup(i->value.string); -} - -int32_t _NPN_IntFromIdentifier(NPIdentifier identifier) -{ - PrivateIdentifier* i = (PrivateIdentifier*)identifier; - if (!i->isString) - return 0; - return i->value.number; -} - -void NPN_InitializeVariantWithStringCopy(NPVariant* variant, const NPString* value) -{ - variant->type = NPVariantType_String; - variant->value.stringValue.UTF8Length = value->UTF8Length; - variant->value.stringValue.UTF8Characters = (NPUTF8 *)malloc(sizeof(NPUTF8) * value->UTF8Length); - memcpy((void*)variant->value.stringValue.UTF8Characters, value->UTF8Characters, sizeof(NPUTF8) * value->UTF8Length); -} - -void _NPN_ReleaseVariantValue(NPVariant* variant) -{ - ASSERT(variant); - - if (variant->type == NPVariantType_Object) { - _NPN_ReleaseObject(variant->value.objectValue); - variant->value.objectValue = 0; - } else if (variant->type == NPVariantType_String) { - free((void*)variant->value.stringValue.UTF8Characters); - variant->value.stringValue.UTF8Characters = 0; - variant->value.stringValue.UTF8Length = 0; - } - - variant->type = NPVariantType_Void; -} - -NPObject *_NPN_CreateObject(NPP npp, NPClass* aClass) -{ - ASSERT(aClass); - - if (aClass) { - NPObject* obj; - if (aClass->allocate != NULL) - obj = aClass->allocate(npp, aClass); - else - obj = (NPObject*)malloc(sizeof(NPObject)); - - obj->_class = aClass; - obj->referenceCount = 1; - - return obj; - } - - return 0; -} - -NPObject* _NPN_RetainObject(NPObject* obj) -{ - ASSERT(obj); - - if (obj) - obj->referenceCount++; - - return obj; -} - -void _NPN_ReleaseObject(NPObject* obj) -{ - ASSERT(obj); - ASSERT(obj->referenceCount >= 1); - - if (obj && obj->referenceCount >= 1) { - if (--obj->referenceCount == 0) - _NPN_DeallocateObject(obj); - } -} - -void _NPN_DeallocateObject(NPObject *obj) -{ - ASSERT(obj); - - if (obj) { - if (obj->_class->deallocate) - obj->_class->deallocate(obj); - else - free(obj); - } -} - -#endif // ENABLE(NETSCAPE_API) diff --git a/bindings/npruntime.h b/bindings/npruntime.h deleted file mode 100644 index 30b94da..0000000 --- a/bindings/npruntime.h +++ /dev/null @@ -1,358 +0,0 @@ -/* - * Copyright (C) 2004, Apple Computer, Inc. and The Mozilla Foundation. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla - * Foundation ("Mozilla") nor the names of their contributors may be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR - * THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Revision 1 (March 4, 2004): - * Initial proposal. - * - * Revision 2 (March 10, 2004): - * All calls into script were made asynchronous. Results are - * provided via the NPScriptResultFunctionPtr callback. - * - * Revision 3 (March 10, 2004): - * Corrected comments to not refer to class retain/release FunctionPtrs. - * - * Revision 4 (March 11, 2004): - * Added additional convenience NPN_SetExceptionWithUTF8(). - * Changed NPHasPropertyFunctionPtr and NPHasMethodFunctionPtr to take NPClass - * pointers instead of NPObject pointers. - * Added NPIsValidIdentifier(). - * - * Revision 5 (March 17, 2004): - * Added context parameter to result callbacks from ScriptObject functions. - * - * Revision 6 (March 29, 2004): - * Renamed functions implemented by user agent to NPN_*. Removed _ from - * type names. - * Renamed "JavaScript" types to "Script". - * - * Revision 7 (April 21, 2004): - * NPIdentifier becomes a void*, was int32_t - * Remove NP_IsValidIdentifier, renamed NP_IdentifierFromUTF8 to NP_GetIdentifier - * Added NPVariant and modified functions to use this new type. - * - * Revision 8 (July 9, 2004): - * Updated to joint Apple-Mozilla license. - * - * Revision 9 (August 12, 2004): - * Changed NPVariantType enum values to form PVariantType_XXX - * Added NPP arguments to NPObject functions. - * Replaced NPVariant functions with macros. - */ -#ifndef _NP_RUNTIME_H_ -#define _NP_RUNTIME_H_ - -#if ENABLE(NETSCAPE_API) - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "npapi.h" - -#if defined(XP_MACOSX) && defined(__LP64__) -#error 64-bit Netscape plug-ins are not supported on Mac OS X -#endif - -/* - This API is used to facilitate binding code written in C to script - objects. The API in this header does not assume the presence of a - user agent. That is, it can be used to bind C code to scripting - environments outside of the context of a user agent. - - However, the normal use of the this API is in the context of a - scripting environment running in a browser or other user agent. - In particular it is used to support the extended Netscape - script-ability API for plugins (NP-SAP). NP-SAP is an extension - of the Netscape plugin API. As such we have adopted the use of - the "NP" prefix for this API. - - The following NP{N|P}Variables were added to the Netscape plugin - API (in npapi.h): - - NPNVWindowNPObject - NPNVPluginElementNPObject - NPPVpluginScriptableNPObject - - These variables are exposed through NPN_GetValue() and - NPP_GetValue() (respectively) and are used to establish the - initial binding between the user agent and native code. The DOM - objects in the user agent can be examined and manipulated using - the NPN_ functions that operate on NPObjects described in this - header. - - To the extent possible the assumptions about the scripting - language used by the scripting environment have been minimized. -*/ - - -/* - Objects (non-primitive data) passed between 'C' and script is - always wrapped in an NPObject. The 'interface' of an NPObject is - described by an NPClass. -*/ -typedef struct NPObject NPObject; -typedef struct NPClass NPClass; - -typedef char NPUTF8; -typedef struct _NPString { - const NPUTF8 *UTF8Characters; - uint32_t UTF8Length; -} NPString; - -typedef enum { - NPVariantType_Void, - NPVariantType_Null, - NPVariantType_Bool, - NPVariantType_Int32, - NPVariantType_Double, - NPVariantType_String, - NPVariantType_Object -} NPVariantType; - -typedef struct _NPVariant { - NPVariantType type; - union { - bool boolValue; - int32_t intValue; - double doubleValue; - NPString stringValue; - NPObject *objectValue; - } value; -} NPVariant; - -/* - NPN_ReleaseVariantValue is called on all 'out' parameters references. - Specifically it is called on variants that are resultant out parameters - in NPGetPropertyFunctionPtr and NPInvokeFunctionPtr. Resultant variants - from these two functions should be initialized using the - NPN_InitializeVariantXXX() functions. - - After calling NPReleaseVariantValue, the type of the variant will - be set to NPVariantUndefinedType. -*/ -void NPN_ReleaseVariantValue (NPVariant *variant); - -#define NPVARIANT_IS_VOID(_v) ((_v).type == NPVariantType_Void) -#define NPVARIANT_IS_NULL(_v) ((_v).type == NPVariantType_Null) -#define NPVARIANT_IS_BOOLEAN(_v) ((_v).type == NPVariantType_Bool) -#define NPVARIANT_IS_INT32(_v) ((_v).type == NPVariantType_Int32) -#define NPVARIANT_IS_DOUBLE(_v) ((_v).type == NPVariantType_Double) -#define NPVARIANT_IS_STRING(_v) ((_v).type == NPVariantType_String) -#define NPVARIANT_IS_OBJECT(_v) ((_v).type == NPVariantType_Object) - -#define NPVARIANT_TO_BOOLEAN(_v) ((_v).value.boolValue) -#define NPVARIANT_TO_INT32(_v) ((_v).value.intValue) -#define NPVARIANT_TO_DOUBLE(_v) ((_v).value.doubleValue) -#define NPVARIANT_TO_STRING(_v) ((_v).value.stringValue) -#define NPVARIANT_TO_OBJECT(_v) ((_v).value.objectValue) - -#define NP_BEGIN_MACRO do { -#define NP_END_MACRO } while (0) - -#define VOID_TO_NPVARIANT(_v) NP_BEGIN_MACRO (_v).type = NPVariantType_Void; (_v).value.objectValue = NULL; NP_END_MACRO -#define NULL_TO_NPVARIANT(_v) NP_BEGIN_MACRO (_v).type = NPVariantType_Null; (_v).value.objectValue = NULL; NP_END_MACRO -#define BOOLEAN_TO_NPVARIANT(_val, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_Bool; (_v).value.boolValue = !!(_val); NP_END_MACRO -#define INT32_TO_NPVARIANT(_val, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_Int32; (_v).value.intValue = _val; NP_END_MACRO -#define DOUBLE_TO_NPVARIANT(_val, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_Double; (_v).value.doubleValue = _val; NP_END_MACRO -#define STRINGZ_TO_NPVARIANT(_val, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_String; NPString str = { _val, strlen(_val) }; (_v).value.stringValue = str; NP_END_MACRO -#define STRINGN_TO_NPVARIANT(_val, _len, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_String; NPString str = { _val, _len }; (_v).value.stringValue = str; NP_END_MACRO -#define OBJECT_TO_NPVARIANT(_val, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_Object; (_v).value.objectValue = _val; NP_END_MACRO - -/* - Type mappings (JavaScript types have been used for illustration - purposes): - - JavaScript to C (NPVariant with type:) - undefined NPVariantType_Void - null NPVariantType_Null - Boolean NPVariantType_Bool - Number NPVariantType_Double or NPVariantType_Int32 - String NPVariantType_String - Object NPVariantType_Object - - C (NPVariant with type:) to JavaScript - NPVariantType_Void undefined - NPVariantType_Null null - NPVariantType_Bool Boolean - NPVariantType_Int32 Number - NPVariantType_Double Number - NPVariantType_String String - NPVariantType_Object Object -*/ - -typedef void *NPIdentifier; - -/* - NPObjects have methods and properties. Methods and properties are - identified with NPIdentifiers. These identifiers may be reflected - in script. NPIdentifiers can be either strings or integers, IOW, - methods and properties can be identified by either strings or - integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be - compared using ==. In case of any errors, the requested - NPIdentifier(s) will be NULL. -*/ -NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name); -void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers); -NPIdentifier NPN_GetIntIdentifier(int32_t intid); -bool NPN_IdentifierIsString(NPIdentifier identifier); - -/* - The NPUTF8 returned from NPN_UTF8FromIdentifier SHOULD be freed. -*/ -NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier); - -/* - Get the integer represented by identifier. If identifier is not an - integer identifier, the behaviour is undefined. -*/ -int32_t NPN_IntFromIdentifier(NPIdentifier identifier); - -/* - NPObject behavior is implemented using the following set of - callback functions. - - The NPVariant *result argument of these functions (where - applicable) should be released using NPN_ReleaseVariantValue(). -*/ -typedef NPObject *(*NPAllocateFunctionPtr)(NPP npp, NPClass *aClass); -typedef void (*NPDeallocateFunctionPtr)(NPObject *obj); -typedef void (*NPInvalidateFunctionPtr)(NPObject *obj); -typedef bool (*NPHasMethodFunctionPtr)(NPObject *obj, NPIdentifier name); -typedef bool (*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result); -typedef bool (*NPInvokeDefaultFunctionPtr)(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); -typedef bool (*NPHasPropertyFunctionPtr)(NPObject *obj, NPIdentifier name); -typedef bool (*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *result); -typedef bool (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value); -typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj, NPIdentifier name); -typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value, uint32_t *count); - -/* - NPObjects returned by create have a reference count of one. It is the caller's responsibility - to release the returned object. - - NPInvokeFunctionPtr function may return false to indicate a the method could not be invoked. - - NPGetPropertyFunctionPtr and NPSetPropertyFunctionPtr may return false to indicate a property doesn't - exist. - - NPInvalidateFunctionPtr is called by the scripting environment when the native code is - shutdown. Any attempt to message a NPObject instance after the invalidate - callback has been called will result in undefined behavior, even if the - native code is still retaining those NPObject instances. - (The runtime will typically return immediately, with 0 or NULL, from an attempt to - dispatch to a NPObject, but this behavior should not be depended upon.) - - The NPEnumerationFunctionPtr function may pass an array of - NPIdentifiers back to the caller. The callee allocs the memory of - the array using NPN_MemAlloc(), and it's the caller's responsibility - to release it using NPN_MemFree(). -*/ -struct NPClass -{ - uint32_t structVersion; - NPAllocateFunctionPtr allocate; - NPDeallocateFunctionPtr deallocate; - NPInvalidateFunctionPtr invalidate; - NPHasMethodFunctionPtr hasMethod; - NPInvokeFunctionPtr invoke; - NPInvokeDefaultFunctionPtr invokeDefault; - NPHasPropertyFunctionPtr hasProperty; - NPGetPropertyFunctionPtr getProperty; - NPSetPropertyFunctionPtr setProperty; - NPRemovePropertyFunctionPtr removeProperty; - NPEnumerationFunctionPtr enumerate; -}; - -#define NP_CLASS_STRUCT_VERSION 2 -#define NP_CLASS_STRUCT_VERSION_ENUM 2 -#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass) \ - ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM) - -struct NPObject { - NPClass *_class; - uint32_t referenceCount; - // Additional space may be allocated here by types of NPObjects -}; - -/* - If the class has an allocate function, NPN_CreateObject invokes that function, - otherwise a NPObject is allocated and returned. If a class has an allocate - function it is the responsibility of that implementation to set the initial retain - count to 1. -*/ -NPObject *NPN_CreateObject(NPP npp, NPClass *aClass); - -/* - Increment the NPObject's reference count. -*/ -NPObject *NPN_RetainObject (NPObject *obj); - -/* - Decremented the NPObject's reference count. If the reference - count goes to zero, the class's destroy function is invoke if - specified, otherwise the object is freed directly. -*/ -void NPN_ReleaseObject (NPObject *obj); - -/* - Functions to access script objects represented by NPObject. - - Calls to script objects are synchronous. If a function returns a - value, it will be supplied via the result NPVariant - argument. Successful calls will return true, false will be - returned in case of an error. - - Calls made from plugin code to script must be made from the thread - on which the plugin was initialized. -*/ -bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); -bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); -bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, NPVariant *result); -bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVariant *result); -bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value); -bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName); -bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName); -bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName); -bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count); - -/* - NPN_SetException may be called to trigger a script exception upon return - from entry points into NPObjects. -*/ -void NPN_SetException (NPObject *obj, const NPUTF8 *message); - -#ifdef __cplusplus -} -#endif - -#endif // ENABLE(NETSCAPE_API) - -#endif diff --git a/bindings/npruntime_impl.h b/bindings/npruntime_impl.h deleted file mode 100644 index 17f6d1c..0000000 --- a/bindings/npruntime_impl.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _NP_RUNTIME_IMPL_H_ -#define _NP_RUNTIME_IMPL_H_ - -#if ENABLE(NETSCAPE_API) - -#include "npruntime_internal.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern void _NPN_ReleaseVariantValue(NPVariant *variant); -extern NPIdentifier _NPN_GetStringIdentifier(const NPUTF8 *name); -extern void _NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers); -extern NPIdentifier _NPN_GetIntIdentifier(int32_t intid); -extern bool _NPN_IdentifierIsString(NPIdentifier identifier); -extern NPUTF8 *_NPN_UTF8FromIdentifier(NPIdentifier identifier); -extern int32_t _NPN_IntFromIdentifier(NPIdentifier identifier); -extern NPObject *_NPN_CreateObject(NPP npp, NPClass *aClass); -extern NPObject *_NPN_RetainObject(NPObject *obj); -extern void _NPN_ReleaseObject(NPObject *obj); -extern void _NPN_DeallocateObject(NPObject *obj); -extern bool _NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); -extern bool _NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result); -extern bool _NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, NPVariant *result); -extern bool _NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVariant *result); -extern bool _NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value); -extern bool _NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName); -extern bool _NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName); -extern bool _NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName); -extern void _NPN_SetException(NPObject *obj, const NPUTF8 *message); -extern bool _NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count); - -#ifdef __cplusplus -} /* end extern "C" */ -#endif - -#endif // ENABLE(NETSCAPE_API) - -#endif diff --git a/bindings/npruntime_internal.h b/bindings/npruntime_internal.h deleted file mode 100644 index f5357cd..0000000 --- a/bindings/npruntime_internal.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2007 Collabora, Ltd. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * This is a internal include header for npapi.h - * - * Some of the #defines which are in X11 headers conflict with type and enum - * names in JavaScriptCore and WebCore - * This header #undefs those defines to fix the conflicts - * If you need to include npapi.h or npruntime.h when building on X11, - * include this file instead of the actual npapi.h or npruntime.h - */ - -#include "npruntime.h" - -#ifdef XP_UNIX - #include - - #undef None - #undef Above - #undef Below - #undef Auto - #undef Complex - #undef Status -#endif diff --git a/bindings/objc/WebScriptObject.h b/bindings/objc/WebScriptObject.h deleted file mode 100644 index 14d77d7..0000000 --- a/bindings/objc/WebScriptObject.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import - -#include "internal.h" -#include "runtime_root.h" - -@class WebUndefined; - -@protocol WebScriptObject -+ (NSString *)webScriptNameForSelector:(SEL)aSelector; -+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector; -+ (NSString *)webScriptNameForKey:(const char *)name; -+ (BOOL)isKeyExcludedFromWebScript:(const char *)name; - -+ (id)_convertValueToObjcValue:(KJS::JSValue *)value originRootObject:(KJS::Bindings::RootObject*)originRootObject rootObject:(KJS::Bindings::RootObject*)rootObject; -- _initWithJSObject:(KJS::JSObject*)imp originRootObject:(PassRefPtr)originRootObject rootObject:(PassRefPtr)rootObject; -- (KJS::JSObject *)_imp; -@end - -@protocol WebUndefined -+ (WebUndefined *)undefined; -@end diff --git a/bindings/objc/objc_class.mm b/bindings/objc/objc_class.mm deleted file mode 100644 index 9a6d48c..0000000 --- a/bindings/objc/objc_class.mm +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "objc_class.h" - -#include "objc_instance.h" -#include "WebScriptObject.h" - -namespace KJS { -namespace Bindings { - -static void deleteMethod(CFAllocatorRef, const void* value) -{ - delete static_cast(value); -} - -static void deleteField(CFAllocatorRef, const void* value) -{ - delete static_cast(value); -} - -const CFDictionaryValueCallBacks MethodDictionaryValueCallBacks = { 0, 0, &deleteMethod, 0 , 0 }; -const CFDictionaryValueCallBacks FieldDictionaryValueCallBacks = { 0, 0, &deleteField, 0 , 0 }; - -ObjcClass::ObjcClass(ClassStructPtr aClass) - : _isa(aClass) - , _methods(AdoptCF, CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &MethodDictionaryValueCallBacks)) - , _fields(AdoptCF, CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &FieldDictionaryValueCallBacks)) -{ -} - -static CFMutableDictionaryRef classesByIsA = 0; - -static void _createClassesByIsAIfNecessary() -{ - if (!classesByIsA) - classesByIsA = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); -} - -ObjcClass* ObjcClass::classForIsA(ClassStructPtr isa) -{ - _createClassesByIsAIfNecessary(); - - ObjcClass* aClass = (ObjcClass*)CFDictionaryGetValue(classesByIsA, isa); - if (!aClass) { - aClass = new ObjcClass(isa); - CFDictionaryAddValue(classesByIsA, isa, aClass); - } - - return aClass; -} - -const char* ObjcClass::name() const -{ - return object_getClassName(_isa); -} - -MethodList ObjcClass::methodsNamed(const Identifier& identifier, Instance*) const -{ - MethodList methodList; - char fixedSizeBuffer[1024]; - char* buffer = fixedSizeBuffer; - const char* JSName = identifier.ascii(); - if (!convertJSMethodNameToObjc(JSName, buffer, sizeof(fixedSizeBuffer))) { - int length = strlen(JSName) + 1; - buffer = new char[length]; - if (!buffer || !convertJSMethodNameToObjc(JSName, buffer, length)) - return methodList; - } - - - RetainPtr methodName(AdoptCF, CFStringCreateWithCString(NULL, buffer, kCFStringEncodingASCII)); - Method* method = (Method*)CFDictionaryGetValue(_methods.get(), methodName.get()); - if (method) { - methodList.append(method); - return methodList; - } - - ClassStructPtr thisClass = _isa; - while (thisClass && methodList.isEmpty()) { -#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 - unsigned numMethodsInClass = 0; - MethodStructPtr* objcMethodList = class_copyMethodList(thisClass, &numMethodsInClass); -#else - void* iterator = 0; - struct objc_method_list* objcMethodList; - while ((objcMethodList = class_nextMethodList(thisClass, &iterator))) { - unsigned numMethodsInClass = objcMethodList->method_count; -#endif - for (unsigned i = 0; i < numMethodsInClass; i++) { -#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 - MethodStructPtr objcMethod = objcMethodList[i]; - SEL objcMethodSelector = method_getName(objcMethod); -#else - struct objc_method* objcMethod = &objcMethodList->method_list[i]; - SEL objcMethodSelector = objcMethod->method_name; -#endif - const char* objcMethodSelectorName = sel_getName(objcMethodSelector); - NSString* mappedName = nil; - - // See if the class wants to exclude the selector from visibility in JavaScript. - if ([thisClass respondsToSelector:@selector(isSelectorExcludedFromWebScript:)]) - if ([thisClass isSelectorExcludedFromWebScript:objcMethodSelector]) - continue; - - // See if the class want to provide a different name for the selector in JavaScript. - // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity - // of the class. - if ([thisClass respondsToSelector:@selector(webScriptNameForSelector:)]) - mappedName = [thisClass webScriptNameForSelector:objcMethodSelector]; - - if ((mappedName && [mappedName isEqual:(NSString*)methodName.get()]) || strcmp(objcMethodSelectorName, buffer) == 0) { - Method* aMethod = new ObjcMethod(thisClass, objcMethodSelectorName); // deleted when the dictionary is destroyed - CFDictionaryAddValue(_methods.get(), methodName.get(), aMethod); - methodList.append(aMethod); - break; - } - } -#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 - thisClass = class_getSuperclass(thisClass); - free(objcMethodList); -#else - } - thisClass = thisClass->super_class; -#endif - } - - if (buffer != fixedSizeBuffer) - delete [] buffer; - - return methodList; -} - -Field* ObjcClass::fieldNamed(const Identifier& identifier, Instance* instance) const -{ - ClassStructPtr thisClass = _isa; - - const char* name = identifier.ascii(); - RetainPtr fieldName(AdoptCF, CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII)); - Field* aField = (Field*)CFDictionaryGetValue(_fields.get(), fieldName.get()); - if (aField) - return aField; - - id targetObject = (static_cast(instance))->getObject(); - id attributes = [targetObject respondsToSelector:@selector(attributeKeys)] ? [targetObject performSelector:@selector(attributeKeys)] : nil; - if (attributes) { - // Class overrides attributeKeys, use that array of key names. - unsigned count = [attributes count]; - for (unsigned i = 0; i < count; i++) { - NSString* keyName = [attributes objectAtIndex:i]; - const char* UTF8KeyName = [keyName UTF8String]; // ObjC actually only supports ASCII names. - - // See if the class wants to exclude the selector from visibility in JavaScript. - if ([thisClass respondsToSelector:@selector(isKeyExcludedFromWebScript:)]) - if ([thisClass isKeyExcludedFromWebScript:UTF8KeyName]) - continue; - - // See if the class want to provide a different name for the selector in JavaScript. - // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity - // of the class. - NSString* mappedName = nil; - if ([thisClass respondsToSelector:@selector(webScriptNameForKey:)]) - mappedName = [thisClass webScriptNameForKey:UTF8KeyName]; - - if ((mappedName && [mappedName isEqual:(NSString*)fieldName.get()]) || [keyName isEqual:(NSString*)fieldName.get()]) { - aField = new ObjcField((CFStringRef)keyName); // deleted when the dictionary is destroyed - CFDictionaryAddValue(_fields.get(), fieldName.get(), aField); - break; - } - } - } else { - // Class doesn't override attributeKeys, so fall back on class runtime - // introspection. - - while (thisClass) { -#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 - unsigned numFieldsInClass = 0; - IvarStructPtr* ivarsInClass = class_copyIvarList(thisClass, &numFieldsInClass); -#else - struct objc_ivar_list* fieldsInClass = thisClass->ivars; - if (fieldsInClass) { - unsigned numFieldsInClass = fieldsInClass->ivar_count; -#endif - for (unsigned i = 0; i < numFieldsInClass; i++) { -#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 - IvarStructPtr objcIVar = ivarsInClass[i]; - const char* objcIvarName = ivar_getName(objcIVar); -#else - IvarStructPtr objcIVar = &fieldsInClass->ivar_list[i]; - const char* objcIvarName = objcIVar->ivar_name; -#endif - NSString* mappedName = 0; - - // See if the class wants to exclude the selector from visibility in JavaScript. - if ([thisClass respondsToSelector:@selector(isKeyExcludedFromWebScript:)]) - if ([thisClass isKeyExcludedFromWebScript:objcIvarName]) - continue; - - // See if the class want to provide a different name for the selector in JavaScript. - // Note that we do not do any checks to guarantee uniqueness. That's the responsiblity - // of the class. - if ([thisClass respondsToSelector:@selector(webScriptNameForKey:)]) - mappedName = [thisClass webScriptNameForKey:objcIvarName]; - - if ((mappedName && [mappedName isEqual:(NSString*)fieldName.get()]) || strcmp(objcIvarName, name) == 0) { - aField = new ObjcField(objcIVar); // deleted when the dictionary is destroyed - CFDictionaryAddValue(_fields.get(), fieldName.get(), aField); - break; - } - } -#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 - thisClass = class_getSuperclass(thisClass); - free(ivarsInClass); -#else - } - thisClass = thisClass->super_class; -#endif - } - } - - return aField; -} - -JSValue* ObjcClass::fallbackObject(ExecState*, Instance* instance, const Identifier &propertyName) -{ - ObjcInstance* objcInstance = static_cast(instance); - id targetObject = objcInstance->getObject(); - - if (![targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)]) - return jsUndefined(); - return new ObjcFallbackObjectImp(objcInstance, propertyName); -} - -} -} diff --git a/bindings/objc/objc_instance.h b/bindings/objc/objc_instance.h deleted file mode 100644 index 2233791..0000000 --- a/bindings/objc/objc_instance.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BINDINGS_OBJC_INSTANCE_H_ -#define BINDINGS_OBJC_INSTANCE_H_ - -#include -#include - -namespace KJS { - -namespace Bindings { - -class ObjcClass; - -class ObjcInstance : public Instance { -public: - ObjcInstance(ObjectStructPtr instance, PassRefPtr); - - ~ObjcInstance(); - - virtual Class *getClass() const; - - virtual void begin(); - virtual void end(); - - virtual JSValue *valueOf() const; - virtual JSValue *defaultValue(JSType hint) const; - - virtual bool implementsCall() const; - - virtual JSValue *invokeMethod(ExecState *exec, const MethodList &method, const List &args); - virtual JSValue *invokeDefaultMethod(ExecState *exec, const List &args); - - virtual bool supportsSetValueOfUndefinedField(); - virtual void setValueOfUndefinedField(ExecState *exec, const Identifier &property, JSValue *aValue); - - virtual JSValue *getValueOfUndefinedField(ExecState *exec, const Identifier &property, JSType hint) const; - - ObjectStructPtr getObject() const { return _instance.get(); } - - JSValue *stringValue() const; - JSValue *numberValue() const; - JSValue *booleanValue() const; - - virtual BindingLanguage getBindingLanguage() const { return ObjectiveCLanguage; } - -private: - RetainPtr _instance; - mutable ObjcClass *_class; - ObjectStructPtr _pool; - int _beginCount; -}; - -} // namespace Bindings - -} // namespace KJS - -#endif // BINDINGS_OBJC_INSTANCE_H_ diff --git a/bindings/objc/objc_instance.mm b/bindings/objc/objc_instance.mm deleted file mode 100644 index 57ebfe8..0000000 --- a/bindings/objc/objc_instance.mm +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "objc_instance.h" - -#import "WebScriptObject.h" -#include - -#ifdef NDEBUG -#define OBJC_LOG(formatAndArgs...) ((void)0) -#else -#define OBJC_LOG(formatAndArgs...) { \ - fprintf (stderr, "%s:%d -- %s: ", __FILE__, __LINE__, __FUNCTION__); \ - fprintf(stderr, formatAndArgs); \ -} -#endif - -using namespace KJS::Bindings; -using namespace KJS; - -ObjcInstance::ObjcInstance(ObjectStructPtr instance, PassRefPtr rootObject) - : Instance(rootObject) - , _instance(instance) - , _class(0) - , _pool(0) - , _beginCount(0) -{ -} - -ObjcInstance::~ObjcInstance() -{ - begin(); // -finalizeForWebScript and -dealloc/-finalize may require autorelease pools. - if ([_instance.get() respondsToSelector:@selector(finalizeForWebScript)]) - [_instance.get() performSelector:@selector(finalizeForWebScript)]; - _instance = 0; - end(); -} - -void ObjcInstance::begin() -{ - if (!_pool) - _pool = [[NSAutoreleasePool alloc] init]; - _beginCount++; -} - -void ObjcInstance::end() -{ - _beginCount--; - ASSERT(_beginCount >= 0); - if (!_beginCount) { - [_pool drain]; - _pool = 0; - } -} - -Bindings::Class* ObjcInstance::getClass() const -{ - if (!_instance) - return 0; - if (!_class) - _class = ObjcClass::classForIsA(_instance->isa); - return static_cast(_class); -} - -bool ObjcInstance::implementsCall() const -{ - return [_instance.get() respondsToSelector:@selector(invokeDefaultMethodWithArguments:)]; -} - -JSValue* ObjcInstance::invokeMethod(ExecState* exec, const MethodList &methodList, const List &args) -{ - JSValue* result = jsUndefined(); - - JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly. - - // Overloading methods is not allowed in ObjectiveC. Should only be one - // name match for a particular method. - ASSERT(methodList.size() == 1); - -@try { - ObjcMethod* method = 0; - method = static_cast(methodList[0]); - NSMethodSignature* signature = method->getMethodSignature(); - NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature]; -#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 - [invocation setSelector:sel_registerName(method->name())]; -#else - [invocation setSelector:(SEL)method->name()]; -#endif - [invocation setTarget:_instance.get()]; - - if (method->isFallbackMethod()) { - if (objcValueTypeForType([signature methodReturnType]) != ObjcObjectType) { - NSLog(@"Incorrect signature for invokeUndefinedMethodFromWebScript:withArguments: -- return type must be object."); - return result; - } - - // Invoke invokeUndefinedMethodFromWebScript:withArguments:, pass JavaScript function - // name as first (actually at 2) argument and array of args as second. - NSString* jsName = (NSString* )method->javaScriptName(); - [invocation setArgument:&jsName atIndex:2]; - - NSMutableArray* objcArgs = [NSMutableArray array]; - int count = args.size(); - for (int i = 0; i < count; i++) { - ObjcValue value = convertValueToObjcValue(exec, args.at(i), ObjcObjectType); - [objcArgs addObject:value.objectValue]; - } - [invocation setArgument:&objcArgs atIndex:3]; - } else { - unsigned count = [signature numberOfArguments]; - for (unsigned i = 2; i < count ; i++) { - const char* type = [signature getArgumentTypeAtIndex:i]; - ObjcValueType objcValueType = objcValueTypeForType(type); - - // Must have a valid argument type. This method signature should have - // been filtered already to ensure that it has acceptable argument - // types. - ASSERT(objcValueType != ObjcInvalidType && objcValueType != ObjcVoidType); - - ObjcValue value = convertValueToObjcValue(exec, args.at(i-2), objcValueType); - - switch (objcValueType) { - case ObjcObjectType: - [invocation setArgument:&value.objectValue atIndex:i]; - break; - case ObjcCharType: - case ObjcUnsignedCharType: - [invocation setArgument:&value.charValue atIndex:i]; - break; - case ObjcShortType: - case ObjcUnsignedShortType: - [invocation setArgument:&value.shortValue atIndex:i]; - break; - case ObjcIntType: - case ObjcUnsignedIntType: - [invocation setArgument:&value.intValue atIndex:i]; - break; - case ObjcLongType: - case ObjcUnsignedLongType: - [invocation setArgument:&value.longValue atIndex:i]; - break; - case ObjcLongLongType: - case ObjcUnsignedLongLongType: - [invocation setArgument:&value.longLongValue atIndex:i]; - break; - case ObjcFloatType: - [invocation setArgument:&value.floatValue atIndex:i]; - break; - case ObjcDoubleType: - [invocation setArgument:&value.doubleValue atIndex:i]; - break; - default: - // Should never get here. Argument types are filtered (and - // the assert above should have fired in the impossible case - // of an invalid type anyway). - fprintf(stderr, "%s: invalid type (%d)\n", __PRETTY_FUNCTION__, (int)objcValueType); - ASSERT(false); - } - } - } - - [invocation invoke]; - - // Get the return value type. - const char* type = [signature methodReturnType]; - ObjcValueType objcValueType = objcValueTypeForType(type); - - // Must have a valid return type. This method signature should have - // been filtered already to ensure that it have an acceptable return - // type. - ASSERT(objcValueType != ObjcInvalidType); - - // Get the return value and convert it to a JavaScript value. Length - // of return value will never exceed the size of largest scalar - // or a pointer. - char buffer[1024]; - ASSERT([signature methodReturnLength] < 1024); - - if (*type != 'v') { - [invocation getReturnValue:buffer]; - result = convertObjcValueToValue(exec, buffer, objcValueType, _rootObject.get()); - } -} @catch(NSException* localException) { -} - return result; -} - -JSValue* ObjcInstance::invokeDefaultMethod(ExecState* exec, const List &args) -{ - JSValue* result = jsUndefined(); - - JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly. - -@try { - if (![_instance.get() respondsToSelector:@selector(invokeDefaultMethodWithArguments:)]) - return result; - - NSMethodSignature* signature = [_instance.get() methodSignatureForSelector:@selector(invokeDefaultMethodWithArguments:)]; - NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature]; - [invocation setSelector:@selector(invokeDefaultMethodWithArguments:)]; - [invocation setTarget:_instance.get()]; - - if (objcValueTypeForType([signature methodReturnType]) != ObjcObjectType) { - NSLog(@"Incorrect signature for invokeDefaultMethodWithArguments: -- return type must be object."); - return result; - } - - NSMutableArray* objcArgs = [NSMutableArray array]; - unsigned count = args.size(); - for (unsigned i = 0; i < count; i++) { - ObjcValue value = convertValueToObjcValue(exec, args.at(i), ObjcObjectType); - [objcArgs addObject:value.objectValue]; - } - [invocation setArgument:&objcArgs atIndex:2]; - - [invocation invoke]; - - // Get the return value type, should always be "@" because of - // check above. - const char* type = [signature methodReturnType]; - ObjcValueType objcValueType = objcValueTypeForType(type); - - // Get the return value and convert it to a JavaScript value. Length - // of return value will never exceed the size of a pointer, so we're - // OK with 32 here. - char buffer[32]; - [invocation getReturnValue:buffer]; - result = convertObjcValueToValue(exec, buffer, objcValueType, _rootObject.get()); -} @catch(NSException* localException) { -} - - return result; -} - -bool ObjcInstance::supportsSetValueOfUndefinedField() -{ - id targetObject = getObject(); - if ([targetObject respondsToSelector:@selector(setValue:forUndefinedKey:)]) - return true; - return false; -} - -void ObjcInstance::setValueOfUndefinedField(ExecState* exec, const Identifier &property, JSValue* aValue) -{ - id targetObject = getObject(); - - JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly. - - // This check is not really necessary because NSObject implements - // setValue:forUndefinedKey:, and unfortnately the default implementation - // throws an exception. - if ([targetObject respondsToSelector:@selector(setValue:forUndefinedKey:)]){ - ObjcValue objcValue = convertValueToObjcValue(exec, aValue, ObjcObjectType); - - @try { - [targetObject setValue:objcValue.objectValue forUndefinedKey:[NSString stringWithCString:property.ascii() encoding:NSASCIIStringEncoding]]; - } @catch(NSException* localException) { - // Do nothing. Class did not override valueForUndefinedKey:. - } - } -} - -JSValue* ObjcInstance::getValueOfUndefinedField(ExecState* exec, const Identifier& property, JSType) const -{ - JSValue* result = jsUndefined(); - - id targetObject = getObject(); - - JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly. - - // This check is not really necessary because NSObject implements - // valueForUndefinedKey:, and unfortnately the default implementation - // throws an exception. - if ([targetObject respondsToSelector:@selector(valueForUndefinedKey:)]){ - @try { - id objcValue = [targetObject valueForUndefinedKey:[NSString stringWithCString:property.ascii() encoding:NSASCIIStringEncoding]]; - result = convertObjcValueToValue(exec, &objcValue, ObjcObjectType, _rootObject.get()); - } @catch(NSException* localException) { - // Do nothing. Class did not override valueForUndefinedKey:. - } - } - - return result; -} - -JSValue* ObjcInstance::defaultValue(JSType hint) const -{ - switch (hint) { - case StringType: - return stringValue(); - case NumberType: - return numberValue(); - case BooleanType: - return booleanValue(); - case UnspecifiedType: - if ([_instance.get() isKindOfClass:[NSString class]]) - return stringValue(); - if ([_instance.get() isKindOfClass:[NSNumber class]]) - return numberValue(); - default: - return valueOf(); - } -} - -JSValue* ObjcInstance::stringValue() const -{ - return convertNSStringToString([getObject() description]); -} - -JSValue* ObjcInstance::numberValue() const -{ - // FIXME: Implement something sensible - return jsNumber(0); -} - -JSValue* ObjcInstance::booleanValue() const -{ - // FIXME: Implement something sensible - return jsBoolean(false); -} - -JSValue* ObjcInstance::valueOf() const -{ - return stringValue(); -} diff --git a/bindings/objc/objc_runtime.h b/bindings/objc/objc_runtime.h deleted file mode 100644 index 1151d53..0000000 --- a/bindings/objc/objc_runtime.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef KJS_BINDINGS_OBJC_RUNTIME_H -#define KJS_BINDINGS_OBJC_RUNTIME_H - -#include -#include -#include -#include - -#include - -namespace KJS { -namespace Bindings { - -extern ClassStructPtr webScriptObjectClass(); -extern ClassStructPtr webUndefinedClass(); - -class ObjcInstance; - -class ObjcField : public Field -{ -public: - ObjcField(IvarStructPtr ivar); - ObjcField(CFStringRef name); - - virtual JSValue *valueFromInstance(ExecState *exec, const Instance *instance) const; - virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue *aValue) const; - - virtual const char *name() const; - -private: - IvarStructPtr _ivar; - RetainPtr _name; -}; - -class ObjcMethod : public Method -{ -public: - ObjcMethod() : _objcClass(0), _selector(0), _javaScriptName(0) {} - ObjcMethod(ClassStructPtr aClass, const char *_selector); - - virtual const char *name() const; - - virtual int numParameters() const; - - NSMethodSignature *getMethodSignature() const; - - bool isFallbackMethod() const { return strcmp(_selector, "invokeUndefinedMethodFromWebScript:withArguments:") == 0; } - void setJavaScriptName(CFStringRef n) { _javaScriptName = n; } - CFStringRef javaScriptName() const { return _javaScriptName.get(); } - -private: - ClassStructPtr _objcClass; - const char *_selector; - RetainPtr _javaScriptName; -}; - -class ObjcArray : public Array -{ -public: - ObjcArray(ObjectStructPtr, PassRefPtr); - - virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const; - virtual JSValue *valueAt(ExecState *exec, unsigned int index) const; - virtual unsigned int getLength() const; - - ObjectStructPtr getObjcArray() const { return _array.get(); } - - static JSValue *convertObjcArrayToArray(ExecState *exec, ObjectStructPtr anObject); - -private: - RetainPtr _array; -}; - -class ObjcFallbackObjectImp : public JSObject { -public: - ObjcFallbackObjectImp(ObjcInstance *i, const Identifier propertyName); - - const ClassInfo *classInfo() const { return &info; } - - virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); - virtual bool canPut(ExecState *exec, const Identifier &propertyName) const; - virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None); - virtual bool implementsCall() const; - virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); - virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName); - virtual JSValue *defaultValue(ExecState *exec, JSType hint) const; - - virtual JSType type() const; - virtual bool toBoolean(ExecState *exec) const; - -private: - ObjcFallbackObjectImp(); // prevent default construction - - static const ClassInfo info; - - RefPtr _instance; - Identifier _item; -}; - -} // namespace Bindings -} // namespace KJS - -#endif diff --git a/bindings/objc/objc_runtime.mm b/bindings/objc/objc_runtime.mm deleted file mode 100644 index ec0b41f..0000000 --- a/bindings/objc/objc_runtime.mm +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "objc_runtime.h" - -#include "objc_instance.h" -#include "runtime_array.h" -#include "runtime_object.h" -#include "WebScriptObject.h" - -using namespace KJS; -using namespace KJS::Bindings; - -extern ClassStructPtr KJS::Bindings::webScriptObjectClass() -{ - static ClassStructPtr webScriptObjectClass = NSClassFromString(@"WebScriptObject"); - return webScriptObjectClass; -} - -extern ClassStructPtr KJS::Bindings::webUndefinedClass() -{ - static ClassStructPtr webUndefinedClass = NSClassFromString(@"WebUndefined"); - return webUndefinedClass; -} - -// ---------------------- ObjcMethod ---------------------- - -ObjcMethod::ObjcMethod(ClassStructPtr aClass, const char* name) -{ - _objcClass = aClass; - _selector = name; // Assume ObjC runtime keeps these around forever. - _javaScriptName = 0; -} - -const char* ObjcMethod::name() const -{ - return _selector; -} - -int ObjcMethod::numParameters() const -{ - return [getMethodSignature() numberOfArguments] - 2; -} - -NSMethodSignature* ObjcMethod::getMethodSignature() const -{ -#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 - return [_objcClass instanceMethodSignatureForSelector:sel_registerName(_selector)]; -#else - return [_objcClass instanceMethodSignatureForSelector:(SEL)_selector]; -#endif -} - -// ---------------------- ObjcField ---------------------- - -ObjcField::ObjcField(Ivar ivar) -{ - _ivar = ivar; // Assume ObjectiveC runtime will keep this alive forever - _name = 0; -} - -ObjcField::ObjcField(CFStringRef name) -{ - _ivar = 0; - _name = (CFStringRef)CFRetain(name); -} - -const char* ObjcField::name() const -{ -#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2 - if (_ivar) - return ivar_getName(_ivar); -#else - if (_ivar) - return _ivar->ivar_name; -#endif - return [(NSString*)_name.get() UTF8String]; -} - -JSValue* ObjcField::valueFromInstance(ExecState* exec, const Instance* instance) const -{ - JSValue* result = jsUndefined(); - - id targetObject = (static_cast(instance))->getObject(); - - JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly. - - @try { - NSString* key = [NSString stringWithCString:name() encoding:NSASCIIStringEncoding]; - if (id objcValue = [targetObject valueForKey:key]) - result = convertObjcValueToValue(exec, &objcValue, ObjcObjectType, instance->rootObject()); - } @catch(NSException* localException) { - JSLock::lock(); - throwError(exec, GeneralError, [localException reason]); - JSLock::unlock(); - } - - return result; -} - -static id convertValueToObjcObject(ExecState* exec, JSValue* value) -{ - RefPtr rootObject = findRootObject(exec->dynamicGlobalObject()); - if (!rootObject) - return nil; - return [webScriptObjectClass() _convertValueToObjcValue:value originRootObject:rootObject.get() rootObject:rootObject.get()]; -} - -void ObjcField::setValueToInstance(ExecState* exec, const Instance* instance, JSValue* aValue) const -{ - id targetObject = (static_cast(instance))->getObject(); - id value = convertValueToObjcObject(exec, aValue); - - JSLock::DropAllLocks dropAllLocks; // Can't put this inside the @try scope because it unwinds incorrectly. - - @try { - NSString* key = [NSString stringWithCString:name() encoding:NSASCIIStringEncoding]; - [targetObject setValue:value forKey:key]; - } @catch(NSException* localException) { - JSLock::lock(); - throwError(exec, GeneralError, [localException reason]); - JSLock::unlock(); - } -} - -// ---------------------- ObjcArray ---------------------- - -ObjcArray::ObjcArray(ObjectStructPtr a, PassRefPtr rootObject) - : Array(rootObject) - , _array(a) -{ -} - -void ObjcArray::setValueAt(ExecState* exec, unsigned int index, JSValue* aValue) const -{ - if (![_array.get() respondsToSelector:@selector(insertObject:atIndex:)]) { - throwError(exec, TypeError, "Array is not mutable."); - return; - } - - if (index > [_array.get() count]) { - throwError(exec, RangeError, "Index exceeds array size."); - return; - } - - // Always try to convert the value to an ObjC object, so it can be placed in the - // array. - ObjcValue oValue = convertValueToObjcValue (exec, aValue, ObjcObjectType); - - @try { - [_array.get() insertObject:oValue.objectValue atIndex:index]; - } @catch(NSException* localException) { - throwError(exec, GeneralError, "Objective-C exception."); - } -} - -JSValue* ObjcArray::valueAt(ExecState* exec, unsigned int index) const -{ - if (index > [_array.get() count]) - return throwError(exec, RangeError, "Index exceeds array size."); - @try { - id obj = [_array.get() objectAtIndex:index]; - if (obj) - return convertObjcValueToValue (exec, &obj, ObjcObjectType, _rootObject.get()); - } @catch(NSException* localException) { - return throwError(exec, GeneralError, "Objective-C exception."); - } - return jsUndefined(); -} - -unsigned int ObjcArray::getLength() const -{ - return [_array.get() count]; -} - -const ClassInfo ObjcFallbackObjectImp::info = { "ObjcFallbackObject", 0, 0 }; - -ObjcFallbackObjectImp::ObjcFallbackObjectImp(ObjcInstance* i, const KJS::Identifier propertyName) -: _instance(i) -, _item(propertyName) -{ -} - -bool ObjcFallbackObjectImp::getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot& slot) -{ - // keep the prototype from getting called instead of just returning false - slot.setUndefined(this); - return true; -} - -void ObjcFallbackObjectImp::put(ExecState*, const Identifier&, JSValue*, int) -{ -} - -bool ObjcFallbackObjectImp::canPut(ExecState*, const Identifier&) const -{ - return false; -} - - -JSType ObjcFallbackObjectImp::type() const -{ - id targetObject = _instance->getObject(); - - if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)]) - return ObjectType; - - return UndefinedType; -} - -bool ObjcFallbackObjectImp::implementsCall() const -{ - id targetObject = _instance->getObject(); - - if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)]) - return true; - - return false; -} - -JSValue* ObjcFallbackObjectImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args) -{ - if (thisObj->classInfo() != &KJS::RuntimeObjectImp::info) - return throwError(exec, TypeError); - - JSValue* result = jsUndefined(); - - RuntimeObjectImp* imp = static_cast(thisObj); - Instance* instance = imp->getInternalInstance(); - - if (!instance) - return RuntimeObjectImp::throwInvalidAccessError(exec); - - instance->begin(); - - ObjcInstance* objcInstance = static_cast(instance); - id targetObject = objcInstance->getObject(); - - if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)]){ - MethodList methodList; - ObjcClass* objcClass = static_cast(instance->getClass()); - ObjcMethod* fallbackMethod = new ObjcMethod (objcClass->isa(), sel_getName(@selector(invokeUndefinedMethodFromWebScript:withArguments:))); - fallbackMethod->setJavaScriptName((CFStringRef)[NSString stringWithCString:_item.ascii() encoding:NSASCIIStringEncoding]); - methodList.append(fallbackMethod); - result = instance->invokeMethod(exec, methodList, args); - delete fallbackMethod; - } - - instance->end(); - - return result; -} - -bool ObjcFallbackObjectImp::deleteProperty(ExecState*, const Identifier&) -{ - return false; -} - -JSValue* ObjcFallbackObjectImp::defaultValue(ExecState* exec, JSType hint) const -{ - return _instance->getValueOfUndefinedField(exec, _item, hint); -} - -bool ObjcFallbackObjectImp::toBoolean(ExecState *) const -{ - id targetObject = _instance->getObject(); - - if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)]) - return true; - - return false; -} diff --git a/bindings/objc/objc_utility.h b/bindings/objc/objc_utility.h deleted file mode 100644 index fbed9b6..0000000 --- a/bindings/objc/objc_utility.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef KJS_BINDINGS_OBJC_UTILITY_H -#define KJS_BINDINGS_OBJC_UTILITY_H - -#include - -#include -#include - -#ifdef __OBJC__ -@class NSString; -#else -class NSString; -#endif - -namespace KJS { -namespace Bindings { - -typedef union { - ObjectStructPtr objectValue; - bool booleanValue; - char charValue; - short shortValue; - int intValue; - long longValue; - long long longLongValue; - float floatValue; - double doubleValue; -} ObjcValue; - -typedef enum { - ObjcVoidType, - ObjcObjectType, - ObjcCharType, - ObjcUnsignedCharType, - ObjcShortType, - ObjcUnsignedShortType, - ObjcIntType, - ObjcUnsignedIntType, - ObjcLongType, - ObjcUnsignedLongType, - ObjcLongLongType, - ObjcUnsignedLongLongType, - ObjcFloatType, - ObjcDoubleType, - ObjcInvalidType -} ObjcValueType; - -class RootObject; - -ObjcValue convertValueToObjcValue(ExecState *exec, JSValue *value, ObjcValueType type); -JSValue *convertNSStringToString(NSString *nsstring); -JSValue *convertObjcValueToValue(ExecState *exec, void *buffer, ObjcValueType type, RootObject*); -ObjcValueType objcValueTypeForType(const char *type); - -bool convertJSMethodNameToObjc(const char *JSName, char *buffer, size_t bufferSize); - -JSObject *throwError(ExecState *, ErrorType, NSString *message); - -} // namespace Bindings -} // namespace KJS - -#endif diff --git a/bindings/objc/objc_utility.mm b/bindings/objc/objc_utility.mm deleted file mode 100644 index 62a0ad0..0000000 --- a/bindings/objc/objc_utility.mm +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "objc_utility.h" - -#include "objc_instance.h" -#include "JSGlobalObject.h" -#include "runtime_array.h" -#include "runtime_object.h" -#include "WebScriptObject.h" -#include - -#if !defined(_C_LNG_LNG) -#define _C_LNG_LNG 'q' -#endif - -#if !defined(_C_ULNG_LNG) -#define _C_ULNG_LNG 'Q' -#endif - -#if !defined(_C_CONST) -#define _C_CONST 'r' -#endif - -#if !defined(_C_BYCOPY) -#define _C_BYCOPY 'O' -#endif - -#if !defined(_C_BYREF) -#define _C_BYREF 'R' -#endif - -#if !defined(_C_ONEWAY) -#define _C_ONEWAY 'V' -#endif - -#if !defined(_C_GCINVISIBLE) -#define _C_GCINVISIBLE '!' -#endif - -namespace KJS { -namespace Bindings { - -/* - By default, a JavaScript method name is produced by concatenating the - components of an ObjectiveC method name, replacing ':' with '_', and - escaping '_' and '$' with a leading '$', such that '_' becomes "$_" and - '$' becomes "$$". For example: - - ObjectiveC name Default JavaScript name - moveTo:: moveTo__ - moveTo_ moveTo$_ - moveTo$_ moveTo$$$_ - - This function performs the inverse of that operation. - - @result Fills 'buffer' with the ObjectiveC method name that corresponds to 'JSName'. - Returns true for success, false for failure. (Failure occurs when 'buffer' - is not big enough to hold the result.) -*/ -bool convertJSMethodNameToObjc(const char *JSName, char *buffer, size_t bufferSize) -{ - ASSERT(JSName && buffer); - - const char *sp = JSName; // source pointer - char *dp = buffer; // destination pointer - - char *end = buffer + bufferSize; - while (dp < end) { - if (*sp == '$') { - ++sp; - *dp = *sp; - } else if (*sp == '_') - *dp = ':'; - else - *dp = *sp; - - // If a future coder puts funny ++ operators above, we might write off the end - // of the buffer in the middle of this loop. Let's make sure to check for that. - ASSERT(dp < end); - - if (*sp == 0) { // We finished converting JSName - ASSERT(strlen(JSName) < bufferSize); - return true; - } - - ++sp; - ++dp; - } - - return false; // We ran out of buffer before converting JSName -} - -/* - - JavaScript to ObjC - Number coerced to char, short, int, long, float, double, or NSNumber, as appropriate - String NSString - wrapper id - Object WebScriptObject - null NSNull - [], other exception - -*/ -ObjcValue convertValueToObjcValue(ExecState *exec, JSValue *value, ObjcValueType type) -{ - ObjcValue result; - double d = 0; - - if (value->isNumber() || value->isString() || value->isBoolean()) - d = value->toNumber(exec); - - switch (type) { - case ObjcObjectType: { - JSLock lock; - - JSGlobalObject *originGlobalObject = exec->dynamicGlobalObject(); - RootObject* originRootObject = findRootObject(originGlobalObject); - - JSGlobalObject* globalObject = 0; - if (value->isObject() && static_cast(value)->isGlobalObject()) - globalObject = static_cast(value); - - if (!globalObject) - globalObject = originGlobalObject; - - RootObject* rootObject = findRootObject(globalObject); - result.objectValue = rootObject - ? [webScriptObjectClass() _convertValueToObjcValue:value originRootObject:originRootObject rootObject:rootObject] - : nil; - } - break; - - case ObjcCharType: - case ObjcUnsignedCharType: - result.charValue = (char)d; - break; - case ObjcShortType: - case ObjcUnsignedShortType: - result.shortValue = (short)d; - break; - case ObjcIntType: - case ObjcUnsignedIntType: - result.intValue = (int)d; - break; - case ObjcLongType: - case ObjcUnsignedLongType: - result.longValue = (long)d; - break; - case ObjcLongLongType: - case ObjcUnsignedLongLongType: - result.longLongValue = (long long)d; - break; - case ObjcFloatType: - result.floatValue = (float)d; - break; - case ObjcDoubleType: - result.doubleValue = (double)d; - break; - case ObjcVoidType: - bzero(&result, sizeof(ObjcValue)); - break; - - case ObjcInvalidType: - default: - // FIXME: throw an exception? - break; - } - - return result; -} - -JSValue *convertNSStringToString(NSString *nsstring) -{ - JSLock lock; - - unichar *chars; - unsigned int length = [nsstring length]; - chars = (unichar *)malloc(sizeof(unichar)*length); - [nsstring getCharacters:chars]; - UString u((const UChar*)chars, length); - JSValue *aValue = jsString(u); - free((void *)chars); - return aValue; -} - -/* - ObjC to JavaScript - ---- ---------- - char number - short number - int number - long number - float number - double number - NSNumber boolean or number - NSString string - NSArray array - NSNull null - WebScriptObject underlying JavaScript object - WebUndefined undefined - id object wrapper - other should not happen -*/ -JSValue* convertObjcValueToValue(ExecState* exec, void* buffer, ObjcValueType type, RootObject* rootObject) -{ - JSLock lock; - - switch (type) { - case ObjcObjectType: { - id obj = *(id*)buffer; - if ([obj isKindOfClass:[NSString class]]) - return convertNSStringToString((NSString *)obj); - if ([obj isKindOfClass:webUndefinedClass()]) - return jsUndefined(); - if ((CFBooleanRef)obj == kCFBooleanTrue) - return jsBoolean(true); - if ((CFBooleanRef)obj == kCFBooleanFalse) - return jsBoolean(false); - if ([obj isKindOfClass:[NSNumber class]]) - return jsNumber([obj doubleValue]); - if ([obj isKindOfClass:[NSArray class]]) - return new RuntimeArray(exec, new ObjcArray(obj, rootObject)); - if ([obj isKindOfClass:webScriptObjectClass()]) { - JSObject* imp = [obj _imp]; - return imp ? imp : jsUndefined(); - } - if ([obj isKindOfClass:[NSNull class]]) - return jsNull(); - if (obj == 0) - return jsUndefined(); - return Instance::createRuntimeObject(Instance::ObjectiveCLanguage, obj, rootObject); - } - case ObjcCharType: - return jsNumber(*(char *)buffer); - case ObjcUnsignedCharType: - return jsNumber(*(unsigned char *)buffer); - case ObjcShortType: - return jsNumber(*(short *)buffer); - case ObjcUnsignedShortType: - return jsNumber(*(unsigned short *)buffer); - case ObjcIntType: - return jsNumber(*(int *)buffer); - case ObjcUnsignedIntType: - return jsNumber(*(unsigned int *)buffer); - case ObjcLongType: - return jsNumber(*(long *)buffer); - case ObjcUnsignedLongType: - return jsNumber(*(unsigned long *)buffer); - case ObjcLongLongType: - return jsNumber(*(long long *)buffer); - case ObjcUnsignedLongLongType: - return jsNumber(*(unsigned long long *)buffer); - case ObjcFloatType: - return jsNumber(*(float *)buffer); - case ObjcDoubleType: - return jsNumber(*(double *)buffer); - default: - // Should never get here. Argument types are filtered. - fprintf(stderr, "%s: invalid type (%d)\n", __PRETTY_FUNCTION__, (int)type); - ASSERT(false); - } - - return 0; -} - -ObjcValueType objcValueTypeForType(const char *type) -{ - int typeLength = strlen(type); - ObjcValueType objcValueType = ObjcInvalidType; - - for (int i = 0; i < typeLength; ++i) { - char typeChar = type[i]; - switch (typeChar) { - case _C_CONST: - case _C_BYCOPY: - case _C_BYREF: - case _C_ONEWAY: - case _C_GCINVISIBLE: - // skip these type modifiers - break; - case _C_ID: - objcValueType = ObjcObjectType; - break; - case _C_CHR: - objcValueType = ObjcCharType; - break; - case _C_UCHR: - objcValueType = ObjcUnsignedCharType; - break; - case _C_SHT: - objcValueType = ObjcShortType; - break; - case _C_USHT: - objcValueType = ObjcUnsignedShortType; - break; - case _C_INT: - objcValueType = ObjcIntType; - break; - case _C_UINT: - objcValueType = ObjcUnsignedIntType; - break; - case _C_LNG: - objcValueType = ObjcLongType; - break; - case _C_ULNG: - objcValueType = ObjcUnsignedLongType; - break; - case _C_LNG_LNG: - objcValueType = ObjcLongLongType; - break; - case _C_ULNG_LNG: - objcValueType = ObjcUnsignedLongLongType; - break; - case _C_FLT: - objcValueType = ObjcFloatType; - break; - case _C_DBL: - objcValueType = ObjcDoubleType; - break; - case _C_VOID: - objcValueType = ObjcVoidType; - break; - default: - // Unhandled type. We don't handle C structs, unions, etc. - // FIXME: throw an exception? - ASSERT(false); - } - - if (objcValueType != ObjcInvalidType) - break; - } - - return objcValueType; -} - -JSObject *throwError(ExecState *exec, ErrorType type, NSString *message) -{ - ASSERT(message); - size_t length = [message length]; - unichar *buffer = new unichar[length]; - [message getCharacters:buffer]; - JSObject *error = throwError(exec, type, UString(reinterpret_cast(buffer), length)); - delete [] buffer; - return error; -} - -} -} diff --git a/bindings/qt/qt_class.cpp b/bindings/qt/qt_class.cpp deleted file mode 100644 index 59730b8..0000000 --- a/bindings/qt/qt_class.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (C) 2006 Trolltech ASA - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "identifier.h" - -#include "qt_class.h" -#include "qt_instance.h" -#include "qt_runtime.h" - -#include -#include - -namespace KJS { -namespace Bindings { - -QtClass::QtClass(const QMetaObject* mo) - : m_metaObject(mo) -{ -} - -QtClass::~QtClass() -{ -} - -typedef HashMap ClassesByMetaObject; -static ClassesByMetaObject* classesByMetaObject = 0; - -QtClass* QtClass::classForObject(QObject* o) -{ - if (!classesByMetaObject) - classesByMetaObject = new ClassesByMetaObject; - - const QMetaObject* mo = o->metaObject(); - QtClass* aClass = classesByMetaObject->get(mo); - if (!aClass) { - aClass = new QtClass(mo); - classesByMetaObject->set(mo, aClass); - } - - return aClass; -} - -const char* QtClass::name() const -{ - return m_metaObject->className(); -} - -// We use this to get at signals (so we can return a proper function object, -// and not get wrapped in RuntimeMethod). Also, use this for methods, -// so we can cache the JSValue* and return the same JSValue for the same -// identifier... -// -// Unfortunately... we need to gcProtect our JSValues, since we don't have -// access to an actual JS class that can mark() our JSValues. -// -JSValue* QtClass::fallbackObject(ExecState *exec, Instance *inst, const Identifier &identifier) -{ - QtInstance* qtinst = static_cast(inst); - - QByteArray name(identifier.ascii()); - - // First see if we have a cache hit - JSValue* val = qtinst->m_methods.value(name); - if (val) - return val; - - // Nope, create an entry - QByteArray normal = QMetaObject::normalizedSignature(name.constData()); - - // See if there is an exact match - int index = -1; - if (normal.contains('(') && (index = m_metaObject->indexOfMethod(normal)) != -1) { - QMetaMethod m = m_metaObject->method(index); - if (m.access() != QMetaMethod::Private) { - JSValue *val = new QtRuntimeMetaMethod(exec, identifier, static_cast(inst), index, normal, false); - gcProtect(val); - qtinst->m_methods.insert(name, val); - return val; - } - } - - // Nope.. try a basename match - int count = m_metaObject->methodCount(); - for (index = count - 1; index >= 0; --index) { - const QMetaMethod m = m_metaObject->method(index); - if (m.access() == QMetaMethod::Private) - continue; - - QByteArray signature = m.signature(); - signature.truncate(signature.indexOf('(')); - - if (normal == signature) { - JSValue* val = new QtRuntimeMetaMethod(exec, identifier, static_cast(inst), index, normal, false); - gcProtect(val); - qtinst->m_methods.insert(name, val); - return val; - } - } - - return jsUndefined(); -} - -// This functionality is handled by the fallback case above... -MethodList QtClass::methodsNamed(const Identifier&, Instance*) const -{ - return MethodList(); -} - -// ### we may end up with a different search order than QtScript by not -// folding this code into the fallbackMethod above, but Fields propagate out -// of the binding code -Field* QtClass::fieldNamed(const Identifier& identifier, Instance* instance) const -{ - // Check static properties first - QtInstance* qtinst = static_cast(instance); - - QObject* obj = qtinst->getObject(); - UString ustring = identifier.ustring(); - QString objName(QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size())); - QByteArray ba = objName.toAscii(); - - // First check for a cached field - QtField* f = qtinst->m_fields.value(objName); - - if (obj) { - if (f) { - // We only cache real metaproperties, but we do store the - // other types so we can delete them later - if (f->fieldType() == QtField::MetaProperty) - return f; - else if (f->fieldType() == QtField::DynamicProperty) { - if (obj->dynamicPropertyNames().indexOf(ba) >= 0) - return f; - else { - // Dynamic property that disappeared - qtinst->m_fields.remove(objName); - delete f; - } - } else { - QList children = obj->children(); - for (int index = 0; index < children.count(); ++index) { - QObject *child = children.at(index); - if (child->objectName() == objName) - return f; - } - - // Didn't find it, delete it from the cache - qtinst->m_fields.remove(objName); - delete f; - } - } - - int index = m_metaObject->indexOfProperty(identifier.ascii()); - if (index >= 0) { - QMetaProperty prop = m_metaObject->property(index); - - if (prop.isScriptable(obj)) { - f = new QtField(prop); - qtinst->m_fields.insert(objName, f); - return f; - } - } - - // Dynamic properties - index = obj->dynamicPropertyNames().indexOf(ba); - if (index >= 0) { - f = new QtField(ba); - qtinst->m_fields.insert(objName, f); - return f; - } - - // Child objects - - QList children = obj->children(); - for (index = 0; index < children.count(); ++index) { - QObject *child = children.at(index); - if (child->objectName() == objName) { - f = new QtField(child); - qtinst->m_fields.insert(objName, f); - return f; - } - } - - // Nothing named this - return 0; - } else { - QByteArray ba(identifier.ascii()); - // For compatibility with qtscript, cached methods don't cause - // errors until they are accessed, so don't blindly create an error - // here. - if (qtinst->m_methods.contains(ba)) - return 0; - - // deleted qobject, but can't throw an error from here (no exec) - // create a fake QtField that will throw upon access - if (!f) { - f = new QtField(ba); - qtinst->m_fields.insert(objName, f); - } - return f; - } -} - -} -} - diff --git a/bindings/qt/qt_class.h b/bindings/qt/qt_class.h deleted file mode 100644 index c3e59ec..0000000 --- a/bindings/qt/qt_class.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2006 Trolltech ASA - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef BINDINGS_QT_CLASS_H_ -#define BINDINGS_QT_CLASS_H_ - -#include "runtime.h" -class QObject; -class QMetaObject; - -namespace KJS { -namespace Bindings { - - -class QtClass : public Class { -protected: - QtClass(const QMetaObject*); - -public: - static QtClass* classForObject(QObject*); - virtual ~QtClass(); - - virtual const char* name() const; - virtual MethodList methodsNamed(const Identifier&, Instance*) const; - virtual Field* fieldNamed(const Identifier&, Instance*) const; - - virtual JSValue* fallbackObject(ExecState*, Instance*, const Identifier&); - -private: - QtClass(const QtClass&); // prohibit copying - QtClass& operator=(const QtClass&); // prohibit assignment - - const QMetaObject* m_metaObject; -}; - -} // namespace Bindings -} // namespace KJS - -#endif diff --git a/bindings/qt/qt_instance.cpp b/bindings/qt/qt_instance.cpp deleted file mode 100644 index 0197b84..0000000 --- a/bindings/qt/qt_instance.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/* - * Copyright (C) 2006 Trolltech ASA - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "qt_instance.h" - -#include "JSGlobalObject.h" -#include "list.h" -#include "qt_class.h" -#include "qt_runtime.h" -#include "PropertyNameArray.h" -#include "runtime_object.h" -#include "object_object.h" - -#include -#include -#include -#include - -namespace KJS { -namespace Bindings { - -// Cache QtInstances -typedef QMultiHash QObjectInstanceMap; -static QObjectInstanceMap cachedInstances; - -// Cache JSObjects -typedef QHash InstanceJSObjectMap; -static InstanceJSObjectMap cachedObjects; - -// Derived RuntimeObject -class QtRuntimeObjectImp : public RuntimeObjectImp { - public: - QtRuntimeObjectImp(Instance*); - ~QtRuntimeObjectImp(); - virtual void invalidate(); - - // Additions - virtual bool implementsConstruct() const {return implementsCall();} - virtual JSObject* construct(ExecState* exec, const List& args); - protected: - void removeFromCache(); -}; - -QtRuntimeObjectImp::QtRuntimeObjectImp(Instance* instance) - : RuntimeObjectImp(instance) -{ -} - -QtRuntimeObjectImp::~QtRuntimeObjectImp() -{ - removeFromCache(); -} - -void QtRuntimeObjectImp::invalidate() -{ - removeFromCache(); - RuntimeObjectImp::invalidate(); -} - -void QtRuntimeObjectImp::removeFromCache() -{ - JSLock lock; - QtInstance* key = cachedObjects.key(this); - if (key) - cachedObjects.remove(key); -} - -JSObject* QtRuntimeObjectImp::construct(ExecState* exec, const List& args) -{ - // ECMA 15.2.2.1 (?) - JSValue *val = callAsFunction(exec, this, args); - - if (!val || val->type() == NullType || val->type() == UndefinedType) - return new JSObject(exec->lexicalGlobalObject()->objectPrototype()); - else - return val->toObject(exec); -} - -// QtInstance -QtInstance::QtInstance(QObject* o, PassRefPtr rootObject) - : Instance(rootObject) - , m_class(0) - , m_object(o) - , m_hashkey(o) - , m_defaultMethod(0) - , m_defaultMethodIndex(-2) -{ -} - -QtInstance::~QtInstance() -{ - JSLock lock; - - cachedObjects.remove(this); - cachedInstances.remove(m_hashkey); - - // clean up (unprotect from gc) the JSValues we've created - foreach(JSValue* val, m_methods.values()) { - gcUnprotect(val); - } - m_methods.clear(); - - foreach(QtField* f, m_fields.values()) { - delete f; - } - m_fields.clear(); - - if (m_defaultMethod) - gcUnprotect(m_defaultMethod); -} - -QtInstance* QtInstance::getQtInstance(QObject* o, PassRefPtr rootObject) -{ - JSLock lock; - - foreach(QtInstance* instance, cachedInstances.values(o)) { - if (instance->rootObject() == rootObject) - return instance; - } - - QtInstance* ret = new QtInstance(o, rootObject); - cachedInstances.insert(o, ret); - - return ret; -} - -JSObject* QtInstance::getRuntimeObject(QtInstance* instance) -{ - JSLock lock; - JSObject* ret = cachedObjects.value(instance); - if (!ret) { - ret = new QtRuntimeObjectImp(instance); - cachedObjects.insert(instance, ret); - } - return ret; -} - -Class* QtInstance::getClass() const -{ - if (!m_class) - m_class = QtClass::classForObject(m_object); - return m_class; -} - -void QtInstance::begin() -{ - // Do nothing. -} - -void QtInstance::end() -{ - // Do nothing. -} - -void QtInstance::getPropertyNames(ExecState* , PropertyNameArray& array) -{ - // This is the enumerable properties, so put: - // properties - // dynamic properties - // slots - QObject* obj = getObject(); - if (obj) { - const QMetaObject* meta = obj->metaObject(); - - int i; - for (i=0; i < meta->propertyCount(); i++) { - QMetaProperty prop = meta->property(i); - if (prop.isScriptable()) { - array.add(Identifier(prop.name())); - } - } - - QList dynProps = obj->dynamicPropertyNames(); - foreach(QByteArray ba, dynProps) { - array.add(Identifier(ba.constData())); - } - - for (i=0; i < meta->methodCount(); i++) { - QMetaMethod method = meta->method(i); - if (method.access() != QMetaMethod::Private) { - array.add(Identifier(method.signature())); - } - } - } -} - -JSValue* QtInstance::invokeMethod(ExecState*, const MethodList&, const List&) -{ - // Implemented via fallbackMethod & QtRuntimeMetaMethod::callAsFunction - return jsUndefined(); -} - -bool QtInstance::implementsCall() const -{ - // See if we have qscript_call - if (m_defaultMethodIndex == -2) { - if (m_object) { - const QMetaObject* meta = m_object->metaObject(); - int count = meta->methodCount(); - const QByteArray defsig("qscript_call"); - for (int index = count - 1; index >= 0; --index) { - const QMetaMethod m = meta->method(index); - - QByteArray signature = m.signature(); - signature.truncate(signature.indexOf('(')); - - if (defsig == signature) { - m_defaultMethodIndex = index; - break; - } - } - } - - if (m_defaultMethodIndex == -2) // Not checked - m_defaultMethodIndex = -1; // No qscript_call - } - - // typeof object that implements call == function - return (m_defaultMethodIndex >= 0); -} - -JSValue* QtInstance::invokeDefaultMethod(ExecState* exec, const List& args) -{ - // QtScript tries to invoke a meta method qscript_call - if (!getObject()) - return throwError(exec, GeneralError, "cannot call function of deleted QObject"); - - // implementsCall will update our default method cache, if possible - if (implementsCall()) { - if (!m_defaultMethod) { - m_defaultMethod = new QtRuntimeMetaMethod(exec, Identifier("[[Call]]"),this, m_defaultMethodIndex, QByteArray("qscript_call"), true); - gcProtect(m_defaultMethod); - } - - return m_defaultMethod->callAsFunction(exec, 0, args); // Luckily QtRuntimeMetaMethod ignores the obj parameter - } else - return throwError(exec, TypeError, "not a function"); -} - -JSValue* QtInstance::defaultValue(JSType hint) const -{ - if (hint == StringType) - return stringValue(); - if (hint == NumberType) - return numberValue(); - if (hint == BooleanType) - return booleanValue(); - return valueOf(); -} - -JSValue* QtInstance::stringValue() const -{ - // Hmm.. see if there is a toString defined - QByteArray buf; - bool useDefault = true; - getClass(); - QObject* obj = getObject(); - if (m_class && obj) { - // Cheat and don't use the full name resolution - int index = obj->metaObject()->indexOfMethod("toString()"); - if (index >= 0) { - QMetaMethod m = obj->metaObject()->method(index); - // Check to see how much we can call it - if (m.access() != QMetaMethod::Private - && m.methodType() != QMetaMethod::Signal - && m.parameterTypes().count() == 0) { - const char* retsig = m.typeName(); - if (retsig && *retsig) { - QVariant ret(QMetaType::type(retsig), (void*)0); - void * qargs[1]; - qargs[0] = ret.data(); - - if (obj->qt_metacall(QMetaObject::InvokeMetaMethod, index, qargs) < 0) { - if (ret.isValid() && ret.canConvert(QVariant::String)) { - buf = ret.toString().toLatin1().constData(); // ### Latin 1? Ascii? - useDefault = false; - } - } - } - } - } - } - - if (useDefault) { - const QMetaObject* meta = obj ? obj->metaObject() : &QObject::staticMetaObject; - QString name = obj ? obj->objectName() : QString::fromUtf8("unnamed"); - QString str = QString::fromUtf8("%0(name = \"%1\")") - .arg(QLatin1String(meta->className())).arg(name); - - buf = str.toLatin1(); - } - return jsString(buf.constData()); -} - -JSValue* QtInstance::numberValue() const -{ - return jsNumber(0); -} - -JSValue* QtInstance::booleanValue() const -{ - // ECMA 9.2 - return jsBoolean(true); -} - -JSValue* QtInstance::valueOf() const -{ - return stringValue(); -} - -// In qt_runtime.cpp -JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr root, const QVariant& variant); -QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type hint, int *distance); - -const char* QtField::name() const -{ - if (m_type == MetaProperty) - return m_property.name(); - else if (m_type == ChildObject && m_childObject) - return m_childObject->objectName().toLatin1(); - else if (m_type == DynamicProperty) - return m_dynamicProperty.constData(); - return ""; // deleted child object -} - -JSValue* QtField::valueFromInstance(ExecState* exec, const Instance* inst) const -{ - const QtInstance* instance = static_cast(inst); - QObject* obj = instance->getObject(); - - if (obj) { - QVariant val; - if (m_type == MetaProperty) { - if (m_property.isReadable()) - val = m_property.read(obj); - else - return jsUndefined(); - } else if (m_type == ChildObject) - val = QVariant::fromValue((QObject*) m_childObject); - else if (m_type == DynamicProperty) - val = obj->property(m_dynamicProperty); - - return convertQVariantToValue(exec, inst->rootObject(), val); - } else { - QString msg = QString("cannot access member `%1' of deleted QObject").arg(name()); - return throwError(exec, GeneralError, msg.toLatin1().constData()); - } -} - -void QtField::setValueToInstance(ExecState* exec, const Instance* inst, JSValue* aValue) const -{ - if (m_type == ChildObject) // QtScript doesn't allow setting to a named child - return; - - const QtInstance* instance = static_cast(inst); - QObject* obj = instance->getObject(); - if (obj) { - QMetaType::Type argtype = QMetaType::Void; - if (m_type == MetaProperty) - argtype = (QMetaType::Type) QMetaType::type(m_property.typeName()); - - // dynamic properties just get any QVariant - QVariant val = convertValueToQVariant(exec, aValue, argtype, 0); - if (m_type == MetaProperty) { - if (m_property.isWritable()) - m_property.write(obj, val); - } else if (m_type == DynamicProperty) - obj->setProperty(m_dynamicProperty.constData(), val); - } else { - QString msg = QString("cannot access member `%1' of deleted QObject").arg(name()); - throwError(exec, GeneralError, msg.toLatin1().constData()); - } -} - - -} -} diff --git a/bindings/qt/qt_instance.h b/bindings/qt/qt_instance.h deleted file mode 100644 index 2304ac5..0000000 --- a/bindings/qt/qt_instance.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2006 Trolltech ASA - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef BINDINGS_QT_INSTANCE_H_ -#define BINDINGS_QT_INSTANCE_H_ - -#include "runtime.h" -#include "runtime_root.h" -#include -#include - -class QObject; - -namespace KJS { - -namespace Bindings { - -class QtClass; -class QtField; -class QtRuntimeMetaMethod; - -class QtInstance : public Instance -{ -public: - ~QtInstance (); - - virtual Class* getClass() const; - - virtual void begin(); - virtual void end(); - - virtual JSValue* valueOf() const; - virtual JSValue* defaultValue (JSType hint) const; - - virtual bool implementsCall() const; - - virtual JSValue* invokeMethod (ExecState *exec, const MethodList &method, const List &args); - virtual JSValue* invokeDefaultMethod (ExecState *exec, const List &args); - - virtual void getPropertyNames(ExecState*, PropertyNameArray&); - - virtual BindingLanguage getBindingLanguage() const { return QtLanguage; } - - JSValue* stringValue() const; - JSValue* numberValue() const; - JSValue* booleanValue() const; - - QObject* getObject() const { return m_object; } - - static QtInstance* getQtInstance(QObject*, PassRefPtr); - static JSObject* getRuntimeObject(QtInstance*); - -private: - friend class QtClass; - QtInstance(QObject*, PassRefPtr); // Factory produced only.. - mutable QtClass* m_class; - QPointer m_object; - QObject* m_hashkey; - mutable QHash m_methods; - mutable QHash m_fields; - mutable QtRuntimeMetaMethod* m_defaultMethod; - mutable int m_defaultMethodIndex; -}; - -} // namespace Bindings - -} // namespace KJS - -#endif diff --git a/bindings/qt/qt_runtime.cpp b/bindings/qt/qt_runtime.cpp deleted file mode 100644 index 113f0c5..0000000 --- a/bindings/qt/qt_runtime.cpp +++ /dev/null @@ -1,1590 +0,0 @@ -/* - * Copyright (C) 2006 Trolltech ASA - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "qt_runtime.h" -#include "qt_instance.h" -#include "object.h" -#include "array_instance.h" -#include "date_object.h" -#include "DateMath.h" -#include "regexp_object.h" -#include -#include -#include -#include "PropertyNameArray.h" -#include "qmetatype.h" -#include "qmetaobject.h" -#include "qobject.h" -#include "qstringlist.h" -#include "qdebug.h" -#include "qvarlengtharray.h" -#include "qdatetime.h" -#include - -// QtScript has these -Q_DECLARE_METATYPE(QObjectList); -Q_DECLARE_METATYPE(QList); -Q_DECLARE_METATYPE(QVariant); - - -namespace KJS { -namespace Bindings { - -// Debugging -//#define QTWK_RUNTIME_CONVERSION_DEBUG -//#define QTWK_RUNTIME_MATCH_DEBUG - -class QWKNoDebug -{ -public: - inline QWKNoDebug(){} - inline ~QWKNoDebug(){} - - template - inline QWKNoDebug &operator<<(const T &) { return *this; } -}; - -#ifdef QTWK_RUNTIME_CONVERSION_DEBUG -#define qConvDebug() qDebug() -#else -#define qConvDebug() QWKNoDebug() -#endif - -#ifdef QTWK_RUNTIME_MATCH_DEBUG -#define qMatchDebug() qDebug() -#else -#define qMatchDebug() QWKNoDebug() -#endif - -typedef enum { - Variant, - Number, - Boolean, - String, - Date, - RegExp, - Array, - QObj, - Object, - Null -} JSRealType; - -static JSRealType valueRealType(ExecState* exec, JSValue* val) -{ - if (val->isNumber()) - return Number; - else if (val->isString()) - return String; - else if (val->isBoolean()) - return Boolean; - else if (val->isNull()) - return Null; - else if (val->isObject()) { - JSObject *object = val->toObject(exec); - if (object->inherits(&ArrayInstance::info)) - return Array; - else if (object->inherits(&DateInstance::info)) - return Date; - else if (object->inherits(&RegExpImp::info)) - return RegExp; - else if (object->inherits(&RuntimeObjectImp::info)) - return QObj; - return Object; - } - - return String; // I don't know. -} - -QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type hint, int *distance) -{ - // check magic pointer values before dereferencing value - if (value == jsNaN() || value == jsUndefined()) { - if (distance) - *distance = -1; - return QVariant(); - } - - JSLock lock; - JSRealType type = valueRealType(exec, value); - if (hint == QMetaType::Void) { - switch(type) { - case Number: - hint = QMetaType::Double; - break; - case Boolean: - hint = QMetaType::Bool; - break; - case String: - default: - hint = QMetaType::QString; - break; - case Date: - hint = QMetaType::QDateTime; - break; - case RegExp: - hint = QMetaType::QRegExp; - break; - case QObj: - hint = QMetaType::QObjectStar; - break; - case Array: - hint = QMetaType::QVariantList; - break; - } - } - - if (value == jsNull() - && hint != QMetaType::QObjectStar - && hint != QMetaType::VoidStar) { - if (distance) - *distance = -1; - return QVariant(); - } - - QVariant ret; - int dist = -1; - switch (hint) { - case QMetaType::Bool: - ret = QVariant(value->toBoolean(exec)); - if (type == Boolean) - dist = 0; - else - dist = 10; - break; - - case QMetaType::Int: - case QMetaType::UInt: - case QMetaType::Long: - case QMetaType::ULong: - case QMetaType::LongLong: - case QMetaType::ULongLong: - case QMetaType::Short: - case QMetaType::UShort: - case QMetaType::Float: - case QMetaType::Double: - ret = QVariant(value->toNumber(exec)); - ret.convert((QVariant::Type)hint); - if (type == Number) { - switch (hint) { - case QMetaType::Double: - dist = 0; - break; - case QMetaType::Float: - dist = 1; - break; - case QMetaType::LongLong: - case QMetaType::ULongLong: - dist = 2; - break; - case QMetaType::Long: - case QMetaType::ULong: - dist = 3; - break; - case QMetaType::Int: - case QMetaType::UInt: - dist = 4; - break; - case QMetaType::Short: - case QMetaType::UShort: - dist = 5; - break; - break; - default: - dist = 10; - break; - } - } else { - dist = 10; - } - break; - - case QMetaType::QChar: - if (type == Number || type == Boolean) { - ret = QVariant(QChar((ushort)value->toNumber(exec))); - if (type == Boolean) - dist = 3; - else - dist = 6; - } else { - UString str = value->toString(exec); - ret = QVariant(QChar(str.size() ? *(const ushort*)str.rep()->data() : 0)); - if (type == String) - dist = 3; - else - dist = 10; - } - break; - - case QMetaType::QString: { - UString ustring = value->toString(exec); - ret = QVariant(QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size())); - if (type == String) - dist = 0; - else - dist = 10; - break; - } - - case QMetaType::QVariantMap: - if (type == Object || type == Array) { - // Enumerate the contents of the object - JSObject* object = value->toObject(exec); - - PropertyNameArray properties; - object->getPropertyNames(exec, properties); - PropertyNameArray::const_iterator it = properties.begin(); - - QVariantMap result; - int objdist = 0; - while(it != properties.end()) { - if (object->propertyIsEnumerable(exec, *it)) { - JSValue* val = object->get(exec, *it); - QVariant v = convertValueToQVariant(exec, val, QMetaType::Void, &objdist); - if (objdist >= 0) { - UString ustring = (*it).ustring(); - QString id = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()); - result.insert(id, v); - } - } - ++it; - } - dist = 1; - ret = QVariant(result); - } - break; - - case QMetaType::QVariantList: - if (type == Array) { - JSObject* object = value->toObject(exec); - ArrayInstance* array = static_cast(object); - - QVariantList result; - int len = array->getLength(); - int objdist = 0; - for (int i = 0; i < len; ++i) { - JSValue *val = array->getItem(i); - result.append(convertValueToQVariant(exec, val, QMetaType::Void, &objdist)); - if (objdist == -1) - break; // Failed converting a list entry, so fail the array - } - if (objdist != -1) { - dist = 5; - ret = QVariant(result); - } - } else { - // Make a single length array - QVariantList result; - int objdist; - result.append(convertValueToQVariant(exec, value, QMetaType::Void, &objdist)); - if (objdist != -1) { - ret = QVariant(result); - dist = 10; - } - } - break; - - case QMetaType::QStringList: { - if (type == Array) { - JSObject* object = value->toObject(exec); - ArrayInstance* array = static_cast(object); - - QStringList result; - int len = array->getLength(); - for (int i = 0; i < len; ++i) { - JSValue* val = array->getItem(i); - UString ustring = val->toString(exec); - QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()); - - result.append(qstring); - } - dist = 5; - ret = QVariant(result); - } else { - // Make a single length array - UString ustring = value->toString(exec); - QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()); - QStringList result; - result.append(qstring); - ret = QVariant(result); - dist = 10; - } - break; - } - - case QMetaType::QByteArray: { - UString ustring = value->toString(exec); - ret = QVariant(QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()).toLatin1()); - if (type == String) - dist = 5; - else - dist = 10; - break; - } - - case QMetaType::QDateTime: - case QMetaType::QDate: - case QMetaType::QTime: - if (type == Date) { - JSObject* object = value->toObject(exec); - DateInstance* date = static_cast(object); - GregorianDateTime gdt; - date->getUTCTime(gdt); - if (hint == QMetaType::QDateTime) { - ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC); - dist = 0; - } else if (hint == QMetaType::QDate) { - ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay); - dist = 1; - } else { - ret = QTime(gdt.hour + 1900, gdt.minute, gdt.second); - dist = 2; - } - } else if (type == Number) { - double b = value->toNumber(exec); - GregorianDateTime gdt; - msToGregorianDateTime(b, true, gdt); - if (hint == QMetaType::QDateTime) { - ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC); - dist = 6; - } else if (hint == QMetaType::QDate) { - ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay); - dist = 8; - } else { - ret = QTime(gdt.hour, gdt.minute, gdt.second); - dist = 10; - } - } else if (type == String) { - UString ustring = value->toString(exec); - QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()); - - if (hint == QMetaType::QDateTime) { - QDateTime dt = QDateTime::fromString(qstring, Qt::ISODate); - if (!dt.isValid()) - dt = QDateTime::fromString(qstring, Qt::TextDate); - if (!dt.isValid()) - dt = QDateTime::fromString(qstring, Qt::SystemLocaleDate); - if (!dt.isValid()) - dt = QDateTime::fromString(qstring, Qt::LocaleDate); - if (dt.isValid()) { - ret = dt; - dist = 2; - } - } else if (hint == QMetaType::QDate) { - QDate dt = QDate::fromString(qstring, Qt::ISODate); - if (!dt.isValid()) - dt = QDate::fromString(qstring, Qt::TextDate); - if (!dt.isValid()) - dt = QDate::fromString(qstring, Qt::SystemLocaleDate); - if (!dt.isValid()) - dt = QDate::fromString(qstring, Qt::LocaleDate); - if (dt.isValid()) { - ret = dt; - dist = 3; - } - } else { - QTime dt = QTime::fromString(qstring, Qt::ISODate); - if (!dt.isValid()) - dt = QTime::fromString(qstring, Qt::TextDate); - if (!dt.isValid()) - dt = QTime::fromString(qstring, Qt::SystemLocaleDate); - if (!dt.isValid()) - dt = QTime::fromString(qstring, Qt::LocaleDate); - if (dt.isValid()) { - ret = dt; - dist = 3; - } - } - } - break; - - case QMetaType::QRegExp: - if (type == RegExp) { -/* JSObject *object = value->toObject(exec); - RegExpImp *re = static_cast(object); -*/ - // Attempt to convert.. a bit risky - UString ustring = value->toString(exec); - QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()); - - // this is of the form '/xxxxxx/i' - int firstSlash = qstring.indexOf('/'); - int lastSlash = qstring.lastIndexOf('/'); - if (firstSlash >=0 && lastSlash > firstSlash) { - QRegExp realRe; - - realRe.setPattern(qstring.mid(firstSlash + 1, lastSlash - firstSlash - 1)); - - if (qstring.mid(lastSlash + 1).contains('i')) - realRe.setCaseSensitivity(Qt::CaseInsensitive); - - ret = qVariantFromValue(realRe); - dist = 0; - } else { - qConvDebug() << "couldn't parse a JS regexp"; - } - } else if (type == String) { - UString ustring = value->toString(exec); - QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()); - - QRegExp re(qstring); - if (re.isValid()) { - ret = qVariantFromValue(re); - dist = 10; - } - } - break; - - case QMetaType::QObjectStar: - if (type == QObj) { - JSObject* object = value->toObject(exec); - QtInstance* qtinst = static_cast(Instance::getInstance(object, Instance::QtLanguage)); - if (qtinst) { - if (qtinst->getObject()) { - qConvDebug() << "found instance, with object:" << (void*) qtinst->getObject(); - ret = qVariantFromValue(qtinst->getObject()); - qConvDebug() << ret; - dist = 0; - } else { - qConvDebug() << "can't convert deleted qobject"; - } - } else { - qConvDebug() << "wasn't a qtinstance"; - } - } else if (type == Null) { - QObject* nullobj = 0; - ret = qVariantFromValue(nullobj); - dist = 0; - } else { - qConvDebug() << "previous type was not an object:" << type; - } - break; - - case QMetaType::VoidStar: - if (type == QObj) { - JSObject* object = value->toObject(exec); - QtInstance* qtinst = static_cast(Instance::getInstance(object, Instance::QtLanguage)); - if (qtinst) { - if (qtinst->getObject()) { - qConvDebug() << "found instance, with object:" << (void*) qtinst->getObject(); - ret = qVariantFromValue((void *)qtinst->getObject()); - qConvDebug() << ret; - dist = 0; - } else { - qConvDebug() << "can't convert deleted qobject"; - } - } else { - qConvDebug() << "wasn't a qtinstance"; - } - } else if (type == Null) { - ret = qVariantFromValue((void*)0); - dist = 0; - } else if (type == Number) { - // I don't think that converting a double to a pointer is a wise - // move. Except maybe 0. - qConvDebug() << "got number for void * - not converting, seems unsafe:" << value->toNumber(exec); - } else { - qConvDebug() << "void* - unhandled type" << type; - } - break; - - default: - // Non const type ids - if (hint == (QMetaType::Type) qMetaTypeId()) - { - if (type == Array) { - JSObject* object = value->toObject(exec); - ArrayInstance* array = static_cast(object); - - QObjectList result; - int len = array->getLength(); - for (int i = 0; i < len; ++i) { - JSValue *val = array->getItem(i); - int itemdist = -1; - QVariant item = convertValueToQVariant(exec, val, QMetaType::QObjectStar, &itemdist); - if (itemdist >= 0) - result.append(item.value()); - else - break; - } - // If we didn't fail conversion - if (result.count() == len) { - dist = 5; - ret = QVariant::fromValue(result); - } else { - qConvDebug() << "type conversion failed (wanted" << len << ", got " << result.count() << ")"; - } - } else { - // Make a single length array - QObjectList result; - int itemdist = -1; - QVariant item = convertValueToQVariant(exec, value, QMetaType::QObjectStar, &itemdist); - if (itemdist >= 0) { - result.append(item.value()); - dist = 10; - ret = QVariant::fromValue(result); - } - } - break; - } else if (hint == (QMetaType::Type) qMetaTypeId >()) { - if (type == Array) { - JSObject* object = value->toObject(exec); - ArrayInstance* array = static_cast(object); - - QList result; - int len = array->getLength(); - for (int i = 0; i < len; ++i) { - JSValue* val = array->getItem(i); - int itemdist = -1; - QVariant item = convertValueToQVariant(exec, val, QMetaType::Int, &itemdist); - if (itemdist >= 0) - result.append(item.value()); - else - break; - } - // If we didn't fail conversion - if (result.count() == len) { - dist = 5; - ret = QVariant::fromValue(result); - } else { - qConvDebug() << "type conversion failed (wanted" << len << ", got " << result.count() << ")"; - } - } else { - // Make a single length array - QList result; - int itemdist = -1; - QVariant item = convertValueToQVariant(exec, value, QMetaType::Int, &itemdist); - if (itemdist >= 0) { - result.append(item.value()); - dist = 10; - ret = QVariant::fromValue(result); - } - } - break; - } else if (hint == (QMetaType::Type) qMetaTypeId()) { - // Well.. we can do anything... just recurse with the autodetect flag - ret = convertValueToQVariant(exec, value, QMetaType::Void, distance); - dist = 10; - break; - } - - dist = 10; - break; - } - - if (!ret.isValid()) - dist = -1; - if (distance) - *distance = dist; - - return ret; -} - -JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr root, const QVariant& variant) -{ - // Variants with QObject * can be isNull but not a null pointer - // An empty QString variant is also null - QMetaType::Type type = (QMetaType::Type) variant.userType(); - if (variant.isNull() && - type != QMetaType::QObjectStar && - type != QMetaType::VoidStar && - type != QMetaType::QWidgetStar && - type != QMetaType::QString) { - return jsNull(); - } - - JSLock lock; - - if (type == QMetaType::Bool) - return jsBoolean(variant.toBool()); - - if (type == QMetaType::Int || - type == QMetaType::UInt || - type == QMetaType::Long || - type == QMetaType::ULong || - type == QMetaType::LongLong || - type == QMetaType::ULongLong || - type == QMetaType::Short || - type == QMetaType::UShort || - type == QMetaType::Float || - type == QMetaType::Double) - return jsNumber(variant.toDouble()); - - if (type == QMetaType::QRegExp) { - QRegExp re = variant.value(); - - if (re.isValid()) { - RegExpObjectImp* regExpObj = static_cast(exec->lexicalGlobalObject()->regExpConstructor()); - List args; - UString uflags; - - if (re.caseSensitivity() == Qt::CaseInsensitive) - uflags = "i"; // ### Can't do g or m - UString ustring((KJS::UChar*)re.pattern().utf16(), re.pattern().length()); - args.append(jsString(ustring)); - args.append(jsString(uflags)); - return regExpObj->construct(exec, args); - } - } - - if (type == QMetaType::QDateTime || - type == QMetaType::QDate || - type == QMetaType::QTime) { - DateObjectImp *dateObj = static_cast(exec->lexicalGlobalObject()->dateConstructor()); - List args; - - QDate date = QDate::currentDate(); - QTime time(0,0,0); // midnight - - if (type == QMetaType::QDate) - date = variant.value(); - else if (type == QMetaType::QTime) - time = variant.value(); - else { - QDateTime dt = variant.value().toLocalTime(); - date = dt.date(); - time = dt.time(); - } - - // Dates specified this way are in local time (we convert DateTimes above) - args.append(jsNumber(date.year())); - args.append(jsNumber(date.month() - 1)); - args.append(jsNumber(date.day())); - args.append(jsNumber(time.hour())); - args.append(jsNumber(time.minute())); - args.append(jsNumber(time.second())); - args.append(jsNumber(time.msec())); - return dateObj->construct(exec, args); - } - - if (type == QMetaType::QByteArray) { - QByteArray ba = variant.value(); - UString ustring(ba.constData()); - return jsString(ustring); - } - - if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) { - QObject* obj = variant.value(); - return Instance::createRuntimeObject(Instance::QtLanguage, obj, root); - } - - if (type == QMetaType::QVariantMap) { - // create a new object, and stuff properties into it - JSObject* ret = new JSObject(exec->lexicalGlobalObject()->objectPrototype()); - QVariantMap map = variant.value(); - QVariantMap::const_iterator i = map.constBegin(); - while (i != map.constEnd()) { - QString s = i.key(); - JSValue* val = convertQVariantToValue(exec, root, i.value()); - if (val) - ret->put(exec, Identifier((const UChar *)s.constData(), s.length()), val); - // ### error case? - ++i; - } - - return ret; - } - - // List types - if (type == QMetaType::QVariantList) { - QVariantList vl = variant.toList(); - return new RuntimeArray(exec, new QtArray(vl, QMetaType::Void, root)); - } else if (type == QMetaType::QStringList) { - QStringList sl = variant.value(); - return new RuntimeArray(exec, new QtArray(sl, QMetaType::QString, root)); - } else if (type == (QMetaType::Type) qMetaTypeId()) { - QObjectList ol= variant.value(); - return new RuntimeArray(exec, new QtArray(ol, QMetaType::QObjectStar, root)); - } else if (type == (QMetaType::Type)qMetaTypeId >()) { - QList il= variant.value >(); - return new RuntimeArray(exec, new QtArray(il, QMetaType::Int, root)); - } - - if (type == (QMetaType::Type)qMetaTypeId()) { - QVariant real = variant.value(); - qConvDebug() << "real variant is:" << real; - return convertQVariantToValue(exec, root, real); - } - - qConvDebug() << "fallback path for" << variant << variant.userType(); - - QString string = variant.toString(); - UString ustring((KJS::UChar*)string.utf16(), string.length()); - return jsString(ustring); -} - -// =============== - -// Qt-like macros -#define QW_D(Class) Class##Data* d = d_func() -#define QW_DS(Class,Instance) Class##Data* d = Instance->d_func() - -QtRuntimeMethod::QtRuntimeMethod(QtRuntimeMethodData* dd, ExecState *exec, const Identifier &ident, PassRefPtr inst) - : InternalFunctionImp (static_cast(exec->lexicalGlobalObject()->functionPrototype()), ident) - , d_ptr(dd) -{ - QW_D(QtRuntimeMethod); - d->m_instance = inst; -} - -QtRuntimeMethod::~QtRuntimeMethod() -{ - delete d_ptr; -} - -CodeType QtRuntimeMethod::codeType() const -{ - return FunctionCode; -} - -Completion QtRuntimeMethod::execute(ExecState*) -{ - return Completion(Normal, jsUndefined()); -} - -// =============== - -QtRuntimeMethodData::~QtRuntimeMethodData() -{ -} - -QtRuntimeMetaMethodData::~QtRuntimeMetaMethodData() -{ - -} - -QtRuntimeConnectionMethodData::~QtRuntimeConnectionMethodData() -{ - -} - -// =============== - -// Type conversion metadata (from QtScript originally) -class QtMethodMatchType -{ -public: - enum Kind { - Invalid, - Variant, - MetaType, - Unresolved, - MetaEnum - }; - - - QtMethodMatchType() - : m_kind(Invalid) { } - - Kind kind() const - { return m_kind; } - - QMetaType::Type typeId() const; - - bool isValid() const - { return (m_kind != Invalid); } - - bool isVariant() const - { return (m_kind == Variant); } - - bool isMetaType() const - { return (m_kind == MetaType); } - - bool isUnresolved() const - { return (m_kind == Unresolved); } - - bool isMetaEnum() const - { return (m_kind == MetaEnum); } - - QByteArray name() const; - - int enumeratorIndex() const - { Q_ASSERT(isMetaEnum()); return m_typeId; } - - static QtMethodMatchType variant() - { return QtMethodMatchType(Variant); } - - static QtMethodMatchType metaType(int typeId, const QByteArray &name) - { return QtMethodMatchType(MetaType, typeId, name); } - - static QtMethodMatchType metaEnum(int enumIndex, const QByteArray &name) - { return QtMethodMatchType(MetaEnum, enumIndex, name); } - - static QtMethodMatchType unresolved(const QByteArray &name) - { return QtMethodMatchType(Unresolved, /*typeId=*/0, name); } - -private: - QtMethodMatchType(Kind kind, int typeId = 0, const QByteArray &name = QByteArray()) - : m_kind(kind), m_typeId(typeId), m_name(name) { } - - Kind m_kind; - int m_typeId; - QByteArray m_name; -}; - -QMetaType::Type QtMethodMatchType::typeId() const -{ - if (isVariant()) - return (QMetaType::Type) QMetaType::type("QVariant"); - return (QMetaType::Type) (isMetaEnum() ? QMetaType::Int : m_typeId); -} - -QByteArray QtMethodMatchType::name() const -{ - if (!m_name.isEmpty()) - return m_name; - else if (m_kind == Variant) - return "QVariant"; - return QByteArray(); -} - -struct QtMethodMatchData -{ - int matchDistance; - int index; - QVector types; - QVarLengthArray args; - - QtMethodMatchData(int dist, int idx, QVector typs, - const QVarLengthArray &as) - : matchDistance(dist), index(idx), types(typs), args(as) { } - QtMethodMatchData() - : index(-1) { } - - bool isValid() const - { return (index != -1); } - - int firstUnresolvedIndex() const - { - for (int i=0; i < types.count(); i++) { - if (types.at(i).isUnresolved()) - return i; - } - return -1; - } -}; - -static int indexOfMetaEnum(const QMetaObject *meta, const QByteArray &str) -{ - QByteArray scope; - QByteArray name; - int scopeIdx = str.indexOf("::"); - if (scopeIdx != -1) { - scope = str.left(scopeIdx); - name = str.mid(scopeIdx + 2); - } else { - name = str; - } - for (int i = meta->enumeratorCount() - 1; i >= 0; --i) { - QMetaEnum m = meta->enumerator(i); - if ((m.name() == name)/* && (scope.isEmpty() || (m.scope() == scope))*/) - return i; - } - return -1; -} - -// Helper function for resolving methods -// Largely based on code in QtScript for compatibility reasons -static int findMethodIndex(ExecState* exec, - const QMetaObject* meta, - const QByteArray& signature, - bool allowPrivate, - const List& jsArgs, - QVarLengthArray &vars, - void** vvars, - JSObject **pError) -{ - QList matchingIndices; - - bool overloads = !signature.contains('('); - - int count = meta->methodCount(); - for (int i = count - 1; i >= 0; --i) { - const QMetaMethod m = meta->method(i); - - // Don't choose private methods - if (m.access() == QMetaMethod::Private && !allowPrivate) - continue; - - // try and find all matching named methods - if (m.signature() == signature) - matchingIndices.append(i); - else if (overloads) { - QByteArray rawsignature = m.signature(); - rawsignature.truncate(rawsignature.indexOf('(')); - if (rawsignature == signature) - matchingIndices.append(i); - } - } - - int chosenIndex = -1; - *pError = 0; - QVector chosenTypes; - - QVarLengthArray args; - QVector candidates; - QVector unresolved; - QVector tooFewArgs; - QVector conversionFailed; - - foreach(int index, matchingIndices) { - QMetaMethod method = meta->method(index); - - QVector types; - bool unresolvedTypes = false; - - // resolve return type - QByteArray returnTypeName = method.typeName(); - int rtype = QMetaType::type(returnTypeName); - if ((rtype == 0) && !returnTypeName.isEmpty()) { - if (returnTypeName == "QVariant") { - types.append(QtMethodMatchType::variant()); - } else if (returnTypeName.endsWith('*')) { - types.append(QtMethodMatchType::metaType(QMetaType::VoidStar, returnTypeName)); - } else { - int enumIndex = indexOfMetaEnum(meta, returnTypeName); - if (enumIndex != -1) - types.append(QtMethodMatchType::metaEnum(enumIndex, returnTypeName)); - else { - unresolvedTypes = true; - types.append(QtMethodMatchType::unresolved(returnTypeName)); - } - } - } else { - if (returnTypeName == "QVariant") - types.append(QtMethodMatchType::variant()); - else - types.append(QtMethodMatchType::metaType(rtype, returnTypeName)); - } - - // resolve argument types - QList parameterTypeNames = method.parameterTypes(); - for (int i = 0; i < parameterTypeNames.count(); ++i) { - QByteArray argTypeName = parameterTypeNames.at(i); - int atype = QMetaType::type(argTypeName); - if (atype == 0) { - if (argTypeName == "QVariant") { - types.append(QtMethodMatchType::variant()); - } else { - int enumIndex = indexOfMetaEnum(meta, argTypeName); - if (enumIndex != -1) - types.append(QtMethodMatchType::metaEnum(enumIndex, argTypeName)); - else { - unresolvedTypes = true; - types.append(QtMethodMatchType::unresolved(argTypeName)); - } - } - } else { - if (argTypeName == "QVariant") - types.append(QtMethodMatchType::variant()); - else - types.append(QtMethodMatchType::metaType(atype, argTypeName)); - } - } - - if (jsArgs.size() < (types.count() - 1)) { - qMatchDebug() << "Match:too few args for" << method.signature(); - tooFewArgs.append(index); - continue; - } - - if (unresolvedTypes) { - qMatchDebug() << "Match:unresolved arg types for" << method.signature(); - // remember it so we can give an error message later, if necessary - unresolved.append(QtMethodMatchData(/*matchDistance=*/INT_MAX, index, - types, QVarLengthArray())); - continue; - } - - // Now convert arguments - if (args.count() != types.count()) - args.resize(types.count()); - - QtMethodMatchType retType = types[0]; - args[0] = QVariant(retType.typeId(), (void *)0); // the return value - - bool converted = true; - int matchDistance = 0; - for (int i = 0; converted && i < types.count() - 1; ++i) { - JSValue* arg = i < jsArgs.size() ? jsArgs[i] : jsUndefined(); - - int argdistance = -1; - QVariant v = convertValueToQVariant(exec, arg, types.at(i+1).typeId(), &argdistance); - if (argdistance >= 0) { - matchDistance += argdistance; - args[i+1] = v; - } else { - qMatchDebug() << "failed to convert argument " << i << "type" << types.at(i+1).typeId() << QMetaType::typeName(types.at(i+1).typeId()); - converted = false; - } - } - - qMatchDebug() << "Match: " << method.signature() << (converted ? "converted":"failed to convert") << "distance " << matchDistance; - - if (converted) { - if ((jsArgs.size() == types.count() - 1) - && (matchDistance == 0)) { - // perfect match, use this one - chosenIndex = index; - break; - } else { - QtMethodMatchData metaArgs(matchDistance, index, types, args); - if (candidates.isEmpty()) { - candidates.append(metaArgs); - } else { - QtMethodMatchData otherArgs = candidates.at(0); - if ((args.count() > otherArgs.args.count()) - || ((args.count() == otherArgs.args.count()) - && (matchDistance <= otherArgs.matchDistance))) { - candidates.prepend(metaArgs); - } else { - candidates.append(metaArgs); - } - } - } - } else { - conversionFailed.append(index); - } - - if (!overloads) - break; - } - - if (chosenIndex == -1 && candidates.count() == 0) { - // No valid functions at all - format an error message - if (!conversionFailed.isEmpty()) { - QString message = QString::fromLatin1("incompatible type of argument(s) in call to %0(); candidates were\n") - .arg(QLatin1String(signature)); - for (int i = 0; i < conversionFailed.size(); ++i) { - if (i > 0) - message += QLatin1String("\n"); - QMetaMethod mtd = meta->method(conversionFailed.at(i)); - message += QString::fromLatin1(" %0").arg(QString::fromLatin1(mtd.signature())); - } - *pError = throwError(exec, TypeError, message.toLatin1().constData()); - } else if (!unresolved.isEmpty()) { - QtMethodMatchData argsInstance = unresolved.first(); - int unresolvedIndex = argsInstance.firstUnresolvedIndex(); - Q_ASSERT(unresolvedIndex != -1); - QtMethodMatchType unresolvedType = argsInstance.types.at(unresolvedIndex); - QString message = QString::fromLatin1("cannot call %0(): unknown type `%1'") - .arg(QString::fromLatin1(signature)) - .arg(QLatin1String(unresolvedType.name())); - *pError = throwError(exec, TypeError, message.toLatin1().constData()); - } else { - QString message = QString::fromLatin1("too few arguments in call to %0(); candidates are\n") - .arg(QLatin1String(signature)); - for (int i = 0; i < tooFewArgs.size(); ++i) { - if (i > 0) - message += QLatin1String("\n"); - QMetaMethod mtd = meta->method(tooFewArgs.at(i)); - message += QString::fromLatin1(" %0").arg(QString::fromLatin1(mtd.signature())); - } - *pError = throwError(exec, SyntaxError, message.toLatin1().constData()); - } - } - - if (chosenIndex == -1 && candidates.count() > 0) { - QtMethodMatchData metaArgs = candidates.at(0); - if ((candidates.size() > 1) - && (metaArgs.args.count() == candidates.at(1).args.count()) - && (metaArgs.matchDistance == candidates.at(1).matchDistance)) { - // ambiguous call - QString message = QString::fromLatin1("ambiguous call of overloaded function %0(); candidates were\n") - .arg(QLatin1String(signature)); - for (int i = 0; i < candidates.size(); ++i) { - if (i > 0) - message += QLatin1String("\n"); - QMetaMethod mtd = meta->method(candidates.at(i).index); - message += QString::fromLatin1(" %0").arg(QString::fromLatin1(mtd.signature())); - } - *pError = throwError(exec, TypeError, message.toLatin1().constData()); - } else { - chosenIndex = metaArgs.index; - args = metaArgs.args; - } - } - - if (chosenIndex != -1) { - /* Copy the stuff over */ - int i; - vars.resize(args.count()); - for (i=0; i < args.count(); i++) { - vars[i] = args[i]; - vvars[i] = vars[i].data(); - } - } - - return chosenIndex; -} - -// Signals are not fuzzy matched as much as methods -static int findSignalIndex(const QMetaObject* meta, int initialIndex, QByteArray signature) -{ - int index = initialIndex; - QMetaMethod method = meta->method(index); - bool overloads = !signature.contains('('); - if (overloads && (method.attributes() & QMetaMethod::Cloned)) { - // find the most general method - do { - method = meta->method(--index); - } while (method.attributes() & QMetaMethod::Cloned); - } - return index; -} - -QtRuntimeMetaMethod::QtRuntimeMetaMethod(ExecState* exec, const Identifier& ident, PassRefPtr inst, int index, const QByteArray& signature, bool allowPrivate) - : QtRuntimeMethod (new QtRuntimeMetaMethodData(), exec, ident, inst) -{ - QW_D(QtRuntimeMetaMethod); - d->m_signature = signature; - d->m_index = index; - d->m_connect = 0; - d->m_disconnect = 0; - d->m_allowPrivate = allowPrivate; -} - -void QtRuntimeMetaMethod::mark() -{ - QtRuntimeMethod::mark(); - QW_D(QtRuntimeMetaMethod); - if (d->m_connect) - d->m_connect->mark(); - if (d->m_disconnect) - d->m_disconnect->mark(); -} - -JSValue* QtRuntimeMetaMethod::callAsFunction(ExecState* exec, JSObject*, const List& args) -{ - QW_D(QtRuntimeMetaMethod); - - // We're limited to 10 args - if (args.size() > 10) - return jsUndefined(); - - // We have to pick a method that matches.. - JSLock lock; - - QObject *obj = d->m_instance->getObject(); - if (obj) { - QVarLengthArray vargs; - void *qargs[11]; - - int methodIndex; - JSObject* errorObj = 0; - if ((methodIndex = findMethodIndex(exec, obj->metaObject(), d->m_signature, d->m_allowPrivate, args, vargs, (void **)qargs, &errorObj)) != -1) { - if (obj->qt_metacall(QMetaObject::InvokeMetaMethod, methodIndex, qargs) >= 0) - return jsUndefined(); - - if (vargs[0].isValid()) - return convertQVariantToValue(exec, d->m_instance->rootObject(), vargs[0]); - } - - if (errorObj) - return errorObj; - } else { - return throwError(exec, GeneralError, "cannot call function of deleted QObject"); - } - - // void functions return undefined - return jsUndefined(); -} - -bool QtRuntimeMetaMethod::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - if (propertyName == "connect") { - slot.setCustom(this, connectGetter); - return true; - } else if (propertyName == "disconnect") { - slot.setCustom(this, disconnectGetter); - return true; - } else if (propertyName == exec->propertyNames().length) { - slot.setCustom(this, lengthGetter); - return true; - } - - return QtRuntimeMethod::getOwnPropertySlot(exec, propertyName, slot); -} - -JSValue *QtRuntimeMetaMethod::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&) -{ - // QtScript always returns 0 - return jsNumber(0); -} - -JSValue *QtRuntimeMetaMethod::connectGetter(ExecState* exec, JSObject*, const Identifier& ident, const PropertySlot& slot) -{ - QtRuntimeMetaMethod* thisObj = static_cast(slot.slotBase()); - QW_DS(QtRuntimeMetaMethod, thisObj); - - if (!d->m_connect) - d->m_connect = new QtRuntimeConnectionMethod(exec, ident, true, d->m_instance, d->m_index, d->m_signature); - return d->m_connect; -} - -JSValue* QtRuntimeMetaMethod::disconnectGetter(ExecState* exec, JSObject*, const Identifier& ident, const PropertySlot& slot) -{ - QtRuntimeMetaMethod* thisObj = static_cast(slot.slotBase()); - QW_DS(QtRuntimeMetaMethod, thisObj); - - if (!d->m_disconnect) - d->m_disconnect = new QtRuntimeConnectionMethod(exec, ident, false, d->m_instance, d->m_index, d->m_signature); - return d->m_disconnect; -} - -// =============== - -QMultiMap QtRuntimeConnectionMethod::connections; - -QtRuntimeConnectionMethod::QtRuntimeConnectionMethod(ExecState* exec, const Identifier& ident, bool isConnect, PassRefPtr inst, int index, const QByteArray& signature) - : QtRuntimeMethod (new QtRuntimeConnectionMethodData(), exec, ident, inst) -{ - QW_D(QtRuntimeConnectionMethod); - - d->m_signature = signature; - d->m_index = index; - d->m_isConnect = isConnect; -} - -JSValue *QtRuntimeConnectionMethod::callAsFunction(ExecState* exec, JSObject*, const List& args) -{ - QW_D(QtRuntimeConnectionMethod); - - JSLock lock; - - QObject* sender = d->m_instance->getObject(); - - if (sender) { - - JSObject* thisObject = exec->lexicalGlobalObject(); - JSObject* funcObject = 0; - - // QtScript checks signalness first, arguments second - int signalIndex = -1; - - // Make sure the initial index is a signal - QMetaMethod m = sender->metaObject()->method(d->m_index); - if (m.methodType() == QMetaMethod::Signal) - signalIndex = findSignalIndex(sender->metaObject(), d->m_index, d->m_signature); - - if (signalIndex != -1) { - if (args.size() == 1) { - funcObject = args[0]->toObject(exec); - if (!funcObject->implementsCall()) { - if (d->m_isConnect) - return throwError(exec, TypeError, "QtMetaMethod.connect: target is not a function"); - else - return throwError(exec, TypeError, "QtMetaMethod.disconnect: target is not a function"); - } - } else if (args.size() >= 2) { - if (args[0]->type() == ObjectType) { - thisObject = args[0]->toObject(exec); - - // Get the actual function to call - JSObject *asObj = args[1]->toObject(exec); - if (asObj->implementsCall()) { - // Function version - funcObject = asObj; - } else { - // Convert it to a string - UString funcName = args[1]->toString(exec); - Identifier funcIdent(funcName); - - // ### DropAllLocks - // This is resolved at this point in QtScript - JSValue* val = thisObject->get(exec, funcIdent); - JSObject* asFuncObj = val->toObject(exec); - - if (asFuncObj->implementsCall()) { - funcObject = asFuncObj; - } else { - if (d->m_isConnect) - return throwError(exec, TypeError, "QtMetaMethod.connect: target is not a function"); - else - return throwError(exec, TypeError, "QtMetaMethod.disconnect: target is not a function"); - } - } - } else { - if (d->m_isConnect) - return throwError(exec, TypeError, "QtMetaMethod.connect: thisObject is not an object"); - else - return throwError(exec, TypeError, "QtMetaMethod.disconnect: thisObject is not an object"); - } - } else { - if (d->m_isConnect) - return throwError(exec, GeneralError, "QtMetaMethod.connect: no arguments given"); - else - return throwError(exec, GeneralError, "QtMetaMethod.disconnect: no arguments given"); - } - - if (d->m_isConnect) { - // to connect, we need: - // target object [from ctor] - // target signal index etc. [from ctor] - // receiver function [from arguments] - // receiver this object [from arguments] - - QtConnectionObject* conn = new QtConnectionObject(d->m_instance, signalIndex, thisObject, funcObject); - bool ok = QMetaObject::connect(sender, signalIndex, conn, conn->metaObject()->methodOffset()); - if (!ok) { - delete conn; - QString msg = QString("QtMetaMethod.connect: failed to connect to %1::%2()") - .arg(sender->metaObject()->className()) - .arg(QLatin1String(d->m_signature)); - return throwError(exec, GeneralError, msg.toLatin1().constData()); - } - else { - // Store connection - connections.insert(sender, conn); - } - } else { - // Now to find our previous connection object. Hmm. - QList conns = connections.values(sender); - bool ret = false; - - foreach(QtConnectionObject* conn, conns) { - // Is this the right connection? - if (conn->match(sender, signalIndex, thisObject, funcObject)) { - // Yep, disconnect it - QMetaObject::disconnect(sender, signalIndex, conn, conn->metaObject()->methodOffset()); - delete conn; // this will also remove it from the map - ret = true; - break; - } - } - - if (!ret) { - QString msg = QString("QtMetaMethod.disconnect: failed to disconnect from %1::%2()") - .arg(sender->metaObject()->className()) - .arg(QLatin1String(d->m_signature)); - return throwError(exec, GeneralError, msg.toLatin1().constData()); - } - } - } else { - QString msg = QString("QtMetaMethod.%1: %2::%3() is not a signal") - .arg(d->m_isConnect ? "connect": "disconnect") - .arg(sender->metaObject()->className()) - .arg(QLatin1String(d->m_signature)); - return throwError(exec, TypeError, msg.toLatin1().constData()); - } - } else { - return throwError(exec, GeneralError, "cannot call function of deleted QObject"); - } - - return jsUndefined(); -} - -bool QtRuntimeConnectionMethod::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - if (propertyName == exec->propertyNames().length) { - slot.setCustom(this, lengthGetter); - return true; - } - - return QtRuntimeMethod::getOwnPropertySlot(exec, propertyName, slot); -} - -JSValue *QtRuntimeConnectionMethod::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&) -{ - // we have one formal argument, and one optional - return jsNumber(1); -} - -// =============== - -QtConnectionObject::QtConnectionObject(PassRefPtr instance, int signalIndex, JSObject* thisObject, JSObject* funcObject) - : m_instance(instance) - , m_signalIndex(signalIndex) - , m_originalObject(m_instance->getObject()) - , m_thisObject(thisObject) - , m_funcObject(funcObject) -{ - setParent(m_originalObject); - ASSERT(JSLock::currentThreadIsHoldingLock()); // so our ProtectedPtrs are safe -} - -QtConnectionObject::~QtConnectionObject() -{ - // Remove us from the map of active connections - QtRuntimeConnectionMethod::connections.remove(m_originalObject, this); -} - -static const uint qt_meta_data_QtConnectionObject[] = { - - // content: - 1, // revision - 0, // classname - 0, 0, // classinfo - 1, 10, // methods - 0, 0, // properties - 0, 0, // enums/sets - - // slots: signature, parameters, type, tag, flags - 28, 27, 27, 27, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_QtConnectionObject[] = { - "KJS::Bindings::QtConnectionObject\0\0execute()\0" -}; - -const QMetaObject QtConnectionObject::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_QtConnectionObject, - qt_meta_data_QtConnectionObject, 0 } -}; - -const QMetaObject *QtConnectionObject::metaObject() const -{ - return &staticMetaObject; -} - -void *QtConnectionObject::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_QtConnectionObject)) - return static_cast(const_cast(this)); - return QObject::qt_metacast(_clname); -} - -int QtConnectionObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: execute(_a); break; - } - _id -= 1; - } - return _id; -} - -void QtConnectionObject::execute(void **argv) -{ - QObject* obj = m_instance->getObject(); - if (obj) { - const QMetaObject* meta = obj->metaObject(); - const QMetaMethod method = meta->method(m_signalIndex); - - QList parameterTypes = method.parameterTypes(); - - int argc = parameterTypes.count(); - - JSLock lock; - - // ### Should the Interpreter/ExecState come from somewhere else? - RefPtr ro = m_instance->rootObject(); - if (ro) { - JSGlobalObject* globalobj = ro->globalObject(); - if (globalobj) { - ExecState* exec = globalobj->globalExec(); - if (exec) { - // Build the argument list (up to the formal argument length of the slot) - List l; - // ### DropAllLocks? - int funcArgC = m_funcObject->get(exec, exec->propertyNames().length)->toInt32(exec); - int argTotal = qMax(funcArgC, argc); - for(int i=0; i < argTotal; i++) { - if (i < argc) { - int argType = QMetaType::type(parameterTypes.at(i)); - l.append(convertQVariantToValue(exec, ro, QVariant(argType, argv[i+1]))); - } else { - l.append(jsUndefined()); - } - } - // Stuff in the __qt_sender property, if we can - if (m_funcObject->inherits(&FunctionImp::info)) { - FunctionImp* fimp = static_cast(m_funcObject.get()); - - JSObject* qt_sender = Instance::createRuntimeObject(Instance::QtLanguage, sender(), ro); - JSObject* wrapper = new JSObject(); - wrapper->put(exec, "__qt_sender__", qt_sender); - ScopeChain oldsc = fimp->scope(); - ScopeChain sc = oldsc; - sc.push(wrapper); - fimp->setScope(sc); - fimp->call(exec, m_thisObject, l); - fimp->setScope(oldsc); - } else - m_funcObject->call(exec, m_thisObject, l); - } - } - } - } else { - // A strange place to be - a deleted object emitted a signal here. - qWarning() << "sender deleted, cannot deliver signal"; - } -} - -bool QtConnectionObject::match(QObject* sender, int signalIndex, JSObject* thisObject, JSObject *funcObject) -{ - if (m_originalObject == sender && m_signalIndex == signalIndex - && thisObject == (JSObject*)m_thisObject && funcObject == (JSObject*)m_funcObject) - return true; - return false; -} - -// =============== - -template QtArray::QtArray(QList list, QMetaType::Type type, PassRefPtr rootObject) - : Array(rootObject) - , m_list(list) - , m_type(type) -{ - m_length = m_list.count(); -} - -template QtArray::~QtArray () -{ -} - -template RootObject* QtArray::rootObject() const -{ - return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0; -} - -template void QtArray::setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const -{ - // QtScript sets the value, but doesn't forward it to the original source - // (e.g. if you do 'object.intList[5] = 6', the object is not updated, but the - // copy of the list is). - int dist = -1; - QVariant val = convertValueToQVariant(exec, aValue, m_type, &dist); - - if (dist >= 0) { - m_list[index] = val.value(); - } -} - - -template JSValue* QtArray::valueAt(ExecState *exec, unsigned int index) const -{ - if (index < m_length) { - T val = m_list.at(index); - return convertQVariantToValue(exec, rootObject(), QVariant::fromValue(val)); - } - - return jsUndefined(); -} - -// =============== - -} } diff --git a/bindings/qt/qt_runtime.h b/bindings/qt/qt_runtime.h deleted file mode 100644 index e44af7b..0000000 --- a/bindings/qt/qt_runtime.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2006 Trolltech ASA - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef BINDINGS_QT_RUNTIME_H_ -#define BINDINGS_QT_RUNTIME_H_ - -#include "runtime.h" -#include "runtime_method.h" -#include "protect.h" - -#include -#include -#include - -namespace KJS { -namespace Bindings { - -class QtInstance; - -class QtField : public Field { -public: - - typedef enum { - MetaProperty, - DynamicProperty, - ChildObject - } QtFieldType; - - QtField(const QMetaProperty &p) - : m_type(MetaProperty), m_property(p) - {} - - QtField(const QByteArray &b) - : m_type(DynamicProperty), m_dynamicProperty(b) - {} - - QtField(QObject *child) - : m_type(ChildObject), m_childObject(child) - {} - - virtual JSValue* valueFromInstance(ExecState*, const Instance*) const; - virtual void setValueToInstance(ExecState*, const Instance*, JSValue*) const; - virtual const char* name() const; - QtFieldType fieldType() const {return m_type;} -private: - QtFieldType m_type; - QByteArray m_dynamicProperty; - QMetaProperty m_property; - QPointer m_childObject; -}; - - -class QtMethod : public Method -{ -public: - QtMethod(const QMetaObject *mo, int i, const QByteArray &ident, int numParameters) - : m_metaObject(mo), - m_index(i), - m_identifier(ident), - m_nParams(numParameters) - { } - - virtual const char* name() const { return m_identifier.constData(); } - virtual int numParameters() const { return m_nParams; } - -private: - friend class QtInstance; - const QMetaObject *m_metaObject; - int m_index; - QByteArray m_identifier; - int m_nParams; -}; - - -template class QtArray : public Array -{ -public: - QtArray(QList list, QMetaType::Type type, PassRefPtr); - virtual ~QtArray(); - - RootObject* rootObject() const; - - virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const; - virtual JSValue *valueAt(ExecState *exec, unsigned int index) const; - virtual unsigned int getLength() const {return m_length;} - -private: - mutable QList m_list; // setValueAt is const! - unsigned int m_length; - QMetaType::Type m_type; -}; - -// Based on RuntimeMethod - -// Extra data classes (to avoid the CELL_SIZE limit on JS objects) - -class QtRuntimeMethodData { - public: - virtual ~QtRuntimeMethodData(); - RefPtr m_instance; -}; - -class QtRuntimeConnectionMethod; -class QtRuntimeMetaMethodData : public QtRuntimeMethodData { - public: - ~QtRuntimeMetaMethodData(); - QByteArray m_signature; - bool m_allowPrivate; - int m_index; - QtRuntimeConnectionMethod *m_connect; - QtRuntimeConnectionMethod *m_disconnect; -}; - -class QtRuntimeConnectionMethodData : public QtRuntimeMethodData { - public: - ~QtRuntimeConnectionMethodData(); - QByteArray m_signature; - int m_index; - bool m_isConnect; -}; - -// Common base class (doesn't really do anything interesting) -class QtRuntimeMethod : public InternalFunctionImp -{ -public: - virtual ~QtRuntimeMethod(); - - virtual CodeType codeType() const; - virtual Completion execute(ExecState *exec); - -protected: - QtRuntimeMethodData *d_func() const {return d_ptr;} - QtRuntimeMethod(QtRuntimeMethodData *dd, ExecState *exec, const Identifier &n, PassRefPtr inst); - QtRuntimeMethodData *d_ptr; -}; - -class QtRuntimeMetaMethod : public QtRuntimeMethod -{ -public: - QtRuntimeMetaMethod(ExecState *exec, const Identifier &n, PassRefPtr inst, int index, const QByteArray& signature, bool allowPrivate); - - virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); - virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); - - virtual void mark(); - -protected: - QtRuntimeMetaMethodData* d_func() const {return reinterpret_cast(d_ptr);} - -private: - static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&); - static JSValue *connectGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&); - static JSValue *disconnectGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&); -}; - -class QtConnectionObject; -class QtRuntimeConnectionMethod : public QtRuntimeMethod -{ -public: - QtRuntimeConnectionMethod(ExecState *exec, const Identifier &n, bool isConnect, PassRefPtr inst, int index, const QByteArray& signature ); - - virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); - virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); - -protected: - QtRuntimeConnectionMethodData* d_func() const {return reinterpret_cast(d_ptr);} - -private: - static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&); - static QMultiMap connections; - friend class QtConnectionObject; -}; - -class QtConnectionObject: public QObject -{ -public: - QtConnectionObject(PassRefPtr instance, int signalIndex, JSObject* thisObject, JSObject* funcObject); - ~QtConnectionObject(); - - static const QMetaObject staticMetaObject; - virtual const QMetaObject *metaObject() const; - virtual void *qt_metacast(const char *); - virtual int qt_metacall(QMetaObject::Call, int, void **argv); - - bool match(QObject *sender, int signalIndex, JSObject* thisObject, JSObject *funcObject); - - // actual slot: - void execute(void **argv); - -private: - RefPtr m_instance; - int m_signalIndex; - QObject* m_originalObject; // only used as a key, not dereferenced - ProtectedPtr m_thisObject; - ProtectedPtr m_funcObject; -}; - -} // namespace Bindings -} // namespace KJS - -#endif diff --git a/bindings/runtime.cpp b/bindings/runtime.cpp deleted file mode 100644 index 9e7e1b7..0000000 --- a/bindings/runtime.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "runtime.h" - -#include "JSLock.h" -#if ENABLE(NETSCAPE_API) -#include "NP_jsobject.h" -#include "c_instance.h" -#endif -#include "runtime_object.h" -#include "runtime_root.h" - -#if HAVE(JNI) -#include "jni_instance.h" -#endif -#include "objc_instance.h" -#if PLATFORM(QT) -#include "qt_instance.h" -#endif - -namespace KJS { namespace Bindings { - -Array::Array(PassRefPtr rootObject) - : _rootObject(rootObject) -{ - ASSERT(_rootObject); -} - -Array::~Array() -{ -} - -Instance::Instance(PassRefPtr rootObject) - : _rootObject(rootObject) - , _refCount(0) -{ - ASSERT(_rootObject); -} - -Instance::~Instance() -{ -} - -static KJSDidExecuteFunctionPtr _DidExecuteFunction; - -void Instance::setDidExecuteFunction(KJSDidExecuteFunctionPtr func) { _DidExecuteFunction = func; } -KJSDidExecuteFunctionPtr Instance::didExecuteFunction() { return _DidExecuteFunction; } - -JSValue *Instance::getValueOfField(ExecState *exec, const Field *aField) const -{ - return aField->valueFromInstance(exec, this); -} - -void Instance::setValueOfField(ExecState *exec, const Field *aField, JSValue *aValue) const -{ - aField->setValueToInstance(exec, this, aValue); -} - -Instance* Instance::createBindingForLanguageInstance(BindingLanguage language, void* nativeInstance, PassRefPtr rootObject) -{ - Instance *newInstance = 0; - - switch (language) { -#if HAVE(JNI) - case Instance::JavaLanguage: { - newInstance = new Bindings::JavaInstance((jobject)nativeInstance, rootObject); - break; - } -#endif - case Instance::ObjectiveCLanguage: { - newInstance = new Bindings::ObjcInstance((ObjectStructPtr)nativeInstance, rootObject); - break; - } -#if ENABLE(NETSCAPE_API) - case Instance::CLanguage: { - newInstance = new Bindings::CInstance((NPObject *)nativeInstance, rootObject); - break; - } -#endif -#if PLATFORM(QT) - case Instance::QtLanguage: { - newInstance = Bindings::QtInstance::getQtInstance((QObject *)nativeInstance, rootObject); - break; - } -#endif - default: - break; - } - - return newInstance; -} - -JSObject* Instance::createRuntimeObject(BindingLanguage language, void* nativeInstance, PassRefPtr rootObject) -{ - Instance* instance = Instance::createBindingForLanguageInstance(language, nativeInstance, rootObject); - - return createRuntimeObject(instance); -} - -JSObject* Instance::createRuntimeObject(Instance* instance) -{ -#if PLATFORM(QT) - if (instance->getBindingLanguage() == QtLanguage) - return QtInstance::getRuntimeObject(static_cast(instance)); -#endif - JSLock lock; - - return new RuntimeObjectImp(instance); -} - -Instance* Instance::getInstance(JSObject* object, BindingLanguage language) -{ - if (!object) - return 0; - if (!object->inherits(&RuntimeObjectImp::info)) - return 0; - Instance* instance = (static_cast(object))->getInternalInstance(); - if (!instance) - return 0; - if (instance->getBindingLanguage() != language) - return 0; - return instance; -} - -RootObject* Instance::rootObject() const -{ - return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0; -} - -} } // namespace KJS::Bindings diff --git a/bindings/runtime.h b/bindings/runtime.h deleted file mode 100644 index dbb324c..0000000 --- a/bindings/runtime.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JAVASCRIPTCORE_BINDINGS_RUNTIME_H -#define JAVASCRIPTCORE_BINDINGS_RUNTIME_H - -#include "value.h" - -#include -#include -#include - -namespace KJS { - -class Identifier; -class List; -class PropertyNameArray; - -namespace Bindings { - -class Instance; -class Method; -class RootObject; - -typedef Vector MethodList; - -class Field -{ -public: - virtual const char* name() const = 0; - - virtual JSValue* valueFromInstance(ExecState*, const Instance*) const = 0; - virtual void setValueToInstance(ExecState*, const Instance*, JSValue*) const = 0; - - virtual ~Field() {} -}; - -class Method : Noncopyable -{ -public: - virtual const char *name() const = 0; - - virtual int numParameters() const = 0; - - virtual ~Method() {} -}; - -class Class : Noncopyable -{ -public: - virtual const char *name() const = 0; - - virtual MethodList methodsNamed(const Identifier&, Instance*) const = 0; - - virtual Field *fieldNamed(const Identifier&, Instance*) const = 0; - - virtual JSValue* fallbackObject(ExecState*, Instance*, const Identifier&) { return jsUndefined(); } - - virtual ~Class() {} -}; - -typedef void (*KJSDidExecuteFunctionPtr)(ExecState*, JSObject* rootObject); - -class Instance : Noncopyable { -public: - typedef enum { - JavaLanguage, - ObjectiveCLanguage, - CLanguage -#if PLATFORM(QT) - , QtLanguage -#endif - } BindingLanguage; - - Instance(PassRefPtr); - - static void setDidExecuteFunction(KJSDidExecuteFunctionPtr func); - static KJSDidExecuteFunctionPtr didExecuteFunction(); - - static Instance* createBindingForLanguageInstance(BindingLanguage, void* nativeInstance, PassRefPtr); - static JSObject* createRuntimeObject(BindingLanguage, void* nativeInstance, PassRefPtr); - static JSObject* createRuntimeObject(Instance*); - - static Instance* getInstance(JSObject*, BindingLanguage); - - void ref() { _refCount++; } - void deref() - { - if (--_refCount == 0) - delete this; - } - - // These functions are called before and after the main entry points into - // the native implementations. They can be used to establish and cleanup - // any needed state. - virtual void begin() {} - virtual void end() {} - - virtual Class *getClass() const = 0; - - virtual JSValue* getValueOfField(ExecState*, const Field*) const; - virtual JSValue* getValueOfUndefinedField(ExecState*, const Identifier&, JSType) const { return jsUndefined(); } - virtual void setValueOfField(ExecState*, const Field*, JSValue*) const; - virtual bool supportsSetValueOfUndefinedField() { return false; } - virtual void setValueOfUndefinedField(ExecState*, const Identifier&, JSValue*) {} - - virtual bool implementsCall() const { return false; } - - virtual JSValue* invokeMethod(ExecState*, const MethodList&, const List& args) = 0; - virtual JSValue* invokeDefaultMethod(ExecState*, const List&) { return jsUndefined(); } - - virtual void getPropertyNames(ExecState*, PropertyNameArray&) { } - - virtual JSValue* defaultValue(JSType hint) const = 0; - - virtual JSValue* valueOf() const { return jsString(getClass()->name()); } - - RootObject* rootObject() const; - - virtual ~Instance(); - - virtual BindingLanguage getBindingLanguage() const = 0; - -protected: - RefPtr _rootObject; - unsigned _refCount; -}; - -class Array : Noncopyable -{ -public: - Array(PassRefPtr); - virtual ~Array(); - - virtual void setValueAt(ExecState *, unsigned index, JSValue*) const = 0; - virtual JSValue* valueAt(ExecState *, unsigned index) const = 0; - virtual unsigned int getLength() const = 0; -protected: - RefPtr _rootObject; -}; - -const char *signatureForParameters(const List&); - -typedef HashMap, MethodList*> MethodListMap; -typedef HashMap, Method*> MethodMap; -typedef HashMap, Field*> FieldMap; - -} // namespace Bindings - -} // namespace KJS - -#endif diff --git a/bindings/runtime_array.cpp b/bindings/runtime_array.cpp deleted file mode 100644 index c8ff075..0000000 --- a/bindings/runtime_array.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "runtime_array.h" - -#include "JSGlobalObject.h" -#include "array_object.h" - -using namespace KJS; - -const ClassInfo RuntimeArray::info = { "RuntimeArray", &ArrayInstance::info, 0 }; - -RuntimeArray::RuntimeArray(ExecState *exec, Bindings::Array *a) - : JSObject(exec->lexicalGlobalObject()->arrayPrototype()) - , _array(a) -{ -} - -JSValue *RuntimeArray::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) -{ - RuntimeArray *thisObj = static_cast(slot.slotBase()); - return jsNumber(thisObj->getLength()); -} - -JSValue *RuntimeArray::indexGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot) -{ - RuntimeArray *thisObj = static_cast(slot.slotBase()); - return thisObj->getConcreteArray()->valueAt(exec, slot.index()); -} - -bool RuntimeArray::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - if (propertyName == exec->propertyNames().length) { - slot.setCustom(this, lengthGetter); - return true; - } - - bool ok; - unsigned index = propertyName.toArrayIndex(&ok); - if (ok) { - if (index < getLength()) { - slot.setCustomIndex(this, index, indexGetter); - return true; - } - } - - return JSObject::getOwnPropertySlot(exec, propertyName, slot); -} - -bool RuntimeArray::getOwnPropertySlot(ExecState *exec, unsigned index, PropertySlot& slot) -{ - if (index < getLength()) { - slot.setCustomIndex(this, index, indexGetter); - return true; - } - - return JSObject::getOwnPropertySlot(exec, index, slot); -} - -void RuntimeArray::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) -{ - if (propertyName == exec->propertyNames().length) { - throwError(exec, RangeError); - return; - } - - bool ok; - unsigned index = propertyName.toArrayIndex(&ok); - if (ok) { - getConcreteArray()->setValueAt(exec, index, value); - return; - } - - JSObject::put(exec, propertyName, value, attr); -} - -void RuntimeArray::put(ExecState* exec, unsigned index, JSValue* value, int) -{ - if (index >= getLength()) { - throwError(exec, RangeError); - return; - } - - getConcreteArray()->setValueAt(exec, index, value); -} - -bool RuntimeArray::deleteProperty(ExecState*, const Identifier&) -{ - return false; -} - -bool RuntimeArray::deleteProperty(ExecState*, unsigned) -{ - return false; -} diff --git a/bindings/runtime_array.h b/bindings/runtime_array.h deleted file mode 100644 index 2182b31..0000000 --- a/bindings/runtime_array.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef RUNTIME_ARRAY_H_ -#define RUNTIME_ARRAY_H_ - -#include - -#include "array_instance.h" -#include "runtime.h" - -namespace KJS { - -class RuntimeArray : public JSObject { -public: - RuntimeArray(ExecState *exec, Bindings::Array *i); - - virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); - virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&); - virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None); - virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None); - - virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName); - virtual bool deleteProperty(ExecState *exec, unsigned propertyName); - - virtual const ClassInfo *classInfo() const { return &info; } - - unsigned getLength() const { return getConcreteArray()->getLength(); } - - Bindings::Array *getConcreteArray() const { return _array.get(); } - - static const ClassInfo info; - -private: - static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&); - static JSValue *indexGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&); - - OwnPtr _array; -}; - -} // namespace KJS - -#endif // RUNTIME_ARRAY_H_ diff --git a/bindings/runtime_method.cpp b/bindings/runtime_method.cpp deleted file mode 100644 index 4430f25..0000000 --- a/bindings/runtime_method.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "runtime_method.h" - -#include "ExecState.h" -#include "JSGlobalObject.h" -#include "runtime_object.h" -#include "function_object.h" - -using namespace KJS::Bindings; -using namespace KJS; - -RuntimeMethod::RuntimeMethod(ExecState *exec, const Identifier &ident, Bindings::MethodList &m) - : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), ident) - , _methodList(new MethodList(m)) -{ -} - -JSValue *RuntimeMethod::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) -{ - RuntimeMethod *thisObj = static_cast(slot.slotBase()); - - // Ick! There may be more than one method with this name. Arbitrarily - // just pick the first method. The fundamental problem here is that - // JavaScript doesn't have the notion of method overloading and - // Java does. - // FIXME: a better solution might be to give the maximum number of parameters - // of any method - return jsNumber(thisObj->_methodList->at(0)->numParameters()); -} - -bool RuntimeMethod::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot &slot) -{ - if (propertyName == exec->propertyNames().length) { - slot.setCustom(this, lengthGetter); - return true; - } - - return InternalFunctionImp::getOwnPropertySlot(exec, propertyName, slot); -} - -JSValue *RuntimeMethod::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) -{ - if (_methodList->isEmpty()) - return jsUndefined(); - - RuntimeObjectImp *imp = 0; - - if (thisObj->classInfo() == &KJS::RuntimeObjectImp::info) { - imp = static_cast(thisObj); - } else { - // If thisObj is the DOM object for a plugin, get the corresponding - // runtime object from the DOM object. - JSValue* value = thisObj->get(exec, "__apple_runtime_object"); - if (value->isObject(&KJS::RuntimeObjectImp::info)) - imp = static_cast(value); - } - - if (!imp) - return throwError(exec, TypeError); - - RefPtr instance = imp->getInternalInstance(); - if (!instance) - return RuntimeObjectImp::throwInvalidAccessError(exec); - - instance->begin(); - JSValue *aValue = instance->invokeMethod(exec, *_methodList, args); - instance->end(); - return aValue; -} diff --git a/bindings/runtime_object.cpp b/bindings/runtime_object.cpp deleted file mode 100644 index c2cb3e8..0000000 --- a/bindings/runtime_object.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "runtime_object.h" - -#include "error_object.h" -#include "operations.h" -#include "runtime_method.h" -#include "runtime_root.h" - -using namespace KJS; -using namespace Bindings; - -const ClassInfo RuntimeObjectImp::info = { "RuntimeObject", 0, 0 }; - -RuntimeObjectImp::RuntimeObjectImp(Bindings::Instance *i) -: instance(i) -{ - instance->rootObject()->addRuntimeObject(this); -} - -RuntimeObjectImp::~RuntimeObjectImp() -{ - if (instance) - instance->rootObject()->removeRuntimeObject(this); -} - -void RuntimeObjectImp::invalidate() -{ - ASSERT(instance); - instance = 0; -} - -JSValue *RuntimeObjectImp::fallbackObjectGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) -{ - RuntimeObjectImp *thisObj = static_cast(slot.slotBase()); - RefPtr instance = thisObj->instance; - - if (!instance) - return throwInvalidAccessError(exec); - - instance->begin(); - - Class *aClass = instance->getClass(); - JSValue* result = aClass->fallbackObject(exec, instance.get(), propertyName); - - instance->end(); - - return result; -} - -JSValue *RuntimeObjectImp::fieldGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) -{ - RuntimeObjectImp *thisObj = static_cast(slot.slotBase()); - RefPtr instance = thisObj->instance; - - if (!instance) - return throwInvalidAccessError(exec); - - instance->begin(); - - Class *aClass = instance->getClass(); - Field* aField = aClass->fieldNamed(propertyName, instance.get()); - JSValue *result = instance->getValueOfField(exec, aField); - - instance->end(); - - return result; -} - -JSValue *RuntimeObjectImp::methodGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) -{ - RuntimeObjectImp *thisObj = static_cast(slot.slotBase()); - RefPtr instance = thisObj->instance; - - if (!instance) - return throwInvalidAccessError(exec); - - instance->begin(); - - Class *aClass = instance->getClass(); - MethodList methodList = aClass->methodsNamed(propertyName, instance.get()); - JSValue *result = new RuntimeMethod(exec, propertyName, methodList); - - instance->end(); - - return result; -} - -bool RuntimeObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) -{ - if (!instance) { - throwInvalidAccessError(exec); - return false; - } - - instance->begin(); - - Class *aClass = instance->getClass(); - - if (aClass) { - // See if the instance has a field with the specified name. - Field *aField = aClass->fieldNamed(propertyName, instance.get()); - if (aField) { - slot.setCustom(this, fieldGetter); - instance->end(); - return true; - } else { - // Now check if a method with specified name exists, if so return a function object for - // that method. - MethodList methodList = aClass->methodsNamed(propertyName, instance.get()); - if (methodList.size() > 0) { - slot.setCustom(this, methodGetter); - - instance->end(); - return true; - } - } - - // Try a fallback object. - if (!aClass->fallbackObject(exec, instance.get(), propertyName)->isUndefined()) { - slot.setCustom(this, fallbackObjectGetter); - instance->end(); - return true; - } - } - - instance->end(); - - // don't call superclass, because runtime objects can't have custom properties or a prototype - return false; -} - -void RuntimeObjectImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int) -{ - if (!instance) { - throwInvalidAccessError(exec); - return; - } - - RefPtr protector(instance); - instance->begin(); - - // Set the value of the property. - Field *aField = instance->getClass()->fieldNamed(propertyName, instance.get()); - if (aField) - instance->setValueOfField(exec, aField, value); - else if (instance->supportsSetValueOfUndefinedField()) - instance->setValueOfUndefinedField(exec, propertyName, value); - - instance->end(); -} - -bool RuntimeObjectImp::canPut(ExecState* exec, const Identifier& propertyName) const -{ - if (!instance) { - throwInvalidAccessError(exec); - return false; - } - - instance->begin(); - - Field *aField = instance->getClass()->fieldNamed(propertyName, instance.get()); - - instance->end(); - - return !!aField; -} - -bool RuntimeObjectImp::deleteProperty(ExecState*, const Identifier&) -{ - // Can never remove a property of a RuntimeObject. - return false; -} - -JSValue *RuntimeObjectImp::defaultValue(ExecState* exec, JSType hint) const -{ - if (!instance) - return throwInvalidAccessError(exec); - - JSValue *result; - - RefPtr protector(instance); - instance->begin(); - - result = instance->defaultValue(hint); - - instance->end(); - - return result; -} - -bool RuntimeObjectImp::implementsCall() const -{ - if (!instance) - return false; - - return instance->implementsCall(); -} - -JSValue *RuntimeObjectImp::callAsFunction(ExecState* exec, JSObject*, const List& args) -{ - if (!instance) - return throwInvalidAccessError(exec); - - RefPtr protector(instance); - instance->begin(); - - JSValue *aValue = instance->invokeDefaultMethod(exec, args); - - instance->end(); - - return aValue; -} - -void RuntimeObjectImp::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) -{ - if (!instance) { - throwInvalidAccessError(exec); - return; - } - - instance->begin(); - instance->getPropertyNames(exec, propertyNames); - instance->end(); -} - -JSObject* RuntimeObjectImp::throwInvalidAccessError(ExecState* exec) -{ - return throwError(exec, ReferenceError, "Trying to access object from destroyed plug-in."); -} diff --git a/bindings/runtime_object.h b/bindings/runtime_object.h deleted file mode 100644 index 0ce7d74..0000000 --- a/bindings/runtime_object.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2003 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef KJS_RUNTIME_OBJECT_H -#define KJS_RUNTIME_OBJECT_H - -#include "runtime.h" -#include "object.h" - -#include - -namespace KJS { - -class RuntimeObjectImp : public JSObject { -public: - virtual ~RuntimeObjectImp(); - - const ClassInfo *classInfo() const { return &info; } - - virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); - virtual bool canPut(ExecState *exec, const Identifier &propertyName) const; - virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None); - virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName); - virtual JSValue *defaultValue(ExecState *exec, JSType hint) const; - virtual bool implementsCall() const; - virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); - - virtual void invalidate(); - Bindings::Instance *getInternalInstance() const { return instance.get(); } - - static JSObject* throwInvalidAccessError(ExecState*); - - static const ClassInfo info; - -protected: - friend class Bindings::Instance; - RuntimeObjectImp(Bindings::Instance*); // Only allow Instances and derived classes to create us - -private: - RuntimeObjectImp(); // prevent default construction - - static JSValue *fallbackObjectGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&); - static JSValue *fieldGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&); - static JSValue *methodGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&); - - RefPtr instance; -}; - -} // namespace - -#endif diff --git a/bindings/runtime_root.cpp b/bindings/runtime_root.cpp deleted file mode 100644 index aa1fa86..0000000 --- a/bindings/runtime_root.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "runtime_root.h" - -#include "JSGlobalObject.h" -#include "object.h" -#include "runtime.h" -#include "runtime_object.h" -#include -#include - -namespace KJS { namespace Bindings { - -// This code attempts to solve two problems: (1) plug-ins leaking references to -// JS and the DOM; (2) plug-ins holding stale references to JS and the DOM. Previous -// comments in this file claimed that problem #1 was an issue in Java, in particular, -// because Java, allegedly, didn't always call finalize when collecting an object. - -typedef HashSet RootObjectSet; - -static RootObjectSet* rootObjectSet() -{ - static RootObjectSet staticRootObjectSet; - return &staticRootObjectSet; -} - -// FIXME: These two functions are a potential performance problem. We could -// fix them by adding a JSObject to RootObject dictionary. - -RootObject* findProtectingRootObject(JSObject* jsObject) -{ - RootObjectSet::const_iterator end = rootObjectSet()->end(); - for (RootObjectSet::const_iterator it = rootObjectSet()->begin(); it != end; ++it) { - if ((*it)->gcIsProtected(jsObject)) - return *it; - } - return 0; -} - -RootObject* findRootObject(JSGlobalObject* globalObject) -{ - RootObjectSet::const_iterator end = rootObjectSet()->end(); - for (RootObjectSet::const_iterator it = rootObjectSet()->begin(); it != end; ++it) { - if ((*it)->globalObject() == globalObject) - return *it; - } - return 0; -} - -// May only be set by dispatchToJavaScriptThread(). -#if ENABLE(JAVA_BINDINGS) -static CFRunLoopSourceRef completionSource; - -static void completedJavaScriptAccess (void *i) -{ - assert (CFRunLoopGetCurrent() != RootObject::runLoop()); - - JSObjectCallContext *callContext = (JSObjectCallContext *)i; - CFRunLoopRef runLoop = (CFRunLoopRef)callContext->originatingLoop; - - assert (CFRunLoopGetCurrent() == runLoop); - - CFRunLoopStop(runLoop); -} - -static pthread_once_t javaScriptAccessLockOnce = PTHREAD_ONCE_INIT; -static pthread_mutex_t javaScriptAccessLock; -static int javaScriptAccessLockCount = 0; - -static void initializeJavaScriptAccessLock() -{ - pthread_mutexattr_t attr; - - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); - - pthread_mutex_init(&javaScriptAccessLock, &attr); -} - -static inline void lockJavaScriptAccess() -{ - // Perhaps add deadlock detection? - pthread_once(&javaScriptAccessLockOnce, initializeJavaScriptAccessLock); - pthread_mutex_lock(&javaScriptAccessLock); - javaScriptAccessLockCount++; -} - -static inline void unlockJavaScriptAccess() -{ - javaScriptAccessLockCount--; - pthread_mutex_unlock(&javaScriptAccessLock); -} - - -void RootObject::dispatchToJavaScriptThread(JSObjectCallContext *context) -{ - // This lock guarantees that only one thread can invoke - // at a time, and also guarantees that completionSource; - // won't get clobbered. - lockJavaScriptAccess(); - - CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent(); - - assert (currentRunLoop != RootObject::runLoop()); - - // Setup a source to signal once the invocation of the JavaScript - // call completes. - // - // FIXME: This could be a potential performance issue. Creating and - // adding run loop sources is expensive. We could create one source - // per thread, as needed, instead. - context->originatingLoop = currentRunLoop; - CFRunLoopSourceContext sourceContext = {0, context, NULL, NULL, NULL, NULL, NULL, NULL, NULL, completedJavaScriptAccess}; - completionSource = CFRunLoopSourceCreate(NULL, 0, &sourceContext); - CFRunLoopAddSource(currentRunLoop, completionSource, kCFRunLoopDefaultMode); - - // Wakeup JavaScript access thread and make it do it's work. - CFRunLoopSourceSignal(RootObject::performJavaScriptSource()); - if (CFRunLoopIsWaiting(RootObject::runLoop())) { - CFRunLoopWakeUp(RootObject::runLoop()); - } - - // Wait until the JavaScript access thread is done. - CFRunLoopRun (); - - CFRunLoopRemoveSource(currentRunLoop, completionSource, kCFRunLoopDefaultMode); - CFRelease (completionSource); - - unlockJavaScriptAccess(); -} - -static void performJavaScriptAccess(void*) -{ - assert (CFRunLoopGetCurrent() == RootObject::runLoop()); - - // Dispatch JavaScript calls here. - CFRunLoopSourceContext sourceContext; - CFRunLoopSourceGetContext (completionSource, &sourceContext); - JSObjectCallContext *callContext = (JSObjectCallContext *)sourceContext.info; - CFRunLoopRef originatingLoop = callContext->originatingLoop; - - JavaJSObject::invoke (callContext); - - // Signal the originating thread that we're done. - CFRunLoopSourceSignal (completionSource); - if (CFRunLoopIsWaiting(originatingLoop)) { - CFRunLoopWakeUp(originatingLoop); - } -} -#endif // ENABLE(JAVA_BINDINGS) - -CreateRootObjectFunction RootObject::_createRootObject = 0; -CFRunLoopRef RootObject::_runLoop = 0; -CFRunLoopSourceRef RootObject::_performJavaScriptSource = 0; - -// Must be called from the thread that will be used to access JavaScript. -void RootObject::setCreateRootObject(CreateRootObjectFunction createRootObject) { - // Should only be called once. - ASSERT(!_createRootObject); - - _createRootObject = createRootObject; - - // Assume that we can retain this run loop forever. It'll most - // likely (always?) be the main loop. - _runLoop = (CFRunLoopRef)CFRetain (CFRunLoopGetCurrent ()); - - // Setup a source the other threads can use to signal the _runLoop - // thread that a JavaScript call needs to be invoked. - -#if ENABLE(JAVA_BINDINGS) - CFRunLoopSourceContext sourceContext = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, performJavaScriptAccess}; - RootObject::_performJavaScriptSource = CFRunLoopSourceCreate(NULL, 0, &sourceContext); - CFRunLoopAddSource(RootObject::_runLoop, RootObject::_performJavaScriptSource, kCFRunLoopDefaultMode); -#endif // ENABLE(JAVA_BINDINGS) -} - - -PassRefPtr RootObject::create(const void* nativeHandle, JSGlobalObject* globalObject) -{ - return new RootObject(nativeHandle, globalObject); -} - -RootObject::RootObject(const void* nativeHandle, JSGlobalObject* globalObject) - : m_isValid(true) - , m_nativeHandle(nativeHandle) - , m_globalObject(globalObject) -{ - ASSERT(globalObject); - rootObjectSet()->add(this); -} - -RootObject::~RootObject() -{ - if (m_isValid) - invalidate(); -} - -void RootObject::invalidate() -{ - if (!m_isValid) - return; - - { - HashSet::iterator end = m_runtimeObjects.end(); - for (HashSet::iterator it = m_runtimeObjects.begin(); it != end; ++it) - (*it)->invalidate(); - - m_runtimeObjects.clear(); - } - - m_isValid = false; - - m_nativeHandle = 0; - m_globalObject = 0; - - ProtectCountSet::iterator end = m_protectCountSet.end(); - for (ProtectCountSet::iterator it = m_protectCountSet.begin(); it != end; ++it) { - JSLock lock; - KJS::gcUnprotect(it->first); - } - m_protectCountSet.clear(); - - rootObjectSet()->remove(this); -} - -void RootObject::gcProtect(JSObject* jsObject) -{ - ASSERT(m_isValid); - - if (!m_protectCountSet.contains(jsObject)) { - JSLock lock; - KJS::gcProtect(jsObject); - } - m_protectCountSet.add(jsObject); -} - -void RootObject::gcUnprotect(JSObject* jsObject) -{ - ASSERT(m_isValid); - - if (!jsObject) - return; - - if (m_protectCountSet.count(jsObject) == 1) { - JSLock lock; - KJS::gcUnprotect(jsObject); - } - m_protectCountSet.remove(jsObject); -} - -bool RootObject::gcIsProtected(JSObject* jsObject) -{ - ASSERT(m_isValid); - return m_protectCountSet.contains(jsObject); -} - -const void* RootObject::nativeHandle() const -{ - ASSERT(m_isValid); - return m_nativeHandle; -} - -JSGlobalObject* RootObject::globalObject() const -{ - ASSERT(m_isValid); - return m_globalObject; -} - -void RootObject::addRuntimeObject(RuntimeObjectImp* object) -{ - ASSERT(m_isValid); - ASSERT(!m_runtimeObjects.contains(object)); - - m_runtimeObjects.add(object); -} - -void RootObject::removeRuntimeObject(RuntimeObjectImp* object) -{ - ASSERT(m_isValid); - ASSERT(m_runtimeObjects.contains(object)); - - m_runtimeObjects.remove(object); -} - -} } // namespace KJS::Bindings diff --git a/bindings/runtime_root.h b/bindings/runtime_root.h deleted file mode 100644 index a941b5f..0000000 --- a/bindings/runtime_root.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef RUNTIME_ROOT_H_ -#define RUNTIME_ROOT_H_ - -#include - -#if ENABLE(JAVA_BINDINGS) -#include "jni_jsobject.h" -#endif -#include "protect.h" - -#include -#include -#include - -namespace KJS { - -class Interpreter; -class JSGlobalObject; -class RuntimeObjectImp; - -namespace Bindings { - -class RootObject; - -typedef PassRefPtr (*CreateRootObjectFunction)(void* nativeHandle); -typedef HashCountedSet ProtectCountSet; - -extern RootObject* findProtectingRootObject(JSObject*); -extern RootObject* findRootObject(JSGlobalObject*); - -class RootObject : public RefCounted { - friend class JavaJSObject; - -public: - ~RootObject(); - - static PassRefPtr create(const void* nativeHandle, JSGlobalObject*); - - bool isValid() { return m_isValid; } - void invalidate(); - - void gcProtect(JSObject*); - void gcUnprotect(JSObject*); - bool gcIsProtected(JSObject*); - - const void* nativeHandle() const; - JSGlobalObject* globalObject() const; - - // Must be called from the thread that will be used to access JavaScript. - static void setCreateRootObject(CreateRootObjectFunction); - static CreateRootObjectFunction createRootObject() { - return _createRootObject; - } - - static CFRunLoopRef runLoop() { return _runLoop; } - static CFRunLoopSourceRef performJavaScriptSource() { return _performJavaScriptSource; } - -#if ENABLE(JAVA_BINDINGS) - static void dispatchToJavaScriptThread(JSObjectCallContext *context); -#endif - - void addRuntimeObject(RuntimeObjectImp*); - void removeRuntimeObject(RuntimeObjectImp*); -private: - RootObject(const void* nativeHandle, JSGlobalObject*); - - bool m_isValid; - - const void* m_nativeHandle; - ProtectedPtr m_globalObject; - ProtectCountSet m_protectCountSet; - - HashSet m_runtimeObjects; - - static CreateRootObjectFunction _createRootObject; - static CFRunLoopRef _runLoop; - static CFRunLoopSourceRef _performJavaScriptSource; -}; - -} // namespace Bindings - -} // namespace KJS - -#endif // RUNTIME_ROOT_H_ diff --git a/bindings/test.js b/bindings/test.js deleted file mode 100644 index 5d4f79f..0000000 --- a/bindings/test.js +++ /dev/null @@ -1,19 +0,0 @@ -myInterface.logMessage ("Starting test"); - -myInterface.logMessage ("Testing properties:"); -myInterface.logMessage ("myInterface.doubleValue = " + myInterface.doubleValue); -myInterface.logMessage ("myInterface.intValue = " + myInterface.intValue); -myInterface.logMessage ("myInterface.stringValue = " + myInterface.stringValue); -myInterface.logMessage ("myInterface.booleanValue = " + myInterface.booleanValue); -myInterface.logMessage ("myInterface.nullValue = " + myInterface.nullValue); -myInterface.logMessage ("myInterface.undefinedValue = " + myInterface.undefinedValue); - -myInterface.logMessage ("myInterface.setInt_(666) = " + myInterface.setInt_(666)); -myInterface.logMessage ("myInterface.getInt() = " + myInterface.getInt()); -myInterface.logMessage ("myInterface.getString() = " + myInterface.getString()); -myInterface.logMessage ("myInterface.myInt = " + myInterface.myInt); -myInterface.logMessage ("setting myInterface.myInt = 777"); -myInterface.myInt = 777; -myInterface.logMessage ("myInterface.myInt = " + myInterface.myInt); -myInterface.logMessage ("myInterface.getMySecondInterface().doubleValue = " + myInterface.getMySecondInterface().doubleValue); -myInterface.logMessage ("myInterface.getMySecondInterface() = " + myInterface.getMySecondInterface()); diff --git a/bindings/testC.js b/bindings/testC.js deleted file mode 100644 index 44677c7..0000000 --- a/bindings/testC.js +++ /dev/null @@ -1,21 +0,0 @@ -myInterface.logMessage ("Starting test"); - -myInterface.logMessage ("Testing properties:"); -myInterface.logMessage (" myInterface.doubleValue = " + myInterface.doubleValue); -myInterface.logMessage (" myInterface.intValue = " + myInterface.intValue); -myInterface.logMessage (" myInterface.stringValue = " + myInterface.stringValue); -myInterface.logMessage (" myInterface.booleanValue = " + myInterface.booleanValue); -myInterface.logMessage (" myInterface.nullValue = " + myInterface.nullValue); -myInterface.logMessage (" myInterface.undefinedValue = " + myInterface.undefinedValue); - -myInterface.logMessage ("Testing methods:"); -myInterface.logMessage (" myInterface.setDoubleValue(1234.1234) = " + myInterface.setDoubleValue(1234.1234)); -myInterface.logMessage (" myInterface.setIntValue(5678) = " + myInterface.setIntValue(5678)); -myInterface.logMessage (" myInterface.setStringValue(Goodbye) = " + myInterface.setStringValue('Goodbye')); -myInterface.logMessage (" myInterface.setBooleanValue(false) = " + myInterface.setBooleanValue(false)); - -myInterface.logMessage ("Value of properties after calling setters:"); -myInterface.logMessage (" myInterface.getDoubleValue() = " + myInterface.getDoubleValue()); -myInterface.logMessage (" myInterface.getIntValue() = " + myInterface.getIntValue()); -myInterface.logMessage (" myInterface.getStringValue() = " + myInterface.getStringValue()); -myInterface.logMessage (" myInterface.getBooleanValue() = " + myInterface.getBooleanValue()); diff --git a/bindings/testM.js b/bindings/testM.js deleted file mode 100644 index 7985d21..0000000 --- a/bindings/testM.js +++ /dev/null @@ -1,29 +0,0 @@ -myInterface.logMessage ("Starting test"); - -myInterface.logMessage ("Testing properties:"); - -myInterface.jsobject = new Function ("arg1","arg2","return arg1 + arg2;"); -myInterface.logMessage ("myInterface.jsobject =" + myInterface.jsobject); - -var functionBody = 'return arg1*arg2;' - -myInterface.setJSObject_(new Function ("arg1","arg2",functionBody)); -myInterface.logMessage ("myInterface.jsobject =" + myInterface.jsobject); -myInterface.callJSObject__(5,6); -myInterface.callJSObject__(8,9); - -myInterface.logMessage ("myInterface.setInt_(666) = " + myInterface.setInt_(666)); -myInterface.logMessage ("myInterface.getInt() = " + myInterface.getInt()); -myInterface.logMessage ("myInterface.getString().foo() = " + myInterface.getString().foo()); -myInterface.logMessage ("myInterface.myInt = " + myInterface.myInt); -myInterface.logMessage ("setting myInterface.myInt = 777"); -myInterface.myInt = 777; -myInterface.logMessage ("myInterface.myInt = " + myInterface.myInt); -myInterface.logMessage ("myInterface.getMySecondInterface().doubleValue = " + myInterface.getMySecondInterface().doubleValue); -myInterface.logMessage ("myInterface.getMySecondInterface() = " + myInterface.getMySecondInterface()); - -myInterface.logMessageWithPrefix ("msg", "prefix"); - -var strings = [ "one", "two", "three" ]; - -myInterface.logMessages (strings); \ No newline at end of file diff --git a/bindings/testbindings.cpp b/bindings/testbindings.cpp deleted file mode 100644 index 25f1f99..0000000 --- a/bindings/testbindings.cpp +++ /dev/null @@ -1,422 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ -#include "config.h" -#include -#include -#include - -#include "value.h" -#include "object.h" -#include "types.h" -#include "interpreter.h" - -#include "npruntime_internal.h" - -#include "runtime.h" -#include "runtime_object.h" - - -#define LOG(formatAndArgs...) { \ - fprintf (stderr, "%s: ", __PRETTY_FUNCTION__); \ - fprintf(stderr, formatAndArgs); \ -} - - -// ------------------ NP Interface definition -------------------- -typedef struct -{ - NPObject object; - double doubleValue; - int intValue; - NPVariant stringValue; - bool boolValue; -} MyObject; - - -static bool identifiersInitialized = false; - -#define ID_DOUBLE_VALUE 0 -#define ID_INT_VALUE 1 -#define ID_STRING_VALUE 2 -#define ID_BOOLEAN_VALUE 3 -#define ID_NULL_VALUE 4 -#define ID_UNDEFINED_VALUE 5 -#define NUM_PROPERTY_IDENTIFIERS 6 - -static NPIdentifier myPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS]; -static const NPUTF8 *myPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = { - "doubleValue", - "intValue", - "stringValue", - "booleanValue", - "nullValue", - "undefinedValue" -}; - -#define ID_LOG_MESSAGE 0 -#define ID_SET_DOUBLE_VALUE 1 -#define ID_SET_INT_VALUE 2 -#define ID_SET_STRING_VALUE 3 -#define ID_SET_BOOLEAN_VALUE 4 -#define ID_GET_DOUBLE_VALUE 5 -#define ID_GET_INT_VALUE 6 -#define ID_GET_STRING_VALUE 7 -#define ID_GET_BOOLEAN_VALUE 8 -#define NUM_METHOD_IDENTIFIERS 9 - -static NPIdentifier myMethodIdentifiers[NUM_METHOD_IDENTIFIERS]; -static const NPUTF8 *myMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = { - "logMessage", - "setDoubleValue", - "setIntValue", - "setStringValue", - "setBooleanValue", - "getDoubleValue", - "getIntValue", - "getStringValue", - "getBooleanValue" -}; - -static void initializeIdentifiers() -{ - NPN_GetStringIdentifiers (myPropertyIdentifierNames, NUM_PROPERTY_IDENTIFIERS, myPropertyIdentifiers); - NPN_GetStringIdentifiers (myMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, myMethodIdentifiers); -}; - -bool myHasProperty (NPClass *theClass, NPIdentifier name) -{ - int i; - for (i = 0; i < NUM_PROPERTY_IDENTIFIERS; i++) { - if (name == myPropertyIdentifiers[i]){ - return true; - } - } - return false; -} - -bool myHasMethod (NPClass *theClass, NPIdentifier name) -{ - int i; - for (i = 0; i < NUM_METHOD_IDENTIFIERS; i++) { - if (name == myMethodIdentifiers[i]){ - return true; - } - } - return false; -} - - -void logMessage (const NPVariant *message) -{ - if (message->type == NPVariantStringType) { - char msgBuf[1024]; - strncpy (msgBuf, message->value.stringValue.UTF8Characters, message->value.stringValue.UTF8Length); - msgBuf[message->value.stringValue.UTF8Length] = 0; - printf ("%s\n", msgBuf); - } - else if (message->type == NPVariantDoubleType) - printf ("%f\n", (float)message->value.doubleValue); - else if (message->type == NPVariantInt32Type) - printf ("%d\n", message->value.intValue); - else if (message->type == NPVariantObjectType) - printf ("%p\n", message->value.objectValue); -} - -void setDoubleValue (MyObject *obj, const NPVariant *variant) -{ - if (!NPN_VariantToDouble (variant, &obj->doubleValue)) { - NPUTF8 *msg = "Attempt to set double value with invalid type."; - NPString aString; - aString.UTF8Characters = msg; - aString.UTF8Length = strlen (msg); - NPN_SetException ((NPObject *)obj, &aString); - } -} - -void setIntValue (MyObject *obj, const NPVariant *variant) -{ - if (!NPN_VariantToInt32 (variant, &obj->intValue)) { - NPUTF8 *msg = "Attempt to set int value with invalid type."; - NPString aString; - aString.UTF8Characters = msg; - aString.UTF8Length = strlen (msg); - NPN_SetException ((NPObject *)obj, &aString); - } -} - -void setStringValue (MyObject *obj, const NPVariant *variant) -{ - NPN_ReleaseVariantValue (&obj->stringValue); - NPN_InitializeVariantWithVariant (&obj->stringValue, variant); -} - -void setBooleanValue (MyObject *obj, const NPVariant *variant) -{ - if (!NPN_VariantToBool (variant, (NPBool *)&obj->boolValue)) { - NPUTF8 *msg = "Attempt to set bool value with invalid type."; - NPString aString; - aString.UTF8Characters = msg; - aString.UTF8Length = strlen (msg); - NPN_SetException ((NPObject *)obj, &aString); - } -} - -void getDoubleValue (MyObject *obj, NPVariant *variant) -{ - NPN_InitializeVariantWithDouble (variant, obj->doubleValue); -} - -void getIntValue (MyObject *obj, NPVariant *variant) -{ - NPN_InitializeVariantWithInt32 (variant, obj->intValue); -} - -void getStringValue (MyObject *obj, NPVariant *variant) -{ - NPN_InitializeVariantWithVariant (variant, &obj->stringValue); -} - -void getBooleanValue (MyObject *obj, NPVariant *variant) -{ - NPN_InitializeVariantWithBool (variant, obj->boolValue); -} - -void myGetProperty (MyObject *obj, NPIdentifier name, NPVariant *variant) -{ - if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]){ - getDoubleValue (obj, variant); - } - else if (name == myPropertyIdentifiers[ID_INT_VALUE]){ - getIntValue (obj, variant); - } - else if (name == myPropertyIdentifiers[ID_STRING_VALUE]){ - getStringValue (obj, variant); - } - else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]){ - getBooleanValue (obj, variant); - } - else if (name == myPropertyIdentifiers[ID_NULL_VALUE]){ - return NPN_InitializeVariantAsNull (variant); - } - else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]){ - return NPN_InitializeVariantAsUndefined (variant); - } - else - NPN_InitializeVariantAsUndefined(variant); -} - -void mySetProperty (MyObject *obj, NPIdentifier name, const NPVariant *variant) -{ - if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]) { - setDoubleValue (obj, variant); - } - else if (name == myPropertyIdentifiers[ID_INT_VALUE]) { - setIntValue (obj, variant); - } - else if (name == myPropertyIdentifiers[ID_STRING_VALUE]) { - setStringValue (obj, variant); - } - else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]) { - setBooleanValue (obj, variant); - } - else if (name == myPropertyIdentifiers[ID_NULL_VALUE]) { - // Do nothing! - } - else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]) { - // Do nothing! - } -} - -void myInvoke (MyObject *obj, NPIdentifier name, NPVariant *args, unsigned argCount, NPVariant *result) -{ - if (name == myMethodIdentifiers[ID_LOG_MESSAGE]) { - if (argCount == 1 && NPN_VariantIsString(&args[0])) - logMessage (&args[0]); - NPN_InitializeVariantAsVoid (result); - } - else if (name == myMethodIdentifiers[ID_SET_DOUBLE_VALUE]) { - if (argCount == 1 && NPN_VariantIsDouble (&args[0])) - setDoubleValue (obj, &args[0]); - NPN_InitializeVariantAsVoid (result); - } - else if (name == myMethodIdentifiers[ID_SET_INT_VALUE]) { - if (argCount == 1 && (NPN_VariantIsDouble (&args[0]) || NPN_VariantIsInt32 (&args[0]))) - setIntValue (obj, &args[0]); - NPN_InitializeVariantAsVoid (result); - } - else if (name == myMethodIdentifiers[ID_SET_STRING_VALUE]) { - if (argCount == 1 && NPN_VariantIsString (&args[0])) - setStringValue (obj, &args[0]); - NPN_InitializeVariantAsVoid (result); - } - else if (name == myMethodIdentifiers[ID_SET_BOOLEAN_VALUE]) { - if (argCount == 1 && NPN_VariantIsBool (&args[0])) - setBooleanValue (obj, &args[0]); - NPN_InitializeVariantAsVoid (result); - } - else if (name == myMethodIdentifiers[ID_GET_DOUBLE_VALUE]) { - getDoubleValue (obj, result); - } - else if (name == myMethodIdentifiers[ID_GET_INT_VALUE]) { - getIntValue (obj, result); - } - else if (name == myMethodIdentifiers[ID_GET_STRING_VALUE]) { - getStringValue (obj, result); - } - else if (name == myMethodIdentifiers[ID_GET_BOOLEAN_VALUE]) { - getBooleanValue (obj, result); - } - else - NPN_InitializeVariantAsUndefined (result); -} - -NPObject *myAllocate () -{ - MyObject *newInstance = (MyObject *)malloc (sizeof(MyObject)); - - if (!identifiersInitialized) { - identifiersInitialized = true; - initializeIdentifiers(); - } - - - newInstance->doubleValue = 666.666; - newInstance->intValue = 1234; - newInstance->boolValue = true; - newInstance->stringValue.type = NPVariantType_String; - newInstance->stringValue.value.stringValue.UTF8Length = strlen ("Hello world"); - newInstance->stringValue.value.stringValue.UTF8Characters = strdup ("Hello world"); - - return (NPObject *)newInstance; -} - -void myInvalidate () -{ - // Make sure we've released any remaining references to JavaScript objects. -} - -void myDeallocate (MyObject *obj) -{ - free ((void *)obj); -} - -static NPClass _myFunctionPtrs = { - kNPClassStructVersionCurrent, - (NPAllocateFunctionPtr) myAllocate, - (NPDeallocateFunctionPtr) myDeallocate, - (NPInvalidateFunctionPtr) myInvalidate, - (NPHasMethodFunctionPtr) myHasMethod, - (NPInvokeFunctionPtr) myInvoke, - (NPHasPropertyFunctionPtr) myHasProperty, - (NPGetPropertyFunctionPtr) myGetProperty, - (NPSetPropertyFunctionPtr) mySetProperty, -}; -static NPClass *myFunctionPtrs = &_myFunctionPtrs; - -// -------------------------------------------------------- - -using namespace KJS; -using namespace KJS::Bindings; - -class GlobalImp : public ObjectImp { -public: - virtual UString className() const { return "global"; } -}; - -#define BufferSize 200000 -static char code[BufferSize]; - -const char *readJavaScriptFromFile (const char *file) -{ - FILE *f = fopen(file, "r"); - if (!f) { - fprintf(stderr, "Error opening %s.\n", file); - return 0; - } - - int num = fread(code, 1, BufferSize, f); - code[num] = '\0'; - if(num >= BufferSize) - fprintf(stderr, "Warning: File may have been too long.\n"); - - fclose(f); - - return code; -} - -int main(int argc, char **argv) -{ - // expecting a filename - if (argc < 2) { - fprintf(stderr, "You have to specify at least one filename\n"); - return -1; - } - - bool ret = true; - { - JSLock lock; - - // create interpreter w/ global object - Object global(new GlobalImp()); - Interpreter interp; - interp.setGlobalObject(global); - ExecState *exec = interp.globalExec(); - - MyObject *myObject = (MyObject *)NPN_CreateObject (myFunctionPtrs); - - global.put(exec, Identifier("myInterface"), Instance::createRuntimeObject(Instance::CLanguage, (void *)myObject)); - - for (int i = 1; i < argc; i++) { - const char *code = readJavaScriptFromFile(argv[i]); - - if (code) { - // run - Completion comp(interp.evaluate(code)); - - if (comp.complType() == Throw) { - Value exVal = comp.value(); - char *msg = exVal.toString(exec).ascii(); - int lineno = -1; - if (exVal.type() == ObjectType) { - Value lineVal = Object::dynamicCast(exVal).get(exec,Identifier("line")); - if (lineVal.type() == NumberType) - lineno = int(lineVal.toNumber(exec)); - } - if (lineno != -1) - fprintf(stderr,"Exception, line %d: %s\n",lineno,msg); - else - fprintf(stderr,"Exception: %s\n",msg); - ret = false; - } - else if (comp.complType() == ReturnValue) { - char *msg = comp.value().toString(interp.globalExec()).ascii(); - fprintf(stderr,"Return value: %s\n",msg); - } - } - } - - NPN_ReleaseObject ((NPObject *)myObject); - - } // end block, so that Interpreter and global get deleted - - return ret ? 0 : 3; -} diff --git a/bindings/testbindings.mm b/bindings/testbindings.mm deleted file mode 100644 index 7061503..0000000 --- a/bindings/testbindings.mm +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include - -#import - -#include -#include - -#include "value.h" -#include "object.h" -#include "types.h" -#include "interpreter.h" - -#include "runtime.h" -#include "runtime_object.h" - -#define LOG(formatAndArgs...) { \ - fprintf (stderr, "%s: ", __PRETTY_FUNCTION__); \ - fprintf(stderr, formatAndArgs); \ -} - -@interface MySecondInterface : NSObject -{ - double doubleValue; -} - -- init; - -@end - -@implementation MySecondInterface - -- init -{ - LOG ("\n"); - doubleValue = 666.666; - return self; -} - -@end - -@interface MyFirstInterface : NSObject -{ - int myInt; - MySecondInterface *mySecondInterface; - id jsobject; - NSString *string; -} - -- (int)getInt; -- (void)setInt: (int)anInt; -- (MySecondInterface *)getMySecondInterface; -- (void)logMessage:(NSString *)message; -- (void)setJSObject:(id)jsobject; -@end - -@implementation MyFirstInterface - -+ (NSString *)webScriptNameForSelector:(SEL)aSelector -{ - if (aSelector == @selector(logMessage:)) - return @"logMessage"; - if (aSelector == @selector(logMessages:)) - return @"logMessages"; - if (aSelector == @selector(logMessage:prefix:)) - return @"logMessageWithPrefix"; - return nil; -} - -+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector -{ - return NO; -} - -+ (BOOL)isKeyExcludedFromWebScript:(const char *)name -{ - return NO; -} - -/* -- (id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)args; -{ - NSLog (@"Call to undefined method %@", name); - NSLog (@"%d args\n", [args count]); - int i; - for (i = 0; i < [args count]; i++) { - NSLog (@"%d: %@\n", i, [args objectAtIndex:i]); - } - return @"success"; -} -*/ - -/* -- (id)valueForUndefinedKey:(NSString *)key -{ - NSLog (@"%s: key = %@", __PRETTY_FUNCTION__, key); - return @"aValue"; -} -*/ - -- (void)setValue:(id)value forUndefinedKey:(NSString *)key -{ - NSLog (@"%s: key = %@", __PRETTY_FUNCTION__, key); -} - -- init -{ - LOG ("\n"); - mySecondInterface = [[MySecondInterface alloc] init]; - return self; -} - -- (void)dealloc -{ - LOG ("\n"); - [mySecondInterface release]; - [super dealloc]; -} - -- (int)getInt -{ - LOG ("myInt = %d\n", myInt); - return myInt; -} - -- (void)setInt: (int)anInt -{ - LOG ("anInt = %d\n", anInt); - myInt = anInt; -} - -- (NSString *)getString -{ - return string; -} - -- (MySecondInterface *)getMySecondInterface -{ - LOG ("\n"); - return mySecondInterface; -} - -- (void)logMessage:(NSString *)message -{ - printf ("%s\n", [message lossyCString]); -} - -- (void)logMessages:(id)messages -{ - int i, count = [[messages valueForKey:@"length"] intValue]; - for (i = 0; i < count; i++) - printf ("%s\n", [[messages webScriptValueAtIndex:i] lossyCString]); -} - -- (void)logMessage:(NSString *)message prefix:(NSString *)prefix -{ - printf ("%s:%s\n", [prefix lossyCString], [message lossyCString]); -} - -- (void)setJSObject:(id)jso -{ - [jsobject autorelease]; - jsobject = [jso retain]; -} - -- (void)callJSObject:(int)arg1 :(int)arg2 -{ - id foo1 = [jsobject callWebScriptMethod:@"call" withArguments:[NSArray arrayWithObjects:jsobject, [NSNumber numberWithInt:arg1], [NSNumber numberWithInt:arg2], nil]]; - printf ("foo (via call) = %s\n", [[foo1 description] lossyCString] ); - id foo2 = [jsobject callWebScriptMethod:@"apply" withArguments:[NSArray arrayWithObjects:jsobject, [NSArray arrayWithObjects:[NSNumber numberWithInt:arg1], [NSNumber numberWithInt:arg2], nil], nil]]; - printf ("foo (via apply) = %s\n", [[foo2 description] lossyCString] ); -} - -@end - - -using namespace KJS; -using namespace KJS::Bindings; - -class GlobalImp : public ObjectImp { -public: - virtual UString className() const { return "global"; } -}; - -#define BufferSize 200000 -static char code[BufferSize]; - -const char *readJavaScriptFromFile (const char *file) -{ - FILE *f = fopen(file, "r"); - if (!f) { - fprintf(stderr, "Error opening %s.\n", file); - return 0; - } - - int num = fread(code, 1, BufferSize, f); - code[num] = '\0'; - if(num >= BufferSize) - fprintf(stderr, "Warning: File may have been too long.\n"); - - fclose(f); - - return code; -} - -int main(int argc, char **argv) -{ - // expecting a filename - if (argc < 2) { - fprintf(stderr, "You have to specify at least one filename\n"); - return -1; - } - - bool ret = true; - { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - JSLock lock; - - // create interpreter w/ global object - Object global(new GlobalImp()); - Interpreter interp; - interp.setGlobalObject(global); - ExecState *exec = interp.globalExec(); - - MyFirstInterface *myInterface = [[MyFirstInterface alloc] init]; - - global.put(exec, Identifier("myInterface"), Instance::createRuntimeObject(Instance::ObjectiveCLanguage, (void *)myInterface)); - - for (int i = 1; i < argc; i++) { - const char *code = readJavaScriptFromFile(argv[i]); - - if (code) { - // run - Completion comp(interp.evaluate(code)); - - if (comp.complType() == Throw) { - Value exVal = comp.value(); - char *msg = exVal.toString(exec).ascii(); - int lineno = -1; - if (exVal.type() == ObjectType) { - Value lineVal = Object::dynamicCast(exVal).get(exec,Identifier("line")); - if (lineVal.type() == NumberType) - lineno = int(lineVal.toNumber(exec)); - } - if (lineno != -1) - fprintf(stderr,"Exception, line %d: %s\n",lineno,msg); - else - fprintf(stderr,"Exception: %s\n",msg); - ret = false; - } - else if (comp.complType() == ReturnValue) { - char *msg = comp.value().toString(interp.globalExec()).ascii(); - fprintf(stderr,"Return value: %s\n",msg); - } - } - } - - [myInterface release]; - [pool drain]; - } // end block, so that Interpreter and global get deleted - - return ret ? 0 : 3; -} diff --git a/bindings/testbindings.pro b/bindings/testbindings.pro deleted file mode 100644 index e6e0b9d..0000000 --- a/bindings/testbindings.pro +++ /dev/null @@ -1,8 +0,0 @@ -QT -= gui - -include(../../WebKit.pri) -INCLUDEPATH += .. ../kjs . -qt-port:INCLUDEPATH += bindings/qt - -SOURCES += testqtbindings.cpp - diff --git a/bindings/testqtbindings.cpp b/bindings/testqtbindings.cpp deleted file mode 100644 index 490b3ff..0000000 --- a/bindings/testqtbindings.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2006 Trolltech ASA - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "config.h" -#include -#include -#include - -#include "value.h" -#include "object.h" -#include "types.h" -#include "interpreter.h" - -#include "qobject.h" -#include "qdebug.h" - -#include "runtime.h" -#include "runtime_object.h" - - - -class MyObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString testString READ testString WRITE setTestString) - Q_PROPERTY(int testInt READ testInt WRITE setTestInt) - -public: - MyObject() : QObject(0), integer(0){} - - void setTestString(const QString &str) { - qDebug() << "called setTestString" << str; - string = str; - } - void setTestInt(int i) { - qDebug() << "called setTestInt" << i; - integer = i; - } - QString testString() const { - qDebug() << "called testString" << string; - return string; - } - int testInt() const { - qDebug() << "called testInt" << integer; - return integer; - } - QString string; - int integer; - -public slots: - void foo() { qDebug() << "foo invoked"; } -}; - -// -------------------------------------------------------- - -using namespace KJS; -using namespace KJS::Bindings; - -class Global : public JSObject { -public: - virtual UString className() const { return "global"; } -}; - -static char code[] = - "myInterface.foo();\n" - "myInterface.testString = \"Hello\";\n" - "str = myInterface.testString;\n" - "myInterface.testInt = 10;\n" - "i = myInterface.testInt;\n"; - -int main(int argc, char** argv) -{ - // expecting a filename - bool ret = true; - { - JSLock lock; - - // create interpreter w/ global object - Global* global = new Global(); - - // create interpreter - RefPtr interp = new Interpreter(global); - ExecState* exec = interp->globalExec(); - - MyObject* myObject = new MyObject; - - global->put(exec, Identifier("myInterface"), Instance::createRuntimeObject(Instance::QtLanguage, (void*)myObject)); - - - if (code) { - // run - Completion comp(interp->evaluate("", 0, code)); - - if (comp.complType() == Throw) { - qDebug() << "exception thrown"; - JSValue* exVal = comp.value(); - char* msg = exVal->toString(exec).ascii(); - int lineno = -1; - if (exVal->type() == ObjectType) { - JSValue* lineVal = exVal->getObject()->get(exec, Identifier("line")); - if (lineVal->type() == NumberType) - lineno = int(lineVal->toNumber(exec)); - } - if (lineno != -1) - fprintf(stderr,"Exception, line %d: %s\n",lineno,msg); - else - fprintf(stderr,"Exception: %s\n",msg); - ret = false; - } - else if (comp.complType() == ReturnValue) { - char* msg = comp.value()->toString(interp->globalExec()).ascii(); - fprintf(stderr,"Return value: %s\n",msg); - } - } - - } // end block, so that Interpreter and global get deleted - - return ret ? 0 : 1; -} - -#include "testqtbindings.moc" diff --git a/bytecode/CodeBlock.cpp b/bytecode/CodeBlock.cpp new file mode 100644 index 0000000..be060d0 --- /dev/null +++ b/bytecode/CodeBlock.cpp @@ -0,0 +1,1686 @@ +/* + * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2008 Cameron Zwarich + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "CodeBlock.h" + +#include "JIT.h" +#include "JSValue.h" +#include "Interpreter.h" +#include "Debugger.h" +#include "BytecodeGenerator.h" +#include +#include + +#define DUMP_CODE_BLOCK_STATISTICS 0 + +namespace JSC { + +#if !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING) + +static UString escapeQuotes(const UString& str) +{ + UString result = str; + int pos = 0; + while ((pos = result.find('\"', pos)) >= 0) { + result = result.substr(0, pos) + "\"\\\"\"" + result.substr(pos + 1); + pos += 4; + } + return result; +} + +static UString valueToSourceString(ExecState* exec, JSValuePtr val) +{ + if (val.isString()) { + UString result("\""); + result += escapeQuotes(val.toString(exec)) + "\""; + return result; + } + + return val.toString(exec); +} + +static CString registerName(int r) +{ + if (r == missingThisObjectMarker()) + return ""; + + return (UString("r") + UString::from(r)).UTF8String(); +} + +static CString constantName(ExecState* exec, int k, JSValuePtr value) +{ + return (valueToSourceString(exec, value) + "(@k" + UString::from(k) + ")").UTF8String(); +} + +static CString idName(int id0, const Identifier& ident) +{ + return (ident.ustring() + "(@id" + UString::from(id0) +")").UTF8String(); +} + +static UString regexpToSourceString(RegExp* regExp) +{ + UString pattern = UString("/") + regExp->pattern() + "/"; + if (regExp->global()) + pattern += "g"; + if (regExp->ignoreCase()) + pattern += "i"; + if (regExp->multiline()) + pattern += "m"; + + return pattern; +} + +static CString regexpName(int re, RegExp* regexp) +{ + return (regexpToSourceString(regexp) + "(@re" + UString::from(re) + ")").UTF8String(); +} + +static UString pointerToSourceString(void* p) +{ + char buffer[2 + 2 * sizeof(void*) + 1]; // 0x [two characters per byte] \0 + snprintf(buffer, sizeof(buffer), "%p", p); + return buffer; +} + +NEVER_INLINE static const char* debugHookName(int debugHookID) +{ + switch (static_cast(debugHookID)) { + case DidEnterCallFrame: + return "didEnterCallFrame"; + case WillLeaveCallFrame: + return "willLeaveCallFrame"; + case WillExecuteStatement: + return "willExecuteStatement"; + case WillExecuteProgram: + return "willExecuteProgram"; + case DidExecuteProgram: + return "didExecuteProgram"; + case DidReachBreakpoint: + return "didReachBreakpoint"; + } + + ASSERT_NOT_REACHED(); + return ""; +} + +static int locationForOffset(const Vector::const_iterator& begin, Vector::const_iterator& it, int offset) +{ + return it - begin + offset; +} + +static void printUnaryOp(int location, Vector::const_iterator& it, const char* op) +{ + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + + printf("[%4d] %s\t\t %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str()); +} + +static void printBinaryOp(int location, Vector::const_iterator& it, const char* op) +{ + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int r2 = (++it)->u.operand; + printf("[%4d] %s\t\t %s, %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str()); +} + +static void printConditionalJump(const Vector::const_iterator& begin, Vector::const_iterator& it, int location, const char* op) +{ + int r0 = (++it)->u.operand; + int offset = (++it)->u.operand; + printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(r0).c_str(), offset, locationForOffset(begin, it, offset)); +} + +static void printGetByIdOp(int location, Vector::const_iterator& it, const Vector& m_identifiers, const char* op) +{ + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int id0 = (++it)->u.operand; + printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str()); + it += 4; +} + +static void printPutByIdOp(int location, Vector::const_iterator& it, const Vector& m_identifiers, const char* op) +{ + int r0 = (++it)->u.operand; + int id0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str()); + it += 4; +} + +#if ENABLE(JIT) +static bool isGlobalResolve(OpcodeID opcodeID) +{ + return opcodeID == op_resolve_global; +} + +static bool isPropertyAccess(OpcodeID opcodeID) +{ + switch (opcodeID) { + case op_get_by_id_self: + case op_get_by_id_proto: + case op_get_by_id_chain: + case op_get_by_id_self_list: + case op_get_by_id_proto_list: + case op_put_by_id_transition: + case op_put_by_id_replace: + case op_get_by_id: + case op_put_by_id: + case op_get_by_id_generic: + case op_put_by_id_generic: + case op_get_array_length: + case op_get_string_length: + return true; + default: + return false; + } +} + +static unsigned instructionOffsetForNth(ExecState* exec, const Vector& instructions, int nth, bool (*predicate)(OpcodeID)) +{ + size_t i = 0; + while (i < instructions.size()) { + OpcodeID currentOpcode = exec->interpreter()->getOpcodeID(instructions[i].u.opcode); + if (predicate(currentOpcode)) { + if (!--nth) + return i; + } + i += opcodeLengths[currentOpcode]; + } + + ASSERT_NOT_REACHED(); + return 0; +} + +static void printGlobalResolveInfo(const GlobalResolveInfo& resolveInfo, unsigned instructionOffset) +{ + printf(" [%4d] %s: %s\n", instructionOffset, "resolve_global", pointerToSourceString(resolveInfo.structure).UTF8String().c_str()); +} + +static void printStructureStubInfo(const StructureStubInfo& stubInfo, unsigned instructionOffset) +{ + switch (stubInfo.opcodeID) { + case op_get_by_id_self: + printf(" [%4d] %s: %s\n", instructionOffset, "get_by_id_self", pointerToSourceString(stubInfo.u.getByIdSelf.baseObjectStructure).UTF8String().c_str()); + return; + case op_get_by_id_proto: + printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_proto", pointerToSourceString(stubInfo.u.getByIdProto.baseObjectStructure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.getByIdProto.prototypeStructure).UTF8String().c_str()); + return; + case op_get_by_id_chain: + printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_chain", pointerToSourceString(stubInfo.u.getByIdChain.baseObjectStructure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.getByIdChain.chain).UTF8String().c_str()); + return; + case op_get_by_id_self_list: + printf(" [%4d] %s: %s (%d)\n", instructionOffset, "op_get_by_id_self_list", pointerToSourceString(stubInfo.u.getByIdSelfList.structureList).UTF8String().c_str(), stubInfo.u.getByIdSelfList.listSize); + return; + case op_get_by_id_proto_list: + printf(" [%4d] %s: %s (%d)\n", instructionOffset, "op_get_by_id_proto_list", pointerToSourceString(stubInfo.u.getByIdProtoList.structureList).UTF8String().c_str(), stubInfo.u.getByIdProtoList.listSize); + return; + case op_put_by_id_transition: + printf(" [%4d] %s: %s, %s, %s\n", instructionOffset, "put_by_id_transition", pointerToSourceString(stubInfo.u.putByIdTransition.previousStructure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.putByIdTransition.structure).UTF8String().c_str(), pointerToSourceString(stubInfo.u.putByIdTransition.chain).UTF8String().c_str()); + return; + case op_put_by_id_replace: + printf(" [%4d] %s: %s\n", instructionOffset, "put_by_id_replace", pointerToSourceString(stubInfo.u.putByIdReplace.baseObjectStructure).UTF8String().c_str()); + return; + case op_get_by_id: + printf(" [%4d] %s\n", instructionOffset, "get_by_id"); + return; + case op_put_by_id: + printf(" [%4d] %s\n", instructionOffset, "put_by_id"); + return; + case op_get_by_id_generic: + printf(" [%4d] %s\n", instructionOffset, "op_get_by_id_generic"); + return; + case op_put_by_id_generic: + printf(" [%4d] %s\n", instructionOffset, "op_put_by_id_generic"); + return; + case op_get_array_length: + printf(" [%4d] %s\n", instructionOffset, "op_get_array_length"); + return; + case op_get_string_length: + printf(" [%4d] %s\n", instructionOffset, "op_get_string_length"); + return; + default: + ASSERT_NOT_REACHED(); + } +} +#endif + +void CodeBlock::printStructure(const char* name, const Instruction* vPC, int operand) const +{ + unsigned instructionOffset = vPC - m_instructions.begin(); + printf(" [%4d] %s: %s\n", instructionOffset, name, pointerToSourceString(vPC[operand].u.structure).UTF8String().c_str()); +} + +void CodeBlock::printStructures(const Instruction* vPC) const +{ + Interpreter* interpreter = m_globalData->interpreter; + unsigned instructionOffset = vPC - m_instructions.begin(); + + if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id)) { + printStructure("get_by_id", vPC, 4); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self)) { + printStructure("get_by_id_self", vPC, 4); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto)) { + printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_proto", pointerToSourceString(vPC[4].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[5].u.structure).UTF8String().c_str()); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition)) { + printf(" [%4d] %s: %s, %s, %s\n", instructionOffset, "put_by_id_transition", pointerToSourceString(vPC[4].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[5].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[6].u.structureChain).UTF8String().c_str()); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain)) { + printf(" [%4d] %s: %s, %s\n", instructionOffset, "get_by_id_chain", pointerToSourceString(vPC[4].u.structure).UTF8String().c_str(), pointerToSourceString(vPC[5].u.structureChain).UTF8String().c_str()); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id)) { + printStructure("put_by_id", vPC, 4); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_replace)) { + printStructure("put_by_id_replace", vPC, 4); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global)) { + printStructure("resolve_global", vPC, 4); + return; + } + + // These m_instructions doesn't ref Structures. + ASSERT(vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_call) || vPC[0].u.opcode == interpreter->getOpcode(op_call_eval) || vPC[0].u.opcode == interpreter->getOpcode(op_construct)); +} + +void CodeBlock::dump(ExecState* exec) const +{ + if (m_instructions.isEmpty()) { + printf("No instructions available.\n"); + return; + } + + size_t instructionCount = 0; + + for (size_t i = 0; i < m_instructions.size(); i += opcodeLengths[exec->interpreter()->getOpcodeID(m_instructions[i].u.opcode)]) + ++instructionCount; + + printf("%lu m_instructions; %lu bytes at %p; %d parameter(s); %d callee register(s)\n\n", + static_cast(instructionCount), + static_cast(m_instructions.size() * sizeof(Instruction)), + this, m_numParameters, m_numCalleeRegisters); + + Vector::const_iterator begin = m_instructions.begin(); + Vector::const_iterator end = m_instructions.end(); + for (Vector::const_iterator it = begin; it != end; ++it) + dump(exec, begin, it); + + if (!m_identifiers.isEmpty()) { + printf("\nIdentifiers:\n"); + size_t i = 0; + do { + printf(" id%u = %s\n", static_cast(i), m_identifiers[i].ascii()); + ++i; + } while (i != m_identifiers.size()); + } + + if (!m_constantRegisters.isEmpty()) { + printf("\nConstants:\n"); + unsigned registerIndex = m_numVars; + size_t i = 0; + do { + printf(" r%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].jsValue(exec)).ascii()); + ++i; + ++registerIndex; + } while (i < m_constantRegisters.size()); + } + + if (m_rareData && !m_rareData->m_unexpectedConstants.isEmpty()) { + printf("\nUnexpected Constants:\n"); + size_t i = 0; + do { + printf(" k%u = %s\n", static_cast(i), valueToSourceString(exec, m_rareData->m_unexpectedConstants[i]).ascii()); + ++i; + } while (i < m_rareData->m_unexpectedConstants.size()); + } + + if (m_rareData && !m_rareData->m_regexps.isEmpty()) { + printf("\nm_regexps:\n"); + size_t i = 0; + do { + printf(" re%u = %s\n", static_cast(i), regexpToSourceString(m_rareData->m_regexps[i].get()).ascii()); + ++i; + } while (i < m_rareData->m_regexps.size()); + } + +#if ENABLE(JIT) + if (!m_globalResolveInfos.isEmpty() || !m_structureStubInfos.isEmpty()) + printf("\nStructures:\n"); + + if (!m_globalResolveInfos.isEmpty()) { + size_t i = 0; + do { + printGlobalResolveInfo(m_globalResolveInfos[i], instructionOffsetForNth(exec, m_instructions, i + 1, isGlobalResolve)); + ++i; + } while (i < m_globalResolveInfos.size()); + } + if (!m_structureStubInfos.isEmpty()) { + size_t i = 0; + do { + printStructureStubInfo(m_structureStubInfos[i], instructionOffsetForNth(exec, m_instructions, i + 1, isPropertyAccess)); + ++i; + } while (i < m_structureStubInfos.size()); + } +#else + if (!m_globalResolveInstructions.isEmpty() || !m_propertyAccessInstructions.isEmpty()) + printf("\nStructures:\n"); + + if (!m_globalResolveInstructions.isEmpty()) { + size_t i = 0; + do { + printStructures(&m_instructions[m_globalResolveInstructions[i]]); + ++i; + } while (i < m_globalResolveInstructions.size()); + } + if (!m_propertyAccessInstructions.isEmpty()) { + size_t i = 0; + do { + printStructures(&m_instructions[m_propertyAccessInstructions[i]]); + ++i; + } while (i < m_propertyAccessInstructions.size()); + } +#endif + + if (m_rareData && !m_rareData->m_exceptionHandlers.isEmpty()) { + printf("\nException Handlers:\n"); + unsigned i = 0; + do { + printf("\t %d: { start: [%4d] end: [%4d] target: [%4d] }\n", i + 1, m_rareData->m_exceptionHandlers[i].start, m_rareData->m_exceptionHandlers[i].end, m_rareData->m_exceptionHandlers[i].target); + ++i; + } while (i < m_rareData->m_exceptionHandlers.size()); + } + + if (m_rareData && !m_rareData->m_immediateSwitchJumpTables.isEmpty()) { + printf("Immediate Switch Jump Tables:\n"); + unsigned i = 0; + do { + printf(" %1d = {\n", i); + int entry = 0; + Vector::const_iterator end = m_rareData->m_immediateSwitchJumpTables[i].branchOffsets.end(); + for (Vector::const_iterator iter = m_rareData->m_immediateSwitchJumpTables[i].branchOffsets.begin(); iter != end; ++iter, ++entry) { + if (!*iter) + continue; + printf("\t\t%4d => %04d\n", entry + m_rareData->m_immediateSwitchJumpTables[i].min, *iter); + } + printf(" }\n"); + ++i; + } while (i < m_rareData->m_immediateSwitchJumpTables.size()); + } + + if (m_rareData && !m_rareData->m_characterSwitchJumpTables.isEmpty()) { + printf("\nCharacter Switch Jump Tables:\n"); + unsigned i = 0; + do { + printf(" %1d = {\n", i); + int entry = 0; + Vector::const_iterator end = m_rareData->m_characterSwitchJumpTables[i].branchOffsets.end(); + for (Vector::const_iterator iter = m_rareData->m_characterSwitchJumpTables[i].branchOffsets.begin(); iter != end; ++iter, ++entry) { + if (!*iter) + continue; + ASSERT(!((i + m_rareData->m_characterSwitchJumpTables[i].min) & ~0xFFFF)); + UChar ch = static_cast(entry + m_rareData->m_characterSwitchJumpTables[i].min); + printf("\t\t\"%s\" => %04d\n", UString(&ch, 1).ascii(), *iter); + } + printf(" }\n"); + ++i; + } while (i < m_rareData->m_characterSwitchJumpTables.size()); + } + + if (m_rareData && !m_rareData->m_stringSwitchJumpTables.isEmpty()) { + printf("\nString Switch Jump Tables:\n"); + unsigned i = 0; + do { + printf(" %1d = {\n", i); + StringJumpTable::StringOffsetTable::const_iterator end = m_rareData->m_stringSwitchJumpTables[i].offsetTable.end(); + for (StringJumpTable::StringOffsetTable::const_iterator iter = m_rareData->m_stringSwitchJumpTables[i].offsetTable.begin(); iter != end; ++iter) + printf("\t\t\"%s\" => %04d\n", UString(iter->first).ascii(), iter->second.branchOffset); + printf(" }\n"); + ++i; + } while (i < m_rareData->m_stringSwitchJumpTables.size()); + } + + printf("\n"); +} + +void CodeBlock::dump(ExecState* exec, const Vector::const_iterator& begin, Vector::const_iterator& it) const +{ + int location = it - begin; + switch (exec->interpreter()->getOpcodeID(it->u.opcode)) { + case op_enter: { + printf("[%4d] enter\n", location); + break; + } + case op_enter_with_activation: { + int r0 = (++it)->u.operand; + printf("[%4d] enter_with_activation %s\n", location, registerName(r0).c_str()); + break; + } + case op_create_arguments: { + printf("[%4d] create_arguments\n", location); + break; + } + case op_convert_this: { + int r0 = (++it)->u.operand; + printf("[%4d] convert_this %s\n", location, registerName(r0).c_str()); + break; + } + case op_unexpected_load: { + int r0 = (++it)->u.operand; + int k0 = (++it)->u.operand; + printf("[%4d] unexpected_load\t %s, %s\n", location, registerName(r0).c_str(), constantName(exec, k0, unexpectedConstant(k0)).c_str()); + break; + } + case op_new_object: { + int r0 = (++it)->u.operand; + printf("[%4d] new_object\t %s\n", location, registerName(r0).c_str()); + break; + } + case op_new_array: { + int dst = (++it)->u.operand; + int argv = (++it)->u.operand; + int argc = (++it)->u.operand; + printf("[%4d] new_array\t %s, %s, %d\n", location, registerName(dst).c_str(), registerName(argv).c_str(), argc); + break; + } + case op_new_regexp: { + int r0 = (++it)->u.operand; + int re0 = (++it)->u.operand; + printf("[%4d] new_regexp\t %s, %s\n", location, registerName(r0).c_str(), regexpName(re0, regexp(re0)).c_str()); + break; + } + case op_mov: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + printf("[%4d] mov\t\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str()); + break; + } + case op_not: { + printUnaryOp(location, it, "not"); + break; + } + case op_eq: { + printBinaryOp(location, it, "eq"); + break; + } + case op_eq_null: { + printUnaryOp(location, it, "eq_null"); + break; + } + case op_neq: { + printBinaryOp(location, it, "neq"); + break; + } + case op_neq_null: { + printUnaryOp(location, it, "neq_null"); + break; + } + case op_stricteq: { + printBinaryOp(location, it, "stricteq"); + break; + } + case op_nstricteq: { + printBinaryOp(location, it, "nstricteq"); + break; + } + case op_less: { + printBinaryOp(location, it, "less"); + break; + } + case op_lesseq: { + printBinaryOp(location, it, "lesseq"); + break; + } + case op_pre_inc: { + int r0 = (++it)->u.operand; + printf("[%4d] pre_inc\t\t %s\n", location, registerName(r0).c_str()); + break; + } + case op_pre_dec: { + int r0 = (++it)->u.operand; + printf("[%4d] pre_dec\t\t %s\n", location, registerName(r0).c_str()); + break; + } + case op_post_inc: { + printUnaryOp(location, it, "post_inc"); + break; + } + case op_post_dec: { + printUnaryOp(location, it, "post_dec"); + break; + } + case op_to_jsnumber: { + printUnaryOp(location, it, "to_jsnumber"); + break; + } + case op_negate: { + printUnaryOp(location, it, "negate"); + break; + } + case op_add: { + printBinaryOp(location, it, "add"); + ++it; + break; + } + case op_mul: { + printBinaryOp(location, it, "mul"); + ++it; + break; + } + case op_div: { + printBinaryOp(location, it, "div"); + break; + } + case op_mod: { + printBinaryOp(location, it, "mod"); + break; + } + case op_sub: { + printBinaryOp(location, it, "sub"); + ++it; + break; + } + case op_lshift: { + printBinaryOp(location, it, "lshift"); + break; + } + case op_rshift: { + printBinaryOp(location, it, "rshift"); + break; + } + case op_urshift: { + printBinaryOp(location, it, "urshift"); + break; + } + case op_bitand: { + printBinaryOp(location, it, "bitand"); + ++it; + break; + } + case op_bitxor: { + printBinaryOp(location, it, "bitxor"); + ++it; + break; + } + case op_bitor: { + printBinaryOp(location, it, "bitor"); + ++it; + break; + } + case op_bitnot: { + printUnaryOp(location, it, "bitnot"); + break; + } + case op_instanceof: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int r2 = (++it)->u.operand; + int r3 = (++it)->u.operand; + printf("[%4d] instanceof\t\t %s, %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), registerName(r3).c_str()); + break; + } + case op_typeof: { + printUnaryOp(location, it, "typeof"); + break; + } + case op_is_undefined: { + printUnaryOp(location, it, "is_undefined"); + break; + } + case op_is_boolean: { + printUnaryOp(location, it, "is_boolean"); + break; + } + case op_is_number: { + printUnaryOp(location, it, "is_number"); + break; + } + case op_is_string: { + printUnaryOp(location, it, "is_string"); + break; + } + case op_is_object: { + printUnaryOp(location, it, "is_object"); + break; + } + case op_is_function: { + printUnaryOp(location, it, "is_function"); + break; + } + case op_in: { + printBinaryOp(location, it, "in"); + break; + } + case op_resolve: { + int r0 = (++it)->u.operand; + int id0 = (++it)->u.operand; + printf("[%4d] resolve\t\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str()); + break; + } + case op_resolve_skip: { + int r0 = (++it)->u.operand; + int id0 = (++it)->u.operand; + int skipLevels = (++it)->u.operand; + printf("[%4d] resolve_skip\t %s, %s, %d\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), skipLevels); + break; + } + case op_resolve_global: { + int r0 = (++it)->u.operand; + JSValuePtr scope = JSValuePtr((++it)->u.jsCell); + int id0 = (++it)->u.operand; + printf("[%4d] resolve_global\t %s, %s, %s\n", location, registerName(r0).c_str(), valueToSourceString(exec, scope).ascii(), idName(id0, m_identifiers[id0]).c_str()); + it += 2; + break; + } + case op_get_scoped_var: { + int r0 = (++it)->u.operand; + int index = (++it)->u.operand; + int skipLevels = (++it)->u.operand; + printf("[%4d] get_scoped_var\t %s, %d, %d\n", location, registerName(r0).c_str(), index, skipLevels); + break; + } + case op_put_scoped_var: { + int index = (++it)->u.operand; + int skipLevels = (++it)->u.operand; + int r0 = (++it)->u.operand; + printf("[%4d] put_scoped_var\t %d, %d, %s\n", location, index, skipLevels, registerName(r0).c_str()); + break; + } + case op_get_global_var: { + int r0 = (++it)->u.operand; + JSValuePtr scope = JSValuePtr((++it)->u.jsCell); + int index = (++it)->u.operand; + printf("[%4d] get_global_var\t %s, %s, %d\n", location, registerName(r0).c_str(), valueToSourceString(exec, scope).ascii(), index); + break; + } + case op_put_global_var: { + JSValuePtr scope = JSValuePtr((++it)->u.jsCell); + int index = (++it)->u.operand; + int r0 = (++it)->u.operand; + printf("[%4d] put_global_var\t %s, %d, %s\n", location, valueToSourceString(exec, scope).ascii(), index, registerName(r0).c_str()); + break; + } + case op_resolve_base: { + int r0 = (++it)->u.operand; + int id0 = (++it)->u.operand; + printf("[%4d] resolve_base\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str()); + break; + } + case op_resolve_with_base: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int id0 = (++it)->u.operand; + printf("[%4d] resolve_with_base %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str()); + break; + } + case op_resolve_func: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int id0 = (++it)->u.operand; + printf("[%4d] resolve_func\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str()); + break; + } + case op_get_by_id: { + printGetByIdOp(location, it, m_identifiers, "get_by_id"); + break; + } + case op_get_by_id_self: { + printGetByIdOp(location, it, m_identifiers, "get_by_id_self"); + break; + } + case op_get_by_id_self_list: { + printGetByIdOp(location, it, m_identifiers, "get_by_id_self_list"); + break; + } + case op_get_by_id_proto: { + printGetByIdOp(location, it, m_identifiers, "get_by_id_proto"); + break; + } + case op_get_by_id_proto_list: { + printGetByIdOp(location, it, m_identifiers, "op_get_by_id_proto_list"); + break; + } + case op_get_by_id_chain: { + printGetByIdOp(location, it, m_identifiers, "get_by_id_chain"); + break; + } + case op_get_by_id_generic: { + printGetByIdOp(location, it, m_identifiers, "get_by_id_generic"); + break; + } + case op_get_array_length: { + printGetByIdOp(location, it, m_identifiers, "get_array_length"); + break; + } + case op_get_string_length: { + printGetByIdOp(location, it, m_identifiers, "get_string_length"); + break; + } + case op_put_by_id: { + printPutByIdOp(location, it, m_identifiers, "put_by_id"); + break; + } + case op_put_by_id_replace: { + printPutByIdOp(location, it, m_identifiers, "put_by_id_replace"); + break; + } + case op_put_by_id_transition: { + printPutByIdOp(location, it, m_identifiers, "put_by_id_transition"); + break; + } + case op_put_by_id_generic: { + printPutByIdOp(location, it, m_identifiers, "put_by_id_generic"); + break; + } + case op_put_getter: { + int r0 = (++it)->u.operand; + int id0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + printf("[%4d] put_getter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str()); + break; + } + case op_put_setter: { + int r0 = (++it)->u.operand; + int id0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + printf("[%4d] put_setter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str()); + break; + } + case op_del_by_id: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int id0 = (++it)->u.operand; + printf("[%4d] del_by_id\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str()); + break; + } + case op_get_by_val: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int r2 = (++it)->u.operand; + printf("[%4d] get_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str()); + break; + } + case op_put_by_val: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int r2 = (++it)->u.operand; + printf("[%4d] put_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str()); + break; + } + case op_del_by_val: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int r2 = (++it)->u.operand; + printf("[%4d] del_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str()); + break; + } + case op_put_by_index: { + int r0 = (++it)->u.operand; + unsigned n0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + printf("[%4d] put_by_index\t %s, %u, %s\n", location, registerName(r0).c_str(), n0, registerName(r1).c_str()); + break; + } + case op_jmp: { + int offset = (++it)->u.operand; + printf("[%4d] jmp\t\t %d(->%d)\n", location, offset, locationForOffset(begin, it, offset)); + break; + } + case op_loop: { + int offset = (++it)->u.operand; + printf("[%4d] loop\t\t %d(->%d)\n", location, offset, locationForOffset(begin, it, offset)); + break; + } + case op_jtrue: { + printConditionalJump(begin, it, location, "jtrue"); + break; + } + case op_loop_if_true: { + printConditionalJump(begin, it, location, "loop_if_true"); + break; + } + case op_jfalse: { + printConditionalJump(begin, it, location, "jfalse"); + break; + } + case op_jeq_null: { + printConditionalJump(begin, it, location, "jeq_null"); + break; + } + case op_jneq_null: { + printConditionalJump(begin, it, location, "jneq_null"); + break; + } + case op_jnless: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int offset = (++it)->u.operand; + printf("[%4d] jnless\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); + break; + } + case op_loop_if_less: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int offset = (++it)->u.operand; + printf("[%4d] loop_if_less\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); + break; + } + case op_loop_if_lesseq: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + int offset = (++it)->u.operand; + printf("[%4d] loop_if_lesseq\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); + break; + } + case op_switch_imm: { + int tableIndex = (++it)->u.operand; + int defaultTarget = (++it)->u.operand; + int scrutineeRegister = (++it)->u.operand; + printf("[%4d] switch_imm\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str()); + break; + } + case op_switch_char: { + int tableIndex = (++it)->u.operand; + int defaultTarget = (++it)->u.operand; + int scrutineeRegister = (++it)->u.operand; + printf("[%4d] switch_char\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str()); + break; + } + case op_switch_string: { + int tableIndex = (++it)->u.operand; + int defaultTarget = (++it)->u.operand; + int scrutineeRegister = (++it)->u.operand; + printf("[%4d] switch_string\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str()); + break; + } + case op_new_func: { + int r0 = (++it)->u.operand; + int f0 = (++it)->u.operand; + printf("[%4d] new_func\t\t %s, f%d\n", location, registerName(r0).c_str(), f0); + break; + } + case op_new_func_exp: { + int r0 = (++it)->u.operand; + int f0 = (++it)->u.operand; + printf("[%4d] new_func_exp\t %s, f%d\n", location, registerName(r0).c_str(), f0); + break; + } + case op_call: { + int dst = (++it)->u.operand; + int func = (++it)->u.operand; + int argCount = (++it)->u.operand; + int registerOffset = (++it)->u.operand; + printf("[%4d] call\t\t %s, %s, %d, %d\n", location, registerName(dst).c_str(), registerName(func).c_str(), argCount, registerOffset); + break; + } + case op_call_eval: { + int dst = (++it)->u.operand; + int func = (++it)->u.operand; + int argCount = (++it)->u.operand; + int registerOffset = (++it)->u.operand; + printf("[%4d] call_eval\t %s, %s, %d, %d\n", location, registerName(dst).c_str(), registerName(func).c_str(), argCount, registerOffset); + break; + } + case op_tear_off_activation: { + int r0 = (++it)->u.operand; + printf("[%4d] tear_off_activation\t %s\n", location, registerName(r0).c_str()); + break; + } + case op_tear_off_arguments: { + printf("[%4d] tear_off_arguments\n", location); + break; + } + case op_ret: { + int r0 = (++it)->u.operand; + printf("[%4d] ret\t\t %s\n", location, registerName(r0).c_str()); + break; + } + case op_construct: { + int dst = (++it)->u.operand; + int func = (++it)->u.operand; + int argCount = (++it)->u.operand; + int registerOffset = (++it)->u.operand; + int proto = (++it)->u.operand; + int thisRegister = (++it)->u.operand; + printf("[%4d] construct\t %s, %s, %d, %d, %s, %s\n", location, registerName(dst).c_str(), registerName(func).c_str(), argCount, registerOffset, registerName(proto).c_str(), registerName(thisRegister).c_str()); + break; + } + case op_construct_verify: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + printf("[%4d] construct_verify\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str()); + break; + } + case op_get_pnames: { + int r0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + printf("[%4d] get_pnames\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str()); + break; + } + case op_next_pname: { + int dest = (++it)->u.operand; + int iter = (++it)->u.operand; + int offset = (++it)->u.operand; + printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(dest).c_str(), registerName(iter).c_str(), offset, locationForOffset(begin, it, offset)); + break; + } + case op_push_scope: { + int r0 = (++it)->u.operand; + printf("[%4d] push_scope\t %s\n", location, registerName(r0).c_str()); + break; + } + case op_pop_scope: { + printf("[%4d] pop_scope\n", location); + break; + } + case op_push_new_scope: { + int r0 = (++it)->u.operand; + int id0 = (++it)->u.operand; + int r1 = (++it)->u.operand; + printf("[%4d] push_new_scope \t%s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str()); + break; + } + case op_jmp_scopes: { + int scopeDelta = (++it)->u.operand; + int offset = (++it)->u.operand; + printf("[%4d] jmp_scopes\t^%d, %d(->%d)\n", location, scopeDelta, offset, locationForOffset(begin, it, offset)); + break; + } + case op_catch: { + int r0 = (++it)->u.operand; + printf("[%4d] catch\t\t %s\n", location, registerName(r0).c_str()); + break; + } + case op_throw: { + int r0 = (++it)->u.operand; + printf("[%4d] throw\t\t %s\n", location, registerName(r0).c_str()); + break; + } + case op_new_error: { + int r0 = (++it)->u.operand; + int errorType = (++it)->u.operand; + int k0 = (++it)->u.operand; + printf("[%4d] new_error\t %s, %d, %s\n", location, registerName(r0).c_str(), errorType, constantName(exec, k0, unexpectedConstant(k0)).c_str()); + break; + } + case op_jsr: { + int retAddrDst = (++it)->u.operand; + int offset = (++it)->u.operand; + printf("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(retAddrDst).c_str(), offset, locationForOffset(begin, it, offset)); + break; + } + case op_sret: { + int retAddrSrc = (++it)->u.operand; + printf("[%4d] sret\t\t %s\n", location, registerName(retAddrSrc).c_str()); + break; + } + case op_debug: { + int debugHookID = (++it)->u.operand; + int firstLine = (++it)->u.operand; + int lastLine = (++it)->u.operand; + printf("[%4d] debug\t\t %s, %d, %d\n", location, debugHookName(debugHookID), firstLine, lastLine); + break; + } + case op_profile_will_call: { + int function = (++it)->u.operand; + printf("[%4d] profile_will_call %s\n", location, registerName(function).c_str()); + break; + } + case op_profile_did_call: { + int function = (++it)->u.operand; + printf("[%4d] profile_did_call\t %s\n", location, registerName(function).c_str()); + break; + } + case op_end: { + int r0 = (++it)->u.operand; + printf("[%4d] end\t\t %s\n", location, registerName(r0).c_str()); + break; + } + } +} + +#endif // !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING) + +#if DUMP_CODE_BLOCK_STATISTICS +static HashSet liveCodeBlockSet; +#endif + +#define FOR_EACH_MEMBER_VECTOR(macro) \ + macro(instructions) \ + macro(globalResolveInfos) \ + macro(structureStubInfos) \ + macro(callLinkInfos) \ + macro(linkedCallerList) \ + macro(identifiers) \ + macro(functionExpressions) \ + macro(constantRegisters) + +#define FOR_EACH_MEMBER_VECTOR_RARE_DATA(macro) \ + macro(regexps) \ + macro(functions) \ + macro(unexpectedConstants) \ + macro(exceptionHandlers) \ + macro(immediateSwitchJumpTables) \ + macro(characterSwitchJumpTables) \ + macro(stringSwitchJumpTables) \ + macro(functionRegisterInfos) + +#define FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(macro) \ + macro(expressionInfo) \ + macro(lineInfo) \ + macro(getByIdExceptionInfo) \ + macro(pcVector) + +template +static size_t sizeInBytes(const Vector& vector) +{ + return vector.capacity() * sizeof(T); +} + +void CodeBlock::dumpStatistics() +{ +#if DUMP_CODE_BLOCK_STATISTICS + #define DEFINE_VARS(name) size_t name##IsNotEmpty = 0; size_t name##TotalSize = 0; + FOR_EACH_MEMBER_VECTOR(DEFINE_VARS) + FOR_EACH_MEMBER_VECTOR_RARE_DATA(DEFINE_VARS) + FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(DEFINE_VARS) + #undef DEFINE_VARS + + // Non-vector data members + size_t evalCodeCacheIsNotEmpty = 0; + + size_t symbolTableIsNotEmpty = 0; + size_t symbolTableTotalSize = 0; + + size_t hasExceptionInfo = 0; + size_t hasRareData = 0; + + size_t isFunctionCode = 0; + size_t isGlobalCode = 0; + size_t isEvalCode = 0; + + HashSet::const_iterator end = liveCodeBlockSet.end(); + for (HashSet::const_iterator it = liveCodeBlockSet.begin(); it != end; ++it) { + CodeBlock* codeBlock = *it; + + #define GET_STATS(name) if (!codeBlock->m_##name.isEmpty()) { name##IsNotEmpty++; name##TotalSize += sizeInBytes(codeBlock->m_##name); } + FOR_EACH_MEMBER_VECTOR(GET_STATS) + #undef GET_STATS + + if (!codeBlock->m_symbolTable.isEmpty()) { + symbolTableIsNotEmpty++; + symbolTableTotalSize += (codeBlock->m_symbolTable.capacity() * (sizeof(SymbolTable::KeyType) + sizeof(SymbolTable::MappedType))); + } + + if (codeBlock->m_exceptionInfo) { + hasExceptionInfo++; + #define GET_STATS(name) if (!codeBlock->m_exceptionInfo->m_##name.isEmpty()) { name##IsNotEmpty++; name##TotalSize += sizeInBytes(codeBlock->m_exceptionInfo->m_##name); } + FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(GET_STATS) + #undef GET_STATS + } + + if (codeBlock->m_rareData) { + hasRareData++; + #define GET_STATS(name) if (!codeBlock->m_rareData->m_##name.isEmpty()) { name##IsNotEmpty++; name##TotalSize += sizeInBytes(codeBlock->m_rareData->m_##name); } + FOR_EACH_MEMBER_VECTOR_RARE_DATA(GET_STATS) + #undef GET_STATS + + if (!codeBlock->m_rareData->m_evalCodeCache.isEmpty()) + evalCodeCacheIsNotEmpty++; + } + + switch (codeBlock->codeType()) { + case FunctionCode: + ++isFunctionCode; + break; + case GlobalCode: + ++isGlobalCode; + break; + case EvalCode: + ++isEvalCode; + break; + } + } + + size_t totalSize = 0; + + #define GET_TOTAL_SIZE(name) totalSize += name##TotalSize; + FOR_EACH_MEMBER_VECTOR(GET_TOTAL_SIZE) + FOR_EACH_MEMBER_VECTOR_RARE_DATA(GET_TOTAL_SIZE) + FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(GET_TOTAL_SIZE) + #undef GET_TOTAL_SIZE + + totalSize += symbolTableTotalSize; + totalSize += (liveCodeBlockSet.size() * sizeof(CodeBlock)); + + printf("Number of live CodeBlocks: %d\n", liveCodeBlockSet.size()); + printf("Size of a single CodeBlock [sizeof(CodeBlock)]: %zu\n", sizeof(CodeBlock)); + printf("Size of all CodeBlocks: %zu\n", totalSize); + printf("Average size of a CodeBlock: %zu\n", totalSize / liveCodeBlockSet.size()); + + printf("Number of FunctionCode CodeBlocks: %zu (%.3f%%)\n", isFunctionCode, static_cast(isFunctionCode) * 100.0 / liveCodeBlockSet.size()); + printf("Number of GlobalCode CodeBlocks: %zu (%.3f%%)\n", isGlobalCode, static_cast(isGlobalCode) * 100.0 / liveCodeBlockSet.size()); + printf("Number of EvalCode CodeBlocks: %zu (%.3f%%)\n", isEvalCode, static_cast(isEvalCode) * 100.0 / liveCodeBlockSet.size()); + + printf("Number of CodeBlocks with exception info: %zu (%.3f%%)\n", hasExceptionInfo, static_cast(hasExceptionInfo) * 100.0 / liveCodeBlockSet.size()); + printf("Number of CodeBlocks with rare data: %zu (%.3f%%)\n", hasRareData, static_cast(hasRareData) * 100.0 / liveCodeBlockSet.size()); + + #define PRINT_STATS(name) printf("Number of CodeBlocks with " #name ": %zu\n", name##IsNotEmpty); printf("Size of all " #name ": %zu\n", name##TotalSize); + FOR_EACH_MEMBER_VECTOR(PRINT_STATS) + FOR_EACH_MEMBER_VECTOR_RARE_DATA(PRINT_STATS) + FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(PRINT_STATS) + #undef PRINT_STATS + + printf("Number of CodeBlocks with evalCodeCache: %zu\n", evalCodeCacheIsNotEmpty); + printf("Number of CodeBlocks with symbolTable: %zu\n", symbolTableIsNotEmpty); + + printf("Size of all symbolTables: %zu\n", symbolTableTotalSize); + +#else + printf("Dumping CodeBlock statistics is not enabled.\n"); +#endif +} + + +CodeBlock::CodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr sourceProvider, unsigned sourceOffset) + : m_numCalleeRegisters(0) + , m_numConstants(0) + , m_numVars(0) + , m_numParameters(0) + , m_ownerNode(ownerNode) + , m_globalData(0) +#ifndef NDEBUG + , m_instructionCount(0) +#endif + , m_needsFullScopeChain(ownerNode->needsActivation()) + , m_usesEval(ownerNode->usesEval()) + , m_isNumericCompareFunction(false) + , m_codeType(codeType) + , m_source(sourceProvider) + , m_sourceOffset(sourceOffset) + , m_exceptionInfo(new ExceptionInfo) +{ + ASSERT(m_source); + +#if DUMP_CODE_BLOCK_STATISTICS + liveCodeBlockSet.add(this); +#endif +} + +CodeBlock::~CodeBlock() +{ +#if !ENABLE(JIT) + for (size_t size = m_globalResolveInstructions.size(), i = 0; i < size; ++i) + derefStructures(&m_instructions[m_globalResolveInstructions[i]]); + + for (size_t size = m_propertyAccessInstructions.size(), i = 0; i < size; ++i) + derefStructures(&m_instructions[m_propertyAccessInstructions[i]]); +#else + for (size_t size = m_globalResolveInfos.size(), i = 0; i < size; ++i) { + if (m_globalResolveInfos[i].structure) + m_globalResolveInfos[i].structure->deref(); + } + + for (size_t size = m_structureStubInfos.size(), i = 0; i < size; ++i) + m_structureStubInfos[i].deref(); + + for (size_t size = m_callLinkInfos.size(), i = 0; i < size; ++i) { + CallLinkInfo* callLinkInfo = &m_callLinkInfos[i]; + if (callLinkInfo->isLinked()) + callLinkInfo->callee->removeCaller(callLinkInfo); + } + + unlinkCallers(); +#endif + +#if DUMP_CODE_BLOCK_STATISTICS + liveCodeBlockSet.remove(this); +#endif +} + +#if ENABLE(JIT) +void CodeBlock::unlinkCallers() +{ + size_t size = m_linkedCallerList.size(); + for (size_t i = 0; i < size; ++i) { + CallLinkInfo* currentCaller = m_linkedCallerList[i]; + JIT::unlinkCall(currentCaller); + currentCaller->setUnlinked(); + } + m_linkedCallerList.clear(); +} +#endif + +void CodeBlock::derefStructures(Instruction* vPC) const +{ + Interpreter* interpreter = m_globalData->interpreter; + + if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self)) { + vPC[4].u.structure->deref(); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto)) { + vPC[4].u.structure->deref(); + vPC[5].u.structure->deref(); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain)) { + vPC[4].u.structure->deref(); + vPC[5].u.structureChain->deref(); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition)) { + vPC[4].u.structure->deref(); + vPC[5].u.structure->deref(); + vPC[6].u.structureChain->deref(); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_replace)) { + vPC[4].u.structure->deref(); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global)) { + if(vPC[4].u.structure) + vPC[4].u.structure->deref(); + return; + } + if ((vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto_list)) + || (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self_list))) { + PolymorphicAccessStructureList* polymorphicStructures = vPC[4].u.polymorphicStructures; + polymorphicStructures->derefStructures(vPC[5].u.operand); + delete polymorphicStructures; + return; + } + + // These instructions don't ref their Structures. + ASSERT(vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_get_array_length) || vPC[0].u.opcode == interpreter->getOpcode(op_get_string_length)); +} + +void CodeBlock::refStructures(Instruction* vPC) const +{ + Interpreter* interpreter = m_globalData->interpreter; + + if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_self)) { + vPC[4].u.structure->ref(); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_proto)) { + vPC[4].u.structure->ref(); + vPC[5].u.structure->ref(); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_chain)) { + vPC[4].u.structure->ref(); + vPC[5].u.structureChain->ref(); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_transition)) { + vPC[4].u.structure->ref(); + vPC[5].u.structure->ref(); + vPC[6].u.structureChain->ref(); + return; + } + if (vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_replace)) { + vPC[4].u.structure->ref(); + return; + } + + // These instructions don't ref their Structures. + ASSERT(vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id) || vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_generic)); +} + +void CodeBlock::mark() +{ + for (size_t i = 0; i < m_constantRegisters.size(); ++i) + if (!m_constantRegisters[i].marked()) + m_constantRegisters[i].mark(); + + for (size_t i = 0; i < m_functionExpressions.size(); ++i) + m_functionExpressions[i]->body()->mark(); + + if (m_rareData) { + for (size_t i = 0; i < m_rareData->m_functions.size(); ++i) + m_rareData->m_functions[i]->body()->mark(); + + for (size_t i = 0; i < m_rareData->m_unexpectedConstants.size(); ++i) { + if (!m_rareData->m_unexpectedConstants[i].marked()) + m_rareData->m_unexpectedConstants[i].mark(); + } + m_rareData->m_evalCodeCache.mark(); + } +} + +void CodeBlock::reparseForExceptionInfoIfNecessary(CallFrame* callFrame) +{ + if (m_exceptionInfo) + return; + + ScopeChainNode* scopeChain = callFrame->scopeChain(); + if (m_needsFullScopeChain) { + ScopeChain sc(scopeChain); + int scopeDelta = sc.localDepth(); + if (m_codeType == EvalCode) + scopeDelta -= static_cast(this)->baseScopeDepth(); + else if (m_codeType == FunctionCode) + scopeDelta++; // Compilation of function code assumes activation is not on the scope chain yet. + ASSERT(scopeDelta >= 0); + while (scopeDelta--) + scopeChain = scopeChain->next; + } + + switch (m_codeType) { + case FunctionCode: { + FunctionBodyNode* ownerFunctionBodyNode = static_cast(m_ownerNode); + RefPtr newFunctionBody = m_globalData->parser->reparse(m_globalData, ownerFunctionBodyNode); + ASSERT(newFunctionBody); + newFunctionBody->finishParsing(ownerFunctionBodyNode->copyParameters(), ownerFunctionBodyNode->parameterCount()); + + m_globalData->scopeNodeBeingReparsed = newFunctionBody.get(); + + CodeBlock& newCodeBlock = newFunctionBody->bytecodeForExceptionInfoReparse(scopeChain, this); + ASSERT(newCodeBlock.m_exceptionInfo); + ASSERT(newCodeBlock.m_instructionCount == m_instructionCount); + +#if ENABLE(JIT) + JIT::compile(m_globalData, &newCodeBlock); + ASSERT(newCodeBlock.m_jitCode.codeSize == m_jitCode.codeSize); +#endif + + m_exceptionInfo.set(newCodeBlock.m_exceptionInfo.release()); + + m_globalData->scopeNodeBeingReparsed = 0; + + break; + } + case EvalCode: { + EvalNode* ownerEvalNode = static_cast(m_ownerNode); + RefPtr newEvalBody = m_globalData->parser->reparse(m_globalData, ownerEvalNode); + + m_globalData->scopeNodeBeingReparsed = newEvalBody.get(); + + EvalCodeBlock& newCodeBlock = newEvalBody->bytecodeForExceptionInfoReparse(scopeChain, this); + ASSERT(newCodeBlock.m_exceptionInfo); + ASSERT(newCodeBlock.m_instructionCount == m_instructionCount); + +#if ENABLE(JIT) + JIT::compile(m_globalData, &newCodeBlock); + ASSERT(newCodeBlock.m_jitCode.codeSize == m_jitCode.codeSize); +#endif + + m_exceptionInfo.set(newCodeBlock.m_exceptionInfo.release()); + + m_globalData->scopeNodeBeingReparsed = 0; + + break; + } + default: + // CodeBlocks for Global code blocks are transient and therefore to not gain from + // from throwing out there exception information. + ASSERT_NOT_REACHED(); + } +} + +HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset) +{ + ASSERT(bytecodeOffset < m_instructionCount); + + if (!m_rareData) + return 0; + + Vector& exceptionHandlers = m_rareData->m_exceptionHandlers; + for (size_t i = 0; i < exceptionHandlers.size(); ++i) { + // Handlers are ordered innermost first, so the first handler we encounter + // that contains the source address is the correct handler to use. + if (exceptionHandlers[i].start <= bytecodeOffset && exceptionHandlers[i].end >= bytecodeOffset) + return &exceptionHandlers[i]; + } + + return 0; +} + +int CodeBlock::lineNumberForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset) +{ + ASSERT(bytecodeOffset < m_instructionCount); + + reparseForExceptionInfoIfNecessary(callFrame); + ASSERT(m_exceptionInfo); + + if (!m_exceptionInfo->m_lineInfo.size()) + return m_ownerNode->source().firstLine(); // Empty function + + int low = 0; + int high = m_exceptionInfo->m_lineInfo.size(); + while (low < high) { + int mid = low + (high - low) / 2; + if (m_exceptionInfo->m_lineInfo[mid].instructionOffset <= bytecodeOffset) + low = mid + 1; + else + high = mid; + } + + if (!low) + return m_ownerNode->source().firstLine(); + return m_exceptionInfo->m_lineInfo[low - 1].lineNumber; +} + +int CodeBlock::expressionRangeForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset) +{ + ASSERT(bytecodeOffset < m_instructionCount); + + reparseForExceptionInfoIfNecessary(callFrame); + ASSERT(m_exceptionInfo); + + if (!m_exceptionInfo->m_expressionInfo.size()) { + // We didn't think anything could throw. Apparently we were wrong. + startOffset = 0; + endOffset = 0; + divot = 0; + return lineNumberForBytecodeOffset(callFrame, bytecodeOffset); + } + + int low = 0; + int high = m_exceptionInfo->m_expressionInfo.size(); + while (low < high) { + int mid = low + (high - low) / 2; + if (m_exceptionInfo->m_expressionInfo[mid].instructionOffset <= bytecodeOffset) + low = mid + 1; + else + high = mid; + } + + ASSERT(low); + if (!low) { + startOffset = 0; + endOffset = 0; + divot = 0; + return lineNumberForBytecodeOffset(callFrame, bytecodeOffset); + } + + startOffset = m_exceptionInfo->m_expressionInfo[low - 1].startOffset; + endOffset = m_exceptionInfo->m_expressionInfo[low - 1].endOffset; + divot = m_exceptionInfo->m_expressionInfo[low - 1].divotPoint + m_sourceOffset; + return lineNumberForBytecodeOffset(callFrame, bytecodeOffset); +} + +bool CodeBlock::getByIdExceptionInfoForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset, OpcodeID& opcodeID) +{ + ASSERT(bytecodeOffset < m_instructionCount); + + reparseForExceptionInfoIfNecessary(callFrame); + ASSERT(m_exceptionInfo); + + if (!m_exceptionInfo->m_getByIdExceptionInfo.size()) + return false; + + int low = 0; + int high = m_exceptionInfo->m_getByIdExceptionInfo.size(); + while (low < high) { + int mid = low + (high - low) / 2; + if (m_exceptionInfo->m_getByIdExceptionInfo[mid].bytecodeOffset <= bytecodeOffset) + low = mid + 1; + else + high = mid; + } + + if (!low || m_exceptionInfo->m_getByIdExceptionInfo[low - 1].bytecodeOffset != bytecodeOffset) + return false; + + opcodeID = m_exceptionInfo->m_getByIdExceptionInfo[low - 1].isOpConstruct ? op_construct : op_instanceof; + return true; +} + +#if ENABLE(JIT) +bool CodeBlock::functionRegisterForBytecodeOffset(unsigned bytecodeOffset, int& functionRegisterIndex) +{ + ASSERT(bytecodeOffset < m_instructionCount); + + if (!m_rareData || !m_rareData->m_functionRegisterInfos.size()) + return false; + + int low = 0; + int high = m_rareData->m_functionRegisterInfos.size(); + while (low < high) { + int mid = low + (high - low) / 2; + if (m_rareData->m_functionRegisterInfos[mid].bytecodeOffset <= bytecodeOffset) + low = mid + 1; + else + high = mid; + } + + if (!low || m_rareData->m_functionRegisterInfos[low - 1].bytecodeOffset != bytecodeOffset) + return false; + + functionRegisterIndex = m_rareData->m_functionRegisterInfos[low - 1].functionRegisterIndex; + return true; +} +#endif + +#if !ENABLE(JIT) +bool CodeBlock::hasGlobalResolveInstructionAtBytecodeOffset(unsigned bytecodeOffset) +{ + if (m_globalResolveInstructions.isEmpty()) + return false; + + int low = 0; + int high = m_globalResolveInstructions.size(); + while (low < high) { + int mid = low + (high - low) / 2; + if (m_globalResolveInstructions[mid] <= bytecodeOffset) + low = mid + 1; + else + high = mid; + } + + if (!low || m_globalResolveInstructions[low - 1] != bytecodeOffset) + return false; + return true; +} +#else +bool CodeBlock::hasGlobalResolveInfoAtBytecodeOffset(unsigned bytecodeOffset) +{ + if (m_globalResolveInfos.isEmpty()) + return false; + + int low = 0; + int high = m_globalResolveInfos.size(); + while (low < high) { + int mid = low + (high - low) / 2; + if (m_globalResolveInfos[mid].bytecodeOffset <= bytecodeOffset) + low = mid + 1; + else + high = mid; + } + + if (!low || m_globalResolveInfos[low - 1].bytecodeOffset != bytecodeOffset) + return false; + return true; +} +#endif + +#if ENABLE(JIT) +void CodeBlock::setJITCode(JITCodeRef& jitCode) +{ + m_jitCode = jitCode; +#if !ENABLE(OPCODE_SAMPLING) + if (!BytecodeGenerator::dumpsGeneratedCode()) + m_instructions.clear(); +#endif +} +#endif + +void CodeBlock::shrinkToFit() +{ + m_instructions.shrinkToFit(); + +#if !ENABLE(JIT) + m_propertyAccessInstructions.shrinkToFit(); + m_globalResolveInstructions.shrinkToFit(); +#else + m_structureStubInfos.shrinkToFit(); + m_globalResolveInfos.shrinkToFit(); + m_callLinkInfos.shrinkToFit(); + m_linkedCallerList.shrinkToFit(); +#endif + + m_identifiers.shrinkToFit(); + m_functionExpressions.shrinkToFit(); + m_constantRegisters.shrinkToFit(); + + if (m_exceptionInfo) { + m_exceptionInfo->m_expressionInfo.shrinkToFit(); + m_exceptionInfo->m_lineInfo.shrinkToFit(); + m_exceptionInfo->m_getByIdExceptionInfo.shrinkToFit(); + } + + if (m_rareData) { + m_rareData->m_exceptionHandlers.shrinkToFit(); + m_rareData->m_functions.shrinkToFit(); + m_rareData->m_unexpectedConstants.shrinkToFit(); + m_rareData->m_regexps.shrinkToFit(); + m_rareData->m_immediateSwitchJumpTables.shrinkToFit(); + m_rareData->m_characterSwitchJumpTables.shrinkToFit(); + m_rareData->m_stringSwitchJumpTables.shrinkToFit(); +#if ENABLE(JIT) + m_rareData->m_functionRegisterInfos.shrinkToFit(); +#endif + } +} + +} // namespace JSC diff --git a/bytecode/CodeBlock.h b/bytecode/CodeBlock.h new file mode 100644 index 0000000..e5d78d3 --- /dev/null +++ b/bytecode/CodeBlock.h @@ -0,0 +1,584 @@ +/* + * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2008 Cameron Zwarich + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CodeBlock_h +#define CodeBlock_h + +#include "EvalCodeCache.h" +#include "Instruction.h" +#include "JSGlobalObject.h" +#include "JumpTable.h" +#include "Nodes.h" +#include "RegExp.h" +#include "UString.h" +#include +#include + +#if ENABLE(JIT) +#include "StructureStubInfo.h" +#endif + +namespace JSC { + + class ExecState; + + enum CodeType { GlobalCode, EvalCode, FunctionCode }; + + static ALWAYS_INLINE int missingThisObjectMarker() { return std::numeric_limits::max(); } + + struct HandlerInfo { + uint32_t start; + uint32_t end; + uint32_t target; + uint32_t scopeDepth; +#if ENABLE(JIT) + void* nativeCode; +#endif + }; + +#if ENABLE(JIT) + // The code, and the associated pool from which it was allocated. + struct JITCodeRef { + void* code; +#ifndef NDEBUG + unsigned codeSize; +#endif + RefPtr executablePool; + + JITCodeRef() + : code(0) +#ifndef NDEBUG + , codeSize(0) +#endif + { + } + + JITCodeRef(void* code, PassRefPtr executablePool) + : code(code) +#ifndef NDEBUG + , codeSize(0) +#endif + , executablePool(executablePool) + { + } + }; +#endif + + struct ExpressionRangeInfo { + enum { + MaxOffset = (1 << 7) - 1, + MaxDivot = (1 << 25) - 1 + }; + uint32_t instructionOffset : 25; + uint32_t divotPoint : 25; + uint32_t startOffset : 7; + uint32_t endOffset : 7; + }; + + struct LineInfo { + uint32_t instructionOffset; + int32_t lineNumber; + }; + + // Both op_construct and op_instanceof require a use of op_get_by_id to get + // the prototype property from an object. The exception messages for exceptions + // thrown by these instances op_get_by_id need to reflect this. + struct GetByIdExceptionInfo { + unsigned bytecodeOffset : 31; + bool isOpConstruct : 1; + }; + +#if ENABLE(JIT) + struct CallLinkInfo { + CallLinkInfo() + : callReturnLocation(0) + , hotPathBegin(0) + , hotPathOther(0) + , coldPathOther(0) + , callee(0) + { + } + + unsigned bytecodeIndex; + void* callReturnLocation; + void* hotPathBegin; + void* hotPathOther; + void* coldPathOther; + CodeBlock* callee; + unsigned position; + + void setUnlinked() { callee = 0; } + bool isLinked() { return callee; } + }; + + struct FunctionRegisterInfo { + FunctionRegisterInfo(unsigned bytecodeOffset, int functionRegisterIndex) + : bytecodeOffset(bytecodeOffset) + , functionRegisterIndex(functionRegisterIndex) + { + } + + unsigned bytecodeOffset; + int functionRegisterIndex; + }; + + struct GlobalResolveInfo { + GlobalResolveInfo(unsigned bytecodeOffset) + : structure(0) + , offset(0) + , bytecodeOffset(bytecodeOffset) + { + } + + Structure* structure; + unsigned offset; + unsigned bytecodeOffset; + }; + + struct PC { + PC(ptrdiff_t nativePCOffset, unsigned bytecodeIndex) + : nativePCOffset(nativePCOffset) + , bytecodeIndex(bytecodeIndex) + { + } + + ptrdiff_t nativePCOffset; + unsigned bytecodeIndex; + }; + + // valueAtPosition helpers for the binaryChop algorithm below. + + inline void* getStructureStubInfoReturnLocation(StructureStubInfo* structureStubInfo) + { + return structureStubInfo->callReturnLocation; + } + + inline void* getCallLinkInfoReturnLocation(CallLinkInfo* callLinkInfo) + { + return callLinkInfo->callReturnLocation; + } + + inline ptrdiff_t getNativePCOffset(PC* pc) + { + return pc->nativePCOffset; + } + + // Binary chop algorithm, calls valueAtPosition on pre-sorted elements in array, + // compares result with key (KeyTypes should be comparable with '--', '<', '>'). + // Optimized for cases where the array contains the key, checked by assertions. + template + inline ArrayType* binaryChop(ArrayType* array, size_t size, KeyType key) + { + // The array must contain at least one element (pre-condition, array does conatin key). + // If the array only contains one element, no need to do the comparison. + while (size > 1) { + // Pick an element to check, half way through the array, and read the value. + int pos = (size - 1) >> 1; + KeyType val = valueAtPosition(&array[pos]); + + // If the key matches, success! + if (val == key) + return &array[pos]; + // The item we are looking for is smaller than the item being check; reduce the value of 'size', + // chopping off the right hand half of the array. + else if (key < val) + size = pos; + // Discard all values in the left hand half of the array, up to and including the item at pos. + else { + size -= (pos + 1); + array += (pos + 1); + } + + // 'size' should never reach zero. + ASSERT(size); + } + + // If we reach this point we've chopped down to one element, no need to check it matches + ASSERT(size == 1); + ASSERT(key == valueAtPosition(&array[0])); + return &array[0]; + } +#endif + + class CodeBlock { + friend class JIT; + public: + CodeBlock(ScopeNode* ownerNode, CodeType, PassRefPtr, unsigned sourceOffset); + ~CodeBlock(); + + void mark(); + void refStructures(Instruction* vPC) const; + void derefStructures(Instruction* vPC) const; +#if ENABLE(JIT) + void unlinkCallers(); +#endif + + static void dumpStatistics(); + +#if !defined(NDEBUG) || ENABLE_OPCODE_SAMPLING + void dump(ExecState*) const; + void printStructures(const Instruction*) const; + void printStructure(const char* name, const Instruction*, int operand) const; +#endif + + inline bool isKnownNotImmediate(int index) + { + if (index == m_thisRegister) + return true; + + if (isConstantRegisterIndex(index)) + return getConstant(index).isCell(); + + return false; + } + + ALWAYS_INLINE bool isConstantRegisterIndex(int index) + { + return index >= m_numVars && index < m_numVars + m_numConstants; + } + + ALWAYS_INLINE JSValuePtr getConstant(int index) + { + return m_constantRegisters[index - m_numVars].getJSValue(); + } + + ALWAYS_INLINE bool isTemporaryRegisterIndex(int index) + { + return index >= m_numVars + m_numConstants; + } + + HandlerInfo* handlerForBytecodeOffset(unsigned bytecodeOffset); + int lineNumberForBytecodeOffset(CallFrame*, unsigned bytecodeOffset); + int expressionRangeForBytecodeOffset(CallFrame*, unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset); + bool getByIdExceptionInfoForBytecodeOffset(CallFrame*, unsigned bytecodeOffset, OpcodeID&); + +#if ENABLE(JIT) + void addCaller(CallLinkInfo* caller) + { + caller->callee = this; + caller->position = m_linkedCallerList.size(); + m_linkedCallerList.append(caller); + } + + void removeCaller(CallLinkInfo* caller) + { + unsigned pos = caller->position; + unsigned lastPos = m_linkedCallerList.size() - 1; + + if (pos != lastPos) { + m_linkedCallerList[pos] = m_linkedCallerList[lastPos]; + m_linkedCallerList[pos]->position = pos; + } + m_linkedCallerList.shrink(lastPos); + } + + StructureStubInfo& getStubInfo(void* returnAddress) + { + return *(binaryChop(m_structureStubInfos.begin(), m_structureStubInfos.size(), returnAddress)); + } + + CallLinkInfo& getCallLinkInfo(void* returnAddress) + { + return *(binaryChop(m_callLinkInfos.begin(), m_callLinkInfos.size(), returnAddress)); + } + + unsigned getBytecodeIndex(CallFrame* callFrame, void* nativePC) + { + reparseForExceptionInfoIfNecessary(callFrame); + ptrdiff_t nativePCOffset = reinterpret_cast(nativePC) - reinterpret_cast(m_jitCode.code); + return binaryChop(m_exceptionInfo->m_pcVector.begin(), m_exceptionInfo->m_pcVector.size(), nativePCOffset)->bytecodeIndex; + } + + bool functionRegisterForBytecodeOffset(unsigned bytecodeOffset, int& functionRegisterIndex); +#endif + + void setIsNumericCompareFunction(bool isNumericCompareFunction) { m_isNumericCompareFunction = isNumericCompareFunction; } + bool isNumericCompareFunction() { return m_isNumericCompareFunction; } + + Vector& instructions() { return m_instructions; } +#ifndef NDEBUG + void setInstructionCount(unsigned instructionCount) { m_instructionCount = instructionCount; } +#endif + +#if ENABLE(JIT) + void setJITCode(JITCodeRef& jitCode); + void* jitCode() { return m_jitCode.code; } + ExecutablePool* executablePool() { return m_jitCode.executablePool.get(); } +#endif + + ScopeNode* ownerNode() const { return m_ownerNode; } + + void setGlobalData(JSGlobalData* globalData) { m_globalData = globalData; } + + void setThisRegister(int thisRegister) { m_thisRegister = thisRegister; } + int thisRegister() const { return m_thisRegister; } + + void setNeedsFullScopeChain(bool needsFullScopeChain) { m_needsFullScopeChain = needsFullScopeChain; } + bool needsFullScopeChain() const { return m_needsFullScopeChain; } + void setUsesEval(bool usesEval) { m_usesEval = usesEval; } + bool usesEval() const { return m_usesEval; } + void setUsesArguments(bool usesArguments) { m_usesArguments = usesArguments; } + bool usesArguments() const { return m_usesArguments; } + + CodeType codeType() const { return m_codeType; } + + SourceProvider* source() const { return m_source.get(); } + unsigned sourceOffset() const { return m_sourceOffset; } + + size_t numberOfJumpTargets() const { return m_jumpTargets.size(); } + void addJumpTarget(unsigned jumpTarget) { m_jumpTargets.append(jumpTarget); } + unsigned jumpTarget(int index) const { return m_jumpTargets[index]; } + unsigned lastJumpTarget() const { return m_jumpTargets.last(); } + +#if !ENABLE(JIT) + void addPropertyAccessInstruction(unsigned propertyAccessInstruction) { m_propertyAccessInstructions.append(propertyAccessInstruction); } + void addGlobalResolveInstruction(unsigned globalResolveInstruction) { m_globalResolveInstructions.append(globalResolveInstruction); } + bool hasGlobalResolveInstructionAtBytecodeOffset(unsigned bytecodeOffset); +#else + size_t numberOfStructureStubInfos() const { return m_structureStubInfos.size(); } + void addStructureStubInfo(const StructureStubInfo& stubInfo) { m_structureStubInfos.append(stubInfo); } + StructureStubInfo& structureStubInfo(int index) { return m_structureStubInfos[index]; } + + void addGlobalResolveInfo(unsigned globalResolveInstruction) { m_globalResolveInfos.append(GlobalResolveInfo(globalResolveInstruction)); } + GlobalResolveInfo& globalResolveInfo(int index) { return m_globalResolveInfos[index]; } + bool hasGlobalResolveInfoAtBytecodeOffset(unsigned bytecodeOffset); + + size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); } + void addCallLinkInfo() { m_callLinkInfos.append(CallLinkInfo()); } + CallLinkInfo& callLinkInfo(int index) { return m_callLinkInfos[index]; } + + void addFunctionRegisterInfo(unsigned bytecodeOffset, int functionIndex) { createRareDataIfNecessary(); m_rareData->m_functionRegisterInfos.append(FunctionRegisterInfo(bytecodeOffset, functionIndex)); } +#endif + + // Exception handling support + + size_t numberOfExceptionHandlers() const { return m_rareData ? m_rareData->m_exceptionHandlers.size() : 0; } + void addExceptionHandler(const HandlerInfo& hanler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(hanler); } + HandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; } + + bool hasExceptionInfo() const { return m_exceptionInfo; } + void clearExceptionInfo() { m_exceptionInfo.clear(); } + + void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_expressionInfo.append(expressionInfo); } + void addGetByIdExceptionInfo(const GetByIdExceptionInfo& info) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_getByIdExceptionInfo.append(info); } + + size_t numberOfLineInfos() const { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.size(); } + void addLineInfo(const LineInfo& lineInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_lineInfo.append(lineInfo); } + LineInfo& lastLineInfo() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.last(); } + +#if ENABLE(JIT) + Vector& pcVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_pcVector; } +#endif + + // Constant Pool + + size_t numberOfIdentifiers() const { return m_identifiers.size(); } + void addIdentifier(const Identifier& i) { return m_identifiers.append(i); } + Identifier& identifier(int index) { return m_identifiers[index]; } + + size_t numberOfConstantRegisters() const { return m_constantRegisters.size(); } + void addConstantRegister(const Register& r) { return m_constantRegisters.append(r); } + Register& constantRegister(int index) { return m_constantRegisters[index]; } + + unsigned addFunctionExpression(FuncExprNode* n) { unsigned size = m_functionExpressions.size(); m_functionExpressions.append(n); return size; } + FuncExprNode* functionExpression(int index) const { return m_functionExpressions[index].get(); } + + unsigned addFunction(FuncDeclNode* n) { createRareDataIfNecessary(); unsigned size = m_rareData->m_functions.size(); m_rareData->m_functions.append(n); return size; } + FuncDeclNode* function(int index) const { ASSERT(m_rareData); return m_rareData->m_functions[index].get(); } + + bool hasFunctions() const { return m_functionExpressions.size() || (m_rareData && m_rareData->m_functions.size()); } + + unsigned addUnexpectedConstant(JSValuePtr v) { createRareDataIfNecessary(); unsigned size = m_rareData->m_unexpectedConstants.size(); m_rareData->m_unexpectedConstants.append(v); return size; } + JSValuePtr unexpectedConstant(int index) const { ASSERT(m_rareData); return m_rareData->m_unexpectedConstants[index]; } + + unsigned addRegExp(RegExp* r) { createRareDataIfNecessary(); unsigned size = m_rareData->m_regexps.size(); m_rareData->m_regexps.append(r); return size; } + RegExp* regexp(int index) const { ASSERT(m_rareData); return m_rareData->m_regexps[index].get(); } + + + // Jump Tables + + size_t numberOfImmediateSwitchJumpTables() const { return m_rareData ? m_rareData->m_immediateSwitchJumpTables.size() : 0; } + SimpleJumpTable& addImmediateSwitchJumpTable() { createRareDataIfNecessary(); m_rareData->m_immediateSwitchJumpTables.append(SimpleJumpTable()); return m_rareData->m_immediateSwitchJumpTables.last(); } + SimpleJumpTable& immediateSwitchJumpTable(int tableIndex) { ASSERT(m_rareData); return m_rareData->m_immediateSwitchJumpTables[tableIndex]; } + + size_t numberOfCharacterSwitchJumpTables() const { return m_rareData ? m_rareData->m_characterSwitchJumpTables.size() : 0; } + SimpleJumpTable& addCharacterSwitchJumpTable() { createRareDataIfNecessary(); m_rareData->m_characterSwitchJumpTables.append(SimpleJumpTable()); return m_rareData->m_characterSwitchJumpTables.last(); } + SimpleJumpTable& characterSwitchJumpTable(int tableIndex) { ASSERT(m_rareData); return m_rareData->m_characterSwitchJumpTables[tableIndex]; } + + size_t numberOfStringSwitchJumpTables() const { return m_rareData ? m_rareData->m_stringSwitchJumpTables.size() : 0; } + StringJumpTable& addStringSwitchJumpTable() { createRareDataIfNecessary(); m_rareData->m_stringSwitchJumpTables.append(StringJumpTable()); return m_rareData->m_stringSwitchJumpTables.last(); } + StringJumpTable& stringSwitchJumpTable(int tableIndex) { ASSERT(m_rareData); return m_rareData->m_stringSwitchJumpTables[tableIndex]; } + + + SymbolTable& symbolTable() { return m_symbolTable; } + + EvalCodeCache& evalCodeCache() { createRareDataIfNecessary(); return m_rareData->m_evalCodeCache; } + + void shrinkToFit(); + + // FIXME: Make these remaining members private. + + int m_numCalleeRegisters; + // NOTE: numConstants holds the number of constant registers allocated + // by the code generator, not the number of constant registers used. + // (Duplicate constants are uniqued during code generation, and spare + // constant registers may be allocated.) + int m_numConstants; + int m_numVars; + int m_numParameters; + + private: +#if !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING) + void dump(ExecState*, const Vector::const_iterator& begin, Vector::const_iterator&) const; +#endif + + void reparseForExceptionInfoIfNecessary(CallFrame*); + + void createRareDataIfNecessary() + { + if (!m_rareData) + m_rareData.set(new RareData); + } + + ScopeNode* m_ownerNode; + JSGlobalData* m_globalData; + + Vector m_instructions; +#ifndef NDEBUG + unsigned m_instructionCount; +#endif +#if ENABLE(JIT) + JITCodeRef m_jitCode; +#endif + + int m_thisRegister; + + bool m_needsFullScopeChain; + bool m_usesEval; + bool m_usesArguments; + bool m_isNumericCompareFunction; + + CodeType m_codeType; + + RefPtr m_source; + unsigned m_sourceOffset; + +#if !ENABLE(JIT) + Vector m_propertyAccessInstructions; + Vector m_globalResolveInstructions; +#else + Vector m_structureStubInfos; + Vector m_globalResolveInfos; + Vector m_callLinkInfos; + Vector m_linkedCallerList; +#endif + + Vector m_jumpTargets; + + // Constant Pool + Vector m_identifiers; + Vector m_constantRegisters; + Vector > m_functionExpressions; + + SymbolTable m_symbolTable; + + struct ExceptionInfo { + Vector m_expressionInfo; + Vector m_lineInfo; + Vector m_getByIdExceptionInfo; + +#if ENABLE(JIT) + Vector m_pcVector; +#endif + }; + OwnPtr m_exceptionInfo; + + struct RareData { + Vector m_exceptionHandlers; + + // Rare Constants + Vector > m_functions; + Vector m_unexpectedConstants; + Vector > m_regexps; + + // Jump Tables + Vector m_immediateSwitchJumpTables; + Vector m_characterSwitchJumpTables; + Vector m_stringSwitchJumpTables; + + EvalCodeCache m_evalCodeCache; + +#if ENABLE(JIT) + Vector m_functionRegisterInfos; +#endif + }; + OwnPtr m_rareData; + }; + + // Program code is not marked by any function, so we make the global object + // responsible for marking it. + + class ProgramCodeBlock : public CodeBlock { + public: + ProgramCodeBlock(ScopeNode* ownerNode, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr sourceProvider) + : CodeBlock(ownerNode, codeType, sourceProvider, 0) + , m_globalObject(globalObject) + { + m_globalObject->codeBlocks().add(this); + } + + ~ProgramCodeBlock() + { + if (m_globalObject) + m_globalObject->codeBlocks().remove(this); + } + + void clearGlobalObject() { m_globalObject = 0; } + + private: + JSGlobalObject* m_globalObject; // For program and eval nodes, the global object that marks the constant pool. + }; + + class EvalCodeBlock : public ProgramCodeBlock { + public: + EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr sourceProvider, int baseScopeDepth) + : ProgramCodeBlock(ownerNode, EvalCode, globalObject, sourceProvider) + , m_baseScopeDepth(baseScopeDepth) + { + } + + int baseScopeDepth() const { return m_baseScopeDepth; } + + private: + int m_baseScopeDepth; + }; + +} // namespace JSC + +#endif // CodeBlock_h diff --git a/bytecode/EvalCodeCache.h b/bytecode/EvalCodeCache.h new file mode 100644 index 0000000..2d6f7dc --- /dev/null +++ b/bytecode/EvalCodeCache.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef EvalCodeCache_h +#define EvalCodeCache_h + +#include "JSGlobalObject.h" +#include "Nodes.h" +#include "Parser.h" +#include "SourceCode.h" +#include "UString.h" +#include +#include + +namespace JSC { + + class EvalCodeCache { + public: + PassRefPtr get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValuePtr& exceptionValue) + { + RefPtr evalNode; + + if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject()) + evalNode = m_cacheMap.get(evalSource.rep()); + + if (!evalNode) { + int errorLine; + UString errorMessage; + + SourceCode source = makeSource(evalSource); + evalNode = exec->globalData().parser->parse(exec, exec->dynamicGlobalObject()->debugger(), source, &errorLine, &errorMessage); + if (evalNode) { + if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries) + m_cacheMap.set(evalSource.rep(), evalNode); + } else { + exceptionValue = Error::create(exec, SyntaxError, errorMessage, errorLine, source.provider()->asID(), 0); + return 0; + } + } + + return evalNode.release(); + } + + bool isEmpty() const { return m_cacheMap.isEmpty(); } + + void mark() + { + EvalCacheMap::iterator end = m_cacheMap.end(); + for (EvalCacheMap::iterator ptr = m_cacheMap.begin(); ptr != end; ++ptr) + ptr->second->mark(); + } + private: + static const int maxCacheableSourceLength = 256; + static const int maxCacheEntries = 64; + + typedef HashMap, RefPtr > EvalCacheMap; + EvalCacheMap m_cacheMap; + }; + +} // namespace JSC + +#endif // EvalCodeCache_h diff --git a/bytecode/Instruction.h b/bytecode/Instruction.h new file mode 100644 index 0000000..1fab106 --- /dev/null +++ b/bytecode/Instruction.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef Instruction_h +#define Instruction_h + +#include "Opcode.h" +#include "Structure.h" +#include + +#define POLYMORPHIC_LIST_CACHE_SIZE 4 + +namespace JSC { + + class JSCell; + class Structure; + class StructureChain; + + // Structure used by op_get_by_id_self_list and op_get_by_id_proto_list instruction to hold data off the main opcode stream. + struct PolymorphicAccessStructureList { + struct PolymorphicStubInfo { + bool isChain; + void* stubRoutine; + Structure* base; + union { + Structure* proto; + StructureChain* chain; + } u; + + void set(void* _stubRoutine, Structure* _base) + { + stubRoutine = _stubRoutine; + base = _base; + u.proto = 0; + isChain = false; + } + + void set(void* _stubRoutine, Structure* _base, Structure* _proto) + { + stubRoutine = _stubRoutine; + base = _base; + u.proto = _proto; + isChain = false; + } + + void set(void* _stubRoutine, Structure* _base, StructureChain* _chain) + { + stubRoutine = _stubRoutine; + base = _base; + u.chain = _chain; + isChain = true; + } + } list[POLYMORPHIC_LIST_CACHE_SIZE]; + + PolymorphicAccessStructureList(void* stubRoutine, Structure* firstBase) + { + list[0].set(stubRoutine, firstBase); + } + + PolymorphicAccessStructureList(void* stubRoutine, Structure* firstBase, Structure* firstProto) + { + list[0].set(stubRoutine, firstBase, firstProto); + } + + PolymorphicAccessStructureList(void* stubRoutine, Structure* firstBase, StructureChain* firstChain) + { + list[0].set(stubRoutine, firstBase, firstChain); + } + + void derefStructures(int count) + { + for (int i = 0; i < count; ++i) { + PolymorphicStubInfo& info = list[i]; + + ASSERT(info.base); + info.base->deref(); + + if (info.u.proto) { + if (info.isChain) + info.u.chain->deref(); + else + info.u.proto->deref(); + } + } + } + }; + + struct Instruction { + Instruction(Opcode opcode) + { +#if !HAVE(COMPUTED_GOTO) + // We have to initialize one of the pointer members to ensure that + // the entire struct is initialized, when opcode is not a pointer. + u.jsCell = 0; +#endif + u.opcode = opcode; + } + + Instruction(int operand) + { + // We have to initialize one of the pointer members to ensure that + // the entire struct is initialized in 64-bit. + u.jsCell = 0; + u.operand = operand; + } + + Instruction(Structure* structure) { u.structure = structure; } + Instruction(StructureChain* structureChain) { u.structureChain = structureChain; } + Instruction(JSCell* jsCell) { u.jsCell = jsCell; } + Instruction(PolymorphicAccessStructureList* polymorphicStructures) { u.polymorphicStructures = polymorphicStructures; } + + union { + Opcode opcode; + int operand; + Structure* structure; + StructureChain* structureChain; + JSCell* jsCell; + PolymorphicAccessStructureList* polymorphicStructures; + } u; + }; + +} // namespace JSC + +namespace WTF { + + template<> struct VectorTraits : VectorTraitsBase { }; + +} // namespace WTF + +#endif // Instruction_h diff --git a/bytecode/JumpTable.cpp b/bytecode/JumpTable.cpp new file mode 100644 index 0000000..175c1b3 --- /dev/null +++ b/bytecode/JumpTable.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008 Cameron Zwarich + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JumpTable.h" + +namespace JSC { + +int32_t SimpleJumpTable::offsetForValue(int32_t value, int32_t defaultOffset) +{ + if (value >= min && static_cast(value - min) < branchOffsets.size()) { + int32_t offset = branchOffsets[value - min]; + if (offset) + return offset; + } + return defaultOffset; +} + +} // namespace JSC diff --git a/bytecode/JumpTable.h b/bytecode/JumpTable.h new file mode 100644 index 0000000..44e224d --- /dev/null +++ b/bytecode/JumpTable.h @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008 Cameron Zwarich + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JumpTable_h +#define JumpTable_h + +#include "UString.h" +#include +#include + +namespace JSC { + + struct OffsetLocation { + int32_t branchOffset; +#if ENABLE(JIT) + void* ctiOffset; +#endif + }; + + struct StringJumpTable { + typedef HashMap, OffsetLocation> StringOffsetTable; + StringOffsetTable offsetTable; +#if ENABLE(JIT) + void* ctiDefault; // FIXME: it should not be necessary to store this. +#endif + + inline int32_t offsetForValue(UString::Rep* value, int32_t defaultOffset) + { + StringOffsetTable::const_iterator end = offsetTable.end(); + StringOffsetTable::const_iterator loc = offsetTable.find(value); + if (loc == end) + return defaultOffset; + return loc->second.branchOffset; + } + +#if ENABLE(JIT) + inline void* ctiForValue(UString::Rep* value) + { + StringOffsetTable::const_iterator end = offsetTable.end(); + StringOffsetTable::const_iterator loc = offsetTable.find(value); + if (loc == end) + return ctiDefault; + return loc->second.ctiOffset; + } +#endif + }; + + struct SimpleJumpTable { + // FIXME: The two Vectors can be combind into one Vector + Vector branchOffsets; + int32_t min; +#if ENABLE(JIT) + Vector ctiOffsets; + void* ctiDefault; +#endif + + int32_t offsetForValue(int32_t value, int32_t defaultOffset); + void add(int32_t key, int32_t offset) + { + if (!branchOffsets[key]) + branchOffsets[key] = offset; + } + +#if ENABLE(JIT) + inline void* ctiForValue(int32_t value) + { + if (value >= min && static_cast(value - min) < ctiOffsets.size()) + return ctiOffsets[value - min]; + return ctiDefault; + } +#endif + }; + +} // namespace JSC + +#endif // JumpTable_h diff --git a/bytecode/Opcode.cpp b/bytecode/Opcode.cpp new file mode 100644 index 0000000..bb7696d --- /dev/null +++ b/bytecode/Opcode.cpp @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008 Cameron Zwarich + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Opcode.h" + +using namespace std; + +namespace JSC { + +#if ENABLE(OPCODE_SAMPLING) || ENABLE(CODEBLOCK_SAMPLING) || ENABLE(OPCODE_STATS) + +const char* const opcodeNames[] = { +#define OPCODE_NAME_ENTRY(opcode, size) #opcode, + FOR_EACH_OPCODE_ID(OPCODE_NAME_ENTRY) +#undef OPCODE_NAME_ENTRY +}; + +#endif + +#if ENABLE(OPCODE_STATS) + +long long OpcodeStats::opcodeCounts[numOpcodeIDs]; +long long OpcodeStats::opcodePairCounts[numOpcodeIDs][numOpcodeIDs]; +int OpcodeStats::lastOpcode = -1; + +static OpcodeStats logger; + +OpcodeStats::OpcodeStats() +{ + for (int i = 0; i < numOpcodeIDs; ++i) + opcodeCounts[i] = 0; + + for (int i = 0; i < numOpcodeIDs; ++i) + for (int j = 0; j < numOpcodeIDs; ++j) + opcodePairCounts[i][j] = 0; +} + +static int compareOpcodeIndices(const void* left, const void* right) +{ + long long leftValue = OpcodeStats::opcodeCounts[*(int*) left]; + long long rightValue = OpcodeStats::opcodeCounts[*(int*) right]; + + if (leftValue < rightValue) + return 1; + else if (leftValue > rightValue) + return -1; + else + return 0; +} + +static int compareOpcodePairIndices(const void* left, const void* right) +{ + pair leftPair = *(pair*) left; + long long leftValue = OpcodeStats::opcodePairCounts[leftPair.first][leftPair.second]; + pair rightPair = *(pair*) right; + long long rightValue = OpcodeStats::opcodePairCounts[rightPair.first][rightPair.second]; + + if (leftValue < rightValue) + return 1; + else if (leftValue > rightValue) + return -1; + else + return 0; +} + +OpcodeStats::~OpcodeStats() +{ + long long totalInstructions = 0; + for (int i = 0; i < numOpcodeIDs; ++i) + totalInstructions += opcodeCounts[i]; + + long long totalInstructionPairs = 0; + for (int i = 0; i < numOpcodeIDs; ++i) + for (int j = 0; j < numOpcodeIDs; ++j) + totalInstructionPairs += opcodePairCounts[i][j]; + + int sortedIndices[numOpcodeIDs]; + for (int i = 0; i < numOpcodeIDs; ++i) + sortedIndices[i] = i; + qsort(sortedIndices, numOpcodeIDs, sizeof(int), compareOpcodeIndices); + + pair sortedPairIndices[numOpcodeIDs * numOpcodeIDs]; + pair* currentPairIndex = sortedPairIndices; + for (int i = 0; i < numOpcodeIDs; ++i) + for (int j = 0; j < numOpcodeIDs; ++j) + *(currentPairIndex++) = make_pair(i, j); + qsort(sortedPairIndices, numOpcodeIDs * numOpcodeIDs, sizeof(pair), compareOpcodePairIndices); + + printf("\nExecuted opcode statistics\n"); + + printf("Total instructions executed: %lld\n\n", totalInstructions); + + printf("All opcodes by frequency:\n\n"); + + for (int i = 0; i < numOpcodeIDs; ++i) { + int index = sortedIndices[i]; + printf("%s:%s %lld - %.2f%%\n", opcodeNames[index], padOpcodeName((OpcodeID)index, 28), opcodeCounts[index], ((double) opcodeCounts[index]) / ((double) totalInstructions) * 100.0); + } + + printf("\n"); + printf("2-opcode sequences by frequency: %lld\n\n", totalInstructions); + + for (int i = 0; i < numOpcodeIDs * numOpcodeIDs; ++i) { + pair indexPair = sortedPairIndices[i]; + long long count = opcodePairCounts[indexPair.first][indexPair.second]; + + if (!count) + break; + + printf("%s%s %s:%s %lld %.2f%%\n", opcodeNames[indexPair.first], padOpcodeName((OpcodeID)indexPair.first, 28), opcodeNames[indexPair.second], padOpcodeName((OpcodeID)indexPair.second, 28), count, ((double) count) / ((double) totalInstructionPairs) * 100.0); + } + + printf("\n"); + printf("Most common opcodes and sequences:\n"); + + for (int i = 0; i < numOpcodeIDs; ++i) { + int index = sortedIndices[i]; + long long opcodeCount = opcodeCounts[index]; + double opcodeProportion = ((double) opcodeCount) / ((double) totalInstructions); + if (opcodeProportion < 0.0001) + break; + printf("\n%s:%s %lld - %.2f%%\n", opcodeNames[index], padOpcodeName((OpcodeID)index, 28), opcodeCount, opcodeProportion * 100.0); + + for (int j = 0; j < numOpcodeIDs * numOpcodeIDs; ++j) { + pair indexPair = sortedPairIndices[j]; + long long pairCount = opcodePairCounts[indexPair.first][indexPair.second]; + double pairProportion = ((double) pairCount) / ((double) totalInstructionPairs); + + if (!pairCount || pairProportion < 0.0001 || pairProportion < opcodeProportion / 100) + break; + + if (indexPair.first != index && indexPair.second != index) + continue; + + printf(" %s%s %s:%s %lld - %.2f%%\n", opcodeNames[indexPair.first], padOpcodeName((OpcodeID)indexPair.first, 28), opcodeNames[indexPair.second], padOpcodeName((OpcodeID)indexPair.second, 28), pairCount, pairProportion * 100.0); + } + + } + printf("\n"); +} + +void OpcodeStats::recordInstruction(int opcode) +{ + opcodeCounts[opcode]++; + + if (lastOpcode != -1) + opcodePairCounts[lastOpcode][opcode]++; + + lastOpcode = opcode; +} + +void OpcodeStats::resetLastInstruction() +{ + lastOpcode = -1; +} + +#endif + +} // namespace JSC diff --git a/bytecode/Opcode.h b/bytecode/Opcode.h new file mode 100644 index 0000000..d00178b --- /dev/null +++ b/bytecode/Opcode.h @@ -0,0 +1,231 @@ +/* + * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2008 Cameron Zwarich + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef Opcode_h +#define Opcode_h + +#include +#include + +#include + +namespace JSC { + + #define FOR_EACH_OPCODE_ID(macro) \ + macro(op_enter, 1) \ + macro(op_enter_with_activation, 2) \ + macro(op_create_arguments, 1) \ + macro(op_convert_this, 2) \ + \ + macro(op_unexpected_load, 3) \ + macro(op_new_object, 2) \ + macro(op_new_array, 4) \ + macro(op_new_regexp, 3) \ + macro(op_mov, 3) \ + \ + macro(op_not, 3) \ + macro(op_eq, 4) \ + macro(op_eq_null, 3) \ + macro(op_neq, 4) \ + macro(op_neq_null, 3) \ + macro(op_stricteq, 4) \ + macro(op_nstricteq, 4) \ + macro(op_less, 4) \ + macro(op_lesseq, 4) \ + \ + macro(op_pre_inc, 2) \ + macro(op_pre_dec, 2) \ + macro(op_post_inc, 3) \ + macro(op_post_dec, 3) \ + macro(op_to_jsnumber, 3) \ + macro(op_negate, 3) \ + macro(op_add, 5) \ + macro(op_mul, 5) \ + macro(op_div, 4) \ + macro(op_mod, 4) \ + macro(op_sub, 5) \ + \ + macro(op_lshift, 4) \ + macro(op_rshift, 4) \ + macro(op_urshift, 4) \ + macro(op_bitand, 5) \ + macro(op_bitxor, 5) \ + macro(op_bitor, 5) \ + macro(op_bitnot, 3) \ + \ + macro(op_instanceof, 5) \ + macro(op_typeof, 3) \ + macro(op_is_undefined, 3) \ + macro(op_is_boolean, 3) \ + macro(op_is_number, 3) \ + macro(op_is_string, 3) \ + macro(op_is_object, 3) \ + macro(op_is_function, 3) \ + macro(op_in, 4) \ + \ + macro(op_resolve, 3) \ + macro(op_resolve_skip, 4) \ + macro(op_resolve_global, 6) \ + macro(op_get_scoped_var, 4) \ + macro(op_put_scoped_var, 4) \ + macro(op_get_global_var, 4) \ + macro(op_put_global_var, 4) \ + macro(op_resolve_base, 3) \ + macro(op_resolve_with_base, 4) \ + macro(op_resolve_func, 4) \ + macro(op_get_by_id, 8) \ + macro(op_get_by_id_self, 8) \ + macro(op_get_by_id_self_list, 8) \ + macro(op_get_by_id_proto, 8) \ + macro(op_get_by_id_proto_list, 8) \ + macro(op_get_by_id_chain, 8) \ + macro(op_get_by_id_generic, 8) \ + macro(op_get_array_length, 8) \ + macro(op_get_string_length, 8) \ + macro(op_put_by_id, 8) \ + macro(op_put_by_id_transition, 8) \ + macro(op_put_by_id_replace, 8) \ + macro(op_put_by_id_generic, 8) \ + macro(op_del_by_id, 4) \ + macro(op_get_by_val, 4) \ + macro(op_put_by_val, 4) \ + macro(op_del_by_val, 4) \ + macro(op_put_by_index, 4) \ + macro(op_put_getter, 4) \ + macro(op_put_setter, 4) \ + \ + macro(op_jmp, 2) \ + macro(op_jtrue, 3) \ + macro(op_jfalse, 3) \ + macro(op_jeq_null, 3) \ + macro(op_jneq_null, 3) \ + macro(op_jnless, 4) \ + macro(op_jmp_scopes, 3) \ + macro(op_loop, 2) \ + macro(op_loop_if_true, 3) \ + macro(op_loop_if_less, 4) \ + macro(op_loop_if_lesseq, 4) \ + macro(op_switch_imm, 4) \ + macro(op_switch_char, 4) \ + macro(op_switch_string, 4) \ + \ + macro(op_new_func, 3) \ + macro(op_new_func_exp, 3) \ + macro(op_call, 5) \ + macro(op_call_eval, 5) \ + macro(op_tear_off_activation, 2) \ + macro(op_tear_off_arguments, 1) \ + macro(op_ret, 2) \ + \ + macro(op_construct, 7) \ + macro(op_construct_verify, 3) \ + \ + macro(op_get_pnames, 3) \ + macro(op_next_pname, 4) \ + \ + macro(op_push_scope, 2) \ + macro(op_pop_scope, 1) \ + macro(op_push_new_scope, 4) \ + \ + macro(op_catch, 2) \ + macro(op_throw, 2) \ + macro(op_new_error, 4) \ + \ + macro(op_jsr, 3) \ + macro(op_sret, 2) \ + \ + macro(op_debug, 4) \ + macro(op_profile_will_call, 2) \ + macro(op_profile_did_call, 2) \ + \ + macro(op_end, 2) // end must be the last opcode in the list + + #define OPCODE_ID_ENUM(opcode, length) opcode, + typedef enum { FOR_EACH_OPCODE_ID(OPCODE_ID_ENUM) } OpcodeID; + #undef OPCODE_ID_ENUM + + const int numOpcodeIDs = op_end + 1; + + #define OPCODE_ID_LENGTHS(id, length) const int id##_length = length; + FOR_EACH_OPCODE_ID(OPCODE_ID_LENGTHS); + #undef OPCODE_ID_SIZES + + #define OPCODE_LENGTH(opcode) opcode##_length + + #define OPCODE_ID_LENGTH_MAP(opcode, length) length, + const int opcodeLengths[numOpcodeIDs] = { FOR_EACH_OPCODE_ID(OPCODE_ID_LENGTH_MAP) }; + #undef OPCODE_ID_LENGTH_MAP + + #define VERIFY_OPCODE_ID(id, size) COMPILE_ASSERT(id <= op_end, ASSERT_THAT_JS_OPCODE_IDS_ARE_VALID); + FOR_EACH_OPCODE_ID(VERIFY_OPCODE_ID); + #undef VERIFY_OPCODE_ID + +#if HAVE(COMPUTED_GOTO) + typedef void* Opcode; +#else + typedef OpcodeID Opcode; +#endif + +#if ENABLE(OPCODE_SAMPLING) || ENABLE(CODEBLOCK_SAMPLING) || ENABLE(OPCODE_STATS) + +#define PADDING_STRING " " +#define PADDING_STRING_LENGTH static_cast(strlen(PADDING_STRING)) + + extern const char* const opcodeNames[]; + + inline const char* padOpcodeName(OpcodeID op, unsigned width) + { + unsigned pad = width - strlen(opcodeNames[op]); + pad = std::min(pad, PADDING_STRING_LENGTH); + return PADDING_STRING + PADDING_STRING_LENGTH - pad; + } + +#undef PADDING_STRING_LENGTH +#undef PADDING_STRING + +#endif + +#if ENABLE(OPCODE_STATS) + + struct OpcodeStats { + OpcodeStats(); + ~OpcodeStats(); + static long long opcodeCounts[numOpcodeIDs]; + static long long opcodePairCounts[numOpcodeIDs][numOpcodeIDs]; + static int lastOpcode; + + static void recordInstruction(int opcode); + static void resetLastInstruction(); + }; + +#endif + +} // namespace JSC + +#endif // Opcode_h diff --git a/bytecode/SamplingTool.cpp b/bytecode/SamplingTool.cpp new file mode 100644 index 0000000..215ebe5 --- /dev/null +++ b/bytecode/SamplingTool.cpp @@ -0,0 +1,298 @@ +/* + * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SamplingTool.h" + +#include "CodeBlock.h" +#include "Interpreter.h" +#include "Opcode.h" + +#if !PLATFORM(WIN_OS) +#include +#endif + +namespace JSC { + +void ScopeSampleRecord::sample(CodeBlock* codeBlock, Instruction* vPC) +{ + if (!m_samples) { + m_size = codeBlock->instructions().size(); + m_samples = static_cast(calloc(m_size, sizeof(int))); + m_codeBlock = codeBlock; + } + + ++m_sampleCount; + + unsigned offest = vPC - codeBlock->instructions().begin(); + // Since we don't read and write codeBlock and vPC atomically, this check + // can fail if we sample mid op_call / op_ret. + if (offest < m_size) { + m_samples[offest]++; + m_opcodeSampleCount++; + } +} + +#if PLATFORM(WIN_OS) + +static void sleepForMicroseconds(unsigned us) +{ + unsigned ms = us / 1000; + if (us && !ms) + ms = 1; + Sleep(ms); +} + +#else + +static void sleepForMicroseconds(unsigned us) +{ + usleep(us); +} + +#endif + +static inline unsigned hertz2us(unsigned hertz) +{ + return 1000000 / hertz; +} + +void SamplingTool::run() +{ + while (m_running) { + sleepForMicroseconds(hertz2us(m_hertz)); + + Sample sample(m_sample, m_codeBlock); + ++m_sampleCount; + + if (sample.isNull()) + continue; + + if (!sample.inHostFunction()) { + unsigned opcodeID = m_interpreter->getOpcodeID(sample.vPC()[0].u.opcode); + + ++m_opcodeSampleCount; + ++m_opcodeSamples[opcodeID]; + + if (sample.inCTIFunction()) + m_opcodeSamplesInCTIFunctions[opcodeID]++; + } + +#if ENABLE(CODEBLOCK_SAMPLING) + MutexLocker locker(m_scopeSampleMapMutex); + ScopeSampleRecord* record = m_scopeSampleMap->get(sample.codeBlock()->ownerNode()); + ASSERT(record); + record->sample(sample.codeBlock(), sample.vPC()); +#endif + } +} + +void* SamplingTool::threadStartFunc(void* samplingTool) +{ + reinterpret_cast(samplingTool)->run(); + return 0; +} + +void SamplingTool::notifyOfScope(ScopeNode* scope) +{ + MutexLocker locker(m_scopeSampleMapMutex); + m_scopeSampleMap->set(scope, new ScopeSampleRecord(scope)); +} + +void SamplingTool::start(unsigned hertz) +{ + ASSERT(!m_running); + m_running = true; + m_hertz = hertz; + + m_samplingThread = createThread(threadStartFunc, this, "JavaScriptCore::Sampler"); +} + +void SamplingTool::stop() +{ + ASSERT(m_running); + m_running = false; + waitForThreadCompletion(m_samplingThread, 0); +} + +#if ENABLE(OPCODE_SAMPLING) + +struct OpcodeSampleInfo { + OpcodeID opcode; + long long count; + long long countInCTIFunctions; +}; + +struct LineCountInfo { + unsigned line; + unsigned count; +}; + +static int compareLineCountInfoSampling(const void* left, const void* right) +{ + const LineCountInfo* leftLineCount = reinterpret_cast(left); + const LineCountInfo* rightLineCount = reinterpret_cast(right); + + return (leftLineCount->line > rightLineCount->line) ? 1 : (leftLineCount->line < rightLineCount->line) ? -1 : 0; +} + +static int compareOpcodeIndicesSampling(const void* left, const void* right) +{ + const OpcodeSampleInfo* leftSampleInfo = reinterpret_cast(left); + const OpcodeSampleInfo* rightSampleInfo = reinterpret_cast(right); + + return (leftSampleInfo->count < rightSampleInfo->count) ? 1 : (leftSampleInfo->count > rightSampleInfo->count) ? -1 : 0; +} + +static int compareScopeSampleRecords(const void* left, const void* right) +{ + const ScopeSampleRecord* const leftValue = *static_cast(left); + const ScopeSampleRecord* const rightValue = *static_cast(right); + + return (leftValue->m_sampleCount < rightValue->m_sampleCount) ? 1 : (leftValue->m_sampleCount > rightValue->m_sampleCount) ? -1 : 0; +} + +void SamplingTool::dump(ExecState* exec) +{ + // Tidies up SunSpider output by removing short scripts - such a small number of samples would likely not be useful anyhow. + if (m_sampleCount < 10) + return; + + // (1) Build and sort 'opcodeSampleInfo' array. + + OpcodeSampleInfo opcodeSampleInfo[numOpcodeIDs]; + for (int i = 0; i < numOpcodeIDs; ++i) { + opcodeSampleInfo[i].opcode = static_cast(i); + opcodeSampleInfo[i].count = m_opcodeSamples[i]; + opcodeSampleInfo[i].countInCTIFunctions = m_opcodeSamplesInCTIFunctions[i]; + } + + qsort(opcodeSampleInfo, numOpcodeIDs, sizeof(OpcodeSampleInfo), compareOpcodeIndicesSampling); + + // (2) Print Opcode sampling results. + + printf("\nBytecode samples [*]\n"); + printf(" sample %% of %% of | cti cti %%\n"); + printf("opcode count VM total | count of self\n"); + printf("------------------------------------------------------- | ----------------\n"); + + for (int i = 0; i < numOpcodeIDs; ++i) { + long long count = opcodeSampleInfo[i].count; + if (!count) + continue; + + OpcodeID opcodeID = opcodeSampleInfo[i].opcode; + + const char* opcodeName = opcodeNames[opcodeID]; + const char* opcodePadding = padOpcodeName(opcodeID, 28); + double percentOfVM = (static_cast(count) * 100) / m_opcodeSampleCount; + double percentOfTotal = (static_cast(count) * 100) / m_sampleCount; + long long countInCTIFunctions = opcodeSampleInfo[i].countInCTIFunctions; + double percentInCTIFunctions = (static_cast(countInCTIFunctions) * 100) / count; + fprintf(stdout, "%s:%s%-6lld %.3f%%\t%.3f%%\t | %-6lld %.3f%%\n", opcodeName, opcodePadding, count, percentOfVM, percentOfTotal, countInCTIFunctions, percentInCTIFunctions); + } + + printf("\n[*] Samples inside host code are not charged to any Bytecode.\n\n"); + printf("\tSamples inside VM:\t\t%lld / %lld (%.3f%%)\n", m_opcodeSampleCount, m_sampleCount, (static_cast(m_opcodeSampleCount) * 100) / m_sampleCount); + printf("\tSamples inside host code:\t%lld / %lld (%.3f%%)\n\n", m_sampleCount - m_opcodeSampleCount, m_sampleCount, (static_cast(m_sampleCount - m_opcodeSampleCount) * 100) / m_sampleCount); + printf("\tsample count:\tsamples inside this opcode\n"); + printf("\t%% of VM:\tsample count / all opcode samples\n"); + printf("\t%% of total:\tsample count / all samples\n"); + printf("\t--------------\n"); + printf("\tcti count:\tsamples inside a CTI function called by this opcode\n"); + printf("\tcti %% of self:\tcti count / sample count\n"); + + // (3) Build and sort 'codeBlockSamples' array. + + int scopeCount = m_scopeSampleMap->size(); + Vector codeBlockSamples(scopeCount); + ScopeSampleRecordMap::iterator iter = m_scopeSampleMap->begin(); + for (int i = 0; i < scopeCount; ++i, ++iter) + codeBlockSamples[i] = iter->second; + + qsort(codeBlockSamples.begin(), scopeCount, sizeof(ScopeSampleRecord*), compareScopeSampleRecords); + + // (4) Print data from 'codeBlockSamples' array. + + printf("\nCodeBlock samples\n\n"); + + for (int i = 0; i < scopeCount; ++i) { + ScopeSampleRecord* record = codeBlockSamples[i]; + CodeBlock* codeBlock = record->m_codeBlock; + + double blockPercent = (record->m_sampleCount * 100.0) / m_sampleCount; + + if (blockPercent >= 1) { + //Instruction* code = codeBlock->instructions().begin(); + printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_scope->sourceURL().UTF8String().c_str(), codeBlock->lineNumberForBytecodeOffset(exec, 0), record->m_sampleCount, m_sampleCount, blockPercent); + if (i < 10) { + HashMap lineCounts; + codeBlock->dump(exec); + + printf(" Opcode and line number samples [*]\n\n"); + for (unsigned op = 0; op < record->m_size; ++op) { + int count = record->m_samples[op]; + if (count) { + printf(" [% 4d] has sample count: % 4d\n", op, count); + unsigned line = codeBlock->lineNumberForBytecodeOffset(exec, op); + lineCounts.set(line, (lineCounts.contains(line) ? lineCounts.get(line) : 0) + count); + } + } + printf("\n"); + + int linesCount = lineCounts.size(); + Vector lineCountInfo(linesCount); + int lineno = 0; + for (HashMap::iterator iter = lineCounts.begin(); iter != lineCounts.end(); ++iter, ++lineno) { + lineCountInfo[lineno].line = iter->first; + lineCountInfo[lineno].count = iter->second; + } + + qsort(lineCountInfo.begin(), linesCount, sizeof(LineCountInfo), compareLineCountInfoSampling); + + for (lineno = 0; lineno < linesCount; ++lineno) { + printf(" Line #%d has sample count %d.\n", lineCountInfo[lineno].line, lineCountInfo[lineno].count); + } + printf("\n"); + printf(" [*] Samples inside host code are charged to the calling Bytecode.\n"); + printf(" Samples on a call / return boundary are not charged to a specific opcode or line.\n\n"); + printf(" Samples on a call / return boundary: %d / %d (%.3f%%)\n\n", record->m_sampleCount - record->m_opcodeSampleCount, record->m_sampleCount, (static_cast(record->m_sampleCount - record->m_opcodeSampleCount) * 100) / record->m_sampleCount); + } + } + } +} + +#else + +void SamplingTool::dump(ExecState*) +{ +} + +#endif + +} // namespace JSC diff --git a/bytecode/SamplingTool.h b/bytecode/SamplingTool.h new file mode 100644 index 0000000..d1cf2e8 --- /dev/null +++ b/bytecode/SamplingTool.h @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SamplingTool_h +#define SamplingTool_h + +#include +#include +#include + +#include "Nodes.h" +#include "Opcode.h" + +namespace JSC { + + class CodeBlock; + class ExecState; + class Interpreter; + class ScopeNode; + struct Instruction; + + struct ScopeSampleRecord { + ScopeSampleRecord(ScopeNode* scope) + : m_scope(scope) + , m_codeBlock(0) + , m_sampleCount(0) + , m_opcodeSampleCount(0) + , m_samples(0) + , m_size(0) + { + } + + ~ScopeSampleRecord() + { + if (m_samples) + free(m_samples); + } + + void sample(CodeBlock*, Instruction*); + + RefPtr m_scope; + CodeBlock* m_codeBlock; + int m_sampleCount; + int m_opcodeSampleCount; + int* m_samples; + unsigned m_size; + }; + + typedef WTF::HashMap ScopeSampleRecordMap; + + class SamplingTool { + public: + friend class CallRecord; + friend class HostCallRecord; + +#if ENABLE(OPCODE_SAMPLING) + class CallRecord : Noncopyable { + public: + CallRecord(SamplingTool* samplingTool) + : m_samplingTool(samplingTool) + , m_savedSample(samplingTool->m_sample) + , m_savedCodeBlock(samplingTool->m_codeBlock) + { + } + + ~CallRecord() + { + m_samplingTool->m_sample = m_savedSample; + m_samplingTool->m_codeBlock = m_savedCodeBlock; + } + + private: + SamplingTool* m_samplingTool; + intptr_t m_savedSample; + CodeBlock* m_savedCodeBlock; + }; + + class HostCallRecord : public CallRecord { + public: + HostCallRecord(SamplingTool* samplingTool) + : CallRecord(samplingTool) + { + samplingTool->m_sample |= 0x1; + } + }; +#else + class CallRecord : Noncopyable { + public: + CallRecord(SamplingTool*) + { + } + }; + + class HostCallRecord : public CallRecord { + public: + HostCallRecord(SamplingTool* samplingTool) + : CallRecord(samplingTool) + { + } + }; +#endif + + SamplingTool(Interpreter* interpreter) + : m_interpreter(interpreter) + , m_running(false) + , m_codeBlock(0) + , m_sample(0) + , m_sampleCount(0) + , m_opcodeSampleCount(0) + , m_scopeSampleMap(new ScopeSampleRecordMap()) + { + memset(m_opcodeSamples, 0, sizeof(m_opcodeSamples)); + memset(m_opcodeSamplesInCTIFunctions, 0, sizeof(m_opcodeSamplesInCTIFunctions)); + } + + ~SamplingTool() + { + deleteAllValues(*m_scopeSampleMap); + } + + void start(unsigned hertz=10000); + void stop(); + void dump(ExecState*); + + void notifyOfScope(ScopeNode* scope); + + void sample(CodeBlock* codeBlock, Instruction* vPC) + { + ASSERT(!(reinterpret_cast(vPC) & 0x3)); + m_codeBlock = codeBlock; + m_sample = reinterpret_cast(vPC); + } + + CodeBlock** codeBlockSlot() { return &m_codeBlock; } + intptr_t* sampleSlot() { return &m_sample; } + + void* encodeSample(Instruction* vPC, bool inCTIFunction = false, bool inHostFunction = false) + { + ASSERT(!(reinterpret_cast(vPC) & 0x3)); + return reinterpret_cast(reinterpret_cast(vPC) | (static_cast(inCTIFunction) << 1) | static_cast(inHostFunction)); + } + + private: + class Sample { + public: + Sample(volatile intptr_t sample, CodeBlock* volatile codeBlock) + : m_sample(sample) + , m_codeBlock(codeBlock) + { + } + + bool isNull() { return !m_sample || !m_codeBlock; } + CodeBlock* codeBlock() { return m_codeBlock; } + Instruction* vPC() { return reinterpret_cast(m_sample & ~0x3); } + bool inHostFunction() { return m_sample & 0x1; } + bool inCTIFunction() { return m_sample & 0x2; } + + private: + intptr_t m_sample; + CodeBlock* m_codeBlock; + }; + + static void* threadStartFunc(void*); + void run(); + + Interpreter* m_interpreter; + + // Sampling thread state. + bool m_running; + unsigned m_hertz; + ThreadIdentifier m_samplingThread; + + // State tracked by the main thread, used by the sampling thread. + CodeBlock* m_codeBlock; + intptr_t m_sample; + + // Gathered sample data. + long long m_sampleCount; + long long m_opcodeSampleCount; + unsigned m_opcodeSamples[numOpcodeIDs]; + unsigned m_opcodeSamplesInCTIFunctions[numOpcodeIDs]; + + Mutex m_scopeSampleMapMutex; + OwnPtr m_scopeSampleMap; + }; + +} // namespace JSC + +#endif // SamplingTool_h diff --git a/bytecode/StructureStubInfo.cpp b/bytecode/StructureStubInfo.cpp new file mode 100644 index 0000000..bf3fdc4 --- /dev/null +++ b/bytecode/StructureStubInfo.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "StructureStubInfo.h" + +namespace JSC { + +#if ENABLE(JIT) +void StructureStubInfo::deref() +{ + switch (opcodeID) { + case op_get_by_id_self: + u.getByIdSelf.baseObjectStructure->deref(); + return; + case op_get_by_id_proto: + u.getByIdProto.baseObjectStructure->deref(); + u.getByIdProto.prototypeStructure->deref(); + return; + case op_get_by_id_chain: + u.getByIdChain.baseObjectStructure->deref(); + u.getByIdChain.chain->deref(); + return; + case op_get_by_id_self_list: { + PolymorphicAccessStructureList* polymorphicStructures = u.getByIdSelfList.structureList; + polymorphicStructures->derefStructures(u.getByIdSelfList.listSize); + delete polymorphicStructures; + return; + } + case op_get_by_id_proto_list: { + PolymorphicAccessStructureList* polymorphicStructures = u.getByIdProtoList.structureList; + polymorphicStructures->derefStructures(u.getByIdProtoList.listSize); + delete polymorphicStructures; + return; + } + case op_put_by_id_transition: + u.putByIdTransition.previousStructure->deref(); + u.putByIdTransition.structure->deref(); + u.putByIdTransition.chain->deref(); + return; + case op_put_by_id_replace: + u.putByIdReplace.baseObjectStructure->deref(); + return; + case op_get_by_id: + case op_put_by_id: + case op_get_by_id_generic: + case op_put_by_id_generic: + case op_get_array_length: + case op_get_string_length: + // These instructions don't ref their Structures. + return; + default: + ASSERT_NOT_REACHED(); + } +} +#endif + +} // namespace JSC diff --git a/bytecode/StructureStubInfo.h b/bytecode/StructureStubInfo.h new file mode 100644 index 0000000..a9e0678 --- /dev/null +++ b/bytecode/StructureStubInfo.h @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef StructureStubInfo_h +#define StructureStubInfo_h + +#include "Instruction.h" +#include "Opcode.h" +#include "Structure.h" + +namespace JSC { + +#if ENABLE(JIT) + struct StructureStubInfo { + StructureStubInfo(OpcodeID opcodeID) + : opcodeID(opcodeID) + , stubRoutine(0) + , callReturnLocation(0) + , hotPathBegin(0) + { + } + + void initGetByIdSelf(Structure* baseObjectStructure) + { + opcodeID = op_get_by_id_self; + + u.getByIdSelf.baseObjectStructure = baseObjectStructure; + baseObjectStructure->ref(); + } + + void initGetByIdProto(Structure* baseObjectStructure, Structure* prototypeStructure) + { + opcodeID = op_get_by_id_proto; + + u.getByIdProto.baseObjectStructure = baseObjectStructure; + baseObjectStructure->ref(); + + u.getByIdProto.prototypeStructure = prototypeStructure; + prototypeStructure->ref(); + } + + void initGetByIdChain(Structure* baseObjectStructure, StructureChain* chain) + { + opcodeID = op_get_by_id_chain; + + u.getByIdChain.baseObjectStructure = baseObjectStructure; + baseObjectStructure->ref(); + + u.getByIdChain.chain = chain; + chain->ref(); + } + + void initGetByIdSelfList(PolymorphicAccessStructureList* structureList, int listSize) + { + opcodeID = op_get_by_id_self_list; + + u.getByIdProtoList.structureList = structureList; + u.getByIdProtoList.listSize = listSize; + } + + void initGetByIdProtoList(PolymorphicAccessStructureList* structureList, int listSize) + { + opcodeID = op_get_by_id_proto_list; + + u.getByIdProtoList.structureList = structureList; + u.getByIdProtoList.listSize = listSize; + } + + // PutById* + + void initPutByIdTransition(Structure* previousStructure, Structure* structure, StructureChain* chain) + { + opcodeID = op_put_by_id_transition; + + u.putByIdTransition.previousStructure = previousStructure; + previousStructure->ref(); + + u.putByIdTransition.structure = structure; + structure->ref(); + + u.putByIdTransition.chain = chain; + chain->ref(); + } + + void initPutByIdReplace(Structure* baseObjectStructure) + { + opcodeID = op_put_by_id_replace; + + u.putByIdReplace.baseObjectStructure = baseObjectStructure; + baseObjectStructure->ref(); + } + + void deref(); + + OpcodeID opcodeID; + union { + struct { + Structure* baseObjectStructure; + } getByIdSelf; + struct { + Structure* baseObjectStructure; + Structure* prototypeStructure; + } getByIdProto; + struct { + Structure* baseObjectStructure; + StructureChain* chain; + } getByIdChain; + struct { + PolymorphicAccessStructureList* structureList; + int listSize; + } getByIdSelfList; + struct { + PolymorphicAccessStructureList* structureList; + int listSize; + } getByIdProtoList; + struct { + Structure* previousStructure; + Structure* structure; + StructureChain* chain; + } putByIdTransition; + struct { + Structure* baseObjectStructure; + } putByIdReplace; + } u; + + void* stubRoutine; + void* callReturnLocation; + void* hotPathBegin; + }; +#endif + +} // namespace JSC + +#endif // StructureStubInfo_h diff --git a/bytecompiler/BytecodeGenerator.cpp b/bytecompiler/BytecodeGenerator.cpp new file mode 100644 index 0000000..cd89c1e --- /dev/null +++ b/bytecompiler/BytecodeGenerator.cpp @@ -0,0 +1,1792 @@ +/* + * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2008 Cameron Zwarich + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "BytecodeGenerator.h" + +#include "BatchedTransitionOptimizer.h" +#include "JSFunction.h" +#include "Interpreter.h" +#include "UString.h" + +using namespace std; + +namespace JSC { + +/* + The layout of a register frame looks like this: + + For + + function f(x, y) { + var v1; + function g() { } + var v2; + return (x) * (y); + } + + assuming (x) and (y) generated temporaries t1 and t2, you would have + + ------------------------------------ + | x | y | g | v2 | v1 | t1 | t2 | <-- value held + ------------------------------------ + | -5 | -4 | -3 | -2 | -1 | +0 | +1 | <-- register index + ------------------------------------ + | params->|<-locals | temps-> + + Because temporary registers are allocated in a stack-like fashion, we + can reclaim them with a simple popping algorithm. The same goes for labels. + (We never reclaim parameter or local registers, because parameters and + locals are DontDelete.) + + The register layout before a function call looks like this: + + For + + function f(x, y) + { + } + + f(1); + + > <------------------------------ + < > reserved: call frame | 1 | <-- value held + > >snip< <------------------------------ + < > +0 | +1 | +2 | +3 | +4 | +5 | <-- register index + > <------------------------------ + | params->|<-locals | temps-> + + The call instruction fills in the "call frame" registers. It also pads + missing arguments at the end of the call: + + > <----------------------------------- + < > reserved: call frame | 1 | ? | <-- value held ("?" stands for "undefined") + > >snip< <----------------------------------- + < > +0 | +1 | +2 | +3 | +4 | +5 | +6 | <-- register index + > <----------------------------------- + | params->|<-locals | temps-> + + After filling in missing arguments, the call instruction sets up the new + stack frame to overlap the end of the old stack frame: + + |----------------------------------> < + | reserved: call frame | 1 | ? < > <-- value held ("?" stands for "undefined") + |----------------------------------> >snip< < + | -7 | -6 | -5 | -4 | -3 | -2 | -1 < > <-- register index + |----------------------------------> < + | | params->|<-locals | temps-> + + That way, arguments are "copied" into the callee's stack frame for free. + + If the caller supplies too many arguments, this trick doesn't work. The + extra arguments protrude into space reserved for locals and temporaries. + In that case, the call instruction makes a real copy of the call frame header, + along with just the arguments expected by the callee, leaving the original + call frame header and arguments behind. (The call instruction can't just discard + extra arguments, because the "arguments" object may access them later.) + This copying strategy ensures that all named values will be at the indices + expected by the callee. +*/ + +#ifndef NDEBUG +static bool s_dumpsGeneratedCode = false; +#endif + +void BytecodeGenerator::setDumpsGeneratedCode(bool dumpsGeneratedCode) +{ +#ifndef NDEBUG + s_dumpsGeneratedCode = dumpsGeneratedCode; +#else + UNUSED_PARAM(dumpsGeneratedCode); +#endif +} + +bool BytecodeGenerator::dumpsGeneratedCode() +{ +#ifndef NDEBUG + return s_dumpsGeneratedCode; +#else + return false; +#endif +} + +void BytecodeGenerator::generate() +{ + m_codeBlock->setThisRegister(m_thisRegister.index()); + + m_scopeNode->emitBytecode(*this); + +#ifndef NDEBUG + m_codeBlock->setInstructionCount(m_codeBlock->instructions().size()); + + if (s_dumpsGeneratedCode) + m_codeBlock->dump(m_scopeChain->globalObject()->globalExec()); +#endif + + if ((m_codeType == FunctionCode && !m_codeBlock->needsFullScopeChain() && !m_codeBlock->usesArguments()) || m_codeType == EvalCode) + symbolTable().clear(); + + m_codeBlock->setIsNumericCompareFunction(instructions() == m_globalData->numericCompareFunction(m_scopeChain->globalObject()->globalExec())); + +#if !ENABLE(OPCODE_SAMPLING) + if (!m_regeneratingForExceptionInfo && (m_codeType == FunctionCode || m_codeType == EvalCode)) + m_codeBlock->clearExceptionInfo(); +#endif + + m_codeBlock->shrinkToFit(); +} + +bool BytecodeGenerator::addVar(const Identifier& ident, bool isConstant, RegisterID*& r0) +{ + int index = m_calleeRegisters.size(); + SymbolTableEntry newEntry(index, isConstant ? ReadOnly : 0); + pair result = symbolTable().add(ident.ustring().rep(), newEntry); + + if (!result.second) { + r0 = ®isterFor(result.first->second.getIndex()); + return false; + } + + ++m_codeBlock->m_numVars; + r0 = newRegister(); + return true; +} + +bool BytecodeGenerator::addGlobalVar(const Identifier& ident, bool isConstant, RegisterID*& r0) +{ + int index = m_nextGlobalIndex; + SymbolTableEntry newEntry(index, isConstant ? ReadOnly : 0); + pair result = symbolTable().add(ident.ustring().rep(), newEntry); + + if (!result.second) + index = result.first->second.getIndex(); + else { + --m_nextGlobalIndex; + m_globals.append(index + m_globalVarStorageOffset); + } + + r0 = ®isterFor(index); + return result.second; +} + +void BytecodeGenerator::allocateConstants(size_t count) +{ + m_codeBlock->m_numConstants = count; + if (!count) + return; + + m_nextConstantIndex = m_calleeRegisters.size(); + + for (size_t i = 0; i < count; ++i) + newRegister(); + m_lastConstant = &m_calleeRegisters.last(); +} + +BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const Debugger* debugger, const ScopeChain& scopeChain, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock) + : m_shouldEmitDebugHooks(!!debugger) + , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling()) + , m_scopeChain(&scopeChain) + , m_symbolTable(symbolTable) + , m_scopeNode(programNode) + , m_codeBlock(codeBlock) + , m_thisRegister(RegisterFile::ProgramCodeThisRegister) + , m_finallyDepth(0) + , m_dynamicScopeDepth(0) + , m_baseScopeDepth(0) + , m_codeType(GlobalCode) + , m_nextGlobalIndex(-1) + , m_globalData(&scopeChain.globalObject()->globalExec()->globalData()) + , m_lastOpcodeID(op_end) + , m_emitNodeDepth(0) + , m_regeneratingForExceptionInfo(false) + , m_codeBlockBeingRegeneratedFrom(0) +{ + if (m_shouldEmitDebugHooks) + m_codeBlock->setNeedsFullScopeChain(true); + + emitOpcode(op_enter); + codeBlock->setGlobalData(m_globalData); + + // FIXME: Move code that modifies the global object to Interpreter::execute. + + m_codeBlock->m_numParameters = 1; // Allocate space for "this" + + JSGlobalObject* globalObject = scopeChain.globalObject(); + ExecState* exec = globalObject->globalExec(); + RegisterFile* registerFile = &exec->globalData().interpreter->registerFile(); + + // Shift register indexes in generated code to elide registers allocated by intermediate stack frames. + m_globalVarStorageOffset = -RegisterFile::CallFrameHeaderSize - m_codeBlock->m_numParameters - registerFile->size(); + + // Add previously defined symbols to bookkeeping. + m_globals.grow(symbolTable->size()); + SymbolTable::iterator end = symbolTable->end(); + for (SymbolTable::iterator it = symbolTable->begin(); it != end; ++it) + registerFor(it->second.getIndex()).setIndex(it->second.getIndex() + m_globalVarStorageOffset); + + BatchedTransitionOptimizer optimizer(globalObject); + + const VarStack& varStack = programNode->varStack(); + const FunctionStack& functionStack = programNode->functionStack(); + bool canOptimizeNewGlobals = symbolTable->size() + functionStack.size() + varStack.size() < registerFile->maxGlobals(); + if (canOptimizeNewGlobals) { + // Shift new symbols so they get stored prior to existing symbols. + m_nextGlobalIndex -= symbolTable->size(); + + for (size_t i = 0; i < functionStack.size(); ++i) { + FuncDeclNode* funcDecl = functionStack[i].get(); + globalObject->removeDirect(funcDecl->m_ident); // Make sure our new function is not shadowed by an old property. + emitNewFunction(addGlobalVar(funcDecl->m_ident, false), funcDecl); + } + + Vector newVars; + for (size_t i = 0; i < varStack.size(); ++i) + if (!globalObject->hasProperty(exec, varStack[i].first)) + newVars.append(addGlobalVar(varStack[i].first, varStack[i].second & DeclarationStacks::IsConstant)); + + allocateConstants(programNode->neededConstants()); + + for (size_t i = 0; i < newVars.size(); ++i) + emitLoad(newVars[i], jsUndefined()); + } else { + for (size_t i = 0; i < functionStack.size(); ++i) { + FuncDeclNode* funcDecl = functionStack[i].get(); + globalObject->putWithAttributes(exec, funcDecl->m_ident, funcDecl->makeFunction(exec, scopeChain.node()), DontDelete); + } + for (size_t i = 0; i < varStack.size(); ++i) { + if (globalObject->hasProperty(exec, varStack[i].first)) + continue; + int attributes = DontDelete; + if (varStack[i].second & DeclarationStacks::IsConstant) + attributes |= ReadOnly; + globalObject->putWithAttributes(exec, varStack[i].first, jsUndefined(), attributes); + } + + allocateConstants(programNode->neededConstants()); + } +} + +BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Debugger* debugger, const ScopeChain& scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock) + : m_shouldEmitDebugHooks(!!debugger) + , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling()) + , m_scopeChain(&scopeChain) + , m_symbolTable(symbolTable) + , m_scopeNode(functionBody) + , m_codeBlock(codeBlock) + , m_finallyDepth(0) + , m_dynamicScopeDepth(0) + , m_baseScopeDepth(0) + , m_codeType(FunctionCode) + , m_globalData(&scopeChain.globalObject()->globalExec()->globalData()) + , m_lastOpcodeID(op_end) + , m_emitNodeDepth(0) + , m_regeneratingForExceptionInfo(false) + , m_codeBlockBeingRegeneratedFrom(0) +{ + if (m_shouldEmitDebugHooks) + m_codeBlock->setNeedsFullScopeChain(true); + + codeBlock->setGlobalData(m_globalData); + + bool usesArguments = functionBody->usesArguments(); + codeBlock->setUsesArguments(usesArguments); + if (usesArguments) { + m_argumentsRegister.setIndex(RegisterFile::OptionalCalleeArguments); + addVar(propertyNames().arguments, false); + } + + if (m_codeBlock->needsFullScopeChain()) { + ++m_codeBlock->m_numVars; + m_activationRegisterIndex = newRegister()->index(); + emitOpcode(op_enter_with_activation); + instructions().append(m_activationRegisterIndex); + } else + emitOpcode(op_enter); + + if (usesArguments) + emitOpcode(op_create_arguments); + + const DeclarationStacks::FunctionStack& functionStack = functionBody->functionStack(); + for (size_t i = 0; i < functionStack.size(); ++i) { + FuncDeclNode* funcDecl = functionStack[i].get(); + const Identifier& ident = funcDecl->m_ident; + m_functions.add(ident.ustring().rep()); + emitNewFunction(addVar(ident, false), funcDecl); + } + + const DeclarationStacks::VarStack& varStack = functionBody->varStack(); + for (size_t i = 0; i < varStack.size(); ++i) + addVar(varStack[i].first, varStack[i].second & DeclarationStacks::IsConstant); + + const Identifier* parameters = functionBody->parameters(); + size_t parameterCount = functionBody->parameterCount(); + m_nextParameterIndex = -RegisterFile::CallFrameHeaderSize - parameterCount - 1; + m_parameters.grow(1 + parameterCount); // reserve space for "this" + + // Add "this" as a parameter + m_thisRegister.setIndex(m_nextParameterIndex); + ++m_nextParameterIndex; + ++m_codeBlock->m_numParameters; + + if (functionBody->usesThis() || m_shouldEmitDebugHooks) { + emitOpcode(op_convert_this); + instructions().append(m_thisRegister.index()); + } + + for (size_t i = 0; i < parameterCount; ++i) + addParameter(parameters[i]); + + allocateConstants(functionBody->neededConstants()); +} + +BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const Debugger* debugger, const ScopeChain& scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock) + : m_shouldEmitDebugHooks(!!debugger) + , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling()) + , m_scopeChain(&scopeChain) + , m_symbolTable(symbolTable) + , m_scopeNode(evalNode) + , m_codeBlock(codeBlock) + , m_thisRegister(RegisterFile::ProgramCodeThisRegister) + , m_finallyDepth(0) + , m_dynamicScopeDepth(0) + , m_baseScopeDepth(codeBlock->baseScopeDepth()) + , m_codeType(EvalCode) + , m_globalData(&scopeChain.globalObject()->globalExec()->globalData()) + , m_lastOpcodeID(op_end) + , m_emitNodeDepth(0) + , m_regeneratingForExceptionInfo(false) + , m_codeBlockBeingRegeneratedFrom(0) +{ + if (m_shouldEmitDebugHooks || m_baseScopeDepth) + m_codeBlock->setNeedsFullScopeChain(true); + + emitOpcode(op_enter); + codeBlock->setGlobalData(m_globalData); + m_codeBlock->m_numParameters = 1; // Allocate space for "this" + + allocateConstants(evalNode->neededConstants()); +} + +RegisterID* BytecodeGenerator::addParameter(const Identifier& ident) +{ + // Parameters overwrite var declarations, but not function declarations. + RegisterID* result = 0; + UString::Rep* rep = ident.ustring().rep(); + if (!m_functions.contains(rep)) { + symbolTable().set(rep, m_nextParameterIndex); + RegisterID& parameter = registerFor(m_nextParameterIndex); + parameter.setIndex(m_nextParameterIndex); + result = ¶meter; + } + + // To maintain the calling convention, we have to allocate unique space for + // each parameter, even if the parameter doesn't make it into the symbol table. + ++m_nextParameterIndex; + ++m_codeBlock->m_numParameters; + return result; +} + +RegisterID* BytecodeGenerator::registerFor(const Identifier& ident) +{ + if (ident == propertyNames().thisIdentifier) + return &m_thisRegister; + + if (!shouldOptimizeLocals()) + return 0; + + SymbolTableEntry entry = symbolTable().get(ident.ustring().rep()); + if (entry.isNull()) + return 0; + + return ®isterFor(entry.getIndex()); +} + +RegisterID* BytecodeGenerator::constRegisterFor(const Identifier& ident) +{ + if (m_codeType == EvalCode) + return 0; + + SymbolTableEntry entry = symbolTable().get(ident.ustring().rep()); + ASSERT(!entry.isNull()); + + return ®isterFor(entry.getIndex()); +} + +bool BytecodeGenerator::isLocal(const Identifier& ident) +{ + if (ident == propertyNames().thisIdentifier) + return true; + + return shouldOptimizeLocals() && symbolTable().contains(ident.ustring().rep()); +} + +bool BytecodeGenerator::isLocalConstant(const Identifier& ident) +{ + return symbolTable().get(ident.ustring().rep()).isReadOnly(); +} + +RegisterID* BytecodeGenerator::newRegister() +{ + m_calleeRegisters.append(m_calleeRegisters.size()); + m_codeBlock->m_numCalleeRegisters = max(m_codeBlock->m_numCalleeRegisters, m_calleeRegisters.size()); + return &m_calleeRegisters.last(); +} + +RegisterID* BytecodeGenerator::newTemporary() +{ + // Reclaim free register IDs. + while (m_calleeRegisters.size() && !m_calleeRegisters.last().refCount()) + m_calleeRegisters.removeLast(); + + RegisterID* result = newRegister(); + result->setTemporary(); + return result; +} + +RegisterID* BytecodeGenerator::highestUsedRegister() +{ + size_t count = m_codeBlock->m_numCalleeRegisters; + while (m_calleeRegisters.size() < count) + newRegister(); + return &m_calleeRegisters.last(); +} + +PassRefPtr BytecodeGenerator::newLabelScope(LabelScope::Type type, const Identifier* name) +{ + // Reclaim free label scopes. + while (m_labelScopes.size() && !m_labelScopes.last().refCount()) + m_labelScopes.removeLast(); + + // Allocate new label scope. + LabelScope scope(type, name, scopeDepth(), newLabel(), type == LabelScope::Loop ? newLabel() : 0); // Only loops have continue targets. + m_labelScopes.append(scope); + return &m_labelScopes.last(); +} + +PassRefPtr diff --git a/kjs/Activation.h b/kjs/Activation.h deleted file mode 100644 index 0fdd2cc..0000000 --- a/kjs/Activation.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) - * Copyright (C) 2007 Maks Orlovich - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef Activation_h -#define Activation_h - -#include "ExecState.h" -#include "JSVariableObject.h" -#include "object.h" - -namespace KJS { - - class Arguments; - class FunctionImp; - - class ActivationImp : public JSVariableObject { - friend class JSGlobalObject; - friend struct StackActivation; - private: - struct ActivationData : public JSVariableObjectData { - ActivationData() : isOnStack(true), leftRelic(false) { } - ActivationData(const ActivationData&); - - ExecState* exec; - FunctionImp* function; - Arguments* argumentsObject; - - bool isOnStack : 1; - bool leftRelic : 1; - }; - - public: - ActivationImp() { } - ActivationImp(const ActivationData&, bool); - - virtual ~ActivationImp(); - - void init(ExecState*); - - virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - virtual void put(ExecState*, const Identifier&, JSValue*, int attr = None); - virtual bool deleteProperty(ExecState*, const Identifier& propertyName); - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - - virtual void mark(); - void markChildren(); - - virtual bool isActivationObject() { return true; } - - bool isOnStack() const { return d()->isOnStack; } - bool needsPop() const { return d()->isOnStack || d()->leftRelic; } - - private: - static PropertySlot::GetValueFunc getArgumentsGetter(); - static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); - void createArgumentsObject(ExecState*); - ActivationData* d() const { return static_cast(JSVariableObject::d); } - }; - - const size_t activationStackNodeSize = 32; - - struct StackActivation { - StackActivation() { activationStorage.JSVariableObject::d = &activationDataStorage; } - StackActivation(const StackActivation&); - - ActivationImp activationStorage; - ActivationImp::ActivationData activationDataStorage; - }; - - struct ActivationStackNode { - ActivationStackNode* prev; - StackActivation data[activationStackNodeSize]; - }; - -} // namespace - -#endif diff --git a/kjs/AllInOneFile.cpp b/kjs/AllInOneFile.cpp deleted file mode 100644 index 8c19f80..0000000 --- a/kjs/AllInOneFile.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -*- mode: c++; c-basic-offset: 4 -*- -/* - * Copyright (C) 2006 Apple Computer, Inc - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -// This file exists to help compile the essential code of -// JavaScriptCore all as one file, for compilers and build systems -// that see a significant speed gain from this. - -#define KDE_USE_FINAL 1 -#include "config.h" - -#include "function.cpp" -#include "debugger.cpp" -#include "array_instance.cpp" -#include "array_object.cpp" -#include "bool_object.cpp" -#include "collector.cpp" -#if PLATFORM(DARWIN) -#include "CollectorHeapIntrospector.cpp" -#endif -#include "CommonIdentifiers.cpp" -#include "date_object.cpp" -#include "DateMath.cpp" -#include "dtoa.cpp" -#include "error_object.cpp" -#include "ExecState.cpp" -#include "function_object.cpp" -#include "grammar.cpp" -#include "identifier.cpp" -#include "internal.cpp" -#include "interpreter.cpp" -#include "JSImmediate.cpp" -#include "JSLock.cpp" -#include "JSWrapperObject.cpp" -#include "lexer.cpp" -#include "list.cpp" -#include "lookup.cpp" -#include "math_object.cpp" -#include "nodes.cpp" -#include "nodes2string.cpp" -#include "number_object.cpp" -#include "object.cpp" -#include "object_object.cpp" -#include "operations.cpp" -#include "Parser.cpp" -#include "property_map.cpp" -#include "property_slot.cpp" -#include "PropertyNameArray.cpp" -#include "regexp.cpp" -#include "regexp_object.cpp" -#include "scope_chain.cpp" -#include "string_object.cpp" -#include "ustring.cpp" -#include "value.cpp" -#include "wtf/FastMalloc.cpp" -#include "wtf/TCSystemAlloc.cpp" diff --git a/kjs/CollectorHeapIntrospector.cpp b/kjs/CollectorHeapIntrospector.cpp deleted file mode 100644 index 6941b58..0000000 --- a/kjs/CollectorHeapIntrospector.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "CollectorHeapIntrospector.h" - -#include "collector.h" -#include "MallocZoneSupport.h" - -namespace KJS { - -extern "C" { -malloc_introspection_t jscore_collector_introspection = { &CollectorHeapIntrospector::enumerate, &CollectorHeapIntrospector::goodSize, &CollectorHeapIntrospector::check, &CollectorHeapIntrospector::print, - &CollectorHeapIntrospector::log, &CollectorHeapIntrospector::forceLock, &CollectorHeapIntrospector::forceUnlock, &CollectorHeapIntrospector::statistics }; -} - -void CollectorHeapIntrospector::init(CollectorHeap* primaryHeap, CollectorHeap* numberHeap) -{ - static CollectorHeapIntrospector zone(primaryHeap, numberHeap); -} - -CollectorHeapIntrospector::CollectorHeapIntrospector(CollectorHeap* primaryHeap, CollectorHeap* numberHeap) - : m_primaryHeap(primaryHeap) - , m_numberHeap(numberHeap) -{ - memset(&m_zone, 0, sizeof(m_zone)); - m_zone.zone_name = "JavaScriptCore Collector"; - m_zone.size = &CollectorHeapIntrospector::size; - m_zone.malloc = &CollectorHeapIntrospector::zoneMalloc; - m_zone.calloc = &CollectorHeapIntrospector::zoneCalloc; - m_zone.realloc = &CollectorHeapIntrospector::zoneRealloc; - m_zone.free = &CollectorHeapIntrospector::zoneFree; - m_zone.valloc = &CollectorHeapIntrospector::zoneValloc; - m_zone.destroy = &CollectorHeapIntrospector::zoneDestroy; - m_zone.introspect = &jscore_collector_introspection; - malloc_zone_register(&m_zone); -} - -kern_return_t CollectorHeapIntrospector::enumerate(task_t task, void* context, unsigned typeMask, vm_address_t zoneAddress, memory_reader_t reader, vm_range_recorder_t recorder) -{ - RemoteMemoryReader memoryReader(task, reader); - CollectorHeapIntrospector* zone = memoryReader(reinterpret_cast(zoneAddress)); - CollectorHeap* heaps[2] = {memoryReader(zone->m_primaryHeap), memoryReader(zone->m_numberHeap)}; - - if (!heaps[0]->blocks && !heaps[1]->blocks) - return 0; - - for (int currentHeap = 0; currentHeap < 2; currentHeap++) { - CollectorHeap* heap = heaps[currentHeap]; - CollectorBlock** blocks = memoryReader(heap->blocks); - for (unsigned i = 0; i < heap->usedBlocks; i++) { - vm_address_t remoteBlockAddress = reinterpret_cast(blocks[i]); - vm_range_t ptrRange = { remoteBlockAddress, sizeof(CollectorBlock) }; - - if (typeMask & (MALLOC_PTR_REGION_RANGE_TYPE | MALLOC_ADMIN_REGION_RANGE_TYPE)) - (*recorder)(task, context, MALLOC_PTR_REGION_RANGE_TYPE, &ptrRange, 1); - - // Recording individual cells causes frequent false-positives. Any garbage cells - // which have yet to be collected are labeled as leaks. Recording on a per-block - // basis provides less detail but avoids these false-positives. - if (memoryReader(blocks[i])->usedCells && (typeMask & MALLOC_PTR_IN_USE_RANGE_TYPE)) - (*recorder)(task, context, MALLOC_PTR_IN_USE_RANGE_TYPE, &ptrRange, 1); - } - } - - return 0; -} - -} // namespace KJS diff --git a/kjs/CollectorHeapIntrospector.h b/kjs/CollectorHeapIntrospector.h deleted file mode 100644 index 76ba324..0000000 --- a/kjs/CollectorHeapIntrospector.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef CollectorHeapIntrospector_h -#define CollectorHeapIntrospector_h - -#include -#include "Assertions.h" - -namespace KJS { - -struct CollectorHeap; - -class CollectorHeapIntrospector { -public: - static void init(CollectorHeap*, CollectorHeap*); - static kern_return_t enumerate(task_t, void* context, unsigned typeMask, vm_address_t zoneAddress, memory_reader_t, vm_range_recorder_t); - static size_t goodSize(malloc_zone_t*, size_t size) { return size; } - static boolean_t check(malloc_zone_t*) { return true; } - static void print(malloc_zone_t*, boolean_t) { } - static void log(malloc_zone_t*, void*) { } - static void forceLock(malloc_zone_t*) { } - static void forceUnlock(malloc_zone_t*) { } - static void statistics(malloc_zone_t*, malloc_statistics_t*) { } - -private: - CollectorHeapIntrospector(CollectorHeap*, CollectorHeap*); - static size_t size(malloc_zone_t*, const void*) { return 0; } - static void* zoneMalloc(malloc_zone_t*, size_t) { LOG_ERROR("malloc is not supported"); return 0; } - static void* zoneCalloc(malloc_zone_t*, size_t, size_t) { LOG_ERROR("calloc is not supported"); return 0; } - static void* zoneRealloc(malloc_zone_t*, void*, size_t) { LOG_ERROR("realloc is not supported"); return 0; } - static void* zoneValloc(malloc_zone_t*, size_t) { LOG_ERROR("valloc is not supported"); return 0; } - static void zoneDestroy(malloc_zone_t*) { } - - static void zoneFree(malloc_zone_t*, void* ptr) - { - // Due to zoneFree may be called by the system free even if the pointer - // is not in this zone. When this happens, the pointer being freed was not allocated by any - // zone so we need to print a useful error for the application developer. - malloc_printf("*** error for object %p: pointer being freed was not allocated\n", ptr); - } - - malloc_zone_t m_zone; - CollectorHeap* m_primaryHeap; - CollectorHeap* m_numberHeap; -}; - -} - -#endif // CollectorHeapIntrospector_h diff --git a/kjs/DateMath.cpp b/kjs/DateMath.cpp deleted file mode 100644 index 22816b3..0000000 --- a/kjs/DateMath.cpp +++ /dev/null @@ -1,506 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Alternatively, the contents of this file may be used under the terms - * of either the Mozilla Public License Version 1.1, found at - * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public - * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html - * (the "GPL"), in which case the provisions of the MPL or the GPL are - * applicable instead of those above. If you wish to allow use of your - * version of this file only under the terms of one of those two - * licenses (the MPL or the GPL) and not to allow others to use your - * version of this file under the LGPL, indicate your decision by - * deletingthe provisions above and replace them with the notice and - * other provisions required by the MPL or the GPL, as the case may be. - * If you do not delete the provisions above, a recipient may use your - * version of this file under any of the LGPL, the MPL or the GPL. - */ - -#include "config.h" -#include "DateMath.h" - -#include -#include -#include - -#include - -#if PLATFORM(DARWIN) -#include -#endif - -#if HAVE(SYS_TIME_H) -#include -#endif - -#if HAVE(SYS_TIMEB_H) -#include -#endif - -namespace KJS { - -/* Constants */ - -static const double minutesPerDay = 24.0 * 60.0; -static const double secondsPerDay = 24.0 * 60.0 * 60.0; -static const double secondsPerYear = 24.0 * 60.0 * 60.0 * 365.0; - -static const double usecPerSec = 1000000.0; - -static const double maxUnixTime = 2145859200.0; // 12/31/2037 - -// Day of year for the first day of each month, where index 0 is January, and day 0 is January 1. -// First for non-leap years, then for leap years. -static const int firstDayOfMonth[2][12] = { - {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, - {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335} -}; - -static inline bool isLeapYear(int year) -{ - if (year % 4 != 0) - return false; - if (year % 400 == 0) - return true; - if (year % 100 == 0) - return false; - return true; -} - -static inline int daysInYear(int year) -{ - return 365 + isLeapYear(year); -} - -static inline double daysFrom1970ToYear(int year) -{ - // The Gregorian Calendar rules for leap years: - // Every fourth year is a leap year. 2004, 2008, and 2012 are leap years. - // However, every hundredth year is not a leap year. 1900 and 2100 are not leap years. - // Every four hundred years, there's a leap year after all. 2000 and 2400 are leap years. - - static const int leapDaysBefore1971By4Rule = 1970 / 4; - static const int excludedLeapDaysBefore1971By100Rule = 1970 / 100; - static const int leapDaysBefore1971By400Rule = 1970 / 400; - - const double yearMinusOne = year - 1; - const double yearsToAddBy4Rule = floor(yearMinusOne / 4.0) - leapDaysBefore1971By4Rule; - const double yearsToExcludeBy100Rule = floor(yearMinusOne / 100.0) - excludedLeapDaysBefore1971By100Rule; - const double yearsToAddBy400Rule = floor(yearMinusOne / 400.0) - leapDaysBefore1971By400Rule; - - return 365.0 * (year - 1970) + yearsToAddBy4Rule - yearsToExcludeBy100Rule + yearsToAddBy400Rule; -} - -static inline double msToDays(double ms) -{ - return floor(ms / msPerDay); -} - -static inline int msToYear(double ms) -{ - int approxYear = static_cast(floor(ms / (msPerDay * 365.2425)) + 1970); - double msFromApproxYearTo1970 = msPerDay * daysFrom1970ToYear(approxYear); - if (msFromApproxYearTo1970 > ms) - return approxYear - 1; - if (msFromApproxYearTo1970 + msPerDay * daysInYear(approxYear) <= ms) - return approxYear + 1; - return approxYear; -} - -static inline int dayInYear(double ms, int year) -{ - return static_cast(msToDays(ms) - daysFrom1970ToYear(year)); -} - -static inline double msToMilliseconds(double ms) -{ - double result = fmod(ms, msPerDay); - if (result < 0) - result += msPerDay; - return result; -} - -// 0: Sunday, 1: Monday, etc. -static inline int msToWeekDay(double ms) -{ - int wd = (static_cast(msToDays(ms)) + 4) % 7; - if (wd < 0) - wd += 7; - return wd; -} - -static inline int msToSeconds(double ms) -{ - double result = fmod(floor(ms / msPerSecond), secondsPerMinute); - if (result < 0) - result += secondsPerMinute; - return static_cast(result); -} - -static inline int msToMinutes(double ms) -{ - double result = fmod(floor(ms / msPerMinute), minutesPerHour); - if (result < 0) - result += minutesPerHour; - return static_cast(result); -} - -static inline int msToHours(double ms) -{ - double result = fmod(floor(ms/msPerHour), hoursPerDay); - if (result < 0) - result += hoursPerDay; - return static_cast(result); -} - -static inline int monthFromDayInYear(int dayInYear, bool leapYear) -{ - const int d = dayInYear; - int step; - - if (d < (step = 31)) - return 0; - step += (leapYear ? 29 : 28); - if (d < step) - return 1; - if (d < (step += 31)) - return 2; - if (d < (step += 30)) - return 3; - if (d < (step += 31)) - return 4; - if (d < (step += 30)) - return 5; - if (d < (step += 31)) - return 6; - if (d < (step += 31)) - return 7; - if (d < (step += 30)) - return 8; - if (d < (step += 31)) - return 9; - if (d < (step += 30)) - return 10; - return 11; -} - -static inline bool checkMonth(int dayInYear, int& startDayOfThisMonth, int& startDayOfNextMonth, int daysInThisMonth) -{ - startDayOfThisMonth = startDayOfNextMonth; - startDayOfNextMonth += daysInThisMonth; - return (dayInYear <= startDayOfNextMonth); -} - -static inline int dayInMonthFromDayInYear(int dayInYear, bool leapYear) -{ - const int d = dayInYear; - int step; - int next = 30; - - if (d <= next) - return d + 1; - const int daysInFeb = (leapYear ? 29 : 28); - if (checkMonth(d, step, next, daysInFeb)) - return d - step; - if (checkMonth(d, step, next, 31)) - return d - step; - if (checkMonth(d, step, next, 30)) - return d - step; - if (checkMonth(d, step, next, 31)) - return d - step; - if (checkMonth(d, step, next, 30)) - return d - step; - if (checkMonth(d, step, next, 31)) - return d - step; - if (checkMonth(d, step, next, 31)) - return d - step; - if (checkMonth(d, step, next, 30)) - return d - step; - if (checkMonth(d, step, next, 31)) - return d - step; - if (checkMonth(d, step, next, 30)) - return d - step; - step = next; - return d - step; -} - -static inline int monthToDayInYear(int month, bool isLeapYear) -{ - return firstDayOfMonth[isLeapYear][month]; -} - -static inline double timeToMS(double hour, double min, double sec, double ms) -{ - return (((hour * minutesPerHour + min) * secondsPerMinute + sec) * msPerSecond + ms); -} - -static int dateToDayInYear(int year, int month, int day) -{ - year += month / 12; - - month %= 12; - if (month < 0) { - month += 12; - --year; - } - - int yearday = static_cast(floor(daysFrom1970ToYear(year))); - int monthday = monthToDayInYear(month, isLeapYear(year)); - - return yearday + monthday + day - 1; -} - -double getCurrentUTCTime() -{ -#if PLATFORM(WIN_OS) -#if COMPILER(BORLAND) - struct timeb timebuffer; - ftime(&timebuffer); -#else - struct _timeb timebuffer; - _ftime(&timebuffer); -#endif - double utc = timebuffer.time * msPerSecond + timebuffer.millitm; -#else - struct timeval tv; - gettimeofday(&tv, 0); - double utc = floor(tv.tv_sec * msPerSecond + tv.tv_usec / 1000); -#endif - return utc; -} - -// There is a hard limit at 2038 that we currently do not have a workaround -// for (rdar://problem/5052975). -static inline int maximumYearForDST() -{ - return 2037; -} - -// It is ok if the cached year is not the current year (e.g. Dec 31st) -// so long as the rules for DST did not change between the two years, if it does -// the app would need to be restarted. -static int mimimumYearForDST() -{ - // Because of the 2038 issue (see maximumYearForDST) if the current year is - // greater than the max year minus 27 (2010), we want to use the max year - // minus 27 instead, to ensure there is a range of 28 years that all years - // can map to. - static int minYear = std::min(msToYear(getCurrentUTCTime()), maximumYearForDST() - 27) ; - return minYear; -} - -/* - * Find an equivalent year for the one given, where equivalence is deterined by - * the two years having the same leapness and the first day of the year, falling - * on the same day of the week. - * - * This function returns a year between this current year and 2037, however this - * function will potentially return incorrect results if the current year is after - * 2010, (rdar://problem/5052975), if the year passed in is before 1900 or after - * 2100, (rdar://problem/5055038). - */ -int equivalentYearForDST(int year) -{ - static int minYear = mimimumYearForDST(); - static int maxYear = maximumYearForDST(); - - int difference; - if (year > maxYear) - difference = minYear - year; - else if (year < minYear) - difference = maxYear - year; - else - return year; - - int quotient = difference / 28; - int product = (quotient) * 28; - - year += product; - ASSERT((year >= minYear && year <= maxYear) || (product - year == static_cast(NaN))); - return year; -} - -/* - * Get the difference in milliseconds between this time zone and UTC (GMT) - * NOT including DST. - */ -double getUTCOffset() -{ -#if PLATFORM(DARWIN) - // Register for a notification whenever the time zone changes. - static bool triedToRegister = false; - static bool haveNotificationToken = false; - static int notificationToken; - if (!triedToRegister) { - triedToRegister = true; - uint32_t status = notify_register_check("com.apple.system.timezone", ¬ificationToken); - if (status == NOTIFY_STATUS_OK) - haveNotificationToken = true; - } - - // If we can verify that we have not received a time zone notification, - // then use the cached offset from the last time this function was called. - static bool haveCachedOffset = false; - static double cachedOffset; - if (haveNotificationToken && haveCachedOffset) { - int notified; - uint32_t status = notify_check(notificationToken, ¬ified); - if (status == NOTIFY_STATUS_OK && !notified) - return cachedOffset; - } -#endif - - tm localt; - - memset(&localt, 0, sizeof(localt)); - - // get the difference between this time zone and UTC on Jan 01, 2000 12:00:00 AM - localt.tm_mday = 1; - localt.tm_year = 100; - double utcOffset = 946684800.0 - mktime(&localt); - - utcOffset *= msPerSecond; - -#if PLATFORM(DARWIN) - haveCachedOffset = true; - cachedOffset = utcOffset; -#endif - - return utcOffset; -} - -/* - * Get the DST offset for the time passed in. Takes - * seconds (not milliseconds) and cannot handle dates before 1970 - * on some OS' - */ -static double getDSTOffsetSimple(double localTimeSeconds, double utcOffset) -{ - if (localTimeSeconds > maxUnixTime) - localTimeSeconds = maxUnixTime; - else if (localTimeSeconds < 0) // Go ahead a day to make localtime work (does not work with 0) - localTimeSeconds += secondsPerDay; - - //input is UTC so we have to shift back to local time to determine DST thus the + getUTCOffset() - double offsetTime = (localTimeSeconds * msPerSecond) + utcOffset; - - // Offset from UTC but doesn't include DST obviously - int offsetHour = msToHours(offsetTime); - int offsetMinute = msToMinutes(offsetTime); - - // FIXME: time_t has a potential problem in 2038 - time_t localTime = static_cast(localTimeSeconds); - - tm localTM; -#if PLATFORM(QT) - // ### this is not threadsafe but we don't use multiple threads anyway - // in the Qt build -#if USE(MULTIPLE_THREADS) -#error Mulitple threads are currently not supported in the Qt/mingw build -#endif - localTM = *localtime(&localTime); -#elif PLATFORM(WIN_OS) - #if COMPILER(MSVC7) - localTM = *localtime(&localTime); - #else - localtime_s(&localTM, &localTime); - #endif -#else - localtime_r(&localTime, &localTM); -#endif - - double diff = ((localTM.tm_hour - offsetHour) * secondsPerHour) + ((localTM.tm_min - offsetMinute) * 60); - - if (diff < 0) - diff += secondsPerDay; - - return (diff * msPerSecond); -} - -// Get the DST offset, given a time in UTC -static double getDSTOffset(double ms, double utcOffset) -{ - // On Mac OS X, the call to localtime (see getDSTOffsetSimple) will return historically accurate - // DST information (e.g. New Zealand did not have DST from 1946 to 1974) however the JavaScript - // standard explicitly dictates that historical information should not be considered when - // determining DST. For this reason we shift away from years that localtime can handle but would - // return historically accurate information. - int year = msToYear(ms); - int equivalentYear = equivalentYearForDST(year); - if (year != equivalentYear) { - bool leapYear = isLeapYear(year); - int dayInYearLocal = dayInYear(ms, year); - int dayInMonth = dayInMonthFromDayInYear(dayInYearLocal, leapYear); - int month = monthFromDayInYear(dayInYearLocal, leapYear); - int day = dateToDayInYear(equivalentYear, month, dayInMonth); - ms = (day * msPerDay) + msToMilliseconds(ms); - } - - return getDSTOffsetSimple(ms / msPerSecond, utcOffset); -} - -double gregorianDateTimeToMS(const GregorianDateTime& t, double milliSeconds, bool inputIsUTC) -{ - int day = dateToDayInYear(t.year + 1900, t.month, t.monthDay); - double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds); - double result = (day * msPerDay) + ms; - - if (!inputIsUTC) { // convert to UTC - double utcOffset = getUTCOffset(); - result -= utcOffset; - result -= getDSTOffset(result, utcOffset); - } - - return result; -} - -void msToGregorianDateTime(double ms, bool outputIsUTC, GregorianDateTime& tm) -{ - // input is UTC - double dstOff = 0.0; - const double utcOff = getUTCOffset(); - - if (!outputIsUTC) { // convert to local time - dstOff = getDSTOffset(ms, utcOff); - ms += dstOff + utcOff; - } - - const int year = msToYear(ms); - tm.second = msToSeconds(ms); - tm.minute = msToMinutes(ms); - tm.hour = msToHours(ms); - tm.weekDay = msToWeekDay(ms); - tm.yearDay = dayInYear(ms, year); - tm.monthDay = dayInMonthFromDayInYear(tm.yearDay, isLeapYear(year)); - tm.month = monthFromDayInYear(tm.yearDay, isLeapYear(year)); - tm.year = year - 1900; - tm.isDST = dstOff != 0.0; - - tm.utcOffset = static_cast((dstOff + utcOff) / msPerSecond); - tm.timeZone = NULL; -} - -} // namespace KJS diff --git a/kjs/ExecState.cpp b/kjs/ExecState.cpp deleted file mode 100644 index b37523e..0000000 --- a/kjs/ExecState.cpp +++ /dev/null @@ -1,215 +0,0 @@ -// -*- mode: c++; c-basic-offset: 4 -*- -/* - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "ExecState.h" - -#include "Activation.h" -#include "JSGlobalObject.h" -#include "function.h" -#include "internal.h" -#include "scope_chain_mark.h" - -namespace KJS { - -static inline List* globalEmptyList() -{ - static List staticEmptyList; - return &staticEmptyList; -} - -// ECMA 10.2 - -// The constructor for the globalExec pseudo-ExecState -inline ExecState::ExecState(JSGlobalObject* globalObject) - : m_globalObject(globalObject) - , m_exception(0) - , m_propertyNames(CommonIdentifiers::shared()) - , m_emptyList(globalEmptyList()) - , m_callingExec(0) - , m_scopeNode(0) - , m_function(0) - , m_arguments(0) - , m_activation(0) - , m_localStorage(&globalObject->localStorage()) - , m_variableObject(globalObject) - , m_thisValue(globalObject) - , m_iterationDepth(0) - , m_switchDepth(0) - , m_codeType(GlobalCode) -{ - m_scopeChain.push(globalObject); -} - -inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* /*thisObject*/, ProgramNode* programNode) - : m_globalObject(globalObject) - , m_exception(0) - , m_propertyNames(CommonIdentifiers::shared()) - , m_emptyList(globalEmptyList()) - , m_callingExec(0) - , m_scopeNode(programNode) - , m_function(0) - , m_arguments(0) - , m_activation(0) - , m_localStorage(&globalObject->localStorage()) - , m_variableObject(globalObject) - , m_thisValue(globalObject) - , m_iterationDepth(0) - , m_switchDepth(0) - , m_codeType(GlobalCode) -{ - // FIXME: This function ignores the "thisObject" parameter, which means that the API for evaluating - // a script with a this object that's not the same as the global object is broken, and probably - // has been for some time. - ASSERT(m_scopeNode); - m_scopeChain.push(globalObject); -} - -inline ExecState::ExecState(JSGlobalObject* globalObject, EvalNode* evalNode, ExecState* callingExec) - : m_globalObject(globalObject) - , m_exception(0) - , m_propertyNames(callingExec->m_propertyNames) - , m_emptyList(callingExec->m_emptyList) - , m_callingExec(callingExec) - , m_scopeNode(evalNode) - , m_function(0) - , m_arguments(0) - , m_activation(0) - , m_localStorage(callingExec->m_localStorage) - , m_scopeChain(callingExec->m_scopeChain) - , m_variableObject(callingExec->m_variableObject) - , m_thisValue(callingExec->m_thisValue) - , m_iterationDepth(0) - , m_switchDepth(0) - , m_codeType(EvalCode) -{ - ASSERT(m_scopeNode); -} - -inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisObject, - FunctionBodyNode* functionBodyNode, ExecState* callingExec, - FunctionImp* func, const List& args) - : m_globalObject(globalObject) - , m_exception(0) - , m_propertyNames(callingExec->m_propertyNames) - , m_emptyList(callingExec->m_emptyList) - , m_callingExec(callingExec) - , m_scopeNode(functionBodyNode) - , m_function(func) - , m_arguments(&args) - , m_scopeChain(func->scope()) - , m_thisValue(thisObject) - , m_iterationDepth(0) - , m_switchDepth(0) - , m_codeType(FunctionCode) -{ - ASSERT(m_scopeNode); - - ActivationImp* activation = globalObject->pushActivation(this); - m_activation = activation; - m_localStorage = &activation->localStorage(); - m_variableObject = activation; - m_scopeChain.push(activation); -} - -inline ExecState::~ExecState() -{ -} - -JSGlobalObject* ExecState::lexicalGlobalObject() const -{ - JSObject* object = m_scopeChain.bottom(); - if (object && object->isGlobalObject()) - return static_cast(object); - return m_globalObject; -} - -void ExecState::markActiveExecStates() -{ - ExecStateStack::const_iterator end = activeExecStates().end(); - for (ExecStateStack::const_iterator it = activeExecStates().begin(); it != end; ++it) - (*it)->m_scopeChain.mark(); -} - -static inline ExecStateStack& inlineActiveExecStates() -{ - static ExecStateStack staticActiveExecStates; - return staticActiveExecStates; -} - -ExecStateStack& ExecState::activeExecStates() -{ - return inlineActiveExecStates(); -} - -GlobalExecState::GlobalExecState(JSGlobalObject* globalObject) - : ExecState(globalObject) -{ -} - -GlobalExecState::~GlobalExecState() -{ -} - -InterpreterExecState::InterpreterExecState(JSGlobalObject* globalObject, JSObject* thisObject, ProgramNode* programNode) - : ExecState(globalObject, thisObject, programNode) -{ - inlineActiveExecStates().append(this); -} - -InterpreterExecState::~InterpreterExecState() -{ - ASSERT(inlineActiveExecStates().last() == this); - inlineActiveExecStates().removeLast(); -} - -EvalExecState::EvalExecState(JSGlobalObject* globalObject, EvalNode* evalNode, ExecState* callingExec) - : ExecState(globalObject, evalNode, callingExec) -{ - inlineActiveExecStates().append(this); -} - -EvalExecState::~EvalExecState() -{ - ASSERT(inlineActiveExecStates().last() == this); - inlineActiveExecStates().removeLast(); -} - -FunctionExecState::FunctionExecState(JSGlobalObject* globalObject, JSObject* thisObject, - FunctionBodyNode* functionBodyNode, ExecState* callingExec, - FunctionImp* func, const List& args) - : ExecState(globalObject, thisObject, functionBodyNode, callingExec, func, args) -{ - inlineActiveExecStates().append(this); -} - -FunctionExecState::~FunctionExecState() -{ - ASSERT(inlineActiveExecStates().last() == this); - inlineActiveExecStates().removeLast(); - - if (m_activation->needsPop()) - m_globalObject->popActivation(); -} - -} // namespace KJS diff --git a/kjs/ExecState.h b/kjs/ExecState.h deleted file mode 100644 index ed8b4d2..0000000 --- a/kjs/ExecState.h +++ /dev/null @@ -1,241 +0,0 @@ -// -*- mode: c++; c-basic-offset: 4 -*- -/* - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef ExecState_h -#define ExecState_h - -#include "LabelStack.h" -#include "LocalStorage.h" -#include "completion.h" -#include "list.h" -#include "scope_chain.h" - -namespace KJS { - - class ActivationImp; - class CommonIdentifiers; - class EvalNode; - class FunctionBodyNode; - class FunctionImp; - class GlobalFuncImp; - class Interpreter; - class JSGlobalObject; - class JSVariableObject; - class ProgramNode; - class ScopeNode; - - enum CodeType { GlobalCode, EvalCode, FunctionCode }; - - typedef Vector ExecStateStack; - - // Represents the current state of script execution. - // Passed as the first argument to most functions. - class ExecState : Noncopyable { - public: - // Global object that was in scope when the current script started executing. - JSGlobalObject* dynamicGlobalObject() const { return m_globalObject; } - - // Global object that was in scope when the current body of code was defined. - JSGlobalObject* lexicalGlobalObject() const; - - void setException(JSValue* e) { m_exception = e; } - void clearException() { m_exception = 0; } - JSValue* exception() const { return m_exception; } - JSValue** exceptionSlot() { return &m_exception; } - bool hadException() const { return !!m_exception; } - - const ScopeChain& scopeChain() const { return m_scopeChain; } - void pushScope(JSObject* s) { m_scopeChain.push(s); } - void popScope() { m_scopeChain.pop(); } - void replaceScopeChainTop(JSObject* o) { m_scopeChain.replaceTop(o); } - - JSVariableObject* variableObject() const { return m_variableObject; } - void setVariableObject(JSVariableObject* v) { m_variableObject = v; } - - JSObject* thisValue() const { return m_thisValue; } - - ExecState* callingExecState() { return m_callingExec; } - - ActivationImp* activationObject() { return m_activation; } - void setActivationObject(ActivationImp* a) { m_activation = a; } - CodeType codeType() { return m_codeType; } - ScopeNode* scopeNode() { return m_scopeNode; } - FunctionImp* function() const { return m_function; } - const List* arguments() const { return m_arguments; } - - LabelStack& seenLabels() { return m_labelStack; } - - void pushIteration() { m_iterationDepth++; } - void popIteration() { m_iterationDepth--; } - bool inIteration() const { return (m_iterationDepth > 0); } - - void pushSwitch() { m_switchDepth++; } - void popSwitch() { m_switchDepth--; } - bool inSwitch() const { return (m_switchDepth > 0); } - - // These pointers are used to avoid accessing global variables for these, - // to avoid taking PIC branches in Mach-O binaries. - const CommonIdentifiers& propertyNames() const { return *m_propertyNames; } - const List& emptyList() const { return *m_emptyList; } - - LocalStorage& localStorage() { return *m_localStorage; } - void setLocalStorage(LocalStorage* s) { m_localStorage = s; } - - // These are only valid right after calling execute(). - ComplType completionType() const { return m_completionType; } - const Identifier& breakOrContinueTarget() const - { - ASSERT(m_completionType == Break || m_completionType == Continue); - return *m_breakOrContinueTarget; - } - - // Only for use in the implementation of execute(). - void setCompletionType(ComplType type) - { - ASSERT(type != Break); - ASSERT(type != Continue); - m_completionType = type; - } - JSValue* setNormalCompletion() - { - ASSERT(!hadException()); - m_completionType = Normal; - return 0; - } - JSValue* setNormalCompletion(JSValue* value) - { - ASSERT(!hadException()); - m_completionType = Normal; - return value; - } - JSValue* setBreakCompletion(const Identifier* target) - { - ASSERT(!hadException()); - m_completionType = Break; - m_breakOrContinueTarget = target; - return 0; - } - JSValue* setContinueCompletion(const Identifier* target) - { - ASSERT(!hadException()); - m_completionType = Continue; - m_breakOrContinueTarget = target; - return 0; - } - JSValue* setReturnValueCompletion(JSValue* returnValue) - { - ASSERT(!hadException()); - ASSERT(returnValue); - m_completionType = ReturnValue; - return returnValue; - } - JSValue* setThrowCompletion(JSValue* exception) - { - ASSERT(!hadException()); - ASSERT(exception); - m_completionType = Throw; - return exception; - } - JSValue* setInterruptedCompletion() - { - ASSERT(!hadException()); - m_completionType = Interrupted; - return 0; - } - JSValue* setInterruptedCompletion(JSValue* returnValue) - { - ASSERT(!hadException()); - ASSERT(returnValue); - m_completionType = Interrupted; - return returnValue; - } - - static void markActiveExecStates(); - static ExecStateStack& activeExecStates(); - - protected: - ExecState(JSGlobalObject*); - ExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*); - ExecState(JSGlobalObject*, EvalNode*, ExecState* callingExecState); - ExecState(JSGlobalObject*, JSObject* thisObject, FunctionBodyNode*, - ExecState* callingExecState, FunctionImp*, const List& args); - ~ExecState(); - - // ExecStates are always stack-allocated, and the garbage collector - // marks the stack, so we don't need to protect the objects below from GC. - - JSGlobalObject* m_globalObject; - JSValue* m_exception; - CommonIdentifiers* m_propertyNames; - const List* m_emptyList; - - ExecState* m_callingExec; - - ScopeNode* m_scopeNode; - - FunctionImp* m_function; - const List* m_arguments; - ActivationImp* m_activation; - LocalStorage* m_localStorage; - - ScopeChain m_scopeChain; - JSVariableObject* m_variableObject; - JSObject* m_thisValue; - - LabelStack m_labelStack; - int m_iterationDepth; - int m_switchDepth; - CodeType m_codeType; - - ComplType m_completionType; - const Identifier* m_breakOrContinueTarget; - }; - - class GlobalExecState : public ExecState { - public: - GlobalExecState(JSGlobalObject*); - ~GlobalExecState(); - }; - - class InterpreterExecState : public ExecState { - public: - InterpreterExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*); - ~InterpreterExecState(); - }; - - class EvalExecState : public ExecState { - public: - EvalExecState(JSGlobalObject*, EvalNode*, ExecState* callingExecState); - ~EvalExecState(); - }; - - class FunctionExecState : public ExecState { - public: - FunctionExecState(JSGlobalObject*, JSObject* thisObject, FunctionBodyNode*, - ExecState* callingExecState, FunctionImp*, const List& args); - ~FunctionExecState(); - }; - -} // namespace KJS - -#endif // ExecState_h diff --git a/kjs/JSGlobalObject.cpp b/kjs/JSGlobalObject.cpp deleted file mode 100644 index 75747d7..0000000 --- a/kjs/JSGlobalObject.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2008 Cameron Zwarich (cwzwarich@uwaterloo.ca) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "JSGlobalObject.h" - -#include "Activation.h" -#include "array_object.h" -#include "bool_object.h" -#include "date_object.h" -#include "debugger.h" -#include "error_object.h" -#include "function_object.h" -#include "math_object.h" -#include "number_object.h" -#include "object_object.h" -#include "regexp_object.h" -#include "SavedBuiltins.h" -#include "string_object.h" - -#if HAVE(SYS_TIME_H) -#include -#endif - -#if PLATFORM(WIN_OS) -#include -#endif - -#if PLATFORM(QT) -#include -#endif - -namespace KJS { - -// Default number of ticks before a timeout check should be done. -static const int initialTickCountThreshold = 255; - -// Preferred number of milliseconds between each timeout check -static const int preferredScriptCheckTimeInterval = 1000; - -static inline void markIfNeeded(JSValue* v) -{ - if (v && !v->marked()) - v->mark(); -} - -// Returns the current time in milliseconds -// It doesn't matter what "current time" is here, just as long as -// it's possible to measure the time difference correctly. -static inline unsigned getCurrentTime() -{ -#if HAVE(SYS_TIME_H) - struct timeval tv; - gettimeofday(&tv, 0); - return tv.tv_sec * 1000 + tv.tv_usec / 1000; -#elif PLATFORM(QT) - QDateTime t = QDateTime::currentDateTime(); - return t.toTime_t() * 1000 + t.time().msec(); -#elif PLATFORM(WIN_OS) - return timeGetTime(); -#else -#error Platform does not have getCurrentTime function -#endif -} - -JSGlobalObject* JSGlobalObject::s_head = 0; - -void JSGlobalObject::deleteActivationStack() -{ - ActivationStackNode* prevNode = 0; - for (ActivationStackNode* currentNode = d()->activations; currentNode; currentNode = prevNode) { - prevNode = currentNode->prev; - delete currentNode; - } -} - -JSGlobalObject::~JSGlobalObject() -{ - ASSERT(JSLock::currentThreadIsHoldingLock()); - - if (d()->debugger) - d()->debugger->detach(this); - - d()->next->d()->prev = d()->prev; - d()->prev->d()->next = d()->next; - s_head = d()->next; - if (s_head == this) - s_head = 0; - - deleteActivationStack(); - - delete d(); -} - -void JSGlobalObject::init() -{ - ASSERT(JSLock::currentThreadIsHoldingLock()); - - if (s_head) { - d()->prev = s_head; - d()->next = s_head->d()->next; - s_head->d()->next->d()->prev = this; - s_head->d()->next = this; - } else - s_head = d()->next = d()->prev = this; - - d()->compatMode = NativeMode; - - resetTimeoutCheck(); - d()->timeoutTime = 0; - d()->timeoutCheckCount = 0; - - d()->recursion = 0; - d()->debugger = 0; - - ActivationStackNode* newStackNode = new ActivationStackNode; - newStackNode->prev = 0; - d()->activations = newStackNode; - d()->activationCount = 0; - - reset(prototype()); -} - -bool JSGlobalObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - if (symbolTableGet(propertyName, slot)) - return true; - return JSVariableObject::getOwnPropertySlot(exec, propertyName, slot); -} - -void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) -{ - if (symbolTablePut(propertyName, value, !(attr & ~DontDelete))) - return; - return JSVariableObject::put(exec, propertyName, value, attr); -} - -static inline JSObject* lastInPrototypeChain(JSObject* object) -{ - JSObject* o = object; - while (o->prototype()->isObject()) - o = static_cast(o->prototype()); - return o; -} - -void JSGlobalObject::reset(JSValue* prototype) -{ - // Clear before inititalizing, to avoid calling mark() on stale pointers -- - // which would be wasteful -- or uninitialized pointers -- which would be - // dangerous. (The allocations below may cause a GC.) - - _prop.clear(); - localStorage().clear(); - symbolTable().clear(); - - // Prototypes - d()->functionPrototype = 0; - d()->objectPrototype = 0; - - d()->arrayPrototype = 0; - d()->stringPrototype = 0; - d()->booleanPrototype = 0; - d()->numberPrototype = 0; - d()->datePrototype = 0; - d()->regExpPrototype = 0; - d()->errorPrototype = 0; - - d()->evalErrorPrototype = 0; - d()->rangeErrorPrototype = 0; - d()->referenceErrorPrototype = 0; - d()->syntaxErrorPrototype = 0; - d()->typeErrorPrototype = 0; - d()->URIErrorPrototype = 0; - - // Constructors - d()->objectConstructor = 0; - d()->functionConstructor = 0; - d()->arrayConstructor = 0; - d()->stringConstructor = 0; - d()->booleanConstructor = 0; - d()->numberConstructor = 0; - d()->dateConstructor = 0; - d()->regExpConstructor = 0; - d()->errorConstructor = 0; - - d()->evalErrorConstructor = 0; - d()->rangeErrorConstructor = 0; - d()->referenceErrorConstructor = 0; - d()->syntaxErrorConstructor = 0; - d()->typeErrorConstructor = 0; - d()->URIErrorConstructor = 0; - - ExecState* exec = &d()->globalExec; - - // Prototypes - d()->functionPrototype = new FunctionPrototype(exec); - d()->objectPrototype = new ObjectPrototype(exec, d()->functionPrototype); - d()->functionPrototype->setPrototype(d()->objectPrototype); - - d()->arrayPrototype = new ArrayPrototype(exec, d()->objectPrototype); - d()->stringPrototype = new StringPrototype(exec, d()->objectPrototype); - d()->booleanPrototype = new BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype); - d()->numberPrototype = new NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype); - d()->datePrototype = new DatePrototype(exec, d()->objectPrototype); - d()->regExpPrototype = new RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype); - d()->errorPrototype = new ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype); - - d()->evalErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "EvalError", "EvalError"); - d()->rangeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "RangeError", "RangeError"); - d()->referenceErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "ReferenceError", "ReferenceError"); - d()->syntaxErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "SyntaxError", "SyntaxError"); - d()->typeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "TypeError", "TypeError"); - d()->URIErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "URIError", "URIError"); - - // Constructors - d()->objectConstructor = new ObjectObjectImp(exec, d()->objectPrototype, d()->functionPrototype); - d()->functionConstructor = new FunctionObjectImp(exec, d()->functionPrototype); - d()->arrayConstructor = new ArrayObjectImp(exec, d()->functionPrototype, d()->arrayPrototype); - d()->stringConstructor = new StringObjectImp(exec, d()->functionPrototype, d()->stringPrototype); - d()->booleanConstructor = new BooleanObjectImp(exec, d()->functionPrototype, d()->booleanPrototype); - d()->numberConstructor = new NumberObjectImp(exec, d()->functionPrototype, d()->numberPrototype); - d()->dateConstructor = new DateObjectImp(exec, d()->functionPrototype, d()->datePrototype); - d()->regExpConstructor = new RegExpObjectImp(exec, d()->functionPrototype, d()->regExpPrototype); - d()->errorConstructor = new ErrorObjectImp(exec, d()->functionPrototype, d()->errorPrototype); - - d()->evalErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->evalErrorPrototype); - d()->rangeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->rangeErrorPrototype); - d()->referenceErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->referenceErrorPrototype); - d()->syntaxErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->syntaxErrorPrototype); - d()->typeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->typeErrorPrototype); - d()->URIErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->URIErrorPrototype); - - d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum); - - d()->objectPrototype->putDirect(exec->propertyNames().constructor, d()->objectConstructor, DontEnum | DontDelete | ReadOnly); - d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum | DontDelete | ReadOnly); - d()->arrayPrototype->putDirect(exec->propertyNames().constructor, d()->arrayConstructor, DontEnum | DontDelete | ReadOnly); - d()->booleanPrototype->putDirect(exec->propertyNames().constructor, d()->booleanConstructor, DontEnum | DontDelete | ReadOnly); - d()->stringPrototype->putDirect(exec->propertyNames().constructor, d()->stringConstructor, DontEnum | DontDelete | ReadOnly); - d()->numberPrototype->putDirect(exec->propertyNames().constructor, d()->numberConstructor, DontEnum | DontDelete | ReadOnly); - d()->datePrototype->putDirect(exec->propertyNames().constructor, d()->dateConstructor, DontEnum | DontDelete | ReadOnly); - d()->regExpPrototype->putDirect(exec->propertyNames().constructor, d()->regExpConstructor, DontEnum | DontDelete | ReadOnly); - d()->errorPrototype->putDirect(exec->propertyNames().constructor, d()->errorConstructor, DontEnum | DontDelete | ReadOnly); - d()->evalErrorPrototype->putDirect(exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum | DontDelete | ReadOnly); - d()->rangeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly); - d()->referenceErrorPrototype->putDirect(exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly); - d()->syntaxErrorPrototype->putDirect(exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly); - d()->typeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum | DontDelete | ReadOnly); - d()->URIErrorPrototype->putDirect(exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum | DontDelete | ReadOnly); - - // Set global constructors - - // FIXME: kjs_window.cpp checks Internal/DontEnum as a performance hack, to - // see that these values can be put directly without a check for override - // properties. - - // FIXME: These properties should be handled by a static hash table. - - putDirect("Object", d()->objectConstructor, DontEnum); - putDirect("Function", d()->functionConstructor, DontEnum); - putDirect("Array", d()->arrayConstructor, DontEnum); - putDirect("Boolean", d()->booleanConstructor, DontEnum); - putDirect("String", d()->stringConstructor, DontEnum); - putDirect("Number", d()->numberConstructor, DontEnum); - putDirect("Date", d()->dateConstructor, DontEnum); - putDirect("RegExp", d()->regExpConstructor, DontEnum); - putDirect("Error", d()->errorConstructor, DontEnum); - putDirect("EvalError", d()->evalErrorConstructor, Internal); - putDirect("RangeError", d()->rangeErrorConstructor, Internal); - putDirect("ReferenceError", d()->referenceErrorConstructor, Internal); - putDirect("SyntaxError", d()->syntaxErrorConstructor, Internal); - putDirect("TypeError", d()->typeErrorConstructor, Internal); - putDirect("URIError", d()->URIErrorConstructor, Internal); - - // Set global values. - - putDirect("Math", new MathObjectImp(exec, d()->objectPrototype), DontEnum); - - putDirect("NaN", jsNaN(), DontEnum | DontDelete); - putDirect("Infinity", jsNumber(Inf), DontEnum | DontDelete); - putDirect("undefined", jsUndefined(), DontEnum | DontDelete); - - // Set global functions. - - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "eval", globalFuncEval), DontEnum); - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 2, "parseInt", globalFuncParseInt), DontEnum); - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "parseFloat", globalFuncParseFloat), DontEnum); - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "isNaN", globalFuncIsNaN), DontEnum); - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "isFinite", globalFuncIsFinite), DontEnum); - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "escape", globalFuncEscape), DontEnum); - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "unescape", globalFuncUnescape), DontEnum); - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "decodeURI", globalFuncDecodeURI), DontEnum); - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "decodeURIComponent", globalFuncDecodeURIComponent), DontEnum); - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "encodeURI", globalFuncEncodeURI), DontEnum); - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "encodeURIComponent", globalFuncEncodeURIComponent), DontEnum); -#ifndef NDEBUG - putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "kjsprint", globalFuncKJSPrint), DontEnum); -#endif - - // Set prototype, and also insert the object prototype at the end of the chain. - - setPrototype(prototype); - lastInPrototypeChain(this)->setPrototype(d()->objectPrototype); -} - -void JSGlobalObject::startTimeoutCheck() -{ - if (!d()->timeoutCheckCount) - resetTimeoutCheck(); - - ++d()->timeoutCheckCount; -} - -void JSGlobalObject::stopTimeoutCheck() -{ - --d()->timeoutCheckCount; -} - -void JSGlobalObject::resetTimeoutCheck() -{ - d()->tickCount = 0; - d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold; - d()->timeAtLastCheckTimeout = 0; - d()->timeExecuting = 0; -} - -bool JSGlobalObject::checkTimeout() -{ - d()->tickCount = 0; - - unsigned currentTime = getCurrentTime(); - - if (!d()->timeAtLastCheckTimeout) { - // Suspicious amount of looping in a script -- start timing it - d()->timeAtLastCheckTimeout = currentTime; - return false; - } - - unsigned timeDiff = currentTime - d()->timeAtLastCheckTimeout; - - if (timeDiff == 0) - timeDiff = 1; - - d()->timeExecuting += timeDiff; - d()->timeAtLastCheckTimeout = currentTime; - - // Adjust the tick threshold so we get the next checkTimeout call in the interval specified in - // preferredScriptCheckTimeInterval - d()->ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * d()->ticksUntilNextTimeoutCheck; - - // If the new threshold is 0 reset it to the default threshold. This can happen if the timeDiff is higher than the - // preferred script check time interval. - if (d()->ticksUntilNextTimeoutCheck == 0) - d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold; - - if (shouldInterruptScriptBeforeTimeout()) - return true; - - if (d()->timeoutTime && d()->timeExecuting > d()->timeoutTime) { - if (shouldInterruptScript()) - return true; - - resetTimeoutCheck(); - } - - return false; -} - -void JSGlobalObject::saveBuiltins(SavedBuiltins& builtins) const -{ - if (!builtins._internal) - builtins._internal = new SavedBuiltinsInternal; - - builtins._internal->objectConstructor = d()->objectConstructor; - builtins._internal->functionConstructor = d()->functionConstructor; - builtins._internal->arrayConstructor = d()->arrayConstructor; - builtins._internal->booleanConstructor = d()->booleanConstructor; - builtins._internal->stringConstructor = d()->stringConstructor; - builtins._internal->numberConstructor = d()->numberConstructor; - builtins._internal->dateConstructor = d()->dateConstructor; - builtins._internal->regExpConstructor = d()->regExpConstructor; - builtins._internal->errorConstructor = d()->errorConstructor; - builtins._internal->evalErrorConstructor = d()->evalErrorConstructor; - builtins._internal->rangeErrorConstructor = d()->rangeErrorConstructor; - builtins._internal->referenceErrorConstructor = d()->referenceErrorConstructor; - builtins._internal->syntaxErrorConstructor = d()->syntaxErrorConstructor; - builtins._internal->typeErrorConstructor = d()->typeErrorConstructor; - builtins._internal->URIErrorConstructor = d()->URIErrorConstructor; - - builtins._internal->objectPrototype = d()->objectPrototype; - builtins._internal->functionPrototype = d()->functionPrototype; - builtins._internal->arrayPrototype = d()->arrayPrototype; - builtins._internal->booleanPrototype = d()->booleanPrototype; - builtins._internal->stringPrototype = d()->stringPrototype; - builtins._internal->numberPrototype = d()->numberPrototype; - builtins._internal->datePrototype = d()->datePrototype; - builtins._internal->regExpPrototype = d()->regExpPrototype; - builtins._internal->errorPrototype = d()->errorPrototype; - builtins._internal->evalErrorPrototype = d()->evalErrorPrototype; - builtins._internal->rangeErrorPrototype = d()->rangeErrorPrototype; - builtins._internal->referenceErrorPrototype = d()->referenceErrorPrototype; - builtins._internal->syntaxErrorPrototype = d()->syntaxErrorPrototype; - builtins._internal->typeErrorPrototype = d()->typeErrorPrototype; - builtins._internal->URIErrorPrototype = d()->URIErrorPrototype; -} - -void JSGlobalObject::restoreBuiltins(const SavedBuiltins& builtins) -{ - if (!builtins._internal) - return; - - d()->objectConstructor = builtins._internal->objectConstructor; - d()->functionConstructor = builtins._internal->functionConstructor; - d()->arrayConstructor = builtins._internal->arrayConstructor; - d()->booleanConstructor = builtins._internal->booleanConstructor; - d()->stringConstructor = builtins._internal->stringConstructor; - d()->numberConstructor = builtins._internal->numberConstructor; - d()->dateConstructor = builtins._internal->dateConstructor; - d()->regExpConstructor = builtins._internal->regExpConstructor; - d()->errorConstructor = builtins._internal->errorConstructor; - d()->evalErrorConstructor = builtins._internal->evalErrorConstructor; - d()->rangeErrorConstructor = builtins._internal->rangeErrorConstructor; - d()->referenceErrorConstructor = builtins._internal->referenceErrorConstructor; - d()->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor; - d()->typeErrorConstructor = builtins._internal->typeErrorConstructor; - d()->URIErrorConstructor = builtins._internal->URIErrorConstructor; - - d()->objectPrototype = builtins._internal->objectPrototype; - d()->functionPrototype = builtins._internal->functionPrototype; - d()->arrayPrototype = builtins._internal->arrayPrototype; - d()->booleanPrototype = builtins._internal->booleanPrototype; - d()->stringPrototype = builtins._internal->stringPrototype; - d()->numberPrototype = builtins._internal->numberPrototype; - d()->datePrototype = builtins._internal->datePrototype; - d()->regExpPrototype = builtins._internal->regExpPrototype; - d()->errorPrototype = builtins._internal->errorPrototype; - d()->evalErrorPrototype = builtins._internal->evalErrorPrototype; - d()->rangeErrorPrototype = builtins._internal->rangeErrorPrototype; - d()->referenceErrorPrototype = builtins._internal->referenceErrorPrototype; - d()->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype; - d()->typeErrorPrototype = builtins._internal->typeErrorPrototype; - d()->URIErrorPrototype = builtins._internal->URIErrorPrototype; -} - -void JSGlobalObject::mark() -{ - JSVariableObject::mark(); - - markIfNeeded(d()->globalExec.exception()); - - markIfNeeded(d()->objectConstructor); - markIfNeeded(d()->functionConstructor); - markIfNeeded(d()->arrayConstructor); - markIfNeeded(d()->booleanConstructor); - markIfNeeded(d()->stringConstructor); - markIfNeeded(d()->numberConstructor); - markIfNeeded(d()->dateConstructor); - markIfNeeded(d()->regExpConstructor); - markIfNeeded(d()->errorConstructor); - markIfNeeded(d()->evalErrorConstructor); - markIfNeeded(d()->rangeErrorConstructor); - markIfNeeded(d()->referenceErrorConstructor); - markIfNeeded(d()->syntaxErrorConstructor); - markIfNeeded(d()->typeErrorConstructor); - markIfNeeded(d()->URIErrorConstructor); - - markIfNeeded(d()->objectPrototype); - markIfNeeded(d()->functionPrototype); - markIfNeeded(d()->arrayPrototype); - markIfNeeded(d()->booleanPrototype); - markIfNeeded(d()->stringPrototype); - markIfNeeded(d()->numberPrototype); - markIfNeeded(d()->datePrototype); - markIfNeeded(d()->regExpPrototype); - markIfNeeded(d()->errorPrototype); - markIfNeeded(d()->evalErrorPrototype); - markIfNeeded(d()->rangeErrorPrototype); - markIfNeeded(d()->referenceErrorPrototype); - markIfNeeded(d()->syntaxErrorPrototype); - markIfNeeded(d()->typeErrorPrototype); - markIfNeeded(d()->URIErrorPrototype); -} - -ExecState* JSGlobalObject::globalExec() -{ - return &d()->globalExec; -} - -ActivationImp* JSGlobalObject::pushActivation(ExecState* exec) -{ - if (d()->activationCount == activationStackNodeSize) { - ActivationStackNode* newNode = new ActivationStackNode; - newNode->prev = d()->activations; - d()->activations = newNode; - d()->activationCount = 0; - } - - StackActivation* stackEntry = &d()->activations->data[d()->activationCount++]; - stackEntry->activationStorage.init(exec); - return &stackEntry->activationStorage; -} - -inline void JSGlobalObject::checkActivationCount() -{ - if (!d()->activationCount) { - ActivationStackNode* prev = d()->activations->prev; - ASSERT(prev); - delete d()->activations; - d()->activations = prev; - d()->activationCount = activationStackNodeSize; - } -} - -void JSGlobalObject::popActivation() -{ - checkActivationCount(); - d()->activations->data[--d()->activationCount].activationDataStorage.localStorage.shrink(0); -} - -void JSGlobalObject::tearOffActivation(ExecState* exec, bool leaveRelic) -{ - ActivationImp* oldActivation = exec->activationObject(); - if (!oldActivation || !oldActivation->isOnStack()) - return; - - ASSERT(exec->codeType() == FunctionCode); - ActivationImp* newActivation = new ActivationImp(*oldActivation->d(), leaveRelic); - - if (!leaveRelic) { - checkActivationCount(); - d()->activationCount--; - } - - oldActivation->d()->localStorage.shrink(0); - - exec->setActivationObject(newActivation); - exec->setVariableObject(newActivation); - exec->setLocalStorage(&newActivation->localStorage()); - exec->replaceScopeChainTop(newActivation); -} - -} // namespace KJS diff --git a/kjs/JSGlobalObject.h b/kjs/JSGlobalObject.h deleted file mode 100644 index 87862dc..0000000 --- a/kjs/JSGlobalObject.h +++ /dev/null @@ -1,262 +0,0 @@ -// -*- c-basic-offset: 4 -*- -/* - * Copyright (C) 2007 Eric Seidel - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_GlobalObject_h -#define KJS_GlobalObject_h - -#include "JSVariableObject.h" - -namespace KJS { - - class ActivationImp; - class ArrayObjectImp; - class ArrayPrototype; - class BooleanObjectImp; - class BooleanPrototype; - class DateObjectImp; - class DatePrototype; - class Debugger; - class ErrorObjectImp; - class ErrorPrototype; - class EvalError; - class EvalErrorPrototype; - class FunctionObjectImp; - class FunctionPrototype; - class JSGlobalObject; - class NativeErrorImp; - class NativeErrorPrototype; - class NumberObjectImp; - class NumberPrototype; - class ObjectObjectImp; - class ObjectPrototype; - class RangeError; - class RangeErrorPrototype; - class ReferenceError; - class ReferenceError; - class ReferenceErrorPrototype; - class RegExpObjectImp; - class RegExpPrototype; - class RuntimeMethod; - class SavedBuiltins; - class ScopeChain; - class StringObjectImp; - class StringPrototype; - class SyntaxErrorPrototype; - class TypeError; - class TypeErrorPrototype; - class UriError; - class UriErrorPrototype; - struct ActivationStackNode; - - enum CompatMode { NativeMode, IECompat, NetscapeCompat }; - - class JSGlobalObject : public JSVariableObject { - protected: - using JSVariableObject::JSVariableObjectData; - - struct JSGlobalObjectData : public JSVariableObjectData { - JSGlobalObjectData(JSGlobalObject* globalObject) - : JSVariableObjectData(&inlineSymbolTable) - , globalExec(globalObject) - { - } - - JSGlobalObject* next; - JSGlobalObject* prev; - - Debugger* debugger; - CompatMode compatMode; - - GlobalExecState globalExec; - int recursion; - - unsigned timeoutTime; - unsigned timeAtLastCheckTimeout; - unsigned timeExecuting; - unsigned timeoutCheckCount; - unsigned tickCount; - unsigned ticksUntilNextTimeoutCheck; - - ObjectObjectImp* objectConstructor; - FunctionObjectImp* functionConstructor; - ArrayObjectImp* arrayConstructor; - BooleanObjectImp* booleanConstructor; - StringObjectImp* stringConstructor; - NumberObjectImp* numberConstructor; - DateObjectImp* dateConstructor; - RegExpObjectImp* regExpConstructor; - ErrorObjectImp* errorConstructor; - NativeErrorImp* evalErrorConstructor; - NativeErrorImp* rangeErrorConstructor; - NativeErrorImp* referenceErrorConstructor; - NativeErrorImp* syntaxErrorConstructor; - NativeErrorImp* typeErrorConstructor; - NativeErrorImp* URIErrorConstructor; - - ObjectPrototype* objectPrototype; - FunctionPrototype* functionPrototype; - ArrayPrototype* arrayPrototype; - BooleanPrototype* booleanPrototype; - StringPrototype* stringPrototype; - NumberPrototype* numberPrototype; - DatePrototype* datePrototype; - RegExpPrototype* regExpPrototype; - ErrorPrototype* errorPrototype; - NativeErrorPrototype* evalErrorPrototype; - NativeErrorPrototype* rangeErrorPrototype; - NativeErrorPrototype* referenceErrorPrototype; - NativeErrorPrototype* syntaxErrorPrototype; - NativeErrorPrototype* typeErrorPrototype; - NativeErrorPrototype* URIErrorPrototype; - - SymbolTable inlineSymbolTable; - - ActivationStackNode* activations; - size_t activationCount; - }; - - public: - JSGlobalObject() - : JSVariableObject(new JSGlobalObjectData(this)) - { - init(); - } - - protected: - JSGlobalObject(JSValue* proto) - : JSVariableObject(proto, new JSGlobalObjectData(this)) - { - init(); - } - - public: - virtual ~JSGlobalObject(); - - virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - virtual void put(ExecState*, const Identifier&, JSValue*, int attr = None); - - // Linked list of all global objects. - static JSGlobalObject* head() { return s_head; } - JSGlobalObject* next() { return d()->next; } - - // Resets the global object to contain only built-in properties, sets - // the global object's prototype to "prototype," then adds the - // default object prototype to the tail of the global object's - // prototype chain. - void reset(JSValue* prototype); - - // The following accessors return pristine values, even if a script - // replaces the global object's associated property. - - ObjectObjectImp* objectConstructor() const { return d()->objectConstructor; } - FunctionObjectImp* functionConstructor() const { return d()->functionConstructor; } - ArrayObjectImp* arrayConstructor() const { return d()->arrayConstructor; } - BooleanObjectImp* booleanConstructor() const { return d()->booleanConstructor; } - StringObjectImp* stringConstructor() const{ return d()->stringConstructor; } - NumberObjectImp* numberConstructor() const{ return d()->numberConstructor; } - DateObjectImp* dateConstructor() const{ return d()->dateConstructor; } - RegExpObjectImp* regExpConstructor() const { return d()->regExpConstructor; } - ErrorObjectImp* errorConstructor() const { return d()->errorConstructor; } - NativeErrorImp* evalErrorConstructor() const { return d()->evalErrorConstructor; } - NativeErrorImp* rangeErrorConstructor() const { return d()->rangeErrorConstructor; } - NativeErrorImp* referenceErrorConstructor() const { return d()->referenceErrorConstructor; } - NativeErrorImp* syntaxErrorConstructor() const { return d()->syntaxErrorConstructor; } - NativeErrorImp* typeErrorConstructor() const { return d()->typeErrorConstructor; } - NativeErrorImp* URIErrorConstructor() const { return d()->URIErrorConstructor; } - - ObjectPrototype* objectPrototype() const { return d()->objectPrototype; } - FunctionPrototype* functionPrototype() const { return d()->functionPrototype; } - ArrayPrototype* arrayPrototype() const { return d()->arrayPrototype; } - BooleanPrototype* booleanPrototype() const { return d()->booleanPrototype; } - StringPrototype* stringPrototype() const { return d()->stringPrototype; } - NumberPrototype* numberPrototype() const { return d()->numberPrototype; } - DatePrototype* datePrototype() const { return d()->datePrototype; } - RegExpPrototype* regExpPrototype() const { return d()->regExpPrototype; } - ErrorPrototype* errorPrototype() const { return d()->errorPrototype; } - NativeErrorPrototype* evalErrorPrototype() const { return d()->evalErrorPrototype; } - NativeErrorPrototype* rangeErrorPrototype() const { return d()->rangeErrorPrototype; } - NativeErrorPrototype* referenceErrorPrototype() const { return d()->referenceErrorPrototype; } - NativeErrorPrototype* syntaxErrorPrototype() const { return d()->syntaxErrorPrototype; } - NativeErrorPrototype* typeErrorPrototype() const { return d()->typeErrorPrototype; } - NativeErrorPrototype* URIErrorPrototype() const { return d()->URIErrorPrototype; } - - void saveBuiltins(SavedBuiltins&) const; - void restoreBuiltins(const SavedBuiltins&); - - void setTimeoutTime(unsigned timeoutTime) { d()->timeoutTime = timeoutTime; } - void startTimeoutCheck(); - void stopTimeoutCheck(); - bool timedOut(); - - Debugger* debugger() const { return d()->debugger; } - void setDebugger(Debugger* debugger) { d()->debugger = debugger; } - - // FIXME: Let's just pick one compatible behavior and go with it. - void setCompatMode(CompatMode mode) { d()->compatMode = mode; } - CompatMode compatMode() const { return d()->compatMode; } - - int recursion() { return d()->recursion; } - void incRecursion() { ++d()->recursion; } - void decRecursion() { --d()->recursion; } - - virtual void mark(); - - virtual bool isGlobalObject() const { return true; } - - virtual ExecState* globalExec(); - - virtual bool shouldInterruptScriptBeforeTimeout() const { return false; } - virtual bool shouldInterruptScript() const { return true; } - - virtual bool allowsAccessFrom(const JSGlobalObject*) const { return true; } - - ActivationImp* pushActivation(ExecState*); - void popActivation(); - void tearOffActivation(ExecState*, bool markAsRelic = false); - - private: - void init(); - - JSGlobalObjectData* d() const { return static_cast(JSVariableObject::d); } - - bool checkTimeout(); - void resetTimeoutCheck(); - - void deleteActivationStack(); - void checkActivationCount(); - - static JSGlobalObject* s_head; - }; - - inline bool JSGlobalObject::timedOut() - { - d()->tickCount++; - - if (d()->tickCount != d()->ticksUntilNextTimeoutCheck) - return false; - - return checkTimeout(); - } - -} // namespace KJS - -#endif // KJS_GlobalObject_h diff --git a/kjs/JSImmediate.cpp b/kjs/JSImmediate.cpp deleted file mode 100644 index ded8ccb..0000000 --- a/kjs/JSImmediate.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003-2006 Apple Computer, Inc - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "JSImmediate.h" - -#include "JSGlobalObject.h" -#include "bool_object.h" -#include "number_object.h" -#include "object.h" - -namespace KJS { - -JSObject *JSImmediate::toObject(const JSValue *v, ExecState *exec) -{ - ASSERT(isImmediate(v)); - if (v == jsNull()) - return throwError(exec, TypeError, "Null value"); - else if (v == jsUndefined()) - return throwError(exec, TypeError, "Undefined value"); - else if (isBoolean(v)) { - List args; - args.append(const_cast(v)); - return exec->lexicalGlobalObject()->booleanConstructor()->construct(exec, args); - } else { - ASSERT(isNumber(v)); - List args; - args.append(const_cast(v)); - return exec->lexicalGlobalObject()->numberConstructor()->construct(exec, args); - } -} - -UString JSImmediate::toString(const JSValue *v) -{ - ASSERT(isImmediate(v)); - - if (v == jsNull()) - return "null"; - else if (v == jsUndefined()) - return "undefined"; - else if (v == jsBoolean(true)) - return "true"; - else if (v == jsBoolean(false)) - return "false"; - else { - ASSERT(isNumber(v)); - double d = toDouble(v); - if (d == 0.0) // +0.0 or -0.0 - return "0"; - return UString::from(d); - } -} - -JSType JSImmediate::type(const JSValue *v) -{ - ASSERT(isImmediate(v)); - - uintptr_t tag = getTag(v); - if (tag == UndefinedType) - return v == jsUndefined() ? UndefinedType : NullType; - return static_cast(tag); -} - -} // namespace KJS diff --git a/kjs/JSImmediate.h b/kjs/JSImmediate.h deleted file mode 100644 index bc0cb16..0000000 --- a/kjs/JSImmediate.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_JS_IMMEDIATE_H -#define KJS_JS_IMMEDIATE_H - -#include "JSType.h" -#include -#include -#include -#include -#include -#include -#include - -namespace KJS { - -class ExecState; -class JSObject; -class JSValue; -class UString; - -/* - * A JSValue* is either a pointer to a cell (a heap-allocated object) or an immediate (a type-tagged - * signed int masquerading as a pointer). The low two bits in a JSValue* are available - * for type tagging because allocator alignment guarantees they will be 00 in cell pointers. - * - * For example, on a 32 bit system: - * - * JSCell*: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 00 - * [ high 30 bits: pointer address ] [ low 2 bits -- always 0 ] - * - * JSImmediate: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX TT - * [ high 30 bits: signed int ] [ low 2 bits -- type tag ] - * - * The bit "payload" (the high 30 bits) is a 30 bit signed int for immediate numbers, a flag to distinguish true/false - * and undefined/null. - * - * Notice that the JSType value of NullType is 4, which requires 3 bits to encode. Since we only have 2 bits - * available for type tagging, we tag the null immediate with UndefinedType, and JSImmediate::type() has - * to sort them out. - */ - -class JSImmediate { -public: - static ALWAYS_INLINE bool isImmediate(const JSValue* v) - { - return getTag(v) != 0; - } - - static ALWAYS_INLINE bool isNumber(const JSValue* v) - { - return (getTag(v) == NumberType); - } - - static ALWAYS_INLINE bool isBoolean(const JSValue* v) - { - return (getTag(v) == BooleanType); - } - - // Since we have room for only 3 unique tags, null and undefined have to share. - static ALWAYS_INLINE bool isUndefinedOrNull(const JSValue* v) - { - return (getTag(v) == UndefinedType); - } - - static JSValue* from(char); - static JSValue* from(signed char); - static JSValue* from(unsigned char); - static JSValue* from(short); - static JSValue* from(unsigned short); - static JSValue* from(int); - static JSValue* from(unsigned); - static JSValue* from(long); - static JSValue* from(unsigned long); - static JSValue* from(long long); - static JSValue* from(unsigned long long); - static JSValue* from(double); - - static ALWAYS_INLINE bool areBothImmediateNumbers(const JSValue* v1, const JSValue* v2) - { - return (reinterpret_cast(v1) & reinterpret_cast(v2) & TagMask) == NumberType; - } - - static ALWAYS_INLINE JSValue* andImmediateNumbers(const JSValue* v1, const JSValue* v2) - { - ASSERT(areBothImmediateNumbers(v1, v2)); - return reinterpret_cast(reinterpret_cast(v1) & reinterpret_cast(v2)); - } - - static double toDouble(const JSValue*); - static bool toBoolean(const JSValue*); - static JSObject* toObject(const JSValue*, ExecState*); - static UString toString(const JSValue*); - static JSType type(const JSValue*); - - static bool getUInt32(const JSValue*, uint32_t&); - static bool getTruncatedInt32(const JSValue*, int32_t&); - static bool getTruncatedUInt32(const JSValue*, uint32_t&); - - static int32_t getTruncatedInt32(const JSValue*); - - static JSValue* trueImmediate(); - static JSValue* falseImmediate(); - static JSValue* undefinedImmediate(); - static JSValue* nullImmediate(); - -private: - static const uintptr_t TagMask = 3; // type tags are 2 bits long - - // Immediate values are restricted to a 30 bit signed value. - static const int minImmediateInt = -(1 << 29); - static const int maxImmediateInt = (1 << 29) - 1; - static const unsigned maxImmediateUInt = maxImmediateInt; - - static ALWAYS_INLINE JSValue* tag(uintptr_t bits, uintptr_t tag) - { - return reinterpret_cast(bits | tag); - } - - static ALWAYS_INLINE uintptr_t unTag(const JSValue* v) - { - return reinterpret_cast(v) & ~TagMask; - } - - static ALWAYS_INLINE uintptr_t getTag(const JSValue* v) - { - return reinterpret_cast(v) & TagMask; - } -}; - -ALWAYS_INLINE JSValue* JSImmediate::trueImmediate() { return tag(1 << 2, BooleanType); } -ALWAYS_INLINE JSValue* JSImmediate::falseImmediate() { return tag(0, BooleanType); } -ALWAYS_INLINE JSValue* JSImmediate::undefinedImmediate() { return tag(1 << 2, UndefinedType); } -ALWAYS_INLINE JSValue* JSImmediate::nullImmediate() { return tag(0, UndefinedType); } - -ALWAYS_INLINE bool JSImmediate::toBoolean(const JSValue* v) -{ - ASSERT(isImmediate(v)); - uintptr_t bits = unTag(v); - return (bits != 0) & (JSImmediate::getTag(v) != UndefinedType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(char i) -{ - return tag(i << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(signed char i) -{ - return tag(i << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(unsigned char i) -{ - return tag(i << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(short i) -{ - return tag(i << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(unsigned short i) -{ - return tag(i << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(int i) -{ - if ((i < minImmediateInt) | (i > maxImmediateInt)) - return 0; - return tag(i << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(unsigned i) -{ - if (i > maxImmediateUInt) - return 0; - return tag(i << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(long i) -{ - if ((i < minImmediateInt) | (i > maxImmediateInt)) - return 0; - return tag(i << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(unsigned long i) -{ - if (i > maxImmediateUInt) - return 0; - return tag(i << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(long long i) -{ - if ((i < minImmediateInt) | (i > maxImmediateInt)) - return 0; - return tag(static_cast(i) << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(unsigned long long i) -{ - if (i > maxImmediateUInt) - return 0; - return tag(static_cast(i) << 2, NumberType); -} - -ALWAYS_INLINE JSValue* JSImmediate::from(double d) -{ - const int intVal = static_cast(d); - - if ((intVal < minImmediateInt) | (intVal > maxImmediateInt)) - return 0; - - // Check for data loss from conversion to int. - if ((intVal != d) || (!intVal && signbit(d))) - return 0; - - return tag(intVal << 2, NumberType); -} - -ALWAYS_INLINE int32_t JSImmediate::getTruncatedInt32(const JSValue* v) -{ - ASSERT(isNumber(v)); - return static_cast(unTag(v)) >> 2; -} - -ALWAYS_INLINE double JSImmediate::toDouble(const JSValue* v) -{ - ASSERT(isImmediate(v)); - const int32_t i = static_cast(unTag(v)) >> 2; - if (JSImmediate::getTag(v) == UndefinedType && i) - return std::numeric_limits::quiet_NaN(); - return i; -} - -ALWAYS_INLINE bool JSImmediate::getUInt32(const JSValue* v, uint32_t& i) -{ - const int32_t si = static_cast(unTag(v)) >> 2; - i = si; - return isNumber(v) & (si >= 0); -} - -ALWAYS_INLINE bool JSImmediate::getTruncatedInt32(const JSValue* v, int32_t& i) -{ - i = static_cast(unTag(v)) >> 2; - return isNumber(v); -} - -ALWAYS_INLINE bool JSImmediate::getTruncatedUInt32(const JSValue* v, uint32_t& i) -{ - return getUInt32(v, i); -} - -} // namespace KJS - -#endif diff --git a/kjs/JSLock.cpp b/kjs/JSLock.cpp deleted file mode 100644 index ce55df3..0000000 --- a/kjs/JSLock.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// -*- mode: c++; c-basic-offset: 4 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 2005 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - * - */ - -#include "config.h" -#include "JSLock.h" - -#include "collector.h" -#if USE(MULTIPLE_THREADS) -#include -#endif - -namespace KJS { - -#if USE(MULTIPLE_THREADS) - -// Acquire this mutex before accessing lock-related data. -static pthread_mutex_t JSMutex = PTHREAD_MUTEX_INITIALIZER; - -// Thread-specific key that tells whether a thread holds the JSMutex. -pthread_key_t didLockJSMutex; - -// Lock nesting count. -static int JSLockCount; - -static void createDidLockJSMutex() -{ - pthread_key_create(&didLockJSMutex, 0); -} -pthread_once_t createDidLockJSMutexOnce = PTHREAD_ONCE_INIT; - -void JSLock::lock() -{ - pthread_once(&createDidLockJSMutexOnce, createDidLockJSMutex); - - if (!pthread_getspecific(didLockJSMutex)) { - int result; - result = pthread_mutex_lock(&JSMutex); - ASSERT(!result); - pthread_setspecific(didLockJSMutex, &didLockJSMutex); - } - ++JSLockCount; -} - -void JSLock::unlock() -{ - ASSERT(JSLockCount); - ASSERT(!!pthread_getspecific(didLockJSMutex)); - - --JSLockCount; - if (!JSLockCount) { - pthread_setspecific(didLockJSMutex, 0); - int result; - result = pthread_mutex_unlock(&JSMutex); - ASSERT(!result); - } -} - -bool JSLock::currentThreadIsHoldingLock() -{ - pthread_once(&createDidLockJSMutexOnce, createDidLockJSMutex); - return !!pthread_getspecific(didLockJSMutex); -} - -void JSLock::registerThread() -{ - Collector::registerThread(); -} - -JSLock::DropAllLocks::DropAllLocks() - : m_lockCount(0) -{ - pthread_once(&createDidLockJSMutexOnce, createDidLockJSMutex); - - m_lockCount = !!pthread_getspecific(didLockJSMutex) ? JSLock::lockCount() : 0; - for (int i = 0; i < m_lockCount; i++) - JSLock::unlock(); -} - -JSLock::DropAllLocks::~DropAllLocks() -{ - for (int i = 0; i < m_lockCount; i++) - JSLock::lock(); - m_lockCount = 0; -} - -#else - -// If threading support is off, set the lock count to a constant value of 1 so assertions -// that the lock is held don't fail -const int JSLockCount = 1; - -bool JSLock::currentThreadIsHoldingLock() -{ - return true; -} - -void JSLock::lock() -{ -} - -void JSLock::unlock() -{ -} - -void JSLock::registerThread() -{ -} - -JSLock::DropAllLocks::DropAllLocks() -{ -} - -JSLock::DropAllLocks::~DropAllLocks() -{ -} - -#endif // USE(MULTIPLE_THREADS) - -int JSLock::lockCount() -{ - return JSLockCount; -} - -} - - -#include "JSLockC.h" - -#ifdef __cplusplus -extern "C" { -#endif - -static JSLock::DropAllLocks* sLockDropper = NULL; - -void JSLockDropAllLocks(void) -{ - ASSERT(sLockDropper == NULL); - sLockDropper = new JSLock::DropAllLocks(); -} - -void JSLockRecoverAllLocks(void) -{ - ASSERT(sLockDropper != NULL); - delete sLockDropper; - sLockDropper = NULL; -} - -static pthread_t javaScriptCollectionThread = 0; - -void JSSetJavaScriptCollectionThread (pthread_t thread) -{ - javaScriptCollectionThread = thread; -} - -pthread_t JSJavaScriptCollectionThread (void) -{ - return javaScriptCollectionThread; -} - -#ifdef __cplusplus -} -#endif - diff --git a/kjs/JSLockC.h b/kjs/JSLockC.h deleted file mode 100644 index 787698d..0000000 --- a/kjs/JSLockC.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2006, 2007, Apple Inc. All rights reserved. - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -void JSLockDropAllLocks(void); -void JSLockRecoverAllLocks(void); -void JSSetJavaScriptCollectionThread (pthread_t thread); -pthread_t JSJavaScriptCollectionThread (void); - -#ifdef __cplusplus -} -#endif - diff --git a/kjs/JSVariableObject.h b/kjs/JSVariableObject.h deleted file mode 100644 index e82013b..0000000 --- a/kjs/JSVariableObject.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSVariableObject_h -#define JSVariableObject_h - -#include "LocalStorage.h" -#include "SymbolTable.h" -#include "object.h" - -namespace KJS { - - class JSVariableObject : public JSObject { - public: - SymbolTable& symbolTable() { return *d->symbolTable; } - LocalStorage& localStorage() { return d->localStorage; } - - void saveLocalStorage(SavedProperties&) const; - void restoreLocalStorage(const SavedProperties&); - - virtual bool deleteProperty(ExecState*, const Identifier&); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); - - virtual void mark(); - - protected: - // Subclasses of JSVariableObject can subclass this struct to add data - // without increasing their own size (since there's a hard limit on the - // size of a JSCell). - struct JSVariableObjectData { - JSVariableObjectData() { } - JSVariableObjectData(SymbolTable* s) - : symbolTable(s) // Subclass owns this pointer. - { - } - - LocalStorage localStorage; // Storage for variables in the symbol table. - SymbolTable* symbolTable; // Maps name -> index in localStorage. - }; - - JSVariableObject() { } - - JSVariableObject(JSVariableObjectData* data) - : d(data) // Subclass owns this pointer. - { - } - - JSVariableObject(JSValue* proto, JSVariableObjectData* data) - : JSObject(proto) - , d(data) // Subclass owns this pointer. - { - } - - bool symbolTableGet(const Identifier&, PropertySlot&); - bool symbolTablePut(const Identifier&, JSValue*, bool checkReadOnly); - - JSVariableObjectData* d; - }; - - inline bool JSVariableObject::symbolTableGet(const Identifier& propertyName, PropertySlot& slot) - { - size_t index = symbolTable().get(propertyName.ustring().rep()); - if (index != missingSymbolMarker()) { -#ifndef NDEBUG - // During initialization, the variable object needs to advertise that it has certain - // properties, even if they're not ready for access yet. This check verifies that - // no one tries to access such a property. - - // In a release build, we optimize this check away and just return an invalid pointer. - // There's no harm in an invalid pointer, since no one dereferences it. - if (index >= d->localStorage.size()) { - slot.setUngettable(this); - return true; - } -#endif - slot.setValueSlot(this, &d->localStorage[index].value); - return true; - } - return false; - } - - inline bool JSVariableObject::symbolTablePut(const Identifier& propertyName, JSValue* value, bool checkReadOnly) - { - size_t index = symbolTable().get(propertyName.ustring().rep()); - if (index == missingSymbolMarker()) - return false; - LocalStorageEntry& entry = d->localStorage[index]; - if (checkReadOnly && (entry.attributes & ReadOnly)) - return true; - entry.value = value; - return true; - } - -} // namespace KJS - -#endif // JSVariableObject_h diff --git a/kjs/JSWrapperObject.h b/kjs/JSWrapperObject.h deleted file mode 100644 index 0a06c9f..0000000 --- a/kjs/JSWrapperObject.h +++ /dev/null @@ -1,84 +0,0 @@ -// -*- mode: c++; c-basic-offset: 4 -*- -/* - * Copyright (C) 2006 Maks Orlovich - * Copyright (C) 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_JSWrapperObject_h -#define KJS_JSWrapperObject_h - -#include "object.h" - -namespace KJS { - - /** - This class is used as a base for classes such as String, - Number, Boolean and Date which which are wrappers for primitive - types. These classes stores the internal value, which is the - actual value represented by the wrapper objects. - */ - class JSWrapperObject : public JSObject { - public: - JSWrapperObject(JSValue* proto); - - /** - * Returns the internal value of the object. This is used for objects such - * as String and Boolean which are wrappers for native types. The interal - * value is the actual value represented by the wrapper objects. - * - * @see ECMA 8.6.2 - * @return The internal value of the object - */ - JSValue* internalValue() const; - - /** - * Sets the internal value of the object - * - * @see internalValue() - * - * @param v The new internal value - */ - void setInternalValue(JSValue* v); - - virtual void mark(); - - private: - JSValue* m_internalValue; - }; - - inline JSWrapperObject::JSWrapperObject(JSValue* proto) - : JSObject(proto) - , m_internalValue(0) - { - } - - inline JSValue* JSWrapperObject::internalValue() const - { - return m_internalValue; - } - - inline void JSWrapperObject::setInternalValue(JSValue* v) - { - ASSERT(v); - m_internalValue = v; - } - -} // namespace KJS - -#endif // KJS_JSWrapperObject_h diff --git a/kjs/LabelStack.h b/kjs/LabelStack.h deleted file mode 100644 index 375edf1..0000000 --- a/kjs/LabelStack.h +++ /dev/null @@ -1,84 +0,0 @@ -// -*- mode: c++; c-basic-offset: 4 -*- -/* - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_LABEL_STACK_H -#define KJS_LABEL_STACK_H - -#include "identifier.h" -#include - -namespace KJS { - /** - * @short The "label set" in Ecma-262 spec - */ - class LabelStack : Noncopyable { - public: - LabelStack() - : tos(0) - { - } - ~LabelStack(); - - /** - * If id is not empty and is not in the stack already, puts it on top of - * the stack and returns true, otherwise returns false - */ - bool push(const Identifier &id); - /** - * Is the id in the stack? - */ - bool contains(const Identifier &id) const; - /** - * Removes from the stack the last pushed id (what else?) - */ - void pop(); - - private: - struct StackElem { - Identifier id; - StackElem *prev; - }; - - StackElem *tos; - }; - -inline LabelStack::~LabelStack() -{ - StackElem *prev; - for (StackElem *e = tos; e; e = prev) { - prev = e->prev; - delete e; - } -} - -inline void LabelStack::pop() -{ - if (StackElem *e = tos) { - tos = e->prev; - delete e; - } -} - -} - -#endif // KJS_LABEL_STACK_H diff --git a/kjs/Parser.cpp b/kjs/Parser.cpp deleted file mode 100644 index 7a63d8e..0000000 --- a/kjs/Parser.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// -*- c-basic-offset: 4 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2006, 2007 Apple Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "Parser.h" - -#include "lexer.h" -#include -#include - -extern int kjsyyparse(); - -namespace KJS { - -void Parser::parse(int* errLine, UString* errMsg) -{ - ASSERT(!m_sourceElements); - - if (errLine) - *errLine = -1; - if (errMsg) - *errMsg = 0; - - Lexer& lexer = KJS::lexer(); - lexer.setCode(*m_source); - - int parseError = kjsyyparse(); - bool lexError = lexer.sawError(); - lexer.clear(); - - ParserRefCounted::deleteNewObjects(); - - if (parseError || lexError) { - if (errLine) - *errLine = lexer.lineNo(); - if (errMsg) - *errMsg = "Parse error"; - m_sourceElements.clear(); - } -} - -void Parser::reparse(FunctionBodyNode* functionBodyNode) -{ - m_source = &functionBodyNode->source(); - parse(0, 0); - ASSERT(m_sourceElements); - - functionBodyNode->setData(m_sourceElements.get(), - m_varDeclarations ? &m_varDeclarations->data : 0, - m_funcDeclarations ? &m_funcDeclarations->data : 0); - functionBodyNode->setLoc(m_source->firstLine(), m_lastLine); - - m_source = 0; - m_sourceElements = 0; - m_varDeclarations = 0; - m_funcDeclarations = 0; -} - -void Parser::didFinishParsing(SourceElements* sourceElements, ParserRefCountedData* varStack, - ParserRefCountedData* funcStack, int lastLine) -{ - m_sourceElements = sourceElements ? sourceElements : new SourceElements; - m_varDeclarations = varStack; - m_funcDeclarations = funcStack; - m_lastLine = lastLine; -} - -Parser& parser() -{ - ASSERT(JSLock::currentThreadIsHoldingLock()); - - static Parser& staticParser = *new Parser; - return staticParser; -} - -} // namespace KJS diff --git a/kjs/PropertyNameArray.h b/kjs/PropertyNameArray.h deleted file mode 100644 index b702d21..0000000 --- a/kjs/PropertyNameArray.h +++ /dev/null @@ -1,56 +0,0 @@ -// -*- mode: c++; c-basic-offset: 4 -*- -/* - * Copyright (C) 2006 Apple Computer, Inc - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_PROPERTY_NAME_ARRAY_H -#define KJS_PROPERTY_NAME_ARRAY_H - -#include "identifier.h" - -#include -#include - -namespace KJS { - - class PropertyNameArray { - public: - typedef Identifier ValueType; - typedef Vector::const_iterator const_iterator; - - void add(const Identifier&); - const_iterator begin() const { return m_vector.begin(); } - const_iterator end() const { return m_vector.end(); } - size_t size() const { return m_vector.size(); } - - Identifier& operator[](unsigned i) { return m_vector[i]; } - const Identifier& operator[](unsigned i) const { return m_vector[i]; } - - void swap(PropertyNameArray&); - private: - typedef HashSet > IdentifierSet; - IdentifierSet m_set; - Vector m_vector; - }; - - -} // namespace KJS - - -#endif // KJS_PROPERTY_NAME_ARRAY_H diff --git a/kjs/SavedBuiltins.h b/kjs/SavedBuiltins.h deleted file mode 100644 index 9901e41..0000000 --- a/kjs/SavedBuiltins.h +++ /dev/null @@ -1,94 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef SavedBuiltins_H -#define SavedBuiltins_H - -#include "protect.h" -#include "object_object.h" -#include "string_object.h" -#include "error_object.h" -#include "regexp_object.h" -#include "array_object.h" -#include "bool_object.h" -#include "date_object.h" -#include "number_object.h" -#include "math_object.h" - -namespace KJS { - -struct SavedBuiltinsInternal { - ProtectedPtr objectConstructor; - ProtectedPtr functionConstructor; - ProtectedPtr arrayConstructor; - ProtectedPtr booleanConstructor; - ProtectedPtr stringConstructor; - ProtectedPtr numberConstructor; - ProtectedPtr dateConstructor; - ProtectedPtr regExpConstructor; - ProtectedPtr errorConstructor; - ProtectedPtr evalErrorConstructor; - ProtectedPtr rangeErrorConstructor; - ProtectedPtr referenceErrorConstructor; - ProtectedPtr syntaxErrorConstructor; - ProtectedPtr typeErrorConstructor; - ProtectedPtr URIErrorConstructor; - - ProtectedPtr objectPrototype; - ProtectedPtr functionPrototype; - ProtectedPtr arrayPrototype; - ProtectedPtr booleanPrototype; - ProtectedPtr stringPrototype; - ProtectedPtr numberPrototype; - ProtectedPtr datePrototype; - ProtectedPtr regExpPrototype; - ProtectedPtr errorPrototype; - ProtectedPtr evalErrorPrototype; - ProtectedPtr rangeErrorPrototype; - ProtectedPtr referenceErrorPrototype; - ProtectedPtr syntaxErrorPrototype; - ProtectedPtr typeErrorPrototype; - ProtectedPtr URIErrorPrototype; -}; - -class SavedBuiltins { - friend class JSGlobalObject; -public: - SavedBuiltins() - : _internal(0) - { - } - - ~SavedBuiltins() - { - delete _internal; - } - -private: - SavedBuiltinsInternal* _internal; -}; - -} // namespace - -#endif // SavedBuiltins_H diff --git a/kjs/array_instance.cpp b/kjs/array_instance.cpp deleted file mode 100644 index fec5c09..0000000 --- a/kjs/array_instance.cpp +++ /dev/null @@ -1,612 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2003 Peter Kelly (pmk@post.com) - * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "array_instance.h" - -#include "JSGlobalObject.h" -#include "PropertyNameArray.h" -#include - -using namespace std; - -namespace KJS { - -typedef HashMap SparseArrayValueMap; - -struct ArrayStorage { - unsigned m_numValuesInVector; - SparseArrayValueMap* m_sparseValueMap; - JSValue* m_vector[1]; -}; - -// 0xFFFFFFFF is a bit weird -- is not an array index even though it's an integer -static const unsigned maxArrayIndex = 0xFFFFFFFEU; - -// Our policy for when to use a vector and when to use a sparse map. -// For all array indices under sparseArrayCutoff, we always use a vector. -// When indices greater than sparseArrayCutoff are involved, we use a vector -// as long as it is 1/8 full. If more sparse than that, we use a map. -// This value has to be a macro to be used in max() and min() without introducing -// a PIC branch in Mach-O binaries, see . -#define sparseArrayCutoff 10000U -static const unsigned minDensityMultiplier = 8; - -static const unsigned copyingSortCutoff = 50000; - -const ClassInfo ArrayInstance::info = {"Array", 0, 0}; - -static inline size_t storageSize(unsigned vectorLength) -{ - return sizeof(ArrayStorage) - sizeof(JSValue*) + vectorLength * sizeof(JSValue*); -} - -static inline unsigned increasedVectorLength(unsigned newLength) -{ - return (newLength * 3 + 1) / 2; -} - -static inline bool isDenseEnoughForVector(unsigned length, unsigned numValues) -{ - return length / minDensityMultiplier <= numValues; -} - -ArrayInstance::ArrayInstance(JSObject* prototype, unsigned initialLength) - : JSObject(prototype) -{ - unsigned initialCapacity = min(initialLength, sparseArrayCutoff); - - m_length = initialLength; - m_vectorLength = initialCapacity; - m_storage = static_cast(fastZeroedMalloc(storageSize(initialCapacity))); - - Collector::reportExtraMemoryCost(initialCapacity * sizeof(JSValue*)); -} - -ArrayInstance::ArrayInstance(JSObject* prototype, const List& list) - : JSObject(prototype) -{ - unsigned length = list.size(); - - m_length = length; - m_vectorLength = length; - - ArrayStorage* storage = static_cast(fastMalloc(storageSize(length))); - - storage->m_numValuesInVector = length; - storage->m_sparseValueMap = 0; - - size_t i = 0; - List::const_iterator end = list.end(); - for (List::const_iterator it = list.begin(); it != end; ++it, ++i) - storage->m_vector[i] = *it; - - m_storage = storage; - - // When the array is created non-empty, its cells are filled, so it's really no worse than - // a property map. Therefore don't report extra memory cost. -} - -ArrayInstance::~ArrayInstance() -{ - delete m_storage->m_sparseValueMap; - fastFree(m_storage); -} - -JSValue* ArrayInstance::getItem(unsigned i) const -{ - ASSERT(i <= maxArrayIndex); - - ArrayStorage* storage = m_storage; - - if (i < m_vectorLength) { - JSValue* value = storage->m_vector[i]; - return value ? value : jsUndefined(); - } - - SparseArrayValueMap* map = storage->m_sparseValueMap; - if (!map) - return jsUndefined(); - - JSValue* value = map->get(i); - return value ? value : jsUndefined(); -} - -JSValue* ArrayInstance::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) -{ - return jsNumber(static_cast(slot.slotBase())->m_length); -} - -ALWAYS_INLINE bool ArrayInstance::inlineGetOwnPropertySlot(ExecState* exec, unsigned i, PropertySlot& slot) -{ - ArrayStorage* storage = m_storage; - - if (i >= m_length) { - if (i > maxArrayIndex) - return getOwnPropertySlot(exec, Identifier::from(i), slot); - return false; - } - - if (i < m_vectorLength) { - JSValue*& valueSlot = storage->m_vector[i]; - if (valueSlot) { - slot.setValueSlot(this, &valueSlot); - return true; - } - } else if (SparseArrayValueMap* map = storage->m_sparseValueMap) { - if (i >= sparseArrayCutoff) { - SparseArrayValueMap::iterator it = map->find(i); - if (it != map->end()) { - slot.setValueSlot(this, &it->second); - return true; - } - } - } - - return false; -} - -bool ArrayInstance::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - if (propertyName == exec->propertyNames().length) { - slot.setCustom(this, lengthGetter); - return true; - } - - bool isArrayIndex; - unsigned i = propertyName.toArrayIndex(&isArrayIndex); - if (isArrayIndex) - return inlineGetOwnPropertySlot(exec, i, slot); - - return JSObject::getOwnPropertySlot(exec, propertyName, slot); -} - -bool ArrayInstance::getOwnPropertySlot(ExecState* exec, unsigned i, PropertySlot& slot) -{ - return inlineGetOwnPropertySlot(exec, i, slot); -} - -// ECMA 15.4.5.1 -void ArrayInstance::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attributes) -{ - bool isArrayIndex; - unsigned i = propertyName.toArrayIndex(&isArrayIndex); - if (isArrayIndex) { - put(exec, i, value, attributes); - return; - } - - if (propertyName == exec->propertyNames().length) { - unsigned newLength = value->toUInt32(exec); - if (value->toNumber(exec) != static_cast(newLength)) { - throwError(exec, RangeError, "Invalid array length."); - return; - } - setLength(newLength); - return; - } - - JSObject::put(exec, propertyName, value, attributes); -} - -void ArrayInstance::put(ExecState* exec, unsigned i, JSValue* value, int attributes) -{ - if (i > maxArrayIndex) { - put(exec, Identifier::from(i), value, attributes); - return; - } - - ArrayStorage* storage = m_storage; - - unsigned length = m_length; - if (i >= length) { - length = i + 1; - m_length = length; - } - - if (i < m_vectorLength) { - JSValue*& valueSlot = storage->m_vector[i]; - storage->m_numValuesInVector += !valueSlot; - valueSlot = value; - return; - } - - SparseArrayValueMap* map = storage->m_sparseValueMap; - - if (i >= sparseArrayCutoff) { - // We miss some cases where we could compact the storage, such as a large array that is being filled from the end - // (which will only be compacted as we reach indices that are less than cutoff) - but this makes the check much faster. - if (!isDenseEnoughForVector(i + 1, storage->m_numValuesInVector + 1)) { - if (!map) { - map = new SparseArrayValueMap; - storage->m_sparseValueMap = map; - } - map->set(i, value); - return; - } - } - - // We have decided that we'll put the new item into the vector. - // Fast case is when there is no sparse map, so we can increase the vector size without moving values from it. - if (!map || map->isEmpty()) { - increaseVectorLength(i + 1); - storage = m_storage; - ++storage->m_numValuesInVector; - storage->m_vector[i] = value; - return; - } - - // Decide how many values it would be best to move from the map. - unsigned newNumValuesInVector = storage->m_numValuesInVector + 1; - unsigned newVectorLength = increasedVectorLength(i + 1); - for (unsigned j = max(m_vectorLength, sparseArrayCutoff); j < newVectorLength; ++j) - newNumValuesInVector += map->contains(j); - if (i >= sparseArrayCutoff) - newNumValuesInVector -= map->contains(i); - if (isDenseEnoughForVector(newVectorLength, newNumValuesInVector)) { - unsigned proposedNewNumValuesInVector = newNumValuesInVector; - while (true) { - unsigned proposedNewVectorLength = increasedVectorLength(newVectorLength + 1); - for (unsigned j = max(newVectorLength, sparseArrayCutoff); j < proposedNewVectorLength; ++j) - proposedNewNumValuesInVector += map->contains(j); - if (!isDenseEnoughForVector(proposedNewVectorLength, proposedNewNumValuesInVector)) - break; - newVectorLength = proposedNewVectorLength; - newNumValuesInVector = proposedNewNumValuesInVector; - } - } - - storage = static_cast(fastRealloc(storage, storageSize(newVectorLength))); - - unsigned vectorLength = m_vectorLength; - if (newNumValuesInVector == storage->m_numValuesInVector + 1) { - for (unsigned j = vectorLength; j < newVectorLength; ++j) - storage->m_vector[j] = 0; - if (i > sparseArrayCutoff) - map->remove(i); - } else { - for (unsigned j = vectorLength; j < max(vectorLength, sparseArrayCutoff); ++j) - storage->m_vector[j] = 0; - for (unsigned j = max(vectorLength, sparseArrayCutoff); j < newVectorLength; ++j) - storage->m_vector[j] = map->take(j); - } - - storage->m_vector[i] = value; - - m_vectorLength = newVectorLength; - storage->m_numValuesInVector = newNumValuesInVector; - - m_storage = storage; -} - -bool ArrayInstance::deleteProperty(ExecState* exec, const Identifier& propertyName) -{ - bool isArrayIndex; - unsigned i = propertyName.toArrayIndex(&isArrayIndex); - if (isArrayIndex) - return deleteProperty(exec, i); - - if (propertyName == exec->propertyNames().length) - return false; - - return JSObject::deleteProperty(exec, propertyName); -} - -bool ArrayInstance::deleteProperty(ExecState* exec, unsigned i) -{ - ArrayStorage* storage = m_storage; - - if (i < m_vectorLength) { - JSValue*& valueSlot = storage->m_vector[i]; - bool hadValue = valueSlot; - valueSlot = 0; - storage->m_numValuesInVector -= hadValue; - return hadValue; - } - - if (SparseArrayValueMap* map = storage->m_sparseValueMap) { - if (i >= sparseArrayCutoff) { - SparseArrayValueMap::iterator it = map->find(i); - if (it != map->end()) { - map->remove(it); - return true; - } - } - } - - if (i > maxArrayIndex) - return deleteProperty(exec, Identifier::from(i)); - - return false; -} - -void ArrayInstance::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) -{ - // FIXME: Filling PropertyNameArray with an identifier for every integer - // is incredibly inefficient for large arrays. We need a different approach. - - ArrayStorage* storage = m_storage; - - unsigned usedVectorLength = min(m_length, m_vectorLength); - for (unsigned i = 0; i < usedVectorLength; ++i) { - if (storage->m_vector[i]) - propertyNames.add(Identifier::from(i)); - } - - if (SparseArrayValueMap* map = storage->m_sparseValueMap) { - SparseArrayValueMap::iterator end = map->end(); - for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it) - propertyNames.add(Identifier::from(it->first)); - } - - JSObject::getPropertyNames(exec, propertyNames); -} - -void ArrayInstance::increaseVectorLength(unsigned newLength) -{ - // This function leaves the array in an internally inconsistent state, because it does not move any values from sparse value map - // to the vector. Callers have to account for that, because they can do it more efficiently. - - ArrayStorage* storage = m_storage; - - unsigned vectorLength = m_vectorLength; - ASSERT(newLength > vectorLength); - unsigned newVectorLength = increasedVectorLength(newLength); - - storage = static_cast(fastRealloc(storage, storageSize(newVectorLength))); - m_vectorLength = newVectorLength; - - for (unsigned i = vectorLength; i < newVectorLength; ++i) - storage->m_vector[i] = 0; - - m_storage = storage; -} - -void ArrayInstance::setLength(unsigned newLength) -{ - ArrayStorage* storage = m_storage; - - unsigned length = m_length; - - if (newLength < length) { - unsigned usedVectorLength = min(length, m_vectorLength); - for (unsigned i = newLength; i < usedVectorLength; ++i) { - JSValue*& valueSlot = storage->m_vector[i]; - bool hadValue = valueSlot; - valueSlot = 0; - storage->m_numValuesInVector -= hadValue; - } - - if (SparseArrayValueMap* map = storage->m_sparseValueMap) { - SparseArrayValueMap copy = *map; - SparseArrayValueMap::iterator end = copy.end(); - for (SparseArrayValueMap::iterator it = copy.begin(); it != end; ++it) { - if (it->first >= newLength) - map->remove(it->first); - } - if (map->isEmpty()) { - delete map; - storage->m_sparseValueMap = 0; - } - } - } - - m_length = newLength; -} - -void ArrayInstance::mark() -{ - JSObject::mark(); - - ArrayStorage* storage = m_storage; - - unsigned usedVectorLength = min(m_length, m_vectorLength); - for (unsigned i = 0; i < usedVectorLength; ++i) { - JSValue* value = storage->m_vector[i]; - if (value && !value->marked()) - value->mark(); - } - - if (SparseArrayValueMap* map = storage->m_sparseValueMap) { - SparseArrayValueMap::iterator end = map->end(); - for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it) { - JSValue* value = it->second; - if (!value->marked()) - value->mark(); - } - } -} - -static int compareByStringPairForQSort(const void* a, const void* b) -{ - const std::pair* va = static_cast*>(a); - const std::pair* vb = static_cast*>(b); - return compare(va->second, vb->second); -} - -static ExecState* execForCompareByStringForQSort = 0; -static int compareByStringForQSort(const void* a, const void* b) -{ - ExecState* exec = execForCompareByStringForQSort; - - JSValue* va = *static_cast(a); - JSValue* vb = *static_cast(b); - ASSERT(!va->isUndefined()); - ASSERT(!vb->isUndefined()); - - return compare(va->toString(exec), vb->toString(exec)); -} - -void ArrayInstance::sort(ExecState* exec) -{ - unsigned lengthNotIncludingUndefined = compactForSorting(); - - if (lengthNotIncludingUndefined < copyingSortCutoff) { - // Converting JavaScript values to strings can be expensive, so we do it once up front and sort based on that. - // This is a considerable improvement over doing it twice per comparison, though it requires a large temporary - // buffer. For large arrays, we fall back to a qsort on the JavaScriptValues to avoid creating copies. - - Vector > values(lengthNotIncludingUndefined); - for (size_t i = 0; i < lengthNotIncludingUndefined; i++) { - JSValue* value = m_storage->m_vector[i]; - ASSERT(!value->isUndefined()); - values[i].first = value; - values[i].second = value->toString(exec); - } - - // FIXME: Since we sort by string value, a fast algorithm might be to use a radix sort. That would be O(N) rather - // than O(N log N). - -#if HAVE(MERGESORT) - mergesort(values.begin(), values.size(), sizeof(std::pair), compareByStringPairForQSort); -#else - qsort(values.begin(), values.size(), sizeof(std::pair), compareByStringPairForQSort); -#endif - for (size_t i = 0; i < lengthNotIncludingUndefined; i++) - m_storage->m_vector[i] = values[i].first; - return; - } - - ExecState* oldExec = execForCompareByStringForQSort; - execForCompareByStringForQSort = exec; - qsort(m_storage->m_vector, lengthNotIncludingUndefined, sizeof(JSValue*), compareByStringForQSort); - execForCompareByStringForQSort = oldExec; -} - -struct CompareWithCompareFunctionArguments { - CompareWithCompareFunctionArguments(ExecState *e, JSObject *cf) - : exec(e) - , compareFunction(cf) - , globalObject(e->dynamicGlobalObject()) - { - } - - ExecState *exec; - JSObject *compareFunction; - List arguments; - JSGlobalObject* globalObject; -}; - -static CompareWithCompareFunctionArguments* compareWithCompareFunctionArguments = 0; - -static int compareWithCompareFunctionForQSort(const void* a, const void* b) -{ - CompareWithCompareFunctionArguments *args = compareWithCompareFunctionArguments; - - JSValue* va = *static_cast(a); - JSValue* vb = *static_cast(b); - ASSERT(!va->isUndefined()); - ASSERT(!vb->isUndefined()); - - args->arguments.clear(); - args->arguments.append(va); - args->arguments.append(vb); - double compareResult = args->compareFunction->call - (args->exec, args->globalObject, args->arguments)->toNumber(args->exec); - return compareResult < 0 ? -1 : compareResult > 0 ? 1 : 0; -} - -void ArrayInstance::sort(ExecState* exec, JSObject* compareFunction) -{ - size_t lengthNotIncludingUndefined = compactForSorting(); - - CompareWithCompareFunctionArguments* oldArgs = compareWithCompareFunctionArguments; - CompareWithCompareFunctionArguments args(exec, compareFunction); - compareWithCompareFunctionArguments = &args; - -#if HAVE(MERGESORT) - // Because mergesort usually does fewer compares, it is faster than qsort here. - // However, because it requires extra copies of the storage buffer, don't use it for very - // large arrays. - - // FIXME: A tree sort using a perfectly balanced tree (e.g. an AVL tree) could do an even - // better job of minimizing compares. - - if (lengthNotIncludingUndefined < copyingSortCutoff) { - // During the sort, we could do a garbage collect, and it's important to still - // have references to every object in the array for ArrayInstance::mark. - // The mergesort algorithm does not guarantee this, so we sort a copy rather - // than the original. - size_t size = storageSize(m_vectorLength); - ArrayStorage* copy = static_cast(fastMalloc(size)); - memcpy(copy, m_storage, size); - mergesort(copy->m_vector, lengthNotIncludingUndefined, sizeof(JSValue*), compareWithCompareFunctionForQSort); - fastFree(m_storage); - m_storage = copy; - compareWithCompareFunctionArguments = oldArgs; - return; - } -#endif - - qsort(m_storage->m_vector, lengthNotIncludingUndefined, sizeof(JSValue*), compareWithCompareFunctionForQSort); - compareWithCompareFunctionArguments = oldArgs; -} - -unsigned ArrayInstance::compactForSorting() -{ - ArrayStorage* storage = m_storage; - - unsigned usedVectorLength = min(m_length, m_vectorLength); - - unsigned numDefined = 0; - unsigned numUndefined = 0; - - for (; numDefined < usedVectorLength; ++numDefined) { - JSValue* v = storage->m_vector[numDefined]; - if (!v || v->isUndefined()) - break; - } - for (unsigned i = numDefined; i < usedVectorLength; ++i) { - if (JSValue* v = storage->m_vector[i]) { - if (v->isUndefined()) - ++numUndefined; - else - storage->m_vector[numDefined++] = v; - } - } - - unsigned newUsedVectorLength = numDefined + numUndefined; - - if (SparseArrayValueMap* map = storage->m_sparseValueMap) { - newUsedVectorLength += map->size(); - if (newUsedVectorLength > m_vectorLength) { - increaseVectorLength(newUsedVectorLength); - storage = m_storage; - } - - SparseArrayValueMap::iterator end = map->end(); - for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it) - storage->m_vector[numDefined++] = it->second; - - delete map; - storage->m_sparseValueMap = 0; - } - - for (unsigned i = numDefined; i < newUsedVectorLength; ++i) - storage->m_vector[i] = jsUndefined(); - for (unsigned i = newUsedVectorLength; i < usedVectorLength; ++i) - storage->m_vector[i] = 0; - - return numDefined; -} - -} diff --git a/kjs/array_instance.h b/kjs/array_instance.h deleted file mode 100644 index 913d0cd..0000000 --- a/kjs/array_instance.h +++ /dev/null @@ -1,72 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ARRAY_INSTANCE_H -#define ARRAY_INSTANCE_H - -#include "object.h" - -namespace KJS { - - struct ArrayStorage; - - class ArrayInstance : public JSObject { - public: - ArrayInstance(JSObject* prototype, unsigned initialLength); - ArrayInstance(JSObject* prototype, const List& initialValues); - ~ArrayInstance(); - - virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); - virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); - virtual void put(ExecState*, const Identifier& propertyName, JSValue*, int attributes = None); - virtual void put(ExecState*, unsigned propertyName, JSValue*, int attributes = None); - virtual bool deleteProperty(ExecState *, const Identifier& propertyName); - virtual bool deleteProperty(ExecState *, unsigned propertyName); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); - - virtual void mark(); - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - - unsigned getLength() const { return m_length; } - JSValue* getItem(unsigned) const; - - void sort(ExecState*); - void sort(ExecState*, JSObject* compareFunction); - - private: - static JSValue* lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); - bool inlineGetOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); - - void setLength(unsigned); - void increaseVectorLength(unsigned newLength); - - unsigned compactForSorting(); - - unsigned m_length; - unsigned m_vectorLength; - ArrayStorage* m_storage; - }; - -} // namespace KJS - -#endif diff --git a/kjs/array_object.cpp b/kjs/array_object.cpp deleted file mode 100644 index 48b0855..0000000 --- a/kjs/array_object.cpp +++ /dev/null @@ -1,760 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2003 Peter Kelly (pmk@post.com) - * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - */ - -#include "config.h" -#include "array_object.h" -#include "array_object.lut.h" - -#include "error_object.h" -#include "lookup.h" -#include "operations.h" -#include -#include -#include - -#include // for std::min - -namespace KJS { - -// ------------------------------ ArrayPrototype ---------------------------- - -const ClassInfo ArrayPrototype::info = {"Array", &ArrayInstance::info, &arrayTable}; - -/* Source for array_object.lut.h -@begin arrayTable 16 - toString arrayProtoFuncToString DontEnum|Function 0 - toLocaleString arrayProtoFuncToLocaleString DontEnum|Function 0 - concat arrayProtoFuncConcat DontEnum|Function 1 - join arrayProtoFuncJoin DontEnum|Function 1 - pop arrayProtoFuncPop DontEnum|Function 0 - push arrayProtoFuncPush DontEnum|Function 1 - reverse arrayProtoFuncReverse DontEnum|Function 0 - shift arrayProtoFuncShift DontEnum|Function 0 - slice arrayProtoFuncSlice DontEnum|Function 2 - sort arrayProtoFuncSort DontEnum|Function 1 - splice arrayProtoFuncSplice DontEnum|Function 2 - unshift arrayProtoFuncUnShift DontEnum|Function 1 - every arrayProtoFuncEvery DontEnum|Function 1 - forEach arrayProtoFuncForEach DontEnum|Function 1 - some arrayProtoFuncSome DontEnum|Function 1 - indexOf arrayProtoFuncIndexOf DontEnum|Function 1 - lastIndexOf arrayProtoFuncLastIndexOf DontEnum|Function 1 - filter arrayProtoFuncFilter DontEnum|Function 1 - map arrayProtoFuncMap DontEnum|Function 1 -@end -*/ - -// ECMA 15.4.4 -ArrayPrototype::ArrayPrototype(ExecState*, ObjectPrototype* objProto) - : ArrayInstance(objProto, 0) -{ -} - -bool ArrayPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticFunctionSlot(exec, &arrayTable, this, propertyName, slot); -} - - -// ------------------------------ Array Functions ---------------------------- - -// Helper function -static JSValue* getProperty(ExecState* exec, JSObject* obj, unsigned index) -{ - PropertySlot slot; - if (!obj->getPropertySlot(exec, index, slot)) - return 0; - return slot.getValue(exec, obj, index); -} - -JSValue* arrayProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&ArrayInstance::info)) - return throwError(exec, TypeError); - - static HashSet visitedElems; - static const UString* empty = new UString(""); - static const UString* comma = new UString(","); - bool alreadyVisited = !visitedElems.add(thisObj).second; - if (alreadyVisited) - return jsString(*empty); - UString separator = *comma; - UString str = *empty; - - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - for (unsigned k = 0; k < length; k++) { - if (k >= 1) - str += separator; - if (str.isNull()) { - JSObject* error = Error::create(exec, GeneralError, "Out of memory"); - exec->setException(error); - break; - } - - JSValue* element = thisObj->get(exec, k); - if (element->isUndefinedOrNull()) - continue; - - str += element->toString(exec); - - if (str.isNull()) { - JSObject* error = Error::create(exec, GeneralError, "Out of memory"); - exec->setException(error); - } - - if (exec->hadException()) - break; - } - visitedElems.remove(thisObj); - return jsString(str); -} - -JSValue* arrayProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&ArrayInstance::info)) - return throwError(exec, TypeError); - - static HashSet visitedElems; - static const UString* empty = new UString(""); - static const UString* comma = new UString(","); - bool alreadyVisited = !visitedElems.add(thisObj).second; - if (alreadyVisited) - return jsString(*empty); - UString separator = *comma; - UString str = *empty; - - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - for (unsigned k = 0; k < length; k++) { - if (k >= 1) - str += separator; - if (str.isNull()) { - JSObject* error = Error::create(exec, GeneralError, "Out of memory"); - exec->setException(error); - break; - } - - JSValue* element = thisObj->get(exec, k); - if (element->isUndefinedOrNull()) - continue; - - JSObject* o = element->toObject(exec); - JSValue* conversionFunction = o->get(exec, exec->propertyNames().toLocaleString); - if (conversionFunction->isObject() && static_cast(conversionFunction)->implementsCall()) - str += static_cast(conversionFunction)->call(exec, o, exec->emptyList())->toString(exec); - else - str += element->toString(exec); - - if (str.isNull()) { - JSObject* error = Error::create(exec, GeneralError, "Out of memory"); - exec->setException(error); - } - - if (exec->hadException()) - break; - } - visitedElems.remove(thisObj); - return jsString(str); -} - -JSValue* arrayProtoFuncJoin(ExecState* exec, JSObject* thisObj, const List& args) -{ - static HashSet visitedElems; - static const UString* empty = new UString(""); - static const UString* comma = new UString(","); - bool alreadyVisited = !visitedElems.add(thisObj).second; - if (alreadyVisited) - return jsString(*empty); - UString separator = *comma; - UString str = *empty; - - if (!args[0]->isUndefined()) - separator = args[0]->toString(exec); - - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - for (unsigned k = 0; k < length; k++) { - if (k >= 1) - str += separator; - if (str.isNull()) { - JSObject* error = Error::create(exec, GeneralError, "Out of memory"); - exec->setException(error); - break; - } - - JSValue* element = thisObj->get(exec, k); - if (element->isUndefinedOrNull()) - continue; - - str += element->toString(exec); - - if (str.isNull()) { - JSObject* error = Error::create(exec, GeneralError, "Out of memory"); - exec->setException(error); - } - - if (exec->hadException()) - break; - } - visitedElems.remove(thisObj); - return jsString(str); -} - -JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject* thisObj, const List& args) -{ - JSObject* arr = static_cast(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList())); - int n = 0; - JSValue* curArg = thisObj; - JSObject* curObj = static_cast(thisObj); - List::const_iterator it = args.begin(); - List::const_iterator end = args.end(); - while (1) { - if (curArg->isObject() && curObj->inherits(&ArrayInstance::info)) { - unsigned k = 0; - // Older versions tried to optimize out getting the length of thisObj - // by checking for n != 0, but that doesn't work if thisObj is an empty array. - unsigned length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - while (k < length) { - if (JSValue* v = getProperty(exec, curObj, k)) - arr->put(exec, n, v); - n++; - k++; - } - } else { - arr->put(exec, n, curArg); - n++; - } - if (it == end) - break; - curArg = *it; - curObj = static_cast(curArg); // may be 0 - ++it; - } - arr->put(exec, exec->propertyNames().length, jsNumber(n)); - return arr; -} - -JSValue* arrayProtoFuncPop(ExecState* exec, JSObject* thisObj, const List&) -{ - JSValue* result = 0; - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - if (length == 0) { - thisObj->put(exec, exec->propertyNames().length, jsNumber(length)); - result = jsUndefined(); - } else { - result = thisObj->get(exec, length - 1); - thisObj->deleteProperty(exec, length - 1); - thisObj->put(exec, exec->propertyNames().length, jsNumber(length - 1)); - } - return result; -} - -JSValue* arrayProtoFuncPush(ExecState* exec, JSObject* thisObj, const List& args) -{ - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - for (unsigned n = 0; n < args.size(); n++) - thisObj->put(exec, length + n, args[n]); - length += args.size(); - thisObj->put(exec, exec->propertyNames().length, jsNumber(length)); - return jsNumber(length); -} - -JSValue* arrayProtoFuncReverse(ExecState* exec, JSObject* thisObj, const List&) -{ - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - unsigned middle = length / 2; - - for (unsigned k = 0; k < middle; k++) { - unsigned lk1 = length - k - 1; - JSValue* obj2 = getProperty(exec, thisObj, lk1); - JSValue* obj = getProperty(exec, thisObj, k); - - if (obj2) - thisObj->put(exec, k, obj2); - else - thisObj->deleteProperty(exec, k); - - if (obj) - thisObj->put(exec, lk1, obj); - else - thisObj->deleteProperty(exec, lk1); - } - return thisObj; -} - -JSValue* arrayProtoFuncShift(ExecState* exec, JSObject* thisObj, const List&) -{ - JSValue* result = 0; - - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - if (length == 0) { - thisObj->put(exec, exec->propertyNames().length, jsNumber(length)); - result = jsUndefined(); - } else { - result = thisObj->get(exec, 0); - for (unsigned k = 1; k < length; k++) { - if (JSValue* obj = getProperty(exec, thisObj, k)) - thisObj->put(exec, k - 1, obj); - else - thisObj->deleteProperty(exec, k - 1); - } - thisObj->deleteProperty(exec, length - 1); - thisObj->put(exec, exec->propertyNames().length, jsNumber(length - 1)); - } - return result; -} - -JSValue* arrayProtoFuncSlice(ExecState* exec, JSObject* thisObj, const List& args) -{ - // http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10 - - // We return a new array - JSObject* resObj = static_cast(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList())); - JSValue* result = resObj; - double begin = args[0]->toInteger(exec); - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - if (begin >= 0) { - if (begin > length) - begin = length; - } else { - begin += length; - if (begin < 0) - begin = 0; - } - double end; - if (args[1]->isUndefined()) - end = length; - else { - end = args[1]->toInteger(exec); - if (end < 0) { - end += length; - if (end < 0) - end = 0; - } else { - if (end > length) - end = length; - } - } - - int n = 0; - int b = static_cast(begin); - int e = static_cast(end); - for (int k = b; k < e; k++, n++) { - if (JSValue* v = getProperty(exec, thisObj, k)) - resObj->put(exec, n, v); - } - resObj->put(exec, exec->propertyNames().length, jsNumber(n)); - return result; -} - -JSValue* arrayProtoFuncSort(ExecState* exec, JSObject* thisObj, const List& args) -{ - JSObject* sortFunction = 0; - if (!args[0]->isUndefined()) { - sortFunction = args[0]->toObject(exec); - if (!sortFunction->implementsCall()) - sortFunction = 0; - } - - if (thisObj->classInfo() == &ArrayInstance::info) { - if (sortFunction) - static_cast(thisObj)->sort(exec, sortFunction); - else - static_cast(thisObj)->sort(exec); - return thisObj; - } - - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - - if (!length) - return thisObj; - - // "Min" sort. Not the fastest, but definitely less code than heapsort - // or quicksort, and much less swapping than bubblesort/insertionsort. - for (unsigned i = 0; i < length - 1; ++i) { - JSValue* iObj = thisObj->get(exec, i); - unsigned themin = i; - JSValue* minObj = iObj; - for (unsigned j = i + 1; j < length; ++j) { - JSValue* jObj = thisObj->get(exec, j); - double compareResult; - if (jObj->isUndefined()) - compareResult = 1; // don't check minObj because there's no need to differentiate == (0) from > (1) - else if (minObj->isUndefined()) - compareResult = -1; - else if (sortFunction) { - List l; - l.append(jObj); - l.append(minObj); - compareResult = sortFunction->call(exec, exec->dynamicGlobalObject(), l)->toNumber(exec); - } else - compareResult = (jObj->toString(exec) < minObj->toString(exec)) ? -1 : 1; - - if (compareResult < 0) { - themin = j; - minObj = jObj; - } - } - // Swap themin and i - if (themin > i) { - thisObj->put(exec, i, minObj); - thisObj->put(exec, themin, iObj); - } - } - return thisObj; -} - -JSValue* arrayProtoFuncSplice(ExecState* exec, JSObject* thisObj, const List& args) -{ - // 15.4.4.12 - JSObject* resObj = static_cast(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList())); - JSValue* result = resObj; - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - if (!args.size()) - return jsUndefined(); - int begin = args[0]->toUInt32(exec); - if (begin < 0) - begin = std::max(begin + length, 0); - else - begin = std::min(begin, length); - - unsigned deleteCount; - if (args.size() > 1) - deleteCount = std::min(std::max(args[1]->toUInt32(exec), 0), length - begin); - else - deleteCount = length - begin; - - for (unsigned k = 0; k < deleteCount; k++) { - if (JSValue* v = getProperty(exec, thisObj, k + begin)) - resObj->put(exec, k, v); - } - resObj->put(exec, exec->propertyNames().length, jsNumber(deleteCount)); - - unsigned additionalArgs = std::max(args.size() - 2, 0); - if (additionalArgs != deleteCount) { - if (additionalArgs < deleteCount) { - for (unsigned k = begin; k < length - deleteCount; ++k) { - if (JSValue* v = getProperty(exec, thisObj, k + deleteCount)) - thisObj->put(exec, k + additionalArgs, v); - else - thisObj->deleteProperty(exec, k + additionalArgs); - } - for (unsigned k = length; k > length - deleteCount + additionalArgs; --k) - thisObj->deleteProperty(exec, k - 1); - } else { - for (unsigned k = length - deleteCount; (int)k > begin; --k) { - if (JSValue* obj = getProperty(exec, thisObj, k + deleteCount - 1)) - thisObj->put(exec, k + additionalArgs - 1, obj); - else - thisObj->deleteProperty(exec, k + additionalArgs - 1); - } - } - } - for (unsigned k = 0; k < additionalArgs; ++k) - thisObj->put(exec, k + begin, args[k + 2]); - - thisObj->put(exec, exec->propertyNames().length, jsNumber(length - deleteCount + additionalArgs)); - return result; -} - -JSValue* arrayProtoFuncUnShift(ExecState* exec, JSObject* thisObj, const List& args) -{ - // 15.4.4.13 - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - unsigned nrArgs = args.size(); - if (nrArgs) { - for (unsigned k = length; k > 0; --k) { - if (JSValue* v = getProperty(exec, thisObj, k - 1)) - thisObj->put(exec, k + nrArgs - 1, v); - else - thisObj->deleteProperty(exec, k + nrArgs - 1); - } - } - for (unsigned k = 0; k < nrArgs; ++k) - thisObj->put(exec, k, args[k]); - JSValue* result = jsNumber(length + nrArgs); - thisObj->put(exec, exec->propertyNames().length, result); - return result; -} - -JSValue* arrayProtoFuncFilter(ExecState* exec, JSObject* thisObj, const List& args) -{ - JSObject* eachFunction = args[0]->toObject(exec); - - if (!eachFunction->implementsCall()) - return throwError(exec, TypeError); - - JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); - JSObject* resultArray = static_cast(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList())); - - unsigned filterIndex = 0; - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - for (unsigned k = 0; k < length && !exec->hadException(); ++k) { - PropertySlot slot; - - if (!thisObj->getPropertySlot(exec, k, slot)) - continue; - - JSValue* v = slot.getValue(exec, thisObj, k); - - List eachArguments; - - eachArguments.append(v); - eachArguments.append(jsNumber(k)); - eachArguments.append(thisObj); - - JSValue* result = eachFunction->call(exec, applyThis, eachArguments); - - if (result->toBoolean(exec)) - resultArray->put(exec, filterIndex++, v); - } - return resultArray; -} - -JSValue* arrayProtoFuncMap(ExecState* exec, JSObject* thisObj, const List& args) -{ - JSObject* eachFunction = args[0]->toObject(exec); - if (!eachFunction->implementsCall()) - return throwError(exec, TypeError); - - JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); - - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - - List mapArgs; - mapArgs.append(jsNumber(length)); - JSObject* resultArray = static_cast(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, mapArgs)); - - for (unsigned k = 0; k < length && !exec->hadException(); ++k) { - PropertySlot slot; - if (!thisObj->getPropertySlot(exec, k, slot)) - continue; - - JSValue* v = slot.getValue(exec, thisObj, k); - - List eachArguments; - - eachArguments.append(v); - eachArguments.append(jsNumber(k)); - eachArguments.append(thisObj); - - JSValue* result = eachFunction->call(exec, applyThis, eachArguments); - resultArray->put(exec, k, result); - } - - return resultArray; -} - -// Documentation for these three is available at: -// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:every -// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach -// http://developer-test.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some - -JSValue* arrayProtoFuncEvery(ExecState* exec, JSObject* thisObj, const List& args) -{ - JSObject* eachFunction = args[0]->toObject(exec); - - if (!eachFunction->implementsCall()) - return throwError(exec, TypeError); - - JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); - - JSValue* result = jsBoolean(true); - - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - for (unsigned k = 0; k < length && !exec->hadException(); ++k) { - PropertySlot slot; - - if (!thisObj->getPropertySlot(exec, k, slot)) - continue; - - List eachArguments; - - eachArguments.append(slot.getValue(exec, thisObj, k)); - eachArguments.append(jsNumber(k)); - eachArguments.append(thisObj); - - bool predicateResult = eachFunction->call(exec, applyThis, eachArguments)->toBoolean(exec); - - if (!predicateResult) { - result = jsBoolean(false); - break; - } - } - - return result; -} - -JSValue* arrayProtoFuncForEach(ExecState* exec, JSObject* thisObj, const List& args) -{ - JSObject* eachFunction = args[0]->toObject(exec); - - if (!eachFunction->implementsCall()) - return throwError(exec, TypeError); - - JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); - - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - for (unsigned k = 0; k < length && !exec->hadException(); ++k) { - PropertySlot slot; - if (!thisObj->getPropertySlot(exec, k, slot)) - continue; - - List eachArguments; - eachArguments.append(slot.getValue(exec, thisObj, k)); - eachArguments.append(jsNumber(k)); - eachArguments.append(thisObj); - - eachFunction->call(exec, applyThis, eachArguments); - } - return jsUndefined(); -} - -JSValue* arrayProtoFuncSome(ExecState* exec, JSObject* thisObj, const List& args) -{ - JSObject* eachFunction = args[0]->toObject(exec); - - if (!eachFunction->implementsCall()) - return throwError(exec, TypeError); - - JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); - - JSValue* result = jsBoolean(false); - - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - for (unsigned k = 0; k < length && !exec->hadException(); ++k) { - PropertySlot slot; - if (!thisObj->getPropertySlot(exec, k, slot)) - continue; - - List eachArguments; - eachArguments.append(slot.getValue(exec, thisObj, k)); - eachArguments.append(jsNumber(k)); - eachArguments.append(thisObj); - - bool predicateResult = eachFunction->call(exec, applyThis, eachArguments)->toBoolean(exec); - - if (predicateResult) { - result = jsBoolean(true); - break; - } - } - return result; -} - -JSValue* arrayProtoFuncIndexOf(ExecState* exec, JSObject* thisObj, const List& args) -{ - // JavaScript 1.5 Extension by Mozilla - // Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf - - unsigned index = 0; - double d = args[1]->toInteger(exec); - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - if (d < 0) - d += length; - if (d > 0) { - if (d > length) - index = length; - else - index = static_cast(d); - } - - JSValue* searchElement = args[0]; - for (; index < length; ++index) { - JSValue* e = getProperty(exec, thisObj, index); - if (!e) - continue; - if (strictEqual(exec, searchElement, e)) - return jsNumber(index); - } - - return jsNumber(-1); -} - -JSValue* arrayProtoFuncLastIndexOf(ExecState* exec, JSObject* thisObj, const List& args) -{ - // JavaScript 1.6 Extension by Mozilla - // Documentation: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:lastIndexOf - - unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - int index = length - 1; - double d = args[1]->toIntegerPreserveNaN(exec); - - if (d < 0) { - d += length; - if (d < 0) - return jsNumber(-1); - } - if (d < length) - index = static_cast(d); - - JSValue* searchElement = args[0]; - for (; index >= 0; --index) { - JSValue* e = getProperty(exec, thisObj, index); - if (!e) - continue; - if (strictEqual(exec, searchElement, e)) - return jsNumber(index); - } - - return jsNumber(-1); -} - -// ------------------------------ ArrayObjectImp ------------------------------- - -ArrayObjectImp::ArrayObjectImp(ExecState* exec, FunctionPrototype* funcProto, ArrayPrototype* arrayProto) - : InternalFunctionImp(funcProto, arrayProto->classInfo()->className) -{ - // ECMA 15.4.3.1 Array.prototype - putDirect(exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly); - - // no. of arguments for constructor - putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); -} - -bool ArrayObjectImp::implementsConstruct() const -{ - return true; -} - -// ECMA 15.4.2 -JSObject* ArrayObjectImp::construct(ExecState* exec, const List& args) -{ - // a single numeric argument denotes the array size (!) - if (args.size() == 1 && args[0]->isNumber()) { - uint32_t n = args[0]->toUInt32(exec); - if (n != args[0]->toNumber(exec)) - return throwError(exec, RangeError, "Array size is not a small enough positive integer."); - return new ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), n); - } - - // otherwise the array is constructed with the arguments in it - return new ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), args); -} - -// ECMA 15.6.1 -JSValue* ArrayObjectImp::callAsFunction(ExecState* exec, JSObject*, const List& args) -{ - // equivalent to 'new Array(....)' - return construct(exec,args); -} - -} diff --git a/kjs/array_object.h b/kjs/array_object.h deleted file mode 100644 index e109c47..0000000 --- a/kjs/array_object.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ARRAY_OBJECT_H_ -#define ARRAY_OBJECT_H_ - -#include "array_instance.h" -#include "function_object.h" -#include "lookup.h" - -namespace KJS { - - class ArrayPrototype : public ArrayInstance { - public: - ArrayPrototype(ExecState*, ObjectPrototype*); - - bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - }; - - class ArrayObjectImp : public InternalFunctionImp { - public: - ArrayObjectImp(ExecState*, FunctionPrototype*, ArrayPrototype*); - - virtual bool implementsConstruct() const; - virtual JSObject* construct(ExecState*, const List&); - virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); - - }; - - JSValue* arrayProtoFuncToString(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncToLocaleString(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncConcat(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncJoin(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncPop(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncPush(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncReverse(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncShift(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncSlice(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncSort(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncSplice(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncUnShift(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncEvery(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncForEach(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncSome(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncIndexOf(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncFilter(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncMap(ExecState*, JSObject*, const List&); - JSValue* arrayProtoFuncLastIndexOf(ExecState*, JSObject*, const List&); - -} // namespace KJS - -#endif // ARRAY_OBJECT_H_ diff --git a/kjs/bool_object.cpp b/kjs/bool_object.cpp deleted file mode 100644 index 10bb738..0000000 --- a/kjs/bool_object.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "bool_object.h" - -#include "JSGlobalObject.h" -#include "error_object.h" -#include "operations.h" -#include - -namespace KJS { - -// ------------------------------ BooleanInstance --------------------------- - -const ClassInfo BooleanInstance::info = { "Boolean", 0, 0 }; - -BooleanInstance::BooleanInstance(JSObject* proto) - : JSWrapperObject(proto) -{ -} - -// ------------------------------ BooleanPrototype -------------------------- - -// Functions -static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, const List&); -static JSValue* booleanProtoFuncValueOf(ExecState*, JSObject*, const List&); - -// ECMA 15.6.4 - -BooleanPrototype::BooleanPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype) - : BooleanInstance(objectPrototype) -{ - setInternalValue(jsBoolean(false)); - - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum); -} - - -// ------------------------------ Functions -------------------------- - -// ECMA 15.6.4.2 + 15.6.4.3 - -JSValue* booleanProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&BooleanInstance::info)) - return throwError(exec, TypeError); - - JSValue* v = static_cast(thisObj)->internalValue(); - ASSERT(v); - - return jsString(v->toString(exec)); -} -JSValue* booleanProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&BooleanInstance::info)) - return throwError(exec, TypeError); - - JSValue* v = static_cast(thisObj)->internalValue(); - ASSERT(v); - - // TODO: optimize for bool case - return jsBoolean(v->toBoolean(exec)); -} - -// ------------------------------ BooleanObjectImp ----------------------------- - - -BooleanObjectImp::BooleanObjectImp(ExecState* exec, FunctionPrototype* functionPrototype, BooleanPrototype* booleanPrototype) - : InternalFunctionImp(functionPrototype, booleanPrototype->classInfo()->className) -{ - putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly); - - // no. of arguments for constructor - putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); -} - - -bool BooleanObjectImp::implementsConstruct() const -{ - return true; -} - -// ECMA 15.6.2 -JSObject* BooleanObjectImp::construct(ExecState* exec, const List& args) -{ - BooleanInstance* obj(new BooleanInstance(exec->lexicalGlobalObject()->booleanPrototype())); - obj->setInternalValue(jsBoolean(args[0]->toBoolean(exec))); - return obj; -} - -// ECMA 15.6.1 -JSValue* BooleanObjectImp::callAsFunction(ExecState* exec, JSObject*, const List& args) -{ - // TODO: optimize for bool case - return jsBoolean(args[0]->toBoolean(exec)); -} - -} // namespace KJS diff --git a/kjs/collector.cpp b/kjs/collector.cpp deleted file mode 100644 index 11d1625..0000000 --- a/kjs/collector.cpp +++ /dev/null @@ -1,1078 +0,0 @@ -// -*- mode: c++; c-basic-offset: 4 -*- -/* - * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2007 Eric Seidel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "collector.h" - -#include "ExecState.h" -#include "JSGlobalObject.h" -#include "internal.h" -#include "list.h" -#include "value.h" -#include "JSLockC.h" -#include -#include -#include -#include -#include -#include - -#if USE(MULTIPLE_THREADS) -#include -#endif - -#if PLATFORM(DARWIN) - -#include -#include -#include -#include -#include - -#include "CollectorHeapIntrospector.h" - -#elif PLATFORM(WIN_OS) - -#include - -#elif PLATFORM(UNIX) - -#include -#include -#include - -#if PLATFORM(SOLARIS) -#include -#endif - -#if HAVE(PTHREAD_NP_H) -#include -#else -#include -#endif - -#endif - -#define DEBUG_COLLECTOR 0 - -using std::max; - -namespace KJS { - -// tunable parameters - -const size_t SPARE_EMPTY_BLOCKS = 2; -const size_t MIN_ARRAY_SIZE = 14; -const size_t GROWTH_FACTOR = 2; -const size_t LOW_WATER_FACTOR = 4; -const size_t ALLOCATIONS_PER_COLLECTION = 4000; - -enum OperationInProgress { NoOperation, Allocation, Collection }; - -struct CollectorHeap { - CollectorBlock** blocks; - size_t numBlocks; - size_t usedBlocks; - size_t firstBlockWithPossibleSpace; - - size_t numLiveObjects; - size_t numLiveObjectsAtLastCollect; - size_t extraCost; - - OperationInProgress operationInProgress; -}; - -static CollectorHeap primaryHeap = { 0, 0, 0, 0, 0, 0, 0, NoOperation }; -static CollectorHeap numberHeap = { 0, 0, 0, 0, 0, 0, 0, NoOperation }; - -// FIXME: I don't think this needs to be a static data member of the Collector class. -// Just a private global like "heap" above would be fine. -size_t Collector::mainThreadOnlyObjectCount = 0; - -static CollectorBlock* allocateBlock() -{ -#if PLATFORM(DARWIN) - vm_address_t address = 0; - vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT); -#elif PLATFORM(WIN_OS) - // windows virtual address granularity is naturally 64k - LPVOID address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); -#elif HAVE(POSIX_MEMALIGN) - void* address; - posix_memalign(&address, BLOCK_SIZE, BLOCK_SIZE); - memset(address, 0, BLOCK_SIZE); -#else - static size_t pagesize = getpagesize(); - - size_t extra = 0; - if (BLOCK_SIZE > pagesize) - extra = BLOCK_SIZE - pagesize; - - void* mmapResult = mmap(NULL, BLOCK_SIZE + extra, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); - uintptr_t address = reinterpret_cast(mmapResult); - - size_t adjust = 0; - if ((address & BLOCK_OFFSET_MASK) != 0) - adjust = BLOCK_SIZE - (address & BLOCK_OFFSET_MASK); - - if (adjust > 0) - munmap(reinterpret_cast(address), adjust); - - if (adjust < extra) - munmap(reinterpret_cast(address + adjust + BLOCK_SIZE), extra - adjust); - - address += adjust; - memset(reinterpret_cast(address), 0, BLOCK_SIZE); -#endif - - return reinterpret_cast(address); -} - -static void freeBlock(CollectorBlock* block) -{ -#if PLATFORM(DARWIN) - vm_deallocate(current_task(), reinterpret_cast(block), BLOCK_SIZE); -#elif PLATFORM(WIN_OS) - VirtualFree(block, BLOCK_SIZE, MEM_RELEASE); -#elif HAVE(POSIX_MEMALIGN) - free(block); -#else - munmap(block, BLOCK_SIZE); -#endif -} - -void Collector::recordExtraCost(size_t cost) -{ - // Our frequency of garbage collection tries to balance memory use against speed - // by collecting based on the number of newly created values. However, for values - // that hold on to a great deal of memory that's not in the form of other JS values, - // that is not good enough - in some cases a lot of those objects can pile up and - // use crazy amounts of memory without a GC happening. So we track these extra - // memory costs. Only unusually large objects are noted, and we only keep track - // of this extra cost until the next GC. In garbage collected languages, most values - // are either very short lived temporaries, or have extremely long lifetimes. So - // if a large value survives one garbage collection, there is not much point to - // collecting more frequently as long as it stays alive. - // NOTE: we target the primaryHeap unconditionally as JSNumber doesn't modify cost - - primaryHeap.extraCost += cost; -} - -template struct HeapConstants; - -template <> struct HeapConstants { - static const size_t cellSize = CELL_SIZE; - static const size_t cellsPerBlock = CELLS_PER_BLOCK; - static const size_t bitmapShift = 0; - typedef CollectorCell Cell; - typedef CollectorBlock Block; -}; - -template <> struct HeapConstants { - static const size_t cellSize = SMALL_CELL_SIZE; - static const size_t cellsPerBlock = SMALL_CELLS_PER_BLOCK; - static const size_t bitmapShift = 1; - typedef SmallCollectorCell Cell; - typedef SmallCellCollectorBlock Block; -}; - -template void* Collector::heapAllocate(size_t s) -{ - typedef typename HeapConstants::Block Block; - typedef typename HeapConstants::Cell Cell; - - CollectorHeap& heap = heapType == PrimaryHeap ? primaryHeap : numberHeap; - ASSERT(JSLock::lockCount() > 0); - ASSERT(JSLock::currentThreadIsHoldingLock()); - ASSERT(s <= HeapConstants::cellSize); - UNUSED_PARAM(s); // s is now only used for the above assert - - ASSERT(heap.operationInProgress == NoOperation); - ASSERT(heapType == PrimaryHeap || heap.extraCost == 0); - // FIXME: If another global variable access here doesn't hurt performance - // too much, we could abort() in NDEBUG builds, which could help ensure we - // don't spend any time debugging cases where we allocate inside an object's - // deallocation code. - - size_t numLiveObjects = heap.numLiveObjects; - size_t usedBlocks = heap.usedBlocks; - size_t i = heap.firstBlockWithPossibleSpace; - - // if we have a huge amount of extra cost, we'll try to collect even if we still have - // free cells left. - if (heapType == PrimaryHeap && heap.extraCost > ALLOCATIONS_PER_COLLECTION) { - size_t numLiveObjectsAtLastCollect = heap.numLiveObjectsAtLastCollect; - size_t numNewObjects = numLiveObjects - numLiveObjectsAtLastCollect; - const size_t newCost = numNewObjects + heap.extraCost; - if (newCost >= ALLOCATIONS_PER_COLLECTION && newCost >= numLiveObjectsAtLastCollect) - goto collect; - } - - ASSERT(heap.operationInProgress == NoOperation); -#ifndef NDEBUG - // FIXME: Consider doing this in NDEBUG builds too (see comment above). - heap.operationInProgress = Allocation; -#endif - -scan: - Block* targetBlock; - size_t targetBlockUsedCells; - if (i != usedBlocks) { - targetBlock = (Block*)heap.blocks[i]; - targetBlockUsedCells = targetBlock->usedCells; - ASSERT(targetBlockUsedCells <= HeapConstants::cellsPerBlock); - while (targetBlockUsedCells == HeapConstants::cellsPerBlock) { - if (++i == usedBlocks) - goto collect; - targetBlock = (Block*)heap.blocks[i]; - targetBlockUsedCells = targetBlock->usedCells; - ASSERT(targetBlockUsedCells <= HeapConstants::cellsPerBlock); - } - heap.firstBlockWithPossibleSpace = i; - } else { - -collect: - size_t numLiveObjectsAtLastCollect = heap.numLiveObjectsAtLastCollect; - size_t numNewObjects = numLiveObjects - numLiveObjectsAtLastCollect; - const size_t newCost = numNewObjects + heap.extraCost; - - if (newCost >= ALLOCATIONS_PER_COLLECTION && newCost >= numLiveObjectsAtLastCollect) { -#ifndef NDEBUG - heap.operationInProgress = NoOperation; -#endif - bool collected = collect(); -#ifndef NDEBUG - heap.operationInProgress = Allocation; -#endif - if (collected) { - numLiveObjects = heap.numLiveObjects; - usedBlocks = heap.usedBlocks; - i = heap.firstBlockWithPossibleSpace; - goto scan; - } - } - - // didn't find a block, and GC didn't reclaim anything, need to allocate a new block - size_t numBlocks = heap.numBlocks; - if (usedBlocks == numBlocks) { - numBlocks = max(MIN_ARRAY_SIZE, numBlocks * GROWTH_FACTOR); - heap.numBlocks = numBlocks; - heap.blocks = static_cast(fastRealloc(heap.blocks, numBlocks * sizeof(CollectorBlock *))); - } - - targetBlock = (Block*)allocateBlock(); - targetBlock->freeList = targetBlock->cells; - targetBlockUsedCells = 0; - heap.blocks[usedBlocks] = (CollectorBlock*)targetBlock; - heap.usedBlocks = usedBlocks + 1; - heap.firstBlockWithPossibleSpace = usedBlocks; - } - - // find a free spot in the block and detach it from the free list - Cell *newCell = targetBlock->freeList; - - // "next" field is a cell offset -- 0 means next cell, so a zeroed block is already initialized - targetBlock->freeList = (newCell + 1) + newCell->u.freeCell.next; - - targetBlock->usedCells = static_cast(targetBlockUsedCells + 1); - heap.numLiveObjects = numLiveObjects + 1; - -#ifndef NDEBUG - // FIXME: Consider doing this in NDEBUG builds too (see comment above). - heap.operationInProgress = NoOperation; -#endif - - return newCell; -} - -void* Collector::allocate(size_t s) -{ - return heapAllocate(s); -} - -void* Collector::allocateNumber(size_t s) -{ - return heapAllocate(s); -} - -static inline void* currentThreadStackBase() -{ -#if PLATFORM(DARWIN) - pthread_t thread = pthread_self(); - return pthread_get_stackaddr_np(thread); -#elif PLATFORM(WIN_OS) && PLATFORM(X86) && COMPILER(MSVC) - // offset 0x18 from the FS segment register gives a pointer to - // the thread information block for the current thread - NT_TIB* pTib; - __asm { - MOV EAX, FS:[18h] - MOV pTib, EAX - } - return (void*)pTib->StackBase; -#elif PLATFORM(WIN_OS) && PLATFORM(X86_64) && COMPILER(MSVC) - PNT_TIB64 pTib = reinterpret_cast(NtCurrentTeb()); - return (void*)pTib->StackBase; -#elif PLATFORM(WIN_OS) && PLATFORM(X86) && COMPILER(GCC) - // offset 0x18 from the FS segment register gives a pointer to - // the thread information block for the current thread - NT_TIB* pTib; - asm ( "movl %%fs:0x18, %0\n" - : "=r" (pTib) - ); - return (void*)pTib->StackBase; -#elif PLATFORM(SOLARIS) - stack_t s; - thr_stksegment(&s); - return s.ss_sp; -#elif PLATFORM(UNIX) - static void* stackBase = 0; - static size_t stackSize = 0; - static pthread_t stackThread; - pthread_t thread = pthread_self(); - if (stackBase == 0 || thread != stackThread) { - pthread_attr_t sattr; - pthread_attr_init(&sattr); -#if HAVE(PTHREAD_NP_H) - // e.g. on FreeBSD 5.4, neundorf@kde.org - pthread_attr_get_np(thread, &sattr); -#else - // FIXME: this function is non-portable; other POSIX systems may have different np alternatives - pthread_getattr_np(thread, &sattr); -#endif - int rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize); - (void)rc; // FIXME: Deal with error code somehow? Seems fatal. - ASSERT(stackBase); - pthread_attr_destroy(&sattr); - stackThread = thread; - } - return static_cast(stackBase) + stackSize; -#else -#error Need a way to get the stack base on this platform -#endif -} - -#if USE(MULTIPLE_THREADS) -static pthread_t mainThread; -#endif - -void Collector::registerAsMainThread() -{ -#if USE(MULTIPLE_THREADS) - mainThread = pthread_self(); -#endif -} - -static inline bool onMainThread() -{ -#if USE(MULTIPLE_THREADS) -#if PLATFORM(DARWIN) - pthread_t javaScriptCollectionThread = JSJavaScriptCollectionThread(); - return javaScriptCollectionThread == 0 || javaScriptCollectionThread == pthread_self(); -#else - return !!pthread_equal(pthread_self(), mainThread); -#endif -#else - return true; -#endif -} - -#if USE(MULTIPLE_THREADS) - -#if PLATFORM(DARWIN) -typedef mach_port_t PlatformThread; -#elif PLATFORM(WIN_OS) -struct PlatformThread { - PlatformThread(DWORD _id, HANDLE _handle) : id(_id), handle(_handle) {} - DWORD id; - HANDLE handle; -}; -#endif - -static inline PlatformThread getCurrentPlatformThread() -{ -#if PLATFORM(DARWIN) - return pthread_mach_thread_np(pthread_self()); -#elif PLATFORM(WIN_OS) - HANDLE threadHandle = pthread_getw32threadhandle_np(pthread_self()); - return PlatformThread(GetCurrentThreadId(), threadHandle); -#endif -} - -class Collector::Thread { -public: - Thread(pthread_t pthread, const PlatformThread& platThread, void* base) - : posixThread(pthread), platformThread(platThread), stackBase(base) {} - Thread* next; - pthread_t posixThread; - PlatformThread platformThread; - void* stackBase; -}; - -pthread_key_t registeredThreadKey; -pthread_once_t registeredThreadKeyOnce = PTHREAD_ONCE_INIT; -Collector::Thread* registeredThreads; - -static void destroyRegisteredThread(void* data) -{ - Collector::Thread* thread = (Collector::Thread*)data; - - // Can't use JSLock convenience object here because we don't want to re-register - // an exiting thread. - JSLock::lock(); - - if (registeredThreads == thread) { - registeredThreads = registeredThreads->next; - } else { - Collector::Thread *last = registeredThreads; - Collector::Thread *t; - for (t = registeredThreads->next; t != NULL; t = t->next) { - if (t == thread) { - last->next = t->next; - break; - } - last = t; - } - ASSERT(t); // If t is NULL, we never found ourselves in the list. - } - - JSLock::unlock(); - - delete thread; -} - -static void initializeRegisteredThreadKey() -{ - pthread_key_create(®isteredThreadKey, destroyRegisteredThread); -} - -void Collector::registerThread() -{ - ASSERT(JSLock::lockCount() > 0); - ASSERT(JSLock::currentThreadIsHoldingLock()); - - pthread_once(®isteredThreadKeyOnce, initializeRegisteredThreadKey); - - if (!pthread_getspecific(registeredThreadKey)) { -#if PLATFORM(DARWIN) - if (onMainThread()) - CollectorHeapIntrospector::init(&primaryHeap, &numberHeap); -#endif - - Collector::Thread *thread = new Collector::Thread(pthread_self(), getCurrentPlatformThread(), currentThreadStackBase()); - - thread->next = registeredThreads; - registeredThreads = thread; - pthread_setspecific(registeredThreadKey, thread); - } -} - -#endif - -#define IS_POINTER_ALIGNED(p) (((intptr_t)(p) & (sizeof(char *) - 1)) == 0) - -// cell size needs to be a power of two for this to be valid -#define IS_HALF_CELL_ALIGNED(p) (((intptr_t)(p) & (CELL_MASK >> 1)) == 0) - -void Collector::markStackObjectsConservatively(void *start, void *end) -{ - if (start > end) { - void* tmp = start; - start = end; - end = tmp; - } - - ASSERT(((char*)end - (char*)start) < 0x1000000); - ASSERT(IS_POINTER_ALIGNED(start)); - ASSERT(IS_POINTER_ALIGNED(end)); - - char** p = (char**)start; - char** e = (char**)end; - - size_t usedPrimaryBlocks = primaryHeap.usedBlocks; - size_t usedNumberBlocks = numberHeap.usedBlocks; - CollectorBlock **primaryBlocks = primaryHeap.blocks; - CollectorBlock **numberBlocks = numberHeap.blocks; - - const size_t lastCellOffset = sizeof(CollectorCell) * (CELLS_PER_BLOCK - 1); - - while (p != e) { - char* x = *p++; - if (IS_HALF_CELL_ALIGNED(x) && x) { - uintptr_t xAsBits = reinterpret_cast(x); - xAsBits &= CELL_ALIGN_MASK; - uintptr_t offset = xAsBits & BLOCK_OFFSET_MASK; - CollectorBlock* blockAddr = reinterpret_cast(xAsBits - offset); - // Mark the the number heap, we can mark these Cells directly to avoid the virtual call cost - for (size_t block = 0; block < usedNumberBlocks; block++) { - if ((numberBlocks[block] == blockAddr) & (offset <= lastCellOffset)) { - Collector::markCell(reinterpret_cast(xAsBits)); - goto endMarkLoop; - } - } - - // Mark the primary heap - for (size_t block = 0; block < usedPrimaryBlocks; block++) { - if ((primaryBlocks[block] == blockAddr) & (offset <= lastCellOffset)) { - if (((CollectorCell*)xAsBits)->u.freeCell.zeroIfFree != 0) { - JSCell* imp = reinterpret_cast(xAsBits); - if (!imp->marked()) - imp->mark(); - } - break; - } - } - endMarkLoop: - ; - } - } -} - -void Collector::markCurrentThreadConservatively() -{ - // setjmp forces volatile registers onto the stack - jmp_buf registers; -#if COMPILER(MSVC) -#pragma warning(push) -#pragma warning(disable: 4611) -#endif - setjmp(registers); -#if COMPILER(MSVC) -#pragma warning(pop) -#endif - - void* dummy; - void* stackPointer = &dummy; - void* stackBase = currentThreadStackBase(); - - markStackObjectsConservatively(stackPointer, stackBase); -} - -#if USE(MULTIPLE_THREADS) - -static inline void suspendThread(const PlatformThread& platformThread) -{ -#if PLATFORM(DARWIN) - thread_suspend(platformThread); -#elif PLATFORM(WIN_OS) - SuspendThread(platformThread.handle); -#else -#error Need a way to suspend threads on this platform -#endif -} - -static inline void resumeThread(const PlatformThread& platformThread) -{ -#if PLATFORM(DARWIN) - thread_resume(platformThread); -#elif PLATFORM(WIN_OS) - ResumeThread(platformThread.handle); -#else -#error Need a way to resume threads on this platform -#endif -} - -typedef unsigned long usword_t; // word size, assumed to be either 32 or 64 bit - -#if PLATFORM(DARWIN) - -#if PLATFORM(X86) -typedef i386_thread_state_t PlatformThreadRegisters; -#elif PLATFORM(X86_64) -typedef x86_thread_state64_t PlatformThreadRegisters; -#elif PLATFORM(PPC) -typedef ppc_thread_state_t PlatformThreadRegisters; -#elif PLATFORM(PPC64) -typedef ppc_thread_state64_t PlatformThreadRegisters; -#elif PLATFORM(ARM) -typedef arm_thread_state_t PlatformThreadRegisters; -#else -#error Unknown Architecture -#endif - -#elif PLATFORM(WIN_OS)&& PLATFORM(X86) -typedef CONTEXT PlatformThreadRegisters; -#else -#error Need a thread register struct for this platform -#endif - -size_t getPlatformThreadRegisters(const PlatformThread& platformThread, PlatformThreadRegisters& regs) -{ -#if PLATFORM(DARWIN) - -#if PLATFORM(X86) - unsigned user_count = sizeof(regs)/sizeof(int); - thread_state_flavor_t flavor = i386_THREAD_STATE; -#elif PLATFORM(X86_64) - unsigned user_count = x86_THREAD_STATE64_COUNT; - thread_state_flavor_t flavor = x86_THREAD_STATE64; -#elif PLATFORM(PPC) - unsigned user_count = PPC_THREAD_STATE_COUNT; - thread_state_flavor_t flavor = PPC_THREAD_STATE; -#elif PLATFORM(PPC64) - unsigned user_count = PPC_THREAD_STATE64_COUNT; - thread_state_flavor_t flavor = PPC_THREAD_STATE64; -#elif PLATFORM(ARM) - unsigned user_count = ARM_THREAD_STATE_COUNT; - thread_state_flavor_t flavor = ARM_THREAD_STATE; -#else -#error Unknown Architecture -#endif - - kern_return_t result = thread_get_state(platformThread, flavor, (thread_state_t)®s, &user_count); - if (result != KERN_SUCCESS) { - WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, - "JavaScript garbage collection failed because thread_get_state returned an error (%d). This is probably the result of running inside Rosetta, which is not supported.", result); - CRASH(); - } - return user_count * sizeof(usword_t); -// end PLATFORM(DARWIN) - -#elif PLATFORM(WIN_OS) && PLATFORM(X86) - regs.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL | CONTEXT_SEGMENTS; - GetThreadContext(platformThread.handle, ®s); - return sizeof(CONTEXT); -#else -#error Need a way to get thread registers on this platform -#endif -} - -static inline void* otherThreadStackPointer(const PlatformThreadRegisters& regs) -{ -#if PLATFORM(DARWIN) - -#if __DARWIN_UNIX03 - -#if PLATFORM(X86) - return (void*)regs.__esp; -#elif PLATFORM(X86_64) - return (void*)regs.__rsp; -#elif PLATFORM(PPC) || PLATFORM(PPC64) - return (void*)regs.__r1; -#elif PLATFORM(ARM) - return (void*)regs.__sp; -#else -#error Unknown Architecture -#endif - -#else // !__DARWIN_UNIX03 - -#if PLATFORM(X86) - return (void*)regs.esp; -#elif PLATFORM(X86_64) - return (void*)regs.rsp; -#elif (PLATFORM(PPC) || PLATFORM(PPC64)) - return (void*)regs.r1; -#else -#error Unknown Architecture -#endif - -#endif // __DARWIN_UNIX03 - -// end PLATFORM(DARWIN) -#elif PLATFORM(X86) && PLATFORM(WIN_OS) - return (void*)(uintptr_t)regs.Esp; -#else -#error Need a way to get the stack pointer for another thread on this platform -#endif -} - -void Collector::markOtherThreadConservatively(Thread* thread) -{ - suspendThread(thread->platformThread); - - PlatformThreadRegisters regs; - size_t regSize = getPlatformThreadRegisters(thread->platformThread, regs); - - // mark the thread's registers - markStackObjectsConservatively((void*)®s, (void*)((char*)®s + regSize)); - - void* stackPointer = otherThreadStackPointer(regs); - markStackObjectsConservatively(stackPointer, thread->stackBase); - - resumeThread(thread->platformThread); -} - -#endif - -void Collector::markStackObjectsConservatively() -{ - markCurrentThreadConservatively(); - -#if USE(MULTIPLE_THREADS) - for (Thread *thread = registeredThreads; thread != NULL; thread = thread->next) { - if (!pthread_equal(thread->posixThread, pthread_self())) { - markOtherThreadConservatively(thread); - } - } -#endif -} - -typedef HashCountedSet ProtectCountSet; - -static ProtectCountSet& protectedValues() -{ - static ProtectCountSet staticProtectCountSet; - return staticProtectCountSet; -} - -void Collector::protect(JSValue *k) -{ - ASSERT(k); - ASSERT(JSLock::lockCount() > 0); - ASSERT(JSLock::currentThreadIsHoldingLock()); - - if (JSImmediate::isImmediate(k)) - return; - - protectedValues().add(k->asCell()); -} - -void Collector::unprotect(JSValue *k) -{ - ASSERT(k); - ASSERT(JSLock::lockCount() > 0); - ASSERT(JSLock::currentThreadIsHoldingLock()); - - if (JSImmediate::isImmediate(k)) - return; - - protectedValues().remove(k->asCell()); -} - -void Collector::collectOnMainThreadOnly(JSValue* value) -{ - ASSERT(value); - ASSERT(JSLock::lockCount() > 0); - ASSERT(JSLock::currentThreadIsHoldingLock()); - - if (JSImmediate::isImmediate(value)) - return; - - JSCell* cell = value->asCell(); - cellBlock(cell)->collectOnMainThreadOnly.set(cellOffset(cell)); - ++mainThreadOnlyObjectCount; -} - -void Collector::markProtectedObjects() -{ - ProtectCountSet& protectedValues = KJS::protectedValues(); - ProtectCountSet::iterator end = protectedValues.end(); - for (ProtectCountSet::iterator it = protectedValues.begin(); it != end; ++it) { - JSCell *val = it->first; - if (!val->marked()) - val->mark(); - } -} - -void Collector::markMainThreadOnlyObjects() -{ -#if USE(MULTIPLE_THREADS) - ASSERT(!onMainThread()); -#endif - - // Optimization for clients that never register "main thread only" objects. - if (!mainThreadOnlyObjectCount) - return; - - // FIXME: We can optimize this marking algorithm by keeping an exact set of - // "main thread only" objects when the "main thread only" object count is - // small. We don't want to keep an exact set all the time, because WebCore - // tends to create lots of "main thread only" objects, and all that set - // thrashing can be expensive. - - size_t count = 0; - - // We don't look at the numberHeap as primitive values can never be marked as main thread only - for (size_t block = 0; block < primaryHeap.usedBlocks; block++) { - ASSERT(count < mainThreadOnlyObjectCount); - - CollectorBlock* curBlock = primaryHeap.blocks[block]; - size_t minimumCellsToProcess = curBlock->usedCells; - for (size_t i = 0; (i < minimumCellsToProcess) & (i < CELLS_PER_BLOCK); i++) { - CollectorCell* cell = curBlock->cells + i; - if (cell->u.freeCell.zeroIfFree == 0) - ++minimumCellsToProcess; - else { - if (curBlock->collectOnMainThreadOnly.get(i)) { - if (!curBlock->marked.get(i)) { - JSCell* imp = reinterpret_cast(cell); - imp->mark(); - } - if (++count == mainThreadOnlyObjectCount) - return; - } - } - } - } -} - -template size_t Collector::sweep(bool currentThreadIsMainThread) -{ - typedef typename HeapConstants::Block Block; - typedef typename HeapConstants::Cell Cell; - - UNUSED_PARAM(currentThreadIsMainThread); // currentThreadIsMainThread is only used in ASSERTs - // SWEEP: delete everything with a zero refcount (garbage) and unmark everything else - CollectorHeap& heap = heapType == Collector::PrimaryHeap ? primaryHeap : numberHeap; - - size_t emptyBlocks = 0; - size_t numLiveObjects = heap.numLiveObjects; - - for (size_t block = 0; block < heap.usedBlocks; block++) { - Block* curBlock = (Block*)heap.blocks[block]; - - size_t usedCells = curBlock->usedCells; - Cell* freeList = curBlock->freeList; - - if (usedCells == HeapConstants::cellsPerBlock) { - // special case with a block where all cells are used -- testing indicates this happens often - for (size_t i = 0; i < HeapConstants::cellsPerBlock; i++) { - if (!curBlock->marked.get(i >> HeapConstants::bitmapShift)) { - Cell* cell = curBlock->cells + i; - - if (heapType != Collector::NumberHeap) { - JSCell* imp = reinterpret_cast(cell); - // special case for allocated but uninitialized object - // (We don't need this check earlier because nothing prior this point - // assumes the object has a valid vptr.) - if (cell->u.freeCell.zeroIfFree == 0) - continue; - - ASSERT(currentThreadIsMainThread || !curBlock->collectOnMainThreadOnly.get(i)); - if (curBlock->collectOnMainThreadOnly.get(i)) { - curBlock->collectOnMainThreadOnly.clear(i); - --Collector::mainThreadOnlyObjectCount; - } - imp->~JSCell(); - } - - --usedCells; - --numLiveObjects; - - // put cell on the free list - cell->u.freeCell.zeroIfFree = 0; - cell->u.freeCell.next = freeList - (cell + 1); - freeList = cell; - } - } - } else { - size_t minimumCellsToProcess = usedCells; - for (size_t i = 0; (i < minimumCellsToProcess) & (i < HeapConstants::cellsPerBlock); i++) { - Cell *cell = curBlock->cells + i; - if (cell->u.freeCell.zeroIfFree == 0) { - ++minimumCellsToProcess; - } else { - if (!curBlock->marked.get(i >> HeapConstants::bitmapShift)) { - if (heapType != Collector::NumberHeap) { - JSCell *imp = reinterpret_cast(cell); - ASSERT(currentThreadIsMainThread || !curBlock->collectOnMainThreadOnly.get(i)); - if (curBlock->collectOnMainThreadOnly.get(i)) { - curBlock->collectOnMainThreadOnly.clear(i); - --Collector::mainThreadOnlyObjectCount; - } - imp->~JSCell(); - } - --usedCells; - --numLiveObjects; - - // put cell on the free list - cell->u.freeCell.zeroIfFree = 0; - cell->u.freeCell.next = freeList - (cell + 1); - freeList = cell; - } - } - } - } - - curBlock->usedCells = static_cast(usedCells); - curBlock->freeList = freeList; - curBlock->marked.clearAll(); - - if (usedCells == 0) { - emptyBlocks++; - if (emptyBlocks > SPARE_EMPTY_BLOCKS) { -#if !DEBUG_COLLECTOR - freeBlock((CollectorBlock*)curBlock); -#endif - // swap with the last block so we compact as we go - heap.blocks[block] = heap.blocks[heap.usedBlocks - 1]; - heap.usedBlocks--; - block--; // Don't move forward a step in this case - - if (heap.numBlocks > MIN_ARRAY_SIZE && heap.usedBlocks < heap.numBlocks / LOW_WATER_FACTOR) { - heap.numBlocks = heap.numBlocks / GROWTH_FACTOR; - heap.blocks = (CollectorBlock**)fastRealloc(heap.blocks, heap.numBlocks * sizeof(CollectorBlock *)); - } - } - } - } - - if (heap.numLiveObjects != numLiveObjects) - heap.firstBlockWithPossibleSpace = 0; - - heap.numLiveObjects = numLiveObjects; - heap.numLiveObjectsAtLastCollect = numLiveObjects; - heap.extraCost = 0; - return numLiveObjects; -} - -bool Collector::collect() -{ - ASSERT(JSLock::lockCount() > 0); - ASSERT(JSLock::currentThreadIsHoldingLock()); - - ASSERT((primaryHeap.operationInProgress == NoOperation) | (numberHeap.operationInProgress == NoOperation)); - if ((primaryHeap.operationInProgress != NoOperation) | (numberHeap.operationInProgress != NoOperation)) - abort(); - - primaryHeap.operationInProgress = Collection; - numberHeap.operationInProgress = Collection; - - bool currentThreadIsMainThread = onMainThread(); - - // MARK: first mark all referenced objects recursively starting out from the set of root objects - -#ifndef NDEBUG - // Forbid malloc during the mark phase. Marking a thread suspends it, so - // a malloc inside mark() would risk a deadlock with a thread that had been - // suspended while holding the malloc lock. - fastMallocForbid(); -#endif - - markStackObjectsConservatively(); - markProtectedObjects(); - ExecState::markActiveExecStates(); - List::markProtectedLists(); -#if USE(MULTIPLE_THREADS) - if (!currentThreadIsMainThread) - markMainThreadOnlyObjects(); -#endif - -#ifndef NDEBUG - fastMallocAllow(); -#endif - - size_t originalLiveObjects = primaryHeap.numLiveObjects + numberHeap.numLiveObjects; - size_t numLiveObjects = sweep(currentThreadIsMainThread); - numLiveObjects += sweep(currentThreadIsMainThread); - - primaryHeap.operationInProgress = NoOperation; - numberHeap.operationInProgress = NoOperation; - - return numLiveObjects < originalLiveObjects; -} - -size_t Collector::size() -{ - return primaryHeap.numLiveObjects + numberHeap.numLiveObjects; -} - -size_t Collector::globalObjectCount() -{ - size_t count = 0; - if (JSGlobalObject::head()) { - JSGlobalObject* o = JSGlobalObject::head(); - do { - ++count; - o = o->next(); - } while (o != JSGlobalObject::head()); - } - return count; -} - -size_t Collector::protectedGlobalObjectCount() -{ - size_t count = 0; - if (JSGlobalObject::head()) { - JSGlobalObject* o = JSGlobalObject::head(); - do { - if (protectedValues().contains(o)) - ++count; - o = o->next(); - } while (o != JSGlobalObject::head()); - } - return count; -} - -size_t Collector::protectedObjectCount() -{ - return protectedValues().size(); -} - -static const char *typeName(JSCell *val) -{ - const char *name = "???"; - switch (val->type()) { - case UnspecifiedType: - break; - case UndefinedType: - name = "undefined"; - break; - case NullType: - name = "null"; - break; - case BooleanType: - name = "boolean"; - break; - case StringType: - name = "string"; - break; - case NumberType: - name = "number"; - break; - case ObjectType: { - const ClassInfo *info = static_cast(val)->classInfo(); - name = info ? info->className : "Object"; - break; - } - case GetterSetterType: - name = "gettersetter"; - break; - } - return name; -} - -HashCountedSet* Collector::protectedObjectTypeCounts() -{ - HashCountedSet* counts = new HashCountedSet; - - ProtectCountSet& protectedValues = KJS::protectedValues(); - ProtectCountSet::iterator end = protectedValues.end(); - for (ProtectCountSet::iterator it = protectedValues.begin(); it != end; ++it) - counts->add(typeName(it->first)); - - return counts; -} - -bool Collector::isBusy() -{ - return (primaryHeap.operationInProgress != NoOperation) | (numberHeap.operationInProgress != NoOperation); -} - -void Collector::reportOutOfMemoryToAllExecStates() -{ - ExecStateStack::const_iterator end = ExecState::activeExecStates().end(); - for (ExecStateStack::const_iterator it = ExecState::activeExecStates().begin(); it != end; ++it) { - (*it)->setException(Error::create(*it, GeneralError, "Out of memory")); - } -} - -} // namespace KJS diff --git a/kjs/collector.h b/kjs/collector.h deleted file mode 100644 index b38faaf..0000000 --- a/kjs/collector.h +++ /dev/null @@ -1,193 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef KJSCOLLECTOR_H_ -#define KJSCOLLECTOR_H_ - -#include -#include -#include - -namespace KJS { - - class JSCell; - class JSValue; - class CollectorBlock; - - class Collector { - public: - static void* allocate(size_t s); - static void* allocateNumber(size_t s); - static bool collect(); - static bool isBusy(); // true if an allocation or collection is in progress - - static const size_t minExtraCostSize = 256; - - static void reportExtraMemoryCost(size_t cost); - - static size_t size(); - - static void protect(JSValue*); - static void unprotect(JSValue*); - - static void collectOnMainThreadOnly(JSValue*); - - static size_t globalObjectCount(); - static size_t protectedObjectCount(); - static size_t protectedGlobalObjectCount(); - static HashCountedSet* protectedObjectTypeCounts(); - - class Thread; - static void registerThread(); - - static void registerAsMainThread(); - - static bool isCellMarked(const JSCell*); - static void markCell(JSCell*); - - enum HeapType { PrimaryHeap, NumberHeap }; - - private: - template static void* heapAllocate(size_t s); - template static size_t sweep(bool); - static const CollectorBlock* cellBlock(const JSCell*); - static CollectorBlock* cellBlock(JSCell*); - static size_t cellOffset(const JSCell*); - - Collector(); - - static void recordExtraCost(size_t); - static void markProtectedObjects(); - static void markMainThreadOnlyObjects(); - static void markCurrentThreadConservatively(); - static void markOtherThreadConservatively(Thread*); - static void markStackObjectsConservatively(); - static void markStackObjectsConservatively(void* start, void* end); - - static size_t mainThreadOnlyObjectCount; - static bool memoryFull; - static void reportOutOfMemoryToAllExecStates(); - }; - - // tunable parameters - template struct CellSize; - - // cell size needs to be a power of two for certain optimizations in collector.cpp - template<> struct CellSize { static const size_t m_value = 32; }; // 32-bit - template<> struct CellSize { static const size_t m_value = 64; }; // 64-bit - const size_t BLOCK_SIZE = 16 * 4096; // 64k - - // derived constants - const size_t BLOCK_OFFSET_MASK = BLOCK_SIZE - 1; - const size_t BLOCK_MASK = ~BLOCK_OFFSET_MASK; - const size_t MINIMUM_CELL_SIZE = CellSize::m_value; - const size_t CELL_ARRAY_LENGTH = (MINIMUM_CELL_SIZE / sizeof(double)) + (MINIMUM_CELL_SIZE % sizeof(double) != 0 ? sizeof(double) : 0); - const size_t CELL_SIZE = CELL_ARRAY_LENGTH * sizeof(double); - const size_t SMALL_CELL_SIZE = CELL_SIZE / 2; - const size_t CELL_MASK = CELL_SIZE - 1; - const size_t CELL_ALIGN_MASK = ~CELL_MASK; - const size_t CELLS_PER_BLOCK = (BLOCK_SIZE * 8 - sizeof(uint32_t) * 8 - sizeof(void *) * 8 - 2 * (7 + 3 * 8)) / (CELL_SIZE * 8 + 2); - const size_t SMALL_CELLS_PER_BLOCK = 2 * CELLS_PER_BLOCK; - const size_t BITMAP_SIZE = (CELLS_PER_BLOCK + 7) / 8; - const size_t BITMAP_WORDS = (BITMAP_SIZE + 3) / sizeof(uint32_t); - - struct CollectorBitmap { - uint32_t bits[BITMAP_WORDS]; - bool get(size_t n) const { return !!(bits[n >> 5] & (1 << (n & 0x1F))); } - void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); } - void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); } - void clearAll() { memset(bits, 0, sizeof(bits)); } - }; - - struct CollectorCell { - union { - double memory[CELL_ARRAY_LENGTH]; - struct { - void* zeroIfFree; - ptrdiff_t next; - } freeCell; - } u; - }; - - struct SmallCollectorCell { - union { - double memory[CELL_ARRAY_LENGTH / 2]; - struct { - void* zeroIfFree; - ptrdiff_t next; - } freeCell; - } u; - }; - - class CollectorBlock { - public: - CollectorCell cells[CELLS_PER_BLOCK]; - uint32_t usedCells; - CollectorCell* freeList; - CollectorBitmap marked; - CollectorBitmap collectOnMainThreadOnly; - }; - - class SmallCellCollectorBlock { - public: - SmallCollectorCell cells[SMALL_CELLS_PER_BLOCK]; - uint32_t usedCells; - SmallCollectorCell* freeList; - CollectorBitmap marked; - CollectorBitmap collectOnMainThreadOnly; - }; - - inline const CollectorBlock* Collector::cellBlock(const JSCell* cell) - { - return reinterpret_cast(reinterpret_cast(cell) & BLOCK_MASK); - } - - inline CollectorBlock* Collector::cellBlock(JSCell* cell) - { - return const_cast(cellBlock(const_cast(cell))); - } - - inline size_t Collector::cellOffset(const JSCell* cell) - { - return (reinterpret_cast(cell) & BLOCK_OFFSET_MASK) / CELL_SIZE; - } - - inline bool Collector::isCellMarked(const JSCell* cell) - { - return cellBlock(cell)->marked.get(cellOffset(cell)); - } - - inline void Collector::markCell(JSCell* cell) - { - cellBlock(cell)->marked.set(cellOffset(cell)); - } - - inline void Collector::reportExtraMemoryCost(size_t cost) - { - if (cost > minExtraCostSize) - recordExtraCost(cost / (CELL_SIZE * 2)); - } - -} // namespace KJS - -#endif /* KJSCOLLECTOR_H_ */ diff --git a/kjs/completion.h b/kjs/completion.h deleted file mode 100644 index 09f3db7..0000000 --- a/kjs/completion.h +++ /dev/null @@ -1,60 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_COMPLETION_H -#define KJS_COMPLETION_H - -namespace KJS { - - class JSValue; - - enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted }; - - /** - * Completion objects are used to convey the return status and value - * from functions. - * - * See FunctionImp::execute() - * - * @see FunctionImp - * - * @short Handle for a Completion type. - */ - class Completion { - public: - Completion(ComplType type = Normal, JSValue* value = 0) - : m_type(type), m_value(value) { } - - ComplType complType() const { return m_type; } - JSValue* value() const { return m_value; } - void setValue(JSValue* v) { m_value = v; } - bool isValueCompletion() const { return !!m_value; } - - private: - ComplType m_type; - JSValue* m_value; - }; - -} - -#endif diff --git a/kjs/create_hash_table b/kjs/create_hash_table deleted file mode 100755 index 6800722..0000000 --- a/kjs/create_hash_table +++ /dev/null @@ -1,250 +0,0 @@ -#! /usr/bin/perl -w -# -# Static Hashtable Generator -# -# (c) 2000-2002 by Harri Porten and -# David Faure -# Modified (c) 2004 by Nikolas Zimmermann -# Copyright (C) 2007 Apple Inc. All rights reserved. -# -# Part of the KJS library. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -# - -use strict; - -my $file = $ARGV[0]; -shift; -my $includelookup = 0; - -# Use -i as second argument to make it include "lookup.h" -$includelookup = 1 if (defined($ARGV[0]) && $ARGV[0] eq "-i"); - -# Use -n as second argument to make it use the third argument as namespace parameter ie. -n KDOM -my $useNameSpace = $ARGV[1] if (defined($ARGV[0]) && $ARGV[0] eq "-n"); - -print STDERR "Creating hashtable for $file\n"; -open(IN, $file) or die "No such file $file"; - -my @keys = (); -my @values = (); -my @attrs = (); -my @params = (); -my @hashes = (); -my @table = (); -my @links = (); - -my $inside = 0; -my $name; -my $size; -my $hashSizeMask; -my $banner = 0; -sub calcTable(); -sub output(); -sub hashValue($); - -while () { - chop; - s/^\s*//g; - if (/^\#|^$/) { - # comment. do nothing - } elsif (/^\@begin/ && !$inside) { - if (/^\@begin\s*([:_\w]+)\s*\d*\s*$/) { - $inside = 1; - $name = $1; - } else { - printf STDERR "WARNING: \@begin without table name and hashsize, skipping $_\n"; - } - } elsif (/^\@end\s*$/ && $inside) { - - calcTable(); - - output(); - @keys = (); - @values = (); - @attrs = (); - @params = (); - @table = (); - @links = (); - @hashes = (); - $inside = 0; - } elsif (/^(\S+)\s*(\S+)\s*([\w\|]*)\s*(\w*)\s*$/ && $inside) { - my $key = $1; - my $val = $2; - my $att = $3; - my $param = $4; - push(@keys, $key); - push(@values, $val); - push(@hashes, hashValue($key)); - printf STDERR "WARNING: Number of arguments missing for $key/$val\n" - if ( $att =~ m/Function/ && length($param) == 0); - push(@attrs, length($att) > 0 ? $att : "0"); - push(@params, length($param) > 0 ? $param : "0"); - } elsif ($inside) { - die "invalid data {" . $_ . "}"; - } -} - -die "missing closing \@end" if ($inside); - -sub ceilingToPowerOf2 -{ - my ($size) = @_; - - my $powerOf2 = 1; - while ($size > $powerOf2) { - $powerOf2 <<= 1; - } - - return $powerOf2; -} - -sub calcTable() { - my $hashsize = ceilingToPowerOf2(2 * @keys); - $hashSizeMask = $hashsize - 1; - $size = $hashsize; - my $collisions = 0; - my $maxdepth = 0; - my $i = 0; - foreach my $key (@keys) { - my $depth = 0; - my $h = hashValue($key) % $hashsize; - while (defined($table[$h])) { - if (defined($links[$h])) { - $h = $links[$h]; - $depth++; - } else { - $collisions++; - $links[$h] = $size; - $h = $size; - $size++; - } - } - $table[$h] = $i; - $i++; - $maxdepth = $depth if ( $depth > $maxdepth); - } - - # Ensure table is big enough (in case of undef entries at the end) - if ( $#table+1 < $size ) { - $#table = $size-1; - } -} - -sub leftShift($$) { - my ($value, $distance) = @_; - return (($value << $distance) & 0xFFFFFFFF); -} - -# Paul Hsieh's SuperFastHash -# http://www.azillionmonkeys.com/qed/hash.html -# Ported from UString.. -sub hashValue($) { - my @chars = split(/ */, $_[0]); - - # This hash is designed to work on 16-bit chunks at a time. But since the normal case - # (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they - # were 16-bit chunks, which should give matching results - - my $EXP2_32 = 4294967296; - - my $hash = 0x9e3779b9; - my $l = scalar @chars; #I wish this was in Ruby --- Maks - my $rem = $l & 1; - $l = $l >> 1; - - my $s = 0; - - # Main loop - for (; $l > 0; $l--) { - $hash += ord($chars[$s]); - my $tmp = leftShift(ord($chars[$s+1]), 11) ^ $hash; - $hash = (leftShift($hash, 16)% $EXP2_32) ^ $tmp; - $s += 2; - $hash += $hash >> 11; - $hash %= $EXP2_32; - } - - # Handle end case - if ($rem !=0) { - $hash += ord($chars[$s]); - $hash ^= (leftShift($hash, 11)% $EXP2_32); - $hash += $hash >> 17; - } - - # Force "avalanching" of final 127 bits - $hash ^= leftShift($hash, 3); - $hash += ($hash >> 5); - $hash = ($hash% $EXP2_32); - $hash ^= (leftShift($hash, 2)% $EXP2_32); - $hash += ($hash >> 15); - $hash = $hash% $EXP2_32; - $hash ^= (leftShift($hash, 10)% $EXP2_32); - - # this avoids ever returning a hash code of 0, since that is used to - # signal "hash not computed yet", using a value that is likely to be - # effectively the same as 0 when the low bits are masked - $hash = 0x80000000 if ($hash == 0); - - return $hash; -} - -sub output() { - if (!$banner) { - $banner = 1; - print "/* Automatically generated from $file using $0. DO NOT EDIT ! */\n"; - } - - my $nameEntries = "${name}Entries"; - $nameEntries =~ s/:/_/g; - - print "\n#include \"lookup.h\"\n" if ($includelookup); - if ($useNameSpace) { - print "\nnamespace ${useNameSpace}\n{\n"; - print "\nusing namespace KJS;"; - } else { - print "\nnamespace KJS {\n"; - } - print "\nstatic const struct HashEntry ".$nameEntries."[] = {\n"; - my $i = 0; - - foreach my $entry (@table) { - if (defined($entry)) { - my $key = $keys[$entry]; - print " \{ \"" . $key . "\""; - print ", { (intptr_t)" . $values[$entry] . " }"; - print ", " . $attrs[$entry]; - print ", " . $params[$entry]; - print ", "; - if (defined($links[$i])) { - print "&" . $nameEntries . "[" . $links[$i] . "]" . " \}"; - } else { - print "0 \}" - } - print "/* " . $hashes[$entry] . " */ "; - } else { - print " { 0, { 0 }, 0, 0, 0 }"; - } - print "," unless ($i == $size - 1); - print "\n"; - $i++; - } - - print "};\n\n"; - print "const struct HashTable $name = "; - print "\{ 3, $size, $nameEntries, $hashSizeMask \};\n\n"; - print "} // namespace\n"; -} diff --git a/kjs/date_object.cpp b/kjs/date_object.cpp deleted file mode 100644 index 0c88d6c..0000000 --- a/kjs/date_object.cpp +++ /dev/null @@ -1,1542 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - */ - -#include "config.h" -#include "date_object.h" -#include "date_object.lut.h" -#include "internal.h" - -#if HAVE(ERRNO_H) -#include -#endif - -#if HAVE(SYS_PARAM_H) -#include -#endif - -#if HAVE(SYS_TIME_H) -#include -#endif - -#if HAVE(SYS_TIMEB_H) -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "error_object.h" -#include "operations.h" -#include "DateMath.h" - -#include -#include -#include -#include -#include - - #include - -using namespace WTF; - -namespace KJS { - -static double parseDate(const UString&); -static double timeClip(double); - -inline int gmtoffset(const GregorianDateTime& t) -{ - return t.utcOffset; -} - - -/** - * @internal - * - * Class to implement all methods that are properties of the - * Date object - */ -class DateObjectFuncImp : public InternalFunctionImp { -public: - DateObjectFuncImp(ExecState *, FunctionPrototype *, int i, int len, const Identifier& ); - - virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args); - - enum { Parse, UTC }; - -private: - int id; -}; - - -static CFDateFormatterStyle styleFromArgString(const UString& string, CFDateFormatterStyle defaultStyle) -{ - if (string == "short") - return kCFDateFormatterShortStyle; - if (string == "medium") - return kCFDateFormatterMediumStyle; - if (string == "long") - return kCFDateFormatterLongStyle; - if (string == "full") - return kCFDateFormatterFullStyle; - return defaultStyle; -} - -static UString formatLocaleDate(ExecState *exec, double time, bool includeDate, bool includeTime, const List &args) -{ - CFDateFormatterStyle dateStyle = (includeDate ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle); - CFDateFormatterStyle timeStyle = (includeTime ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle); - - bool useCustomFormat = false; - UString customFormatString; - - UString arg0String = args[0]->toString(exec); - if (arg0String == "custom" && !args[1]->isUndefined()) { - useCustomFormat = true; - customFormatString = args[1]->toString(exec); - } else if (includeDate && includeTime && !args[1]->isUndefined()) { - dateStyle = styleFromArgString(arg0String, dateStyle); - timeStyle = styleFromArgString(args[1]->toString(exec), timeStyle); - } else if (includeDate && !args[0]->isUndefined()) { - dateStyle = styleFromArgString(arg0String, dateStyle); - } else if (includeTime && !args[0]->isUndefined()) { - timeStyle = styleFromArgString(arg0String, timeStyle); - } - - CFLocaleRef locale = CFLocaleCopyCurrent(); - CFDateFormatterRef formatter = CFDateFormatterCreate(0, locale, dateStyle, timeStyle); - CFRelease(locale); - - if (useCustomFormat) { - CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, (UniChar *)customFormatString.data(), customFormatString.size()); - CFDateFormatterSetFormat(formatter, customFormatCFString); - CFRelease(customFormatCFString); - } - - CFStringRef string = CFDateFormatterCreateStringWithAbsoluteTime(0, formatter, time - kCFAbsoluteTimeIntervalSince1970); - - CFRelease(formatter); - - // We truncate the string returned from CFDateFormatter if it's absurdly long (> 200 characters). - // That's not great error handling, but it just won't happen so it doesn't matter. - UChar buffer[200]; - const size_t bufferLength = sizeof(buffer) / sizeof(buffer[0]); - size_t length = CFStringGetLength(string); - ASSERT(length <= bufferLength); - if (length > bufferLength) - length = bufferLength; - CFStringGetCharacters(string, CFRangeMake(0, length), reinterpret_cast(buffer)); - - CFRelease(string); - - return UString(buffer, length); -} - - -static UString formatDate(const GregorianDateTime &t) -{ - char buffer[100]; - snprintf(buffer, sizeof(buffer), "%s %s %02d %04d", - weekdayName[(t.weekDay + 6) % 7], - monthName[t.month], t.monthDay, t.year + 1900); - return buffer; -} - -static UString formatDateUTCVariant(const GregorianDateTime &t) -{ - char buffer[100]; - snprintf(buffer, sizeof(buffer), "%s, %02d %s %04d", - weekdayName[(t.weekDay + 6) % 7], - t.monthDay, monthName[t.month], t.year + 1900); - return buffer; -} - -static UString formatTime(const GregorianDateTime &t, bool utc) -{ - char buffer[100]; - if (utc) { - snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT", t.hour, t.minute, t.second); - } else { - int offset = abs(gmtoffset(t)); - char tzname[70]; - struct tm gtm = t; - strftime(tzname, sizeof(tzname), "%Z", >m); - - if (tzname[0]) { - snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT%c%02d%02d (%s)", - t.hour, t.minute, t.second, - gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60, tzname); - } else { - snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT%c%02d%02d", - t.hour, t.minute, t.second, - gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60); - } - } - return UString(buffer); -} - -// Converts a list of arguments sent to a Date member function into milliseconds, updating -// ms (representing milliseconds) and t (representing the rest of the date structure) appropriately. -// -// Format of member function: f([hour,] [min,] [sec,] [ms]) -static void fillStructuresUsingTimeArgs(ExecState* exec, const List& args, int maxArgs, double* ms, GregorianDateTime* t) -{ - double milliseconds = 0; - int idx = 0; - int numArgs = args.size(); - - // JS allows extra trailing arguments -- ignore them - if (numArgs > maxArgs) - numArgs = maxArgs; - - // hours - if (maxArgs >= 4 && idx < numArgs) { - t->hour = 0; - milliseconds += args[idx++]->toInt32(exec) * msPerHour; - } - - // minutes - if (maxArgs >= 3 && idx < numArgs) { - t->minute = 0; - milliseconds += args[idx++]->toInt32(exec) * msPerMinute; - } - - // seconds - if (maxArgs >= 2 && idx < numArgs) { - t->second = 0; - milliseconds += args[idx++]->toInt32(exec) * msPerSecond; - } - - // milliseconds - if (idx < numArgs) - milliseconds += args[idx]->toNumber(exec); - else - milliseconds += *ms; - - *ms = milliseconds; -} - -// Converts a list of arguments sent to a Date member function into years, months, and milliseconds, updating -// ms (representing milliseconds) and t (representing the rest of the date structure) appropriately. -// -// Format of member function: f([years,] [months,] [days]) -static void fillStructuresUsingDateArgs(ExecState *exec, const List &args, int maxArgs, double *ms, GregorianDateTime *t) -{ - int idx = 0; - int numArgs = args.size(); - - // JS allows extra trailing arguments -- ignore them - if (numArgs > maxArgs) - numArgs = maxArgs; - - // years - if (maxArgs >= 3 && idx < numArgs) - t->year = args[idx++]->toInt32(exec) - 1900; - - // months - if (maxArgs >= 2 && idx < numArgs) - t->month = args[idx++]->toInt32(exec); - - // days - if (idx < numArgs) { - t->monthDay = 0; - *ms += args[idx]->toInt32(exec) * msPerDay; - } -} - -// ------------------------------ DateInstance ------------------------------ - -const ClassInfo DateInstance::info = {"Date", 0, 0}; - -DateInstance::DateInstance(JSObject *proto) - : JSWrapperObject(proto) -{ -} - -bool DateInstance::getTime(GregorianDateTime &t, int &offset) const -{ - double milli = internalValue()->getNumber(); - if (isnan(milli)) - return false; - - msToGregorianDateTime(milli, false, t); - offset = gmtoffset(t); - return true; -} - -bool DateInstance::getUTCTime(GregorianDateTime &t) const -{ - double milli = internalValue()->getNumber(); - if (isnan(milli)) - return false; - - msToGregorianDateTime(milli, true, t); - return true; -} - -bool DateInstance::getTime(double &milli, int &offset) const -{ - milli = internalValue()->getNumber(); - if (isnan(milli)) - return false; - - GregorianDateTime t; - msToGregorianDateTime(milli, false, t); - offset = gmtoffset(t); - return true; -} - -bool DateInstance::getUTCTime(double &milli) const -{ - milli = internalValue()->getNumber(); - if (isnan(milli)) - return false; - - return true; -} - -static inline bool isTime_tSigned() -{ - time_t minusOne = (time_t)(-1); - return minusOne < 0; -} - -// ------------------------------ DatePrototype ----------------------------- - -const ClassInfo DatePrototype::info = {"Date", &DateInstance::info, &dateTable}; - -/* Source for date_object.lut.h - FIXMEL We could use templates to simplify the UTC variants. -@begin dateTable 61 - toString dateProtoFuncToString DontEnum|Function 0 - toUTCString dateProtoFuncToUTCString DontEnum|Function 0 - toDateString dateProtoFuncToDateString DontEnum|Function 0 - toTimeString dateProtoFuncToTimeString DontEnum|Function 0 - toLocaleString dateProtoFuncToLocaleString DontEnum|Function 0 - toLocaleDateString dateProtoFuncToLocaleDateString DontEnum|Function 0 - toLocaleTimeString dateProtoFuncToLocaleTimeString DontEnum|Function 0 - valueOf dateProtoFuncValueOf DontEnum|Function 0 - getTime dateProtoFuncGetTime DontEnum|Function 0 - getFullYear dateProtoFuncGetFullYear DontEnum|Function 0 - getUTCFullYear dateProtoFuncGetUTCFullYear DontEnum|Function 0 - toGMTString dateProtoFuncToGMTString DontEnum|Function 0 - getMonth dateProtoFuncGetMonth DontEnum|Function 0 - getUTCMonth dateProtoFuncGetUTCMonth DontEnum|Function 0 - getDate dateProtoFuncGetDate DontEnum|Function 0 - getUTCDate dateProtoFuncGetUTCDate DontEnum|Function 0 - getDay dateProtoFuncGetDay DontEnum|Function 0 - getUTCDay dateProtoFuncGetUTCDay DontEnum|Function 0 - getHours dateProtoFuncGetHours DontEnum|Function 0 - getUTCHours dateProtoFuncGetUTCHours DontEnum|Function 0 - getMinutes dateProtoFuncGetMinutes DontEnum|Function 0 - getUTCMinutes dateProtoFuncGetUTCMinutes DontEnum|Function 0 - getSeconds dateProtoFuncGetSeconds DontEnum|Function 0 - getUTCSeconds dateProtoFuncGetUTCSeconds DontEnum|Function 0 - getMilliseconds dateProtoFuncGetMilliSeconds DontEnum|Function 0 - getUTCMilliseconds dateProtoFuncGetUTCMilliseconds DontEnum|Function 0 - getTimezoneOffset dateProtoFuncGetTimezoneOffset DontEnum|Function 0 - setTime dateProtoFuncSetTime DontEnum|Function 1 - setMilliseconds dateProtoFuncSetMilliSeconds DontEnum|Function 1 - setUTCMilliseconds dateProtoFuncSetUTCMilliseconds DontEnum|Function 1 - setSeconds dateProtoFuncSetSeconds DontEnum|Function 2 - setUTCSeconds dateProtoFuncSetUTCSeconds DontEnum|Function 2 - setMinutes dateProtoFuncSetMinutes DontEnum|Function 3 - setUTCMinutes dateProtoFuncSetUTCMinutes DontEnum|Function 3 - setHours dateProtoFuncSetHours DontEnum|Function 4 - setUTCHours dateProtoFuncSetUTCHours DontEnum|Function 4 - setDate dateProtoFuncSetDate DontEnum|Function 1 - setUTCDate dateProtoFuncSetUTCDate DontEnum|Function 1 - setMonth dateProtoFuncSetMonth DontEnum|Function 2 - setUTCMonth dateProtoFuncSetUTCMonth DontEnum|Function 2 - setFullYear dateProtoFuncSetFullYear DontEnum|Function 3 - setUTCFullYear dateProtoFuncSetUTCFullYear DontEnum|Function 3 - setYear dateProtoFuncSetYear DontEnum|Function 1 - getYear dateProtoFuncGetYear DontEnum|Function 0 -@end -*/ -// ECMA 15.9.4 - -DatePrototype::DatePrototype(ExecState *, ObjectPrototype *objectProto) - : DateInstance(objectProto) -{ - setInternalValue(jsNaN()); - // The constructor will be added later, after DateObjectImp has been built. -} - -bool DatePrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticFunctionSlot(exec, &dateTable, this, propertyName, slot); -} - -// ------------------------------ DateObjectImp -------------------------------- - -// TODO: MakeTime (15.9.11.1) etc. ? - -DateObjectImp::DateObjectImp(ExecState* exec, FunctionPrototype* funcProto, DatePrototype* dateProto) - : InternalFunctionImp(funcProto, dateProto->classInfo()->className) -{ - static const Identifier* parsePropertyName = new Identifier("parse"); - static const Identifier* UTCPropertyName = new Identifier("UTC"); - - putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly); - putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, *parsePropertyName), DontEnum); - putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, *UTCPropertyName), DontEnum); - putDirect(exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum); -} - -bool DateObjectImp::implementsConstruct() const -{ - return true; -} - -// ECMA 15.9.3 -JSObject *DateObjectImp::construct(ExecState *exec, const List &args) -{ - int numArgs = args.size(); - - double value; - - if (numArgs == 0) { // new Date() ECMA 15.9.3.3 - value = getCurrentUTCTime(); - } else if (numArgs == 1) { - if (args[0]->isObject(&DateInstance::info)) - value = static_cast(args[0])->internalValue()->toNumber(exec); - else { - JSValue* primitive = args[0]->toPrimitive(exec); - if (primitive->isString()) - value = parseDate(primitive->getString()); - else - value = primitive->toNumber(exec); - } - } else { - if (isnan(args[0]->toNumber(exec)) - || isnan(args[1]->toNumber(exec)) - || (numArgs >= 3 && isnan(args[2]->toNumber(exec))) - || (numArgs >= 4 && isnan(args[3]->toNumber(exec))) - || (numArgs >= 5 && isnan(args[4]->toNumber(exec))) - || (numArgs >= 6 && isnan(args[5]->toNumber(exec))) - || (numArgs >= 7 && isnan(args[6]->toNumber(exec)))) { - value = NaN; - } else { - GregorianDateTime t; - int year = args[0]->toInt32(exec); - t.year = (year >= 0 && year <= 99) ? year : year - 1900; - t.month = args[1]->toInt32(exec); - t.monthDay = (numArgs >= 3) ? args[2]->toInt32(exec) : 1; - t.hour = args[3]->toInt32(exec); - t.minute = args[4]->toInt32(exec); - t.second = args[5]->toInt32(exec); - t.isDST = -1; - double ms = (numArgs >= 7) ? args[6]->toNumber(exec) : 0; - value = gregorianDateTimeToMS(t, ms, false); - } - } - - DateInstance *ret = new DateInstance(exec->lexicalGlobalObject()->datePrototype()); - ret->setInternalValue(jsNumber(timeClip(value))); - return ret; -} - -// ECMA 15.9.2 -JSValue *DateObjectImp::callAsFunction(ExecState * /*exec*/, JSObject * /*thisObj*/, const List &/*args*/) -{ - time_t t = time(0); - GregorianDateTime ts(*localtime(&t)); - return jsString(formatDate(ts) + " " + formatTime(ts, false)); -} - -// ------------------------------ DateObjectFuncImp ---------------------------- - -DateObjectFuncImp::DateObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name) - : InternalFunctionImp(funcProto, name), id(i) -{ - putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum); -} - -// ECMA 15.9.4.2 - 3 -JSValue *DateObjectFuncImp::callAsFunction(ExecState* exec, JSObject*, const List& args) -{ - if (id == Parse) { - return jsNumber(parseDate(args[0]->toString(exec))); - } - else { // UTC - int n = args.size(); - if (isnan(args[0]->toNumber(exec)) - || isnan(args[1]->toNumber(exec)) - || (n >= 3 && isnan(args[2]->toNumber(exec))) - || (n >= 4 && isnan(args[3]->toNumber(exec))) - || (n >= 5 && isnan(args[4]->toNumber(exec))) - || (n >= 6 && isnan(args[5]->toNumber(exec))) - || (n >= 7 && isnan(args[6]->toNumber(exec)))) { - return jsNaN(); - } - - GregorianDateTime t; - memset(&t, 0, sizeof(t)); - int year = args[0]->toInt32(exec); - t.year = (year >= 0 && year <= 99) ? year : year - 1900; - t.month = args[1]->toInt32(exec); - t.monthDay = (n >= 3) ? args[2]->toInt32(exec) : 1; - t.hour = args[3]->toInt32(exec); - t.minute = args[4]->toInt32(exec); - t.second = args[5]->toInt32(exec); - double ms = (n >= 7) ? args[6]->toNumber(exec) : 0; - return jsNumber(gregorianDateTimeToMS(t, ms, true)); - } -} - -// ----------------------------------------------------------------------------- - -// Code originally from krfcdate.cpp, but we don't want to use kdecore, and we want double range. - -static inline double ymdhmsToSeconds(long year, int mon, int day, int hour, int minute, int second) -{ - double days = (day - 32075) - + floor(1461 * (year + 4800.0 + (mon - 14) / 12) / 4) - + 367 * (mon - 2 - (mon - 14) / 12 * 12) / 12 - - floor(3 * ((year + 4900.0 + (mon - 14) / 12) / 100) / 4) - - 2440588; - return ((days * hoursPerDay + hour) * minutesPerHour + minute) * secondsPerMinute + second; -} - -// We follow the recommendation of RFC 2822 to consider all -// obsolete time zones not listed here equivalent to "-0000". -static const struct KnownZone { -#if !PLATFORM(WIN_OS) - const -#endif - char tzName[4]; - int tzOffset; -} known_zones[] = { - { "UT", 0 }, - { "GMT", 0 }, - { "EST", -300 }, - { "EDT", -240 }, - { "CST", -360 }, - { "CDT", -300 }, - { "MST", -420 }, - { "MDT", -360 }, - { "PST", -480 }, - { "PDT", -420 } -}; - -inline static void skipSpacesAndComments(const char*& s) -{ - int nesting = 0; - char ch; - while ((ch = *s)) { - if (!isASCIISpace(ch)) { - if (ch == '(') - nesting++; - else if (ch == ')' && nesting > 0) - nesting--; - else if (nesting == 0) - break; - } - s++; - } -} - -// returns 0-11 (Jan-Dec); -1 on failure -static int findMonth(const char* monthStr) -{ - ASSERT(monthStr); - char needle[4]; - for (int i = 0; i < 3; ++i) { - if (!*monthStr) - return -1; - needle[i] = static_cast(toASCIILower(*monthStr++)); - } - needle[3] = '\0'; - const char *haystack = "janfebmaraprmayjunjulaugsepoctnovdec"; - const char *str = strstr(haystack, needle); - if (str) { - int position = static_cast(str - haystack); - if (position % 3 == 0) - return position / 3; - } - return -1; -} - -static double parseDate(const UString &date) -{ - // This parses a date in the form: - // Tuesday, 09-Nov-99 23:12:40 GMT - // or - // Sat, 01-Jan-2000 08:00:00 GMT - // or - // Sat, 01 Jan 2000 08:00:00 GMT - // or - // 01 Jan 99 22:00 +0100 (exceptions in rfc822/rfc2822) - // ### non RFC formats, added for Javascript: - // [Wednesday] January 09 1999 23:12:40 GMT - // [Wednesday] January 09 23:12:40 GMT 1999 - // - // We ignore the weekday. - - CString dateCString = date.UTF8String(); - const char *dateString = dateCString.c_str(); - - // Skip leading space - skipSpacesAndComments(dateString); - - long month = -1; - const char *wordStart = dateString; - // Check contents of first words if not number - while (*dateString && !isASCIIDigit(*dateString)) { - if (isASCIISpace(*dateString) || *dateString == '(') { - if (dateString - wordStart >= 3) - month = findMonth(wordStart); - skipSpacesAndComments(dateString); - wordStart = dateString; - } else - dateString++; - } - - // Missing delimiter between month and day (like "January29")? - if (month == -1 && wordStart != dateString) - month = findMonth(wordStart); - - skipSpacesAndComments(dateString); - - if (!*dateString) - return NaN; - - // ' 09-Nov-99 23:12:40 GMT' - char *newPosStr; - errno = 0; - long day = strtol(dateString, &newPosStr, 10); - if (errno) - return NaN; - dateString = newPosStr; - - if (!*dateString) - return NaN; - - if (day < 0) - return NaN; - - long year = 0; - if (day > 31) { - // ### where is the boundary and what happens below? - if (*dateString != '/') - return NaN; - // looks like a YYYY/MM/DD date - if (!*++dateString) - return NaN; - year = day; - month = strtol(dateString, &newPosStr, 10) - 1; - if (errno) - return NaN; - dateString = newPosStr; - if (*dateString++ != '/' || !*dateString) - return NaN; - day = strtol(dateString, &newPosStr, 10); - if (errno) - return NaN; - dateString = newPosStr; - } else if (*dateString == '/' && month == -1) { - dateString++; - // This looks like a MM/DD/YYYY date, not an RFC date. - month = day - 1; // 0-based - day = strtol(dateString, &newPosStr, 10); - if (errno) - return NaN; - if (day < 1 || day > 31) - return NaN; - dateString = newPosStr; - if (*dateString == '/') - dateString++; - if (!*dateString) - return NaN; - } else { - if (*dateString == '-') - dateString++; - - skipSpacesAndComments(dateString); - - if (*dateString == ',') - dateString++; - - if (month == -1) { // not found yet - month = findMonth(dateString); - if (month == -1) - return NaN; - - while (*dateString && *dateString != '-' && *dateString != ',' && !isASCIISpace(*dateString)) - dateString++; - - if (!*dateString) - return NaN; - - // '-99 23:12:40 GMT' - if (*dateString != '-' && *dateString != '/' && *dateString != ',' && !isASCIISpace(*dateString)) - return NaN; - dateString++; - } - } - - if (month < 0 || month > 11) - return NaN; - - // '99 23:12:40 GMT' - if (year <= 0 && *dateString) { - year = strtol(dateString, &newPosStr, 10); - if (errno) - return NaN; - } - - // Don't fail if the time is missing. - long hour = 0; - long minute = 0; - long second = 0; - if (!*newPosStr) - dateString = newPosStr; - else { - // ' 23:12:40 GMT' - if (!(isASCIISpace(*newPosStr) || *newPosStr == ',')) { - if (*newPosStr != ':') - return NaN; - // There was no year; the number was the hour. - year = -1; - } else { - // in the normal case (we parsed the year), advance to the next number - dateString = ++newPosStr; - skipSpacesAndComments(dateString); - } - - hour = strtol(dateString, &newPosStr, 10); - // Do not check for errno here since we want to continue - // even if errno was set becasue we are still looking - // for the timezone! - - // Read a number? If not, this might be a timezone name. - if (newPosStr != dateString) { - dateString = newPosStr; - - if (hour < 0 || hour > 23) - return NaN; - - if (!*dateString) - return NaN; - - // ':12:40 GMT' - if (*dateString++ != ':') - return NaN; - - minute = strtol(dateString, &newPosStr, 10); - if (errno) - return NaN; - dateString = newPosStr; - - if (minute < 0 || minute > 59) - return NaN; - - // ':40 GMT' - if (*dateString && *dateString != ':' && !isASCIISpace(*dateString)) - return NaN; - - // seconds are optional in rfc822 + rfc2822 - if (*dateString ==':') { - dateString++; - - second = strtol(dateString, &newPosStr, 10); - if (errno) - return NaN; - dateString = newPosStr; - - if (second < 0 || second > 59) - return NaN; - } - - skipSpacesAndComments(dateString); - - if (strncasecmp(dateString, "AM", 2) == 0) { - if (hour > 12) - return NaN; - if (hour == 12) - hour = 0; - dateString += 2; - skipSpacesAndComments(dateString); - } else if (strncasecmp(dateString, "PM", 2) == 0) { - if (hour > 12) - return NaN; - if (hour != 12) - hour += 12; - dateString += 2; - skipSpacesAndComments(dateString); - } - } - } - - bool haveTZ = false; - int offset = 0; - - // Don't fail if the time zone is missing. - // Some websites omit the time zone (4275206). - if (*dateString) { - if (strncasecmp(dateString, "GMT", 3) == 0 || strncasecmp(dateString, "UTC", 3) == 0) { - dateString += 3; - haveTZ = true; - } - - if (*dateString == '+' || *dateString == '-') { - long o = strtol(dateString, &newPosStr, 10); - if (errno) - return NaN; - dateString = newPosStr; - - if (o < -9959 || o > 9959) - return NaN; - - int sgn = (o < 0) ? -1 : 1; - o = abs(o); - if (*dateString != ':') { - offset = ((o / 100) * 60 + (o % 100)) * sgn; - } else { // GMT+05:00 - long o2 = strtol(dateString, &newPosStr, 10); - if (errno) - return NaN; - dateString = newPosStr; - offset = (o * 60 + o2) * sgn; - } - haveTZ = true; - } else { - for (int i = 0; i < int(sizeof(known_zones) / sizeof(KnownZone)); i++) { - if (0 == strncasecmp(dateString, known_zones[i].tzName, strlen(known_zones[i].tzName))) { - offset = known_zones[i].tzOffset; - dateString += strlen(known_zones[i].tzName); - haveTZ = true; - break; - } - } - } - } - - skipSpacesAndComments(dateString); - - if (*dateString && year == -1) { - year = strtol(dateString, &newPosStr, 10); - if (errno) - return NaN; - dateString = newPosStr; - } - - skipSpacesAndComments(dateString); - - // Trailing garbage - if (*dateString) - return NaN; - - // Y2K: Handle 2 digit years. - if (year >= 0 && year < 100) { - if (year < 50) - year += 2000; - else - year += 1900; - } - - // fall back to local timezone - if (!haveTZ) { - GregorianDateTime t; - memset(&t, 0, sizeof(tm)); - t.monthDay = day; - t.month = month; - t.year = year - 1900; - t.isDST = -1; - t.second = second; - t.minute = minute; - t.hour = hour; - - // Use our gregorianDateTimeToMS() rather than mktime() as the latter can't handle the full year range. - return gregorianDateTimeToMS(t, 0, false); - } - - return (ymdhmsToSeconds(year, month + 1, day, hour, minute, second) - (offset * 60.0)) * msPerSecond; -} - -double timeClip(double t) -{ - if (!isfinite(t)) - return NaN; - if (fabs(t) > 8.64E15) - return NaN; - return trunc(t); -} - -// Functions - -JSValue* dateProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsString("Invalid Date"); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsString(formatDate(t) + " " + formatTime(t, utc)); -} - -JSValue* dateProtoFuncToUTCString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = true; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsString("Invalid Date"); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsString(formatDateUTCVariant(t) + " " + formatTime(t, utc)); -} - -JSValue* dateProtoFuncToDateString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsString("Invalid Date"); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsString(formatDate(t)); -} - -JSValue* dateProtoFuncToTimeString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsString("Invalid Date"); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsString(formatTime(t, utc)); -} - -JSValue* dateProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsString("Invalid Date"); - - double secs = floor(milli / msPerSecond); - return jsString(formatLocaleDate(exec, secs, true, true, args)); -} - -JSValue* dateProtoFuncToLocaleDateString(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsString("Invalid Date"); - - double secs = floor(milli / msPerSecond); - return jsString(formatLocaleDate(exec, secs, true, false, args)); -} - -JSValue* dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsString("Invalid Date"); - - double secs = floor(milli / msPerSecond); - return jsString(formatLocaleDate(exec, secs, false, true, args)); -} - -JSValue* dateProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - return jsNumber(milli); -} - -JSValue* dateProtoFuncGetTime(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - return jsNumber(milli); -} - -JSValue* dateProtoFuncGetFullYear(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(1900 + t.year); -} - -JSValue* dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = true; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(1900 + t.year); -} - -JSValue* dateProtoFuncToGMTString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = true; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsString("Invalid Date"); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsString(formatDateUTCVariant(t) + " " + formatTime(t, utc)); -} - -JSValue* dateProtoFuncGetMonth(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.month); -} - -JSValue* dateProtoFuncGetUTCMonth(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = true; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.month); -} - -JSValue* dateProtoFuncGetDate(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.monthDay); -} - -JSValue* dateProtoFuncGetUTCDate(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = true; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.monthDay); -} - -JSValue* dateProtoFuncGetDay(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.weekDay); -} - -JSValue* dateProtoFuncGetUTCDay(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = true; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.weekDay); -} - -JSValue* dateProtoFuncGetHours(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.hour); -} - -JSValue* dateProtoFuncGetUTCHours(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = true; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.hour); -} - -JSValue* dateProtoFuncGetMinutes(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.minute); -} - -JSValue* dateProtoFuncGetUTCMinutes(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = true; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.minute); -} - -JSValue* dateProtoFuncGetSeconds(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.second); -} - -JSValue* dateProtoFuncGetUTCSeconds(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = true; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(t.second); -} - -JSValue* dateProtoFuncGetMilliSeconds(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - double secs = floor(milli / msPerSecond); - double ms = milli - secs * msPerSecond; - return jsNumber(ms); -} - -JSValue* dateProtoFuncGetUTCMilliseconds(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - double secs = floor(milli / msPerSecond); - double ms = milli - secs * msPerSecond; - return jsNumber(ms); -} - -JSValue* dateProtoFuncGetTimezoneOffset(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - return jsNumber(-gmtoffset(t) / minutesPerHour); -} - -JSValue* dateProtoFuncSetTime(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - DateInstance* thisDateObj = static_cast(thisObj); - - double milli = timeClip(args[0]->toNumber(exec)); - JSValue* result = jsNumber(milli); - thisDateObj->setInternalValue(result); - return result; -} - -static JSValue* setNewValueFromTimeArgs(ExecState* exec, JSObject* thisObj, const List& args, int numArgsToUse, bool inputIsUTC) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - double secs = floor(milli / msPerSecond); - double ms = milli - secs * msPerSecond; - - GregorianDateTime t; - msToGregorianDateTime(milli, inputIsUTC, t); - - fillStructuresUsingTimeArgs(exec, args, numArgsToUse, &ms, &t); - - JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, inputIsUTC)); - thisDateObj->setInternalValue(result); - return result; -} - -static JSValue* setNewValueFromDateArgs(ExecState* exec, JSObject* thisObj, const List& args, int numArgsToUse, bool inputIsUTC) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - double secs = floor(milli / msPerSecond); - double ms = milli - secs * msPerSecond; - - GregorianDateTime t; - msToGregorianDateTime(milli, inputIsUTC, t); - - fillStructuresUsingDateArgs(exec, args, numArgsToUse, &ms, &t); - - JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, inputIsUTC)); - thisDateObj->setInternalValue(result); - return result; -} - -JSValue* dateProtoFuncSetMilliSeconds(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = false; - return setNewValueFromTimeArgs(exec, thisObj, args, 1, inputIsUTC); -} - -JSValue* dateProtoFuncSetUTCMilliseconds(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = true; - return setNewValueFromTimeArgs(exec, thisObj, args, 1, inputIsUTC); -} - -JSValue* dateProtoFuncSetSeconds(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = false; - return setNewValueFromTimeArgs(exec, thisObj, args, 2, inputIsUTC); -} - -JSValue* dateProtoFuncSetUTCSeconds(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = true; - return setNewValueFromTimeArgs(exec, thisObj, args, 2, inputIsUTC); -} - -JSValue* dateProtoFuncSetMinutes(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = false; - return setNewValueFromTimeArgs(exec, thisObj, args, 3, inputIsUTC); -} - -JSValue* dateProtoFuncSetUTCMinutes(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = true; - return setNewValueFromTimeArgs(exec, thisObj, args, 3, inputIsUTC); -} - -JSValue* dateProtoFuncSetHours(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = false; - return setNewValueFromTimeArgs(exec, thisObj, args, 4, inputIsUTC); -} - -JSValue* dateProtoFuncSetUTCHours(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = true; - return setNewValueFromTimeArgs(exec, thisObj, args, 4, inputIsUTC); -} - -JSValue* dateProtoFuncSetDate(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = false; - return setNewValueFromDateArgs(exec, thisObj, args, 1, inputIsUTC); -} - -JSValue* dateProtoFuncSetUTCDate(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = true; - return setNewValueFromDateArgs(exec, thisObj, args, 1, inputIsUTC); -} - -JSValue* dateProtoFuncSetMonth(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = false; - return setNewValueFromDateArgs(exec, thisObj, args, 2, inputIsUTC); -} - -JSValue* dateProtoFuncSetUTCMonth(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = true; - return setNewValueFromDateArgs(exec, thisObj, args, 2, inputIsUTC); -} - -JSValue* dateProtoFuncSetFullYear(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = false; - return setNewValueFromDateArgs(exec, thisObj, args, 3, inputIsUTC); -} - -JSValue* dateProtoFuncSetUTCFullYear(ExecState* exec, JSObject* thisObj, const List& args) -{ - const bool inputIsUTC = true; - return setNewValueFromDateArgs(exec, thisObj, args, 3, inputIsUTC); -} - -JSValue* dateProtoFuncSetYear(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - double secs = floor(milli / msPerSecond); - double ms = milli - secs * msPerSecond; - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - - t.year = (args[0]->toInt32(exec) > 99 || args[0]->toInt32(exec) < 0) ? args[0]->toInt32(exec) - 1900 : args[0]->toInt32(exec); - - JSValue* result = jsNumber(gregorianDateTimeToMS(t, ms, utc)); - thisDateObj->setInternalValue(result); - return result; -} - -JSValue* dateProtoFuncGetYear(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&DateInstance::info)) - return throwError(exec, TypeError); - - const bool utc = false; - - DateInstance* thisDateObj = static_cast(thisObj); - JSValue* v = thisDateObj->internalValue(); - double milli = v->toNumber(exec); - if (isnan(milli)) - return jsNaN(); - - GregorianDateTime t; - msToGregorianDateTime(milli, utc, t); - - // IE returns the full year even in getYear. - if (exec->dynamicGlobalObject()->compatMode() == IECompat) - return jsNumber(1900 + t.year); - return jsNumber(t.year); -} - -} // namespace KJS diff --git a/kjs/date_object.h b/kjs/date_object.h deleted file mode 100644 index c545980..0000000 --- a/kjs/date_object.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef DATE_OBJECT_H -#define DATE_OBJECT_H - -#include "function.h" -#include "JSWrapperObject.h" -#include "lookup.h" - -namespace KJS { - - struct GregorianDateTime; - - class FunctionPrototype; - class ObjectPrototype; - - class DateInstance : public JSWrapperObject { - public: - DateInstance(JSObject *proto); - - bool getTime(GregorianDateTime&, int& offset) const; - bool getUTCTime(GregorianDateTime&) const; - bool getTime(double& milli, int& offset) const; - bool getUTCTime(double& milli) const; - - virtual const ClassInfo *classInfo() const { return &info; } - static const ClassInfo info; - }; - - /** - * @internal - * - * The initial value of Date.prototype (and thus all objects created - * with the Date constructor - */ - class DatePrototype : public DateInstance { - public: - DatePrototype(ExecState *, ObjectPrototype *); - virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&); - virtual const ClassInfo *classInfo() const { return &info; } - static const ClassInfo info; - }; - - /** - * @internal - * - * Functions to implement all methods that are properties of the - * Date.prototype object - */ - - // Non-normative properties (Appendix B) - // GetYear, SetYear, ToGMTString - - JSValue* dateProtoFuncToString(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncToUTCString(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncToDateString(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncToTimeString(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncToLocaleString(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncToLocaleDateString(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncToLocaleTimeString(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncValueOf(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetTime(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetFullYear(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetUTCFullYear(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncToGMTString(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetMonth(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetUTCMonth(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetUTCDate(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetDay(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetUTCDay(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetHours(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetUTCHours(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetMinutes(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetUTCMinutes(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetSeconds(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetUTCSeconds(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetMilliSeconds(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetUTCMilliseconds(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetTimezoneOffset(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetTime(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetMilliSeconds(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetUTCMilliseconds(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetSeconds(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetUTCSeconds(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetMinutes(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetUTCMinutes(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetHours(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetUTCHours(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetDate(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetUTCDate(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetMonth(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetUTCMonth(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetFullYear(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetUTCFullYear(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncSetYear(ExecState*, JSObject*, const List&); - JSValue* dateProtoFuncGetYear(ExecState*, JSObject*, const List&); - - /** - * @internal - * - * The initial value of the the global variable's "Date" property - */ - class DateObjectImp : public InternalFunctionImp { - public: - DateObjectImp(ExecState *, FunctionPrototype *, DatePrototype *); - - virtual bool implementsConstruct() const; - virtual JSObject *construct(ExecState *, const List &args); - virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args); - - JSObject *construct(const List &); - }; - -} // namespace - -#endif diff --git a/kjs/debugger.cpp b/kjs/debugger.cpp deleted file mode 100644 index 9e69b2c..0000000 --- a/kjs/debugger.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "debugger.h" - -#include "JSGlobalObject.h" -#include "internal.h" -#include "ustring.h" - -using namespace KJS; - -// ------------------------------ Debugger ------------------------------------- - -namespace KJS { - struct AttachedGlobalObject - { - public: - AttachedGlobalObject(JSGlobalObject* o, AttachedGlobalObject* ai) : globalObj(o), next(ai) { ++Debugger::debuggersPresent; } - ~AttachedGlobalObject() { --Debugger::debuggersPresent; } - JSGlobalObject* globalObj; - AttachedGlobalObject* next; - }; - -} - -int Debugger::debuggersPresent = 0; - -Debugger::Debugger() -{ - rep = new DebuggerImp(); -} - -Debugger::~Debugger() -{ - detach(0); - delete rep; -} - -void Debugger::attach(JSGlobalObject* globalObject) -{ - Debugger* other = globalObject->debugger(); - if (other == this) - return; - if (other) - other->detach(globalObject); - globalObject->setDebugger(this); - rep->globalObjects = new AttachedGlobalObject(globalObject, rep->globalObjects); -} - -void Debugger::detach(JSGlobalObject* globalObj) -{ - // iterate the addresses where AttachedGlobalObject pointers are stored - // so we can unlink items from the list - AttachedGlobalObject **p = &rep->globalObjects; - AttachedGlobalObject *q; - while ((q = *p)) { - if (!globalObj || q->globalObj == globalObj) { - *p = q->next; - q->globalObj->setDebugger(0); - delete q; - } else - p = &q->next; - } - - if (globalObj) - latestExceptions.remove(globalObj); - else - latestExceptions.clear(); -} - -bool Debugger::hasHandledException(ExecState *exec, JSValue *exception) -{ - if (latestExceptions.get(exec->dynamicGlobalObject()).get() == exception) - return true; - - latestExceptions.set(exec->dynamicGlobalObject(), exception); - return false; -} - -bool Debugger::sourceParsed(ExecState*, const SourceCode&, int /*errorLine*/, const UString& /*errorMsg*/) -{ - return true; -} - -bool Debugger::sourceUnused(ExecState*, intptr_t /*sourceID*/) -{ - return true; -} - -bool Debugger::exception(ExecState*, intptr_t /*sourceID*/, int /*lineno*/, - JSValue* /*exception */) -{ - return true; -} - -bool Debugger::atStatement(ExecState*, intptr_t /*sourceID*/, int /*firstLine*/, - int /*lastLine*/) -{ - return true; -} - -bool Debugger::callEvent(ExecState*, intptr_t /*sourceID*/, int /*lineno*/, - JSObject* /*function*/, const List &/*args*/) -{ - return true; -} - -bool Debugger::returnEvent(ExecState*, intptr_t /*sourceID*/, int /*lineno*/, - JSObject* /*function*/) -{ - return true; -} - diff --git a/kjs/debugger.h b/kjs/debugger.h deleted file mode 100644 index 6aa15e2..0000000 --- a/kjs/debugger.h +++ /dev/null @@ -1,225 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef _KJSDEBUGGER_H_ -#define _KJSDEBUGGER_H_ - -#include -#include "protect.h" - -namespace KJS { - - class DebuggerImp; - class ExecState; - class JSGlobalObject; - class JSObject; - class JSValue; - class SourceCode; - class UString; - class List; - - /** - * @internal - * - * Provides an interface which receives notification about various - * script-execution related events such as statement execution and function - * calls. - * - * WARNING: This interface is still a work in progress and is not yet - * offically publicly available. It is likely to change in binary incompatible - * (and possibly source incompatible) ways in future versions. It is - * anticipated that at some stage the interface will be frozen and made - * available for general use. - */ - class Debugger { - public: - - /** - * Creates a new debugger - */ - Debugger(); - - /** - * Destroys the debugger. If the debugger is attached to any global objects, - * it is automatically detached. - */ - virtual ~Debugger(); - - DebuggerImp *imp() const { return rep; } - - /** - * Attaches the debugger to specified global object. This will cause this - * object to receive notification of events during execution. - * - * If the global object is deleted, it will detach the debugger. - * - * Note: only one debugger can be attached to a global object at a time. - * Attaching another debugger to the same global object will cause the - * original debugger to be detached. - * - * @param The global object to attach to. - * - * @see detach() - */ - void attach(JSGlobalObject*); - - /** - * Detach the debugger from a global object. - * - * @param The global object to detach from. If 0, the debugger will be - * detached from all global objects to which it is attached. - * - * @see attach() - */ - void detach(JSGlobalObject*); - - /** - * Called to notify the debugger that some javascript source code has - * been parsed. For calls to Interpreter::evaluate(), this will be called - * with the supplied source code before any other code is parsed. - * Other situations in which this may be called include creation of a - * function using the Function() constructor, or the eval() function. - * - * The default implementation does nothing. Override this method if - * you want to process this event. - * - * @param exec The current execution state - * @param sourceId The ID of the source code (corresponds to the - * sourceId supplied in other functions such as atStatement() - * @param sourceURL Where the source code that was parsed came from - * @param source The source code that was parsed - * @param startingLineNumber The line number at which parsing started - * @param errorLine The line number at which parsing encountered an - * error, or -1 if the source code was valid and parsed successfully - * @param errorMsg The error description, or null if the source code - was valid and parsed successfully - * @return true if execution should be continue, false if it should - * be aborted - */ - virtual bool sourceParsed(ExecState*, const SourceCode&, int errorLine, const UString& errorMsg) = 0; - - /** - * Called when all functions/programs associated with a particular - * sourceId have been deleted. After this function has been called for - * a particular sourceId, that sourceId will not be used again. - * - * The default implementation does nothing. Override this method if - * you want to process this event. - * - * @param exec The current execution state - * @param sourceId The ID of the source code (corresponds to the - * sourceId supplied in other functions such as atLine() - * @return true if execution should be continue, false if it should - * be aborted - */ - virtual bool sourceUnused(ExecState *exec, intptr_t sourceID); - - /** - * Called when an exception is thrown during script execution. - * - * The default implementation does nothing. Override this method if - * you want to process this event. - * - * @param exec The current execution state - * @param sourceId The ID of the source code being executed - * @param lineno The line at which the error occurred - * @param exceptionObj The exception object - * @return true if execution should be continue, false if it should - * be aborted - */ - virtual bool exception(ExecState *exec, intptr_t sourceID, int lineno, - JSValue *exception); - - bool hasHandledException(ExecState *, JSValue *); - - /** - * Called when a line of the script is reached (before it is executed) - * - * The default implementation does nothing. Override this method if - * you want to process this event. - * - * @param exec The current execution state - * @param sourceId The ID of the source code being executed - * @param firstLine The starting line of the statement that is about to be - * executed - * @param lastLine The ending line of the statement that is about to be - * executed (usually the same as firstLine) - * @return true if execution should be continue, false if it should - * be aborted - */ - virtual bool atStatement(ExecState *exec, intptr_t sourceID, int firstLine, - int lastLine); - /** - * Called on each function call. Use together with @ref #returnEvent - * if you want to keep track of the call stack. - * - * Note: This only gets called for functions that are declared in ECMAScript - * source code or passed to eval(), not for internal KJS or - * application-supplied functions. - * - * The default implementation does nothing. Override this method if - * you want to process this event. - * - * @param exec The current execution state - * @param sourceId The ID of the source code being executed - * @param lineno The line that is about to be executed - * @param function The function being called - * @param args The arguments that were passed to the function - * line is being executed - * @return true if execution should be continue, false if it should - * be aborted - */ - virtual bool callEvent(ExecState *exec, intptr_t sourceID, int lineno, - JSObject *function, const List &args); - - /** - * Called on each function exit. The function being returned from is that - * which was supplied in the last callEvent(). - * - * Note: This only gets called for functions that are declared in ECMAScript - * source code or passed to eval(), not for internal KJS or - * application-supplied functions. - * - * The default implementation does nothing. Override this method if - * you want to process this event. - * - * @param exec The current execution state - * @param sourceId The ID of the source code being executed - * @param lineno The line that is about to be executed - * @param function The function being called - * @return true if execution should be continue, false if it should - * be aborted - */ - virtual bool returnEvent(ExecState *exec, intptr_t sourceID, int lineno, - JSObject *function); - - private: - DebuggerImp *rep; - HashMap > latestExceptions; - - public: - static int debuggersPresent; - }; - -} - -#endif diff --git a/kjs/dtoa.cpp b/kjs/dtoa.cpp deleted file mode 100644 index a8e3a68..0000000 --- a/kjs/dtoa.cpp +++ /dev/null @@ -1,3300 +0,0 @@ -/**************************************************************** - * - * The author of this software is David M. Gay. - * - * Copyright (c) 1991, 2000, 2001 by Lucent Technologies. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. - * - ***************************************************************/ - -/* Please send bug reports to - David M. Gay - Bell Laboratories, Room 2C-463 - 600 Mountain Avenue - Murray Hill, NJ 07974-0636 - U.S.A. - dmg@bell-labs.com - */ - -/* On a machine with IEEE extended-precision registers, it is - * necessary to specify double-precision (53-bit) rounding precision - * before invoking strtod or dtoa. If the machine uses (the equivalent - * of) Intel 80x87 arithmetic, the call - * _control87(PC_53, MCW_PC); - * does this with many compilers. Whether this or another call is - * appropriate depends on the compiler; for this to work, it may be - * necessary to #include "float.h" or another system-dependent header - * file. - */ - -/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. - * - * This strtod returns a nearest machine number to the input decimal - * string (or sets errno to ERANGE). With IEEE arithmetic, ties are - * broken by the IEEE round-even rule. Otherwise ties are broken by - * biased rounding (add half and chop). - * - * Inspired loosely by William D. Clinger's paper "How to Read Floating - * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. - * - * Modifications: - * - * 1. We only require IEEE, IBM, or VAX double-precision - * arithmetic (not IEEE double-extended). - * 2. We get by with floating-point arithmetic in a case that - * Clinger missed -- when we're computing d * 10^n - * for a small integer d and the integer n is not too - * much larger than 22 (the maximum integer k for which - * we can represent 10^k exactly), we may be able to - * compute (d*10^k) * 10^(e-k) with just one roundoff. - * 3. Rather than a bit-at-a-time adjustment of the binary - * result in the hard case, we use floating-point - * arithmetic to determine the adjustment to within - * one bit; only in really hard cases do we need to - * compute a second residual. - * 4. Because of 3., we don't need a large table of powers of 10 - * for ten-to-e (just some small tables, e.g. of 10^k - * for 0 <= k <= 22). - */ - -/* - * #define IEEE_8087 for IEEE-arithmetic machines where the least - * significant byte has the lowest address. - * #define IEEE_MC68k for IEEE-arithmetic machines where the most - * significant byte has the lowest address. - * #define Long int on machines with 32-bit ints and 64-bit longs. - * #define IBM for IBM mainframe-style floating-point arithmetic. - * #define VAX for VAX-style floating-point arithmetic (D_floating). - * #define No_leftright to omit left-right logic in fast floating-point - * computation of dtoa. - * #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3 - * and strtod and dtoa should round accordingly. - * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3 - * and Honor_FLT_ROUNDS is not #defined. - * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines - * that use extended-precision instructions to compute rounded - * products and quotients) with IBM. - * #define ROUND_BIASED for IEEE-format with biased rounding. - * #define Inaccurate_Divide for IEEE-format with correctly rounded - * products but inaccurate quotients, e.g., for Intel i860. - * #define NO_LONG_LONG on machines that do not have a "long long" - * integer type (of >= 64 bits). On such machines, you can - * #define Just_16 to store 16 bits per 32-bit Long when doing - * high-precision integer arithmetic. Whether this speeds things - * up or slows things down depends on the machine and the number - * being converted. If long long is available and the name is - * something other than "long long", #define Llong to be the name, - * and if "unsigned Llong" does not work as an unsigned version of - * Llong, #define #ULLong to be the corresponding unsigned type. - * #define KR_headers for old-style C function headers. - * #define Bad_float_h if your system lacks a float.h or if it does not - * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, - * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. - * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) - * if memory is available and otherwise does something you deem - * appropriate. If MALLOC is undefined, malloc will be invoked - * directly -- and assumed always to succeed. - * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making - * memory allocations from a private pool of memory when possible. - * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes, - * unless #defined to be a different length. This default length - * suffices to get rid of MALLOC calls except for unusual cases, - * such as decimal-to-binary conversion of a very long string of - * digits. The longest string dtoa can return is about 751 bytes - * long. For conversions by strtod of strings of 800 digits and - * all dtoa conversions in single-threaded executions with 8-byte - * pointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte - * pointers, PRIVATE_MEM >= 7112 appears adequate. - * #define INFNAN_CHECK on IEEE systems to cause strtod to check for - * Infinity and NaN (case insensitively). On some systems (e.g., - * some HP systems), it may be necessary to #define NAN_WORD0 - * appropriately -- to the most significant word of a quiet NaN. - * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.) - * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined, - * strtod also accepts (case insensitively) strings of the form - * NaN(x), where x is a string of hexadecimal digits and spaces; - * if there is only one string of hexadecimal digits, it is taken - * for the 52 fraction bits of the resulting NaN; if there are two - * or more strings of hex digits, the first is for the high 20 bits, - * the second and subsequent for the low 32 bits, with intervening - * white space ignored; but if this results in none of the 52 - * fraction bits being on (an IEEE Infinity symbol), then NAN_WORD0 - * and NAN_WORD1 are used instead. - * #define MULTIPLE_THREADS if the system offers preemptively scheduled - * multiple threads. In this case, you must provide (or suitably - * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed - * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed - * in pow5mult, ensures lazy evaluation of only one copy of high - * powers of 5; omitting this lock would introduce a small - * probability of wasting memory, but would otherwise be harmless.) - * You must also invoke freedtoa(s) to free the value s returned by - * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. - * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that - * avoids underflows on inputs whose result does not underflow. - * If you #define NO_IEEE_Scale on a machine that uses IEEE-format - * floating-point numbers and flushes underflows to zero rather - * than implementing gradual underflow, then you must also #define - * Sudden_Underflow. - * #define YES_ALIAS to permit aliasing certain double values with - * arrays of ULongs. This leads to slightly better code with - * some compilers and was always used prior to 19990916, but it - * is not strictly legal and can cause trouble with aggressively - * optimizing compilers (e.g., gcc 2.95.1 under -O2). - * #define SET_INEXACT if IEEE arithmetic is being used and extra - * computation should be done to set the inexact flag when the - * result is inexact and avoid setting inexact when the result - * is exact. In this case, dtoa.c must be compiled in - * an environment, perhaps provided by #include "dtoa.c" in a - * suitable wrapper, that defines two functions, - * int get_inexact(void); - * void clear_inexact(void); - * such that get_inexact() returns a nonzero value if the - * inexact bit is already set, and clear_inexact() sets the - * inexact bit to 0. When SET_INEXACT is #defined, strtod - * also does extra computations to set the underflow and overflow - * flags when appropriate (i.e., when the result is tiny and - * inexact or when it is a numeric value rounded to +-infinity). - * #define NO_ERRNO if strtod should not assign errno = ERANGE when - * the result overflows to +-Infinity or underflows to 0. - */ - -#include "config.h" -#include "dtoa.h" - -#if COMPILER(MSVC) -#pragma warning(disable: 4244) -#pragma warning(disable: 4245) -#pragma warning(disable: 4554) -#endif - -#if PLATFORM(BIG_ENDIAN) -#define IEEE_MC68k -#else -#define IEEE_8087 -#endif -#define INFNAN_CHECK - - - -#ifndef Long -#define Long int -#endif -#ifndef ULong -typedef unsigned Long ULong; -#endif - -#ifdef DEBUG -#include -#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} -#endif - -#include -#include - -#ifdef MALLOC -#ifdef KR_headers -extern char *MALLOC(); -#else -extern void *MALLOC(size_t); -#endif -#else -#define MALLOC malloc -#endif - -#ifndef Omit_Private_Memory -#ifndef PRIVATE_MEM -#define PRIVATE_MEM 2304 -#endif -#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) -static double private_mem[PRIVATE_mem], *pmem_next = private_mem; -#endif - -#undef IEEE_Arith -#undef Avoid_Underflow -#ifdef IEEE_MC68k -#define IEEE_Arith -#endif -#ifdef IEEE_8087 -#define IEEE_Arith -#endif - -#include - -#ifdef Bad_float_h - -#ifdef IEEE_Arith -#define DBL_DIG 15 -#define DBL_MAX_10_EXP 308 -#define DBL_MAX_EXP 1024 -#define FLT_RADIX 2 -#endif /*IEEE_Arith*/ - -#ifdef IBM -#define DBL_DIG 16 -#define DBL_MAX_10_EXP 75 -#define DBL_MAX_EXP 63 -#define FLT_RADIX 16 -#define DBL_MAX 7.2370055773322621e+75 -#endif - -#ifdef VAX -#define DBL_DIG 16 -#define DBL_MAX_10_EXP 38 -#define DBL_MAX_EXP 127 -#define FLT_RADIX 2 -#define DBL_MAX 1.7014118346046923e+38 -#endif - -#ifndef LONG_MAX -#define LONG_MAX 2147483647 -#endif - -#else /* ifndef Bad_float_h */ -#include -#endif /* Bad_float_h */ - -#ifndef __MATH_H__ -#include -#endif - -#define strtod kjs_strtod -#define dtoa kjs_dtoa -#define freedtoa kjs_freedtoa - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef CONST_ -#ifdef KR_headers -#define CONST_ /* blank */ -#else -#define CONST_ const -#endif -#endif - -#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 -Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. -#endif - -typedef union { double d; ULong L[2]; } U; - -#ifdef YES_ALIAS -#define dval(x) x -#ifdef IEEE_8087 -#define word0(x) ((ULong *)&x)[1] -#define word1(x) ((ULong *)&x)[0] -#else -#define word0(x) ((ULong *)&x)[0] -#define word1(x) ((ULong *)&x)[1] -#endif -#else -#ifdef IEEE_8087 -#define word0(x) ((U*)&x)->L[1] -#define word1(x) ((U*)&x)->L[0] -#else -#define word0(x) ((U*)&x)->L[0] -#define word1(x) ((U*)&x)->L[1] -#endif -#define dval(x) ((U*)&x)->d -#endif - -/* The following definition of Storeinc is appropriate for MIPS processors. - * An alternative that might be better on some machines is - * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) - */ -#if defined(IEEE_8087) + defined(VAX) -#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ -((unsigned short *)a)[0] = (unsigned short)c, a++) -#else -#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ -((unsigned short *)a)[1] = (unsigned short)c, a++) -#endif - -/* #define P DBL_MANT_DIG */ -/* Ten_pmax = floor(P*log(2)/log(5)) */ -/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ -/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ -/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ - -#ifdef IEEE_Arith -#define Exp_shift 20 -#define Exp_shift1 20 -#define Exp_msk1 0x100000 -#define Exp_msk11 0x100000 -#define Exp_mask 0x7ff00000 -#define P 53 -#define Bias 1023 -#define Emin (-1022) -#define Exp_1 0x3ff00000 -#define Exp_11 0x3ff00000 -#define Ebits 11 -#define Frac_mask 0xfffff -#define Frac_mask1 0xfffff -#define Ten_pmax 22 -#define Bletch 0x10 -#define Bndry_mask 0xfffff -#define Bndry_mask1 0xfffff -#define LSB 1 -#define Sign_bit 0x80000000 -#define Log2P 1 -#define Tiny0 0 -#define Tiny1 1 -#define Quick_max 14 -#define Int_max 14 -#ifndef NO_IEEE_Scale -#define Avoid_Underflow -#ifdef Flush_Denorm /* debugging option */ -#undef Sudden_Underflow -#endif -#endif - -#ifndef Flt_Rounds -#ifdef FLT_ROUNDS -#define Flt_Rounds FLT_ROUNDS -#else -#define Flt_Rounds 1 -#endif -#endif /*Flt_Rounds*/ - -#ifdef Honor_FLT_ROUNDS -#define Rounding rounding -#undef Check_FLT_ROUNDS -#define Check_FLT_ROUNDS -#else -#define Rounding Flt_Rounds -#endif - -#else /* ifndef IEEE_Arith */ -#undef Check_FLT_ROUNDS -#undef Honor_FLT_ROUNDS -#undef SET_INEXACT -#undef Sudden_Underflow -#define Sudden_Underflow -#ifdef IBM -#undef Flt_Rounds -#define Flt_Rounds 0 -#define Exp_shift 24 -#define Exp_shift1 24 -#define Exp_msk1 0x1000000 -#define Exp_msk11 0x1000000 -#define Exp_mask 0x7f000000 -#define P 14 -#define Bias 65 -#define Exp_1 0x41000000 -#define Exp_11 0x41000000 -#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ -#define Frac_mask 0xffffff -#define Frac_mask1 0xffffff -#define Bletch 4 -#define Ten_pmax 22 -#define Bndry_mask 0xefffff -#define Bndry_mask1 0xffffff -#define LSB 1 -#define Sign_bit 0x80000000 -#define Log2P 4 -#define Tiny0 0x100000 -#define Tiny1 0 -#define Quick_max 14 -#define Int_max 15 -#else /* VAX */ -#undef Flt_Rounds -#define Flt_Rounds 1 -#define Exp_shift 23 -#define Exp_shift1 7 -#define Exp_msk1 0x80 -#define Exp_msk11 0x800000 -#define Exp_mask 0x7f80 -#define P 56 -#define Bias 129 -#define Exp_1 0x40800000 -#define Exp_11 0x4080 -#define Ebits 8 -#define Frac_mask 0x7fffff -#define Frac_mask1 0xffff007f -#define Ten_pmax 24 -#define Bletch 2 -#define Bndry_mask 0xffff007f -#define Bndry_mask1 0xffff007f -#define LSB 0x10000 -#define Sign_bit 0x8000 -#define Log2P 1 -#define Tiny0 0x80 -#define Tiny1 0 -#define Quick_max 15 -#define Int_max 15 -#endif /* IBM, VAX */ -#endif /* IEEE_Arith */ - -#ifndef IEEE_Arith -#define ROUND_BIASED -#endif - -#ifdef RND_PRODQUOT -#define rounded_product(a,b) a = rnd_prod(a, b) -#define rounded_quotient(a,b) a = rnd_quot(a, b) -#ifdef KR_headers -extern double rnd_prod(), rnd_quot(); -#else -extern double rnd_prod(double, double), rnd_quot(double, double); -#endif -#else -#define rounded_product(a,b) a *= b -#define rounded_quotient(a,b) a /= b -#endif - -#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) -#define Big1 0xffffffff - -#ifndef Pack_32 -#define Pack_32 -#endif - -#ifdef KR_headers -#define FFFFFFFF ((((unsigned long)0xffff)<<16)|(unsigned long)0xffff) -#else -#define FFFFFFFF 0xffffffffUL -#endif - -#ifdef NO_LONG_LONG -#undef ULLong -#ifdef Just_16 -#undef Pack_32 -/* When Pack_32 is not defined, we store 16 bits per 32-bit Long. - * This makes some inner loops simpler and sometimes saves work - * during multiplications, but it often seems to make things slightly - * slower. Hence the default is now to store 32 bits per Long. - */ -#endif -#else /* long long available */ -#ifndef Llong -#define Llong long long -#endif -#ifndef ULLong -#define ULLong unsigned Llong -#endif -#endif /* NO_LONG_LONG */ - -#ifndef MULTIPLE_THREADS -#define ACQUIRE_DTOA_LOCK(n) /*nothing*/ -#define FREE_DTOA_LOCK(n) /*nothing*/ -#endif - -#define Kmax 15 - - struct -Bigint { - struct Bigint *next; - int k, maxwds, sign, wds; - ULong x[1]; - }; - - typedef struct Bigint Bigint; - - static Bigint *freelist[Kmax+1]; - - static Bigint * -Balloc -#ifdef KR_headers - (k) int k; -#else - (int k) -#endif -{ - int x; - Bigint *rv; -#ifndef Omit_Private_Memory - unsigned int len; -#endif - - ACQUIRE_DTOA_LOCK(0); - if ((rv = freelist[k])) { - freelist[k] = rv->next; - } - else { - x = 1 << k; -#ifdef Omit_Private_Memory - rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong)); -#else - len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) - /sizeof(double); - if (pmem_next - private_mem + len <= (unsigned)PRIVATE_mem) { - rv = (Bigint*)pmem_next; - pmem_next += len; - } - else - rv = (Bigint*)MALLOC(len*sizeof(double)); -#endif - rv->k = k; - rv->maxwds = x; - } - FREE_DTOA_LOCK(0); - rv->sign = rv->wds = 0; - return rv; - } - - static void -Bfree -#ifdef KR_headers - (v) Bigint *v; -#else - (Bigint *v) -#endif -{ - if (v) { - ACQUIRE_DTOA_LOCK(0); - v->next = freelist[v->k]; - freelist[v->k] = v; - FREE_DTOA_LOCK(0); - } - } - -#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \ -y->wds*sizeof(Long) + 2*sizeof(int)) - - static Bigint * -multadd -#ifdef KR_headers - (b, m, a) Bigint *b; int m, a; -#else - (Bigint *b, int m, int a) /* multiply by m and add a */ -#endif -{ - int i, wds; -#ifdef ULLong - ULong *x; - ULLong carry, y; -#else - ULong carry, *x, y; -#ifdef Pack_32 - ULong xi, z; -#endif -#endif - Bigint *b1; - - wds = b->wds; - x = b->x; - i = 0; - carry = a; - do { -#ifdef ULLong - y = *x * (ULLong)m + carry; - carry = y >> 32; - *x++ = (ULong)y & FFFFFFFF; -#else -#ifdef Pack_32 - xi = *x; - y = (xi & 0xffff) * m + carry; - z = (xi >> 16) * m + (y >> 16); - carry = z >> 16; - *x++ = (z << 16) + (y & 0xffff); -#else - y = *x * m + carry; - carry = y >> 16; - *x++ = y & 0xffff; -#endif -#endif - } - while(++i < wds); - if (carry) { - if (wds >= b->maxwds) { - b1 = Balloc(b->k+1); - Bcopy(b1, b); - Bfree(b); - b = b1; - } - b->x[wds++] = (ULong)carry; - b->wds = wds; - } - return b; - } - - static Bigint * -s2b -#ifdef KR_headers - (s, nd0, nd, y9) CONST_ char *s; int nd0, nd; ULong y9; -#else - (CONST_ char *s, int nd0, int nd, ULong y9) -#endif -{ - Bigint *b; - int i, k; - Long x, y; - - x = (nd + 8) / 9; - for(k = 0, y = 1; x > y; y <<= 1, k++) ; -#ifdef Pack_32 - b = Balloc(k); - b->x[0] = y9; - b->wds = 1; -#else - b = Balloc(k+1); - b->x[0] = y9 & 0xffff; - b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; -#endif - - i = 9; - if (9 < nd0) { - s += 9; - do b = multadd(b, 10, *s++ - '0'); - while(++i < nd0); - s++; - } - else - s += 10; - for(; i < nd; i++) - b = multadd(b, 10, *s++ - '0'); - return b; - } - - static int -hi0bits -#ifdef KR_headers - (x) register ULong x; -#else - (register ULong x) -#endif -{ - register int k = 0; - - if (!(x & 0xffff0000)) { - k = 16; - x <<= 16; - } - if (!(x & 0xff000000)) { - k += 8; - x <<= 8; - } - if (!(x & 0xf0000000)) { - k += 4; - x <<= 4; - } - if (!(x & 0xc0000000)) { - k += 2; - x <<= 2; - } - if (!(x & 0x80000000)) { - k++; - if (!(x & 0x40000000)) - return 32; - } - return k; - } - - static int -lo0bits -#ifdef KR_headers - (y) ULong *y; -#else - (ULong *y) -#endif -{ - register int k; - register ULong x = *y; - - if (x & 7) { - if (x & 1) - return 0; - if (x & 2) { - *y = x >> 1; - return 1; - } - *y = x >> 2; - return 2; - } - k = 0; - if (!(x & 0xffff)) { - k = 16; - x >>= 16; - } - if (!(x & 0xff)) { - k += 8; - x >>= 8; - } - if (!(x & 0xf)) { - k += 4; - x >>= 4; - } - if (!(x & 0x3)) { - k += 2; - x >>= 2; - } - if (!(x & 1)) { - k++; - x >>= 1; - if (!x & 1) - return 32; - } - *y = x; - return k; - } - - static Bigint * -i2b -#ifdef KR_headers - (i) int i; -#else - (int i) -#endif -{ - Bigint *b; - - b = Balloc(1); - b->x[0] = i; - b->wds = 1; - return b; - } - - static Bigint * -mult -#ifdef KR_headers - (a, b) Bigint *a, *b; -#else - (Bigint *a, Bigint *b) -#endif -{ - Bigint *c; - int k, wa, wb, wc; - ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; - ULong y; -#ifdef ULLong - ULLong carry, z; -#else - ULong carry, z; -#ifdef Pack_32 - ULong z2; -#endif -#endif - - if (a->wds < b->wds) { - c = a; - a = b; - b = c; - } - k = a->k; - wa = a->wds; - wb = b->wds; - wc = wa + wb; - if (wc > a->maxwds) - k++; - c = Balloc(k); - for(x = c->x, xa = x + wc; x < xa; x++) - *x = 0; - xa = a->x; - xae = xa + wa; - xb = b->x; - xbe = xb + wb; - xc0 = c->x; -#ifdef ULLong - for(; xb < xbe; xc0++) { - if ((y = *xb++)) { - x = xa; - xc = xc0; - carry = 0; - do { - z = *x++ * (ULLong)y + *xc + carry; - carry = z >> 32; - *xc++ = (ULong)z & FFFFFFFF; - } - while(x < xae); - *xc = (ULong)carry; - } - } -#else -#ifdef Pack_32 - for(; xb < xbe; xb++, xc0++) { - if (y = *xb & 0xffff) { - x = xa; - xc = xc0; - carry = 0; - do { - z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; - carry = z >> 16; - z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; - carry = z2 >> 16; - Storeinc(xc, z2, z); - } - while(x < xae); - *xc = carry; - } - if (y = *xb >> 16) { - x = xa; - xc = xc0; - carry = 0; - z2 = *xc; - do { - z = (*x & 0xffff) * y + (*xc >> 16) + carry; - carry = z >> 16; - Storeinc(xc, z, z2); - z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; - carry = z2 >> 16; - } - while(x < xae); - *xc = z2; - } - } -#else - for(; xb < xbe; xc0++) { - if (y = *xb++) { - x = xa; - xc = xc0; - carry = 0; - do { - z = *x++ * y + *xc + carry; - carry = z >> 16; - *xc++ = z & 0xffff; - } - while(x < xae); - *xc = carry; - } - } -#endif -#endif - for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; - c->wds = wc; - return c; - } - - static Bigint *p5s; - - static Bigint * -pow5mult -#ifdef KR_headers - (b, k) Bigint *b; int k; -#else - (Bigint *b, int k) -#endif -{ - Bigint *b1, *p5, *p51; - int i; - static int p05[3] = { 5, 25, 125 }; - - if ((i = k & 3)) - b = multadd(b, p05[i-1], 0); - - if (!(k >>= 2)) - return b; - if (!(p5 = p5s)) { - /* first time */ -#ifdef MULTIPLE_THREADS - ACQUIRE_DTOA_LOCK(1); - if (!(p5 = p5s)) { - p5 = p5s = i2b(625); - p5->next = 0; - } - FREE_DTOA_LOCK(1); -#else - p5 = p5s = i2b(625); - p5->next = 0; -#endif - } - for(;;) { - if (k & 1) { - b1 = mult(b, p5); - Bfree(b); - b = b1; - } - if (!(k >>= 1)) - break; - if (!(p51 = p5->next)) { -#ifdef MULTIPLE_THREADS - ACQUIRE_DTOA_LOCK(1); - if (!(p51 = p5->next)) { - p51 = p5->next = mult(p5,p5); - p51->next = 0; - } - FREE_DTOA_LOCK(1); -#else - p51 = p5->next = mult(p5,p5); - p51->next = 0; -#endif - } - p5 = p51; - } - return b; - } - - static Bigint * -lshift -#ifdef KR_headers - (b, k) Bigint *b; int k; -#else - (Bigint *b, int k) -#endif -{ - int i, k1, n, n1; - Bigint *b1; - ULong *x, *x1, *xe, z; - -#ifdef Pack_32 - n = k >> 5; -#else - n = k >> 4; -#endif - k1 = b->k; - n1 = n + b->wds + 1; - for(i = b->maxwds; n1 > i; i <<= 1) - k1++; - b1 = Balloc(k1); - x1 = b1->x; - for(i = 0; i < n; i++) - *x1++ = 0; - x = b->x; - xe = x + b->wds; -#ifdef Pack_32 - if (k &= 0x1f) { - k1 = 32 - k; - z = 0; - do { - *x1++ = *x << k | z; - z = *x++ >> k1; - } - while(x < xe); - if ((*x1 = z)) - ++n1; - } -#else - if (k &= 0xf) { - k1 = 16 - k; - z = 0; - do { - *x1++ = *x << k & 0xffff | z; - z = *x++ >> k1; - } - while(x < xe); - if (*x1 = z) - ++n1; - } -#endif - else do - *x1++ = *x++; - while(x < xe); - b1->wds = n1 - 1; - Bfree(b); - return b1; - } - - static int -cmp -#ifdef KR_headers - (a, b) Bigint *a, *b; -#else - (Bigint *a, Bigint *b) -#endif -{ - ULong *xa, *xa0, *xb, *xb0; - int i, j; - - i = a->wds; - j = b->wds; -#ifdef DEBUG - if (i > 1 && !a->x[i-1]) - Bug("cmp called with a->x[a->wds-1] == 0"); - if (j > 1 && !b->x[j-1]) - Bug("cmp called with b->x[b->wds-1] == 0"); -#endif - if (i -= j) - return i; - xa0 = a->x; - xa = xa0 + j; - xb0 = b->x; - xb = xb0 + j; - for(;;) { - if (*--xa != *--xb) - return *xa < *xb ? -1 : 1; - if (xa <= xa0) - break; - } - return 0; - } - - static Bigint * -diff -#ifdef KR_headers - (a, b) Bigint *a, *b; -#else - (Bigint *a, Bigint *b) -#endif -{ - Bigint *c; - int i, wa, wb; - ULong *xa, *xae, *xb, *xbe, *xc; -#ifdef ULLong - ULLong borrow, y; -#else - ULong borrow, y; -#ifdef Pack_32 - ULong z; -#endif -#endif - - i = cmp(a,b); - if (!i) { - c = Balloc(0); - c->wds = 1; - c->x[0] = 0; - return c; - } - if (i < 0) { - c = a; - a = b; - b = c; - i = 1; - } - else - i = 0; - c = Balloc(a->k); - c->sign = i; - wa = a->wds; - xa = a->x; - xae = xa + wa; - wb = b->wds; - xb = b->x; - xbe = xb + wb; - xc = c->x; - borrow = 0; -#ifdef ULLong - do { - y = (ULLong)*xa++ - *xb++ - borrow; - borrow = y >> 32 & (ULong)1; - *xc++ = (ULong)y & FFFFFFFF; - } - while(xb < xbe); - while(xa < xae) { - y = *xa++ - borrow; - borrow = y >> 32 & (ULong)1; - *xc++ = (ULong)y & FFFFFFFF; - } -#else -#ifdef Pack_32 - do { - y = (*xa & 0xffff) - (*xb & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*xa++ >> 16) - (*xb++ >> 16) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(xc, z, y); - } - while(xb < xbe); - while(xa < xae) { - y = (*xa & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*xa++ >> 16) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(xc, z, y); - } -#else - do { - y = *xa++ - *xb++ - borrow; - borrow = (y & 0x10000) >> 16; - *xc++ = y & 0xffff; - } - while(xb < xbe); - while(xa < xae) { - y = *xa++ - borrow; - borrow = (y & 0x10000) >> 16; - *xc++ = y & 0xffff; - } -#endif -#endif - while(!*--xc) - wa--; - c->wds = wa; - return c; - } - - static double -ulp -#ifdef KR_headers - (x) double x; -#else - (double x) -#endif -{ - register Long L; - double a; - - L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; -#ifndef Avoid_Underflow -#ifndef Sudden_Underflow - if (L > 0) { -#endif -#endif -#ifdef IBM - L |= Exp_msk1 >> 4; -#endif - word0(a) = L; - word1(a) = 0; -#ifndef Avoid_Underflow -#ifndef Sudden_Underflow - } - else { - L = -L >> Exp_shift; - if (L < Exp_shift) { - word0(a) = 0x80000 >> L; - word1(a) = 0; - } - else { - word0(a) = 0; - L -= Exp_shift; - word1(a) = L >= 31 ? 1 : 1 << 31 - L; - } - } -#endif -#endif - return dval(a); - } - - static double -b2d -#ifdef KR_headers - (a, e) Bigint *a; int *e; -#else - (Bigint *a, int *e) -#endif -{ - ULong *xa, *xa0, w, y, z; - int k; - double d; -#ifdef VAX - ULong d0, d1; -#else -#define d0 word0(d) -#define d1 word1(d) -#endif - - xa0 = a->x; - xa = xa0 + a->wds; - y = *--xa; -#ifdef DEBUG - if (!y) Bug("zero y in b2d"); -#endif - k = hi0bits(y); - *e = 32 - k; -#ifdef Pack_32 - if (k < Ebits) { - d0 = Exp_1 | y >> Ebits - k; - w = xa > xa0 ? *--xa : 0; - d1 = y << (32-Ebits) + k | w >> Ebits - k; - goto ret_d; - } - z = xa > xa0 ? *--xa : 0; - if (k -= Ebits) { - d0 = Exp_1 | y << k | z >> 32 - k; - y = xa > xa0 ? *--xa : 0; - d1 = z << k | y >> 32 - k; - } - else { - d0 = Exp_1 | y; - d1 = z; - } -#else - if (k < Ebits + 16) { - z = xa > xa0 ? *--xa : 0; - d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k; - w = xa > xa0 ? *--xa : 0; - y = xa > xa0 ? *--xa : 0; - d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k; - goto ret_d; - } - z = xa > xa0 ? *--xa : 0; - w = xa > xa0 ? *--xa : 0; - k -= Ebits + 16; - d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k; - y = xa > xa0 ? *--xa : 0; - d1 = w << k + 16 | y << k; -#endif - ret_d: -#ifdef VAX - word0(d) = d0 >> 16 | d0 << 16; - word1(d) = d1 >> 16 | d1 << 16; -#else -#undef d0 -#undef d1 -#endif - return dval(d); - } - - static Bigint * -d2b -#ifdef KR_headers - (d, e, bits) double d; int *e, *bits; -#else - (double d, int *e, int *bits) -#endif -{ - Bigint *b; - int de, k; - ULong *x, y, z; -#ifndef Sudden_Underflow - int i; -#endif -#ifdef VAX - ULong d0, d1; - d0 = word0(d) >> 16 | word0(d) << 16; - d1 = word1(d) >> 16 | word1(d) << 16; -#else -#define d0 word0(d) -#define d1 word1(d) -#endif - -#ifdef Pack_32 - b = Balloc(1); -#else - b = Balloc(2); -#endif - x = b->x; - - z = d0 & Frac_mask; - d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ -#ifdef Sudden_Underflow - de = (int)(d0 >> Exp_shift); -#ifndef IBM - z |= Exp_msk11; -#endif -#else - if ((de = (int)(d0 >> Exp_shift))) - z |= Exp_msk1; -#endif -#ifdef Pack_32 - if ((y = d1)) { - if ((k = lo0bits(&y))) { - x[0] = y | z << 32 - k; - z >>= k; - } - else - x[0] = y; -#ifndef Sudden_Underflow - i = -#endif - b->wds = (x[1] = z) ? 2 : 1; - } - else { -#ifdef DEBUG - if (!z) - Bug("Zero passed to d2b"); -#endif - k = lo0bits(&z); - x[0] = z; -#ifndef Sudden_Underflow - i = -#endif - b->wds = 1; - k += 32; - } -#else - if (y = d1) { - if (k = lo0bits(&y)) - if (k >= 16) { - x[0] = y | z << 32 - k & 0xffff; - x[1] = z >> k - 16 & 0xffff; - x[2] = z >> k; - i = 2; - } - else { - x[0] = y & 0xffff; - x[1] = y >> 16 | z << 16 - k & 0xffff; - x[2] = z >> k & 0xffff; - x[3] = z >> k+16; - i = 3; - } - else { - x[0] = y & 0xffff; - x[1] = y >> 16; - x[2] = z & 0xffff; - x[3] = z >> 16; - i = 3; - } - } - else { -#ifdef DEBUG - if (!z) - Bug("Zero passed to d2b"); -#endif - k = lo0bits(&z); - if (k >= 16) { - x[0] = z; - i = 0; - } - else { - x[0] = z & 0xffff; - x[1] = z >> 16; - i = 1; - } - k += 32; - } - while(!x[i]) - --i; - b->wds = i + 1; -#endif -#ifndef Sudden_Underflow - if (de) { -#endif -#ifdef IBM - *e = (de - Bias - (P-1) << 2) + k; - *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask); -#else - *e = de - Bias - (P-1) + k; - *bits = P - k; -#endif -#ifndef Sudden_Underflow - } - else { - *e = de - Bias - (P-1) + 1 + k; -#ifdef Pack_32 - *bits = 32*i - hi0bits(x[i-1]); -#else - *bits = (i+2)*16 - hi0bits(x[i]); -#endif - } -#endif - return b; - } -#undef d0 -#undef d1 - - static double -ratio -#ifdef KR_headers - (a, b) Bigint *a, *b; -#else - (Bigint *a, Bigint *b) -#endif -{ - double da, db; - int k, ka, kb; - - dval(da) = b2d(a, &ka); - dval(db) = b2d(b, &kb); -#ifdef Pack_32 - k = ka - kb + 32*(a->wds - b->wds); -#else - k = ka - kb + 16*(a->wds - b->wds); -#endif -#ifdef IBM - if (k > 0) { - word0(da) += (k >> 2)*Exp_msk1; - if (k &= 3) - dval(da) *= 1 << k; - } - else { - k = -k; - word0(db) += (k >> 2)*Exp_msk1; - if (k &= 3) - dval(db) *= 1 << k; - } -#else - if (k > 0) - word0(da) += k*Exp_msk1; - else { - k = -k; - word0(db) += k*Exp_msk1; - } -#endif - return dval(da) / dval(db); - } - - static CONST_ double -tens[] = { - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - 1e20, 1e21, 1e22 -#ifdef VAX - , 1e23, 1e24 -#endif - }; - - static CONST_ double -#ifdef IEEE_Arith -bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; -static CONST_ double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, -#ifdef Avoid_Underflow - 9007199254740992.*9007199254740992.e-256 - /* = 2^106 * 1e-53 */ -#else - 1e-256 -#endif - }; -/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */ -/* flag unnecessarily. It leads to a song and dance at the end of strtod. */ -#define Scale_Bit 0x10 -#define n_bigtens 5 -#else -#ifdef IBM -bigtens[] = { 1e16, 1e32, 1e64 }; -static CONST_ double tinytens[] = { 1e-16, 1e-32, 1e-64 }; -#define n_bigtens 3 -#else -bigtens[] = { 1e16, 1e32 }; -static CONST_ double tinytens[] = { 1e-16, 1e-32 }; -#define n_bigtens 2 -#endif -#endif - -#ifndef IEEE_Arith -#undef INFNAN_CHECK -#endif - -#ifdef INFNAN_CHECK - -#ifndef NAN_WORD0 -#define NAN_WORD0 0x7ff80000 -#endif - -#ifndef NAN_WORD1 -#define NAN_WORD1 0 -#endif - - static int -match -#ifdef KR_headers - (sp, t) char **sp, *t; -#else - (CONST_ char **sp, CONST_ char *t) -#endif -{ - int c, d; - CONST_ char *s = *sp; - - while((d = *t++)) { - if ((c = *++s) >= 'A' && c <= 'Z') - c += 'a' - 'A'; - if (c != d) - return 0; - } - *sp = s + 1; - return 1; - } - -#ifndef No_Hex_NaN - static void -hexnan -#ifdef KR_headers - (rvp, sp) double *rvp; CONST_ char **sp; -#else - (double *rvp, CONST_ char **sp) -#endif -{ - ULong c, x[2]; - CONST_ char *s; - int havedig, udx0, xshift; - - x[0] = x[1] = 0; - havedig = xshift = 0; - udx0 = 1; - s = *sp; - while((c = *(CONST_ unsigned char*)++s)) { - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'a' && c <= 'f') - c += 10 - 'a'; - else if (c >= 'A' && c <= 'F') - c += 10 - 'A'; - else if (c <= ' ') { - if (udx0 && havedig) { - udx0 = 0; - xshift = 1; - } - continue; - } - else if (/*(*/ c == ')' && havedig) { - *sp = s + 1; - break; - } - else - return; /* invalid form: don't change *sp */ - havedig = 1; - if (xshift) { - xshift = 0; - x[0] = x[1]; - x[1] = 0; - } - if (udx0) - x[0] = (x[0] << 4) | (x[1] >> 28); - x[1] = (x[1] << 4) | c; - } - if ((x[0] &= 0xfffff) || x[1]) { - word0(*rvp) = Exp_mask | x[0]; - word1(*rvp) = x[1]; - } - } -#endif /*No_Hex_NaN*/ -#endif /* INFNAN_CHECK */ - - double -strtod -#ifdef KR_headers - (s00, se) CONST_ char *s00; char **se; -#else - (CONST_ char *s00, char **se) -#endif -{ -#ifdef Avoid_Underflow - int scale; -#endif - int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, - e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; - CONST_ char *s, *s0, *s1; - double aadj, aadj1, adj, rv, rv0; - Long L; - ULong y, z; - Bigint *bb = NULL, *bb1 = NULL, *bd = NULL, *bd0 = NULL, *bs = NULL, *delta = NULL; -#ifdef SET_INEXACT - int inexact, oldinexact; -#endif -#ifdef Honor_FLT_ROUNDS - int rounding; -#endif - - sign = nz0 = nz = 0; - dval(rv) = 0.; - for(s = s00;;s++) switch(*s) { - case '-': - sign = 1; - /* no break */ - case '+': - if (*++s) - goto break2; - /* no break */ - case 0: - goto ret0; - case '\t': - case '\n': - case '\v': - case '\f': - case '\r': - case ' ': - continue; - default: - goto break2; - } - break2: - if (*s == '0') { - nz0 = 1; - while(*++s == '0') ; - if (!*s) - goto ret; - } - s0 = s; - y = z = 0; - for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) - if (nd < 9) - y = 10*y + c - '0'; - else if (nd < 16) - z = 10*z + c - '0'; - nd0 = nd; - if (c == '.') { - c = *++s; - if (!nd) { - for(; c == '0'; c = *++s) - nz++; - if (c > '0' && c <= '9') { - s0 = s; - nf += nz; - nz = 0; - goto have_dig; - } - goto dig_done; - } - for(; c >= '0' && c <= '9'; c = *++s) { - have_dig: - nz++; - if (c -= '0') { - nf += nz; - for(i = 1; i < nz; i++) - if (nd++ < 9) - y *= 10; - else if (nd <= DBL_DIG + 1) - z *= 10; - if (nd++ < 9) - y = 10*y + c; - else if (nd <= DBL_DIG + 1) - z = 10*z + c; - nz = 0; - } - } - } - dig_done: - e = 0; - if (c == 'e' || c == 'E') { - if (!nd && !nz && !nz0) { - goto ret0; - } - s00 = s; - esign = 0; - switch(c = *++s) { - case '-': - esign = 1; - case '+': - c = *++s; - } - if (c >= '0' && c <= '9') { - while(c == '0') - c = *++s; - if (c > '0' && c <= '9') { - L = c - '0'; - s1 = s; - while((c = *++s) >= '0' && c <= '9') - L = 10*L + c - '0'; - if (s - s1 > 8 || L > 19999) - /* Avoid confusion from exponents - * so large that e might overflow. - */ - e = 19999; /* safe for 16 bit ints */ - else - e = (int)L; - if (esign) - e = -e; - } - else - e = 0; - } - else - s = s00; - } - if (!nd) { - if (!nz && !nz0) { -#ifdef INFNAN_CHECK - /* Check for Nan and Infinity */ - switch(c) { - case 'i': - case 'I': - if (match(&s,"nf")) { - --s; - if (!match(&s,"inity")) - ++s; - word0(rv) = 0x7ff00000; - word1(rv) = 0; - goto ret; - } - break; - case 'n': - case 'N': - if (match(&s, "an")) { - word0(rv) = NAN_WORD0; - word1(rv) = NAN_WORD1; -#ifndef No_Hex_NaN - if (*s == '(') /*)*/ - hexnan(&rv, &s); -#endif - goto ret; - } - } -#endif /* INFNAN_CHECK */ - ret0: - s = s00; - sign = 0; - } - goto ret; - } - e1 = e -= nf; - - /* Now we have nd0 digits, starting at s0, followed by a - * decimal point, followed by nd-nd0 digits. The number we're - * after is the integer represented by those digits times - * 10**e */ - - if (!nd0) - nd0 = nd; - k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; - dval(rv) = y; - if (k > 9) { -#ifdef SET_INEXACT - if (k > DBL_DIG) - oldinexact = get_inexact(); -#endif - dval(rv) = tens[k - 9] * dval(rv) + z; - } - bd0 = 0; - if (nd <= DBL_DIG -#ifndef RND_PRODQUOT -#ifndef Honor_FLT_ROUNDS - && Flt_Rounds == 1 -#endif -#endif - ) { - if (!e) - goto ret; - if (e > 0) { - if (e <= Ten_pmax) { -#ifdef VAX - goto vax_ovfl_check; -#else -#ifdef Honor_FLT_ROUNDS - /* round correctly FLT_ROUNDS = 2 or 3 */ - if (sign) { - rv = -rv; - sign = 0; - } -#endif - /* rv = */ rounded_product(dval(rv), tens[e]); - goto ret; -#endif - } - i = DBL_DIG - nd; - if (e <= Ten_pmax + i) { - /* A fancier test would sometimes let us do - * this for larger i values. - */ -#ifdef Honor_FLT_ROUNDS - /* round correctly FLT_ROUNDS = 2 or 3 */ - if (sign) { - rv = -rv; - sign = 0; - } -#endif - e -= i; - dval(rv) *= tens[i]; -#ifdef VAX - /* VAX exponent range is so narrow we must - * worry about overflow here... - */ - vax_ovfl_check: - word0(rv) -= P*Exp_msk1; - /* rv = */ rounded_product(dval(rv), tens[e]); - if ((word0(rv) & Exp_mask) - > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) - goto ovfl; - word0(rv) += P*Exp_msk1; -#else - /* rv = */ rounded_product(dval(rv), tens[e]); -#endif - goto ret; - } - } -#ifndef Inaccurate_Divide - else if (e >= -Ten_pmax) { -#ifdef Honor_FLT_ROUNDS - /* round correctly FLT_ROUNDS = 2 or 3 */ - if (sign) { - rv = -rv; - sign = 0; - } -#endif - /* rv = */ rounded_quotient(dval(rv), tens[-e]); - goto ret; - } -#endif - } - e1 += nd - k; - -#ifdef IEEE_Arith -#ifdef SET_INEXACT - inexact = 1; - if (k <= DBL_DIG) - oldinexact = get_inexact(); -#endif -#ifdef Avoid_Underflow - scale = 0; -#endif -#ifdef Honor_FLT_ROUNDS - if ((rounding = Flt_Rounds) >= 2) { - if (sign) - rounding = rounding == 2 ? 0 : 2; - else - if (rounding != 2) - rounding = 0; - } -#endif -#endif /*IEEE_Arith*/ - - /* Get starting approximation = rv * 10**e1 */ - - if (e1 > 0) { - if ((i = e1 & 15)) - dval(rv) *= tens[i]; - if (e1 &= ~15) { - if (e1 > DBL_MAX_10_EXP) { - ovfl: -#ifndef NO_ERRNO - errno = ERANGE; -#endif - /* Can't trust HUGE_VAL */ -#ifdef IEEE_Arith -#ifdef Honor_FLT_ROUNDS - switch(rounding) { - case 0: /* toward 0 */ - case 3: /* toward -infinity */ - word0(rv) = Big0; - word1(rv) = Big1; - break; - default: - word0(rv) = Exp_mask; - word1(rv) = 0; - } -#else /*Honor_FLT_ROUNDS*/ - word0(rv) = Exp_mask; - word1(rv) = 0; -#endif /*Honor_FLT_ROUNDS*/ -#ifdef SET_INEXACT - /* set overflow bit */ - dval(rv0) = 1e300; - dval(rv0) *= dval(rv0); -#endif -#else /*IEEE_Arith*/ - word0(rv) = Big0; - word1(rv) = Big1; -#endif /*IEEE_Arith*/ - if (bd0) - goto retfree; - goto ret; - } - e1 >>= 4; - for(j = 0; e1 > 1; j++, e1 >>= 1) - if (e1 & 1) - dval(rv) *= bigtens[j]; - /* The last multiplication could overflow. */ - word0(rv) -= P*Exp_msk1; - dval(rv) *= bigtens[j]; - if ((z = word0(rv) & Exp_mask) - > Exp_msk1*(DBL_MAX_EXP+Bias-P)) - goto ovfl; - if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { - /* set to largest number */ - /* (Can't trust DBL_MAX) */ - word0(rv) = Big0; - word1(rv) = Big1; - } - else - word0(rv) += P*Exp_msk1; - } - } - else if (e1 < 0) { - e1 = -e1; - if ((i = e1 & 15)) - dval(rv) /= tens[i]; - if (e1 >>= 4) { - if (e1 >= 1 << n_bigtens) - goto undfl; -#ifdef Avoid_Underflow - if (e1 & Scale_Bit) - scale = 2*P; - for(j = 0; e1 > 0; j++, e1 >>= 1) - if (e1 & 1) - dval(rv) *= tinytens[j]; - if (scale && (j = 2*P + 1 - ((word0(rv) & Exp_mask) - >> Exp_shift)) > 0) { - /* scaled rv is denormal; zap j low bits */ - if (j >= 32) { - word1(rv) = 0; - if (j >= 53) - word0(rv) = (P+2)*Exp_msk1; - else - word0(rv) &= 0xffffffff << j-32; - } - else - word1(rv) &= 0xffffffff << j; - } -#else - for(j = 0; e1 > 1; j++, e1 >>= 1) - if (e1 & 1) - dval(rv) *= tinytens[j]; - /* The last multiplication could underflow. */ - dval(rv0) = dval(rv); - dval(rv) *= tinytens[j]; - if (!dval(rv)) { - dval(rv) = 2.*dval(rv0); - dval(rv) *= tinytens[j]; -#endif - if (!dval(rv)) { - undfl: - dval(rv) = 0.; -#ifndef NO_ERRNO - errno = ERANGE; -#endif - if (bd0) - goto retfree; - goto ret; - } -#ifndef Avoid_Underflow - word0(rv) = Tiny0; - word1(rv) = Tiny1; - /* The refinement below will clean - * this approximation up. - */ - } -#endif - } - } - - /* Now the hard part -- adjusting rv to the correct value.*/ - - /* Put digits into bd: true value = bd * 10^e */ - - bd0 = s2b(s0, nd0, nd, y); - - for(;;) { - bd = Balloc(bd0->k); - Bcopy(bd, bd0); - bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */ - bs = i2b(1); - - if (e >= 0) { - bb2 = bb5 = 0; - bd2 = bd5 = e; - } - else { - bb2 = bb5 = -e; - bd2 = bd5 = 0; - } - if (bbe >= 0) - bb2 += bbe; - else - bd2 -= bbe; - bs2 = bb2; -#ifdef Honor_FLT_ROUNDS - if (rounding != 1) - bs2++; -#endif -#ifdef Avoid_Underflow - j = bbe - scale; - i = j + bbbits - 1; /* logb(rv) */ - if (i < Emin) /* denormal */ - j += P - Emin; - else - j = P + 1 - bbbits; -#else /*Avoid_Underflow*/ -#ifdef Sudden_Underflow -#ifdef IBM - j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); -#else - j = P + 1 - bbbits; -#endif -#else /*Sudden_Underflow*/ - j = bbe; - i = j + bbbits - 1; /* logb(rv) */ - if (i < Emin) /* denormal */ - j += P - Emin; - else - j = P + 1 - bbbits; -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow*/ - bb2 += j; - bd2 += j; -#ifdef Avoid_Underflow - bd2 += scale; -#endif - i = bb2 < bd2 ? bb2 : bd2; - if (i > bs2) - i = bs2; - if (i > 0) { - bb2 -= i; - bd2 -= i; - bs2 -= i; - } - if (bb5 > 0) { - bs = pow5mult(bs, bb5); - bb1 = mult(bs, bb); - Bfree(bb); - bb = bb1; - } - if (bb2 > 0) - bb = lshift(bb, bb2); - if (bd5 > 0) - bd = pow5mult(bd, bd5); - if (bd2 > 0) - bd = lshift(bd, bd2); - if (bs2 > 0) - bs = lshift(bs, bs2); - delta = diff(bb, bd); - dsign = delta->sign; - delta->sign = 0; - i = cmp(delta, bs); -#ifdef Honor_FLT_ROUNDS - if (rounding != 1) { - if (i < 0) { - /* Error is less than an ulp */ - if (!delta->x[0] && delta->wds <= 1) { - /* exact */ -#ifdef SET_INEXACT - inexact = 0; -#endif - break; - } - if (rounding) { - if (dsign) { - adj = 1.; - goto apply_adj; - } - } - else if (!dsign) { - adj = -1.; - if (!word1(rv) - && !(word0(rv) & Frac_mask)) { - y = word0(rv) & Exp_mask; -#ifdef Avoid_Underflow - if (!scale || y > 2*P*Exp_msk1) -#else - if (y) -#endif - { - delta = lshift(delta,Log2P); - if (cmp(delta, bs) <= 0) - adj = -0.5; - } - } - apply_adj: -#ifdef Avoid_Underflow - if (scale && (y = word0(rv) & Exp_mask) - <= 2*P*Exp_msk1) - word0(adj) += (2*P+1)*Exp_msk1 - y; -#else -#ifdef Sudden_Underflow - if ((word0(rv) & Exp_mask) <= - P*Exp_msk1) { - word0(rv) += P*Exp_msk1; - dval(rv) += adj*ulp(dval(rv)); - word0(rv) -= P*Exp_msk1; - } - else -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow*/ - dval(rv) += adj*ulp(dval(rv)); - } - break; - } - adj = ratio(delta, bs); - if (adj < 1.) - adj = 1.; - if (adj <= 0x7ffffffe) { - /* adj = rounding ? ceil(adj) : floor(adj); */ - y = adj; - if (y != adj) { - if (!((rounding>>1) ^ dsign)) - y++; - adj = y; - } - } -#ifdef Avoid_Underflow - if (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1) - word0(adj) += (2*P+1)*Exp_msk1 - y; -#else -#ifdef Sudden_Underflow - if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { - word0(rv) += P*Exp_msk1; - adj *= ulp(dval(rv)); - if (dsign) - dval(rv) += adj; - else - dval(rv) -= adj; - word0(rv) -= P*Exp_msk1; - goto cont; - } -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow*/ - adj *= ulp(dval(rv)); - if (dsign) - dval(rv) += adj; - else - dval(rv) -= adj; - goto cont; - } -#endif /*Honor_FLT_ROUNDS*/ - - if (i < 0) { - /* Error is less than half an ulp -- check for - * special case of mantissa a power of two. - */ - if (dsign || word1(rv) || word0(rv) & Bndry_mask -#ifdef IEEE_Arith -#ifdef Avoid_Underflow - || (word0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1 -#else - || (word0(rv) & Exp_mask) <= Exp_msk1 -#endif -#endif - ) { -#ifdef SET_INEXACT - if (!delta->x[0] && delta->wds <= 1) - inexact = 0; -#endif - break; - } - if (!delta->x[0] && delta->wds <= 1) { - /* exact result */ -#ifdef SET_INEXACT - inexact = 0; -#endif - break; - } - delta = lshift(delta,Log2P); - if (cmp(delta, bs) > 0) - goto drop_down; - break; - } - if (i == 0) { - /* exactly half-way between */ - if (dsign) { - if ((word0(rv) & Bndry_mask1) == Bndry_mask1 - && word1(rv) == ( -#ifdef Avoid_Underflow - (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1) - ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) : -#endif - 0xffffffff)) { - /*boundary case -- increment exponent*/ - word0(rv) = (word0(rv) & Exp_mask) - + Exp_msk1 -#ifdef IBM - | Exp_msk1 >> 4 -#endif - ; - word1(rv) = 0; -#ifdef Avoid_Underflow - dsign = 0; -#endif - break; - } - } - else if (!(word0(rv) & Bndry_mask) && !word1(rv)) { - drop_down: - /* boundary case -- decrement exponent */ -#ifdef Sudden_Underflow /*{{*/ - L = word0(rv) & Exp_mask; -#ifdef IBM - if (L < Exp_msk1) -#else -#ifdef Avoid_Underflow - if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1)) -#else - if (L <= Exp_msk1) -#endif /*Avoid_Underflow*/ -#endif /*IBM*/ - goto undfl; - L -= Exp_msk1; -#else /*Sudden_Underflow}{*/ -#ifdef Avoid_Underflow - if (scale) { - L = word0(rv) & Exp_mask; - if (L <= (2*P+1)*Exp_msk1) { - if (L > (P+2)*Exp_msk1) - /* round even ==> */ - /* accept rv */ - break; - /* rv = smallest denormal */ - goto undfl; - } - } -#endif /*Avoid_Underflow*/ - L = (word0(rv) & Exp_mask) - Exp_msk1; -#endif /*Sudden_Underflow}}*/ - word0(rv) = L | Bndry_mask1; - word1(rv) = 0xffffffff; -#ifdef IBM - goto cont; -#else - break; -#endif - } -#ifndef ROUND_BIASED - if (!(word1(rv) & LSB)) - break; -#endif - if (dsign) - dval(rv) += ulp(dval(rv)); -#ifndef ROUND_BIASED - else { - dval(rv) -= ulp(dval(rv)); -#ifndef Sudden_Underflow - if (!dval(rv)) - goto undfl; -#endif - } -#ifdef Avoid_Underflow - dsign = 1 - dsign; -#endif -#endif - break; - } - if ((aadj = ratio(delta, bs)) <= 2.) { - if (dsign) - aadj = aadj1 = 1.; - else if (word1(rv) || word0(rv) & Bndry_mask) { -#ifndef Sudden_Underflow - if (word1(rv) == Tiny1 && !word0(rv)) - goto undfl; -#endif - aadj = 1.; - aadj1 = -1.; - } - else { - /* special case -- power of FLT_RADIX to be */ - /* rounded down... */ - - if (aadj < 2./FLT_RADIX) - aadj = 1./FLT_RADIX; - else - aadj *= 0.5; - aadj1 = -aadj; - } - } - else { - aadj *= 0.5; - aadj1 = dsign ? aadj : -aadj; -#ifdef Check_FLT_ROUNDS - switch(Rounding) { - case 2: /* towards +infinity */ - aadj1 -= 0.5; - break; - case 0: /* towards 0 */ - case 3: /* towards -infinity */ - aadj1 += 0.5; - } -#else - if (Flt_Rounds == 0) - aadj1 += 0.5; -#endif /*Check_FLT_ROUNDS*/ - } - y = word0(rv) & Exp_mask; - - /* Check for overflow */ - - if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { - dval(rv0) = dval(rv); - word0(rv) -= P*Exp_msk1; - adj = aadj1 * ulp(dval(rv)); - dval(rv) += adj; - if ((word0(rv) & Exp_mask) >= - Exp_msk1*(DBL_MAX_EXP+Bias-P)) { - if (word0(rv0) == Big0 && word1(rv0) == Big1) - goto ovfl; - word0(rv) = Big0; - word1(rv) = Big1; - goto cont; - } - else - word0(rv) += P*Exp_msk1; - } - else { -#ifdef Avoid_Underflow - if (scale && y <= 2*P*Exp_msk1) { - if (aadj <= 0x7fffffff) { - if ((z = (ULong)aadj) <= 0) - z = 1; - aadj = z; - aadj1 = dsign ? aadj : -aadj; - } - word0(aadj1) += (2*P+1)*Exp_msk1 - y; - } - adj = aadj1 * ulp(dval(rv)); - dval(rv) += adj; -#else -#ifdef Sudden_Underflow - if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { - dval(rv0) = dval(rv); - word0(rv) += P*Exp_msk1; - adj = aadj1 * ulp(dval(rv)); - dval(rv) += adj; -#ifdef IBM - if ((word0(rv) & Exp_mask) < P*Exp_msk1) -#else - if ((word0(rv) & Exp_mask) <= P*Exp_msk1) -#endif - { - if (word0(rv0) == Tiny0 - && word1(rv0) == Tiny1) - goto undfl; - word0(rv) = Tiny0; - word1(rv) = Tiny1; - goto cont; - } - else - word0(rv) -= P*Exp_msk1; - } - else { - adj = aadj1 * ulp(dval(rv)); - dval(rv) += adj; - } -#else /*Sudden_Underflow*/ - /* Compute adj so that the IEEE rounding rules will - * correctly round rv + adj in some half-way cases. - * If rv * ulp(rv) is denormalized (i.e., - * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid - * trouble from bits lost to denormalization; - * example: 1.2e-307 . - */ - if (y <= (P-1)*Exp_msk1 && aadj > 1.) { - aadj1 = (double)(int)(aadj + 0.5); - if (!dsign) - aadj1 = -aadj1; - } - adj = aadj1 * ulp(dval(rv)); - dval(rv) += adj; -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow*/ - } - z = word0(rv) & Exp_mask; -#ifndef SET_INEXACT -#ifdef Avoid_Underflow - if (!scale) -#endif - if (y == z) { - /* Can we stop now? */ - L = (Long)aadj; - aadj -= L; - /* The tolerances below are conservative. */ - if (dsign || word1(rv) || word0(rv) & Bndry_mask) { - if (aadj < .4999999 || aadj > .5000001) - break; - } - else if (aadj < .4999999/FLT_RADIX) - break; - } -#endif - cont: - Bfree(bb); - Bfree(bd); - Bfree(bs); - Bfree(delta); - } -#ifdef SET_INEXACT - if (inexact) { - if (!oldinexact) { - word0(rv0) = Exp_1 + (70 << Exp_shift); - word1(rv0) = 0; - dval(rv0) += 1.; - } - } - else if (!oldinexact) - clear_inexact(); -#endif -#ifdef Avoid_Underflow - if (scale) { - word0(rv0) = Exp_1 - 2*P*Exp_msk1; - word1(rv0) = 0; - dval(rv) *= dval(rv0); -#ifndef NO_ERRNO - /* try to avoid the bug of testing an 8087 register value */ - if (word0(rv) == 0 && word1(rv) == 0) - errno = ERANGE; -#endif - } -#endif /* Avoid_Underflow */ -#ifdef SET_INEXACT - if (inexact && !(word0(rv) & Exp_mask)) { - /* set underflow bit */ - dval(rv0) = 1e-300; - dval(rv0) *= dval(rv0); - } -#endif - retfree: - Bfree(bb); - Bfree(bd); - Bfree(bs); - Bfree(bd0); - Bfree(delta); - ret: - if (se) - *se = (char *)s; - return sign ? -dval(rv) : dval(rv); - } - - static int -quorem -#ifdef KR_headers - (b, S) Bigint *b, *S; -#else - (Bigint *b, Bigint *S) -#endif -{ - int n; - ULong *bx, *bxe, q, *sx, *sxe; -#ifdef ULLong - ULLong borrow, carry, y, ys; -#else - ULong borrow, carry, y, ys; -#ifdef Pack_32 - ULong si, z, zs; -#endif -#endif - - n = S->wds; -#ifdef DEBUG - /*debug*/ if (b->wds > n) - /*debug*/ Bug("oversize b in quorem"); -#endif - if (b->wds < n) - return 0; - sx = S->x; - sxe = sx + --n; - bx = b->x; - bxe = bx + n; - q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ -#ifdef DEBUG - /*debug*/ if (q > 9) - /*debug*/ Bug("oversized quotient in quorem"); -#endif - if (q) { - borrow = 0; - carry = 0; - do { -#ifdef ULLong - ys = *sx++ * (ULLong)q + carry; - carry = ys >> 32; - y = *bx - (ys & FFFFFFFF) - borrow; - borrow = y >> 32 & (ULong)1; - *bx++ = (ULong)y & FFFFFFFF; -#else -#ifdef Pack_32 - si = *sx++; - ys = (si & 0xffff) * q + carry; - zs = (si >> 16) * q + (ys >> 16); - carry = zs >> 16; - y = (*bx & 0xffff) - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*bx >> 16) - (zs & 0xffff) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(bx, z, y); -#else - ys = *sx++ * q + carry; - carry = ys >> 16; - y = *bx - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - *bx++ = y & 0xffff; -#endif -#endif - } - while(sx <= sxe); - if (!*bxe) { - bx = b->x; - while(--bxe > bx && !*bxe) - --n; - b->wds = n; - } - } - if (cmp(b, S) >= 0) { - q++; - borrow = 0; - carry = 0; - bx = b->x; - sx = S->x; - do { -#ifdef ULLong - ys = *sx++ + carry; - carry = ys >> 32; - y = *bx - (ys & FFFFFFFF) - borrow; - borrow = y >> 32 & (ULong)1; - *bx++ = (ULong)y & FFFFFFFF; -#else -#ifdef Pack_32 - si = *sx++; - ys = (si & 0xffff) + carry; - zs = (si >> 16) + (ys >> 16); - carry = zs >> 16; - y = (*bx & 0xffff) - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*bx >> 16) - (zs & 0xffff) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(bx, z, y); -#else - ys = *sx++ + carry; - carry = ys >> 16; - y = *bx - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - *bx++ = y & 0xffff; -#endif -#endif - } - while(sx <= sxe); - bx = b->x; - bxe = bx + n; - if (!*bxe) { - while(--bxe > bx && !*bxe) - --n; - b->wds = n; - } - } - return q; - } - -#ifndef MULTIPLE_THREADS - static char *dtoa_result; -#endif - - static char * -#ifdef KR_headers -rv_alloc(i) int i; -#else -rv_alloc(int i) -#endif -{ - int j, k, *r; - - j = sizeof(ULong); - for(k = 0; - sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= (unsigned)i; - j <<= 1) - k++; - r = (int*)Balloc(k); - *r = k; - return -#ifndef MULTIPLE_THREADS - dtoa_result = -#endif - (char *)(r+1); - } - - static char * -#ifdef KR_headers -nrv_alloc(s, rve, n) char *s, **rve; int n; -#else -nrv_alloc(CONST_ char *s, char **rve, int n) -#endif -{ - char *rv, *t; - - t = rv = rv_alloc(n); - while((*t = *s++)) t++; - if (rve) - *rve = t; - return rv; - } - -/* freedtoa(s) must be used to free values s returned by dtoa - * when MULTIPLE_THREADS is #defined. It should be used in all cases, - * but for consistency with earlier versions of dtoa, it is optional - * when MULTIPLE_THREADS is not defined. - */ - - void -#ifdef KR_headers -freedtoa(s) char *s; -#else -freedtoa(char *s) -#endif -{ - Bigint *b = (Bigint *)((int *)s - 1); - b->maxwds = 1 << (b->k = *(int*)b); - Bfree(b); -#ifndef MULTIPLE_THREADS - if (s == dtoa_result) - dtoa_result = 0; -#endif - } - -/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. - * - * Inspired by "How to Print Floating-Point Numbers Accurately" by - * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101]. - * - * Modifications: - * 1. Rather than iterating, we use a simple numeric overestimate - * to determine k = floor(log10(d)). We scale relevant - * quantities using O(log2(k)) rather than O(k) multiplications. - * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't - * try to generate digits strictly left to right. Instead, we - * compute with fewer bits and propagate the carry if necessary - * when rounding the final digit up. This is often faster. - * 3. Under the assumption that input will be rounded nearest, - * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. - * That is, we allow equality in stopping tests when the - * round-nearest rule will give the same floating-point value - * as would satisfaction of the stopping test with strict - * inequality. - * 4. We remove common factors of powers of 2 from relevant - * quantities. - * 5. When converting floating-point integers less than 1e16, - * we use floating-point arithmetic rather than resorting - * to multiple-precision integers. - * 6. When asked to produce fewer than 15 digits, we first try - * to get by with floating-point arithmetic; we resort to - * multiple-precision integer arithmetic only if we cannot - * guarantee that the floating-point calculation has given - * the correctly rounded result. For k requested digits and - * "uniformly" distributed input, the probability is - * something like 10^(k-15) that we must resort to the Long - * calculation. - */ - - char * -dtoa -#ifdef KR_headers - (d, mode, ndigits, decpt, sign, rve) - double d; int mode, ndigits, *decpt, *sign; char **rve; -#else - (double d, int mode, int ndigits, int *decpt, int *sign, char **rve) -#endif -{ - /* Arguments ndigits, decpt, sign are similar to those - of ecvt and fcvt; trailing zeros are suppressed from - the returned string. If not null, *rve is set to point - to the end of the return value. If d is +-Infinity or NaN, - then *decpt is set to 9999. - - mode: - 0 ==> shortest string that yields d when read in - and rounded to nearest. - 1 ==> like 0, but with Steele & White stopping rule; - e.g. with IEEE P754 arithmetic , mode 0 gives - 1e23 whereas mode 1 gives 9.999999999999999e22. - 2 ==> max(1,ndigits) significant digits. This gives a - return value similar to that of ecvt, except - that trailing zeros are suppressed. - 3 ==> through ndigits past the decimal point. This - gives a return value similar to that from fcvt, - except that trailing zeros are suppressed, and - ndigits can be negative. - 4,5 ==> similar to 2 and 3, respectively, but (in - round-nearest mode) with the tests of mode 0 to - possibly return a shorter string that rounds to d. - With IEEE arithmetic and compilation with - -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same - as modes 2 and 3 when FLT_ROUNDS != 1. - 6-9 ==> Debugging modes similar to mode - 4: don't try - fast floating-point estimate (if applicable). - - Values of mode other than 0-9 are treated as mode 0. - - Sufficient space is allocated to the return value - to hold the suppressed trailing zeros. - */ - - int bbits, b2, b5, be, dig, i, ieps, ilim = 0, ilim0, ilim1 = 0, - j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, - spec_case, try_quick; - Long L; -#ifndef Sudden_Underflow - int denorm; - ULong x; -#endif - Bigint *b, *b1, *delta, *mlo = NULL, *mhi, *S; - double d2, ds, eps; - char *s, *s0; -#ifdef Honor_FLT_ROUNDS - int rounding; -#endif -#ifdef SET_INEXACT - int inexact, oldinexact; -#endif - -#ifndef MULTIPLE_THREADS - if (dtoa_result) { - freedtoa(dtoa_result); - dtoa_result = 0; - } -#endif - - if (word0(d) & Sign_bit) { - /* set sign for everything, including 0's and NaNs */ - *sign = 1; - word0(d) &= ~Sign_bit; /* clear sign bit */ - } - else - *sign = 0; - -#if defined(IEEE_Arith) + defined(VAX) -#ifdef IEEE_Arith - if ((word0(d) & Exp_mask) == Exp_mask) -#else - if (word0(d) == 0x8000) -#endif - { - /* Infinity or NaN */ - *decpt = 9999; -#ifdef IEEE_Arith - if (!word1(d) && !(word0(d) & 0xfffff)) - return nrv_alloc("Infinity", rve, 8); -#endif - return nrv_alloc("NaN", rve, 3); - } -#endif -#ifdef IBM - dval(d) += 0; /* normalize */ -#endif - if (!dval(d)) { - *decpt = 1; - return nrv_alloc("0", rve, 1); - } - -#ifdef SET_INEXACT - try_quick = oldinexact = get_inexact(); - inexact = 1; -#endif -#ifdef Honor_FLT_ROUNDS - if ((rounding = Flt_Rounds) >= 2) { - if (*sign) - rounding = rounding == 2 ? 0 : 2; - else - if (rounding != 2) - rounding = 0; - } -#endif - - b = d2b(dval(d), &be, &bbits); -#ifdef Sudden_Underflow - i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); -#else - if ((i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)))) { -#endif - dval(d2) = dval(d); - word0(d2) &= Frac_mask1; - word0(d2) |= Exp_11; -#ifdef IBM - if (j = 11 - hi0bits(word0(d2) & Frac_mask)) - dval(d2) /= 1 << j; -#endif - - /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 - * log10(x) = log(x) / log(10) - * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) - * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) - * - * This suggests computing an approximation k to log10(d) by - * - * k = (i - Bias)*0.301029995663981 - * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); - * - * We want k to be too large rather than too small. - * The error in the first-order Taylor series approximation - * is in our favor, so we just round up the constant enough - * to compensate for any error in the multiplication of - * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, - * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, - * adding 1e-13 to the constant term more than suffices. - * Hence we adjust the constant term to 0.1760912590558. - * (We could get a more accurate k by invoking log10, - * but this is probably not worthwhile.) - */ - - i -= Bias; -#ifdef IBM - i <<= 2; - i += j; -#endif -#ifndef Sudden_Underflow - denorm = 0; - } - else { - /* d is denormalized */ - - i = bbits + be + (Bias + (P-1) - 1); - x = i > 32 ? word0(d) << 64 - i | word1(d) >> i - 32 - : word1(d) << 32 - i; - dval(d2) = x; - word0(d2) -= 31*Exp_msk1; /* adjust exponent */ - i -= (Bias + (P-1) - 1) + 1; - denorm = 1; - } -#endif - ds = (dval(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; - k = (int)ds; - if (ds < 0. && ds != k) - k--; /* want k = floor(ds) */ - k_check = 1; - if (k >= 0 && k <= Ten_pmax) { - if (dval(d) < tens[k]) - k--; - k_check = 0; - } - j = bbits - i - 1; - if (j >= 0) { - b2 = 0; - s2 = j; - } - else { - b2 = -j; - s2 = 0; - } - if (k >= 0) { - b5 = 0; - s5 = k; - s2 += k; - } - else { - b2 -= k; - b5 = -k; - s5 = 0; - } - if (mode < 0 || mode > 9) - mode = 0; - -#ifndef SET_INEXACT -#ifdef Check_FLT_ROUNDS - try_quick = Rounding == 1; -#else - try_quick = 1; -#endif -#endif /*SET_INEXACT*/ - - if (mode > 5) { - mode -= 4; - try_quick = 0; - } - leftright = 1; - switch(mode) { - case 0: - case 1: - ilim = ilim1 = -1; - i = 18; - ndigits = 0; - break; - case 2: - leftright = 0; - /* no break */ - case 4: - if (ndigits <= 0) - ndigits = 1; - ilim = ilim1 = i = ndigits; - break; - case 3: - leftright = 0; - /* no break */ - case 5: - i = ndigits + k + 1; - ilim = i; - ilim1 = i - 1; - if (i <= 0) - i = 1; - } - s = s0 = rv_alloc(i); - -#ifdef Honor_FLT_ROUNDS - if (mode > 1 && rounding != 1) - leftright = 0; -#endif - - if (ilim >= 0 && ilim <= Quick_max && try_quick) { - - /* Try to get by with floating-point arithmetic. */ - - i = 0; - dval(d2) = dval(d); - k0 = k; - ilim0 = ilim; - ieps = 2; /* conservative */ - if (k > 0) { - ds = tens[k&0xf]; - j = k >> 4; - if (j & Bletch) { - /* prevent overflows */ - j &= Bletch - 1; - dval(d) /= bigtens[n_bigtens-1]; - ieps++; - } - for(; j; j >>= 1, i++) - if (j & 1) { - ieps++; - ds *= bigtens[i]; - } - dval(d) /= ds; - } - else if ((j1 = -k)) { - dval(d) *= tens[j1 & 0xf]; - for(j = j1 >> 4; j; j >>= 1, i++) - if (j & 1) { - ieps++; - dval(d) *= bigtens[i]; - } - } - if (k_check && dval(d) < 1. && ilim > 0) { - if (ilim1 <= 0) - goto fast_failed; - ilim = ilim1; - k--; - dval(d) *= 10.; - ieps++; - } - dval(eps) = ieps*dval(d) + 7.; - word0(eps) -= (P-1)*Exp_msk1; - if (ilim == 0) { - S = mhi = 0; - dval(d) -= 5.; - if (dval(d) > dval(eps)) - goto one_digit; - if (dval(d) < -dval(eps)) - goto no_digits; - goto fast_failed; - } -#ifndef No_leftright - if (leftright) { - /* Use Steele & White method of only - * generating digits needed. - */ - dval(eps) = 0.5/tens[ilim-1] - dval(eps); - for(i = 0;;) { - L = (long int)dval(d); - dval(d) -= L; - *s++ = '0' + (int)L; - if (dval(d) < dval(eps)) - goto ret1; - if (1. - dval(d) < dval(eps)) - goto bump_up; - if (++i >= ilim) - break; - dval(eps) *= 10.; - dval(d) *= 10.; - } - } - else { -#endif - /* Generate ilim digits, then fix them up. */ - dval(eps) *= tens[ilim-1]; - for(i = 1;; i++, dval(d) *= 10.) { - L = (Long)(dval(d)); - if (!(dval(d) -= L)) - ilim = i; - *s++ = '0' + (int)L; - if (i == ilim) { - if (dval(d) > 0.5 + dval(eps)) - goto bump_up; - else if (dval(d) < 0.5 - dval(eps)) { - while (*--s == '0') { } - s++; - goto ret1; - } - break; - } - } -#ifndef No_leftright - } -#endif - fast_failed: - s = s0; - dval(d) = dval(d2); - k = k0; - ilim = ilim0; - } - - /* Do we have a "small" integer? */ - - if (be >= 0 && k <= Int_max) { - /* Yes. */ - ds = tens[k]; - if (ndigits < 0 && ilim <= 0) { - S = mhi = 0; - if (ilim < 0 || dval(d) <= 5*ds) - goto no_digits; - goto one_digit; - } - for(i = 1;; i++, dval(d) *= 10.) { - L = (Long)(dval(d) / ds); - dval(d) -= L*ds; -#ifdef Check_FLT_ROUNDS - /* If FLT_ROUNDS == 2, L will usually be high by 1 */ - if (dval(d) < 0) { - L--; - dval(d) += ds; - } -#endif - *s++ = '0' + (int)L; - if (!dval(d)) { -#ifdef SET_INEXACT - inexact = 0; -#endif - break; - } - if (i == ilim) { -#ifdef Honor_FLT_ROUNDS - if (mode > 1) - switch(rounding) { - case 0: goto ret1; - case 2: goto bump_up; - } -#endif - dval(d) += dval(d); - if (dval(d) > ds || dval(d) == ds && L & 1) { - bump_up: - while(*--s == '9') - if (s == s0) { - k++; - *s = '0'; - break; - } - ++*s++; - } - break; - } - } - goto ret1; - } - - m2 = b2; - m5 = b5; - mhi = mlo = 0; - if (leftright) { - i = -#ifndef Sudden_Underflow - denorm ? be + (Bias + (P-1) - 1 + 1) : -#endif -#ifdef IBM - 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3); -#else - 1 + P - bbits; -#endif - b2 += i; - s2 += i; - mhi = i2b(1); - } - if (m2 > 0 && s2 > 0) { - i = m2 < s2 ? m2 : s2; - b2 -= i; - m2 -= i; - s2 -= i; - } - if (b5 > 0) { - if (leftright) { - if (m5 > 0) { - mhi = pow5mult(mhi, m5); - b1 = mult(mhi, b); - Bfree(b); - b = b1; - } - if ((j = b5 - m5)) - b = pow5mult(b, j); - } - else - b = pow5mult(b, b5); - } - S = i2b(1); - if (s5 > 0) - S = pow5mult(S, s5); - - /* Check for special case that d is a normalized power of 2. */ - - spec_case = 0; - if ((mode < 2 || leftright) -#ifdef Honor_FLT_ROUNDS - && rounding == 1 -#endif - ) { - if (!word1(d) && !(word0(d) & Bndry_mask) -#ifndef Sudden_Underflow - && word0(d) & (Exp_mask & ~Exp_msk1) -#endif - ) { - /* The special case */ - b2 += Log2P; - s2 += Log2P; - spec_case = 1; - } - } - - /* Arrange for convenient computation of quotients: - * shift left if necessary so divisor has 4 leading 0 bits. - * - * Perhaps we should just compute leading 28 bits of S once - * and for all and pass them and a shift to quorem, so it - * can do shifts and ors to compute the numerator for q. - */ -#ifdef Pack_32 - if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f)) - i = 32 - i; -#else - if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf) - i = 16 - i; -#endif - if (i > 4) { - i -= 4; - b2 += i; - m2 += i; - s2 += i; - } - else if (i < 4) { - i += 28; - b2 += i; - m2 += i; - s2 += i; - } - if (b2 > 0) - b = lshift(b, b2); - if (s2 > 0) - S = lshift(S, s2); - if (k_check) { - if (cmp(b,S) < 0) { - k--; - b = multadd(b, 10, 0); /* we botched the k estimate */ - if (leftright) - mhi = multadd(mhi, 10, 0); - ilim = ilim1; - } - } - if (ilim <= 0 && (mode == 3 || mode == 5)) { - if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { - /* no digits, fcvt style */ - no_digits: - k = -1 - ndigits; - goto ret; - } - one_digit: - *s++ = '1'; - k++; - goto ret; - } - if (leftright) { - if (m2 > 0) - mhi = lshift(mhi, m2); - - /* Compute mlo -- check for special case - * that d is a normalized power of 2. - */ - - mlo = mhi; - if (spec_case) { - mhi = Balloc(mhi->k); - Bcopy(mhi, mlo); - mhi = lshift(mhi, Log2P); - } - - for(i = 1;;i++) { - dig = quorem(b,S) + '0'; - /* Do we yet have the shortest decimal string - * that will round to d? - */ - j = cmp(b, mlo); - delta = diff(S, mhi); - j1 = delta->sign ? 1 : cmp(b, delta); - Bfree(delta); -#ifndef ROUND_BIASED - if (j1 == 0 && mode != 1 && !(word1(d) & 1) -#ifdef Honor_FLT_ROUNDS - && rounding >= 1 -#endif - ) { - if (dig == '9') - goto round_9_up; - if (j > 0) - dig++; -#ifdef SET_INEXACT - else if (!b->x[0] && b->wds <= 1) - inexact = 0; -#endif - *s++ = dig; - goto ret; - } -#endif - if (j < 0 || j == 0 && mode != 1 -#ifndef ROUND_BIASED - && !(word1(d) & 1) -#endif - ) { - if (!b->x[0] && b->wds <= 1) { -#ifdef SET_INEXACT - inexact = 0; -#endif - goto accept_dig; - } -#ifdef Honor_FLT_ROUNDS - if (mode > 1) - switch(rounding) { - case 0: goto accept_dig; - case 2: goto keep_dig; - } -#endif /*Honor_FLT_ROUNDS*/ - if (j1 > 0) { - b = lshift(b, 1); - j1 = cmp(b, S); - if ((j1 > 0 || j1 == 0 && dig & 1) - && dig++ == '9') - goto round_9_up; - } - accept_dig: - *s++ = dig; - goto ret; - } - if (j1 > 0) { -#ifdef Honor_FLT_ROUNDS - if (!rounding) - goto accept_dig; -#endif - if (dig == '9') { /* possible if i == 1 */ - round_9_up: - *s++ = '9'; - goto roundoff; - } - *s++ = dig + 1; - goto ret; - } -#ifdef Honor_FLT_ROUNDS - keep_dig: -#endif - *s++ = dig; - if (i == ilim) - break; - b = multadd(b, 10, 0); - if (mlo == mhi) - mlo = mhi = multadd(mhi, 10, 0); - else { - mlo = multadd(mlo, 10, 0); - mhi = multadd(mhi, 10, 0); - } - } - } - else - for(i = 1;; i++) { - *s++ = dig = quorem(b,S) + '0'; - if (!b->x[0] && b->wds <= 1) { -#ifdef SET_INEXACT - inexact = 0; -#endif - goto ret; - } - if (i >= ilim) - break; - b = multadd(b, 10, 0); - } - - /* Round off last digit */ - -#ifdef Honor_FLT_ROUNDS - switch(rounding) { - case 0: goto trimzeros; - case 2: goto roundoff; - } -#endif - b = lshift(b, 1); - j = cmp(b, S); - if (j > 0 || j == 0 && dig & 1) { - roundoff: - while(*--s == '9') - if (s == s0) { - k++; - *s++ = '1'; - goto ret; - } - ++*s++; - } - else { -#ifdef Honor_FLT_ROUNDS -trimzeros: -#endif - while (*--s == '0') { } - s++; - } - ret: - Bfree(S); - if (mhi) { - if (mlo && mlo != mhi) - Bfree(mlo); - Bfree(mhi); - } - ret1: -#ifdef SET_INEXACT - if (inexact) { - if (!oldinexact) { - word0(d) = Exp_1 + (70 << Exp_shift); - word1(d) = 0; - dval(d) += 1.; - } - } - else if (!oldinexact) - clear_inexact(); -#endif - Bfree(b); - *s = 0; - *decpt = k + 1; - if (rve) - *rve = s; - return s0; - } -#ifdef __cplusplus -} -#endif diff --git a/kjs/error_object.cpp b/kjs/error_object.cpp deleted file mode 100644 index 75ef0ba..0000000 --- a/kjs/error_object.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "error_object.h" - -#include "JSGlobalObject.h" -#include "object.h" -#include "operations.h" -#include "types.h" -#include "value.h" - -namespace KJS { - -// ------------------------------ ErrorInstance ---------------------------- - -const ClassInfo ErrorInstance::info = { "Error", 0, 0 }; - -ErrorInstance::ErrorInstance(JSObject* prototype) - : JSObject(prototype) -{ -} - -// ------------------------------ ErrorPrototype ---------------------------- - -// ECMA 15.9.4 -ErrorPrototype::ErrorPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype) - : ErrorInstance(objectPrototype) -{ - // The constructor will be added later in ErrorObjectImp's constructor - - putDirect(exec->propertyNames().name, jsString("Error"), DontEnum); - putDirect(exec->propertyNames().message, jsString("Unknown error"), DontEnum); - - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum); -} - -JSValue* errorProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) -{ - UString s = "Error"; - - JSValue* v = thisObj->get(exec, exec->propertyNames().name); - if (!v->isUndefined()) - s = v->toString(exec); - - v = thisObj->get(exec, exec->propertyNames().message); - if (!v->isUndefined()) - // Mozilla compatible format - s += ": " + v->toString(exec); - - return jsString(s); -} - -// ------------------------------ ErrorObjectImp ------------------------------- - -ErrorObjectImp::ErrorObjectImp(ExecState* exec, FunctionPrototype* funcProto, ErrorPrototype* errorProto) - : InternalFunctionImp(funcProto, errorProto->classInfo()->className) -{ - // ECMA 15.11.3.1 Error.prototype - putDirect(exec->propertyNames().prototype, errorProto, DontEnum|DontDelete|ReadOnly); - putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum); -} - -bool ErrorObjectImp::implementsConstruct() const -{ - return true; -} - -// ECMA 15.9.3 -JSObject* ErrorObjectImp::construct(ExecState* exec, const List& args) -{ - JSObject* proto = static_cast(exec->lexicalGlobalObject()->errorPrototype()); - JSObject* imp = new ErrorInstance(proto); - JSObject* obj(imp); - - if (!args[0]->isUndefined()) - imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec))); - - return obj; -} - -// ECMA 15.9.2 -JSValue* ErrorObjectImp::callAsFunction(ExecState* exec, JSObject* /*thisObj*/, const List& args) -{ - // "Error()" gives the sames result as "new Error()" - return construct(exec, args); -} - -// ------------------------------ NativeErrorPrototype ---------------------- - -NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, ErrorPrototype* errorProto, const UString& name, const UString& message) - : JSObject(errorProto) -{ - putDirect(exec->propertyNames().name, jsString(name), 0); - putDirect(exec->propertyNames().message, jsString(message), 0); -} - -// ------------------------------ NativeErrorImp ------------------------------- - -const ClassInfo NativeErrorImp::info = { "Function", &InternalFunctionImp::info, 0 }; - -NativeErrorImp::NativeErrorImp(ExecState* exec, FunctionPrototype* funcProto, NativeErrorPrototype* prot) - : InternalFunctionImp(funcProto, Identifier(prot->getDirect(exec->propertyNames().name)->getString())) - , proto(prot) -{ - putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5 - putDirect(exec->propertyNames().prototype, proto, DontDelete|ReadOnly|DontEnum); -} - -bool NativeErrorImp::implementsConstruct() const -{ - return true; -} - -JSObject* NativeErrorImp::construct(ExecState* exec, const List& args) -{ - JSObject* imp = new ErrorInstance(proto); - JSObject* obj(imp); - if (!args[0]->isUndefined()) - imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec))); - return obj; -} - -JSValue* NativeErrorImp::callAsFunction(ExecState* exec, JSObject*, const List& args) -{ - return construct(exec, args); -} - -void NativeErrorImp::mark() -{ - JSObject::mark(); - if (proto && !proto->marked()) - proto->mark(); -} - -} // namespace KJS diff --git a/kjs/error_object.h b/kjs/error_object.h deleted file mode 100644 index 9734085..0000000 --- a/kjs/error_object.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef ERROR_OBJECT_H_ -#define ERROR_OBJECT_H_ - -#include "function_object.h" - -namespace KJS { - - class ErrorInstance : public JSObject { - public: - ErrorInstance(JSObject* prototype); - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - }; - - class ErrorPrototype : public ErrorInstance { - public: - ErrorPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*); - }; - - JSValue* errorProtoFuncToString(ExecState*, JSObject*, const List&); - - class ErrorObjectImp : public InternalFunctionImp { - public: - ErrorObjectImp(ExecState*, FunctionPrototype*, ErrorPrototype*); - - virtual bool implementsConstruct() const; - virtual JSObject* construct(ExecState*, const List&); - - virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); - }; - - class NativeErrorPrototype : public JSObject { - public: - NativeErrorPrototype(ExecState*, ErrorPrototype*, const UString& name, const UString& message); - }; - - class NativeErrorImp : public InternalFunctionImp { - public: - NativeErrorImp(ExecState*, FunctionPrototype*, NativeErrorPrototype*); - - virtual bool implementsConstruct() const; - virtual JSObject* construct(ExecState*, const List&); - virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); - - virtual void mark(); - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - - private: - JSObject* proto; - }; - -} // namespace KJS - -#endif // ERROR_OBJECT_H_ diff --git a/kjs/function.cpp b/kjs/function.cpp deleted file mode 100644 index 92b3446..0000000 --- a/kjs/function.cpp +++ /dev/null @@ -1,877 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2002 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) - * Copyright (C) 2007 Maks Orlovich - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "function.h" - -#include "Activation.h" -#include "ExecState.h" -#include "JSGlobalObject.h" -#include "Parser.h" -#include "PropertyNameArray.h" -#include "debugger.h" -#include "dtoa.h" -#include "function_object.h" -#include "internal.h" -#include "lexer.h" -#include "nodes.h" -#include "operations.h" -#include "scope_chain_mark.h" -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace WTF; -using namespace Unicode; - -namespace KJS { - -// ----------------------------- FunctionImp ---------------------------------- - -const ClassInfo FunctionImp::info = { "Function", &InternalFunctionImp::info, 0 }; - -FunctionImp::FunctionImp(ExecState* exec, const Identifier& name, FunctionBodyNode* b, const ScopeChain& sc) - : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name) - , body(b) - , _scope(sc) -{ -} - -void FunctionImp::mark() -{ - InternalFunctionImp::mark(); - _scope.mark(); -} - -JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) -{ - FunctionExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), exec, this, args); - JSValue* result = body->execute(&newExec); - if (newExec.completionType() == Throw) { - exec->setException(result); - return result; - } - if (newExec.completionType() == ReturnValue) - return result; - return jsUndefined(); -} - -JSValue* FunctionImp::argumentsGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) -{ - FunctionImp* thisObj = static_cast(slot.slotBase()); - - for (ExecState* e = exec; e; e = e->callingExecState()) - if (e->function() == thisObj) { - e->dynamicGlobalObject()->tearOffActivation(e, e != exec); - return e->activationObject()->get(exec, propertyName); - } - - return jsNull(); -} - -JSValue* FunctionImp::callerGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot) -{ - FunctionImp* thisObj = static_cast(slot.slotBase()); - ExecState* e = exec; - while (e) { - if (e->function() == thisObj) - break; - e = e->callingExecState(); - } - - if (!e) - return jsNull(); - - ExecState* callingExecState = e->callingExecState(); - if (!callingExecState) - return jsNull(); - - FunctionImp* callingFunction = callingExecState->function(); - if (!callingFunction) - return jsNull(); - - return callingFunction; -} - -JSValue* FunctionImp::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) -{ - FunctionImp* thisObj = static_cast(slot.slotBase()); - return jsNumber(thisObj->body->parameters().size()); -} - -bool FunctionImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - // Find the arguments from the closest context. - if (propertyName == exec->propertyNames().arguments) { - slot.setCustom(this, argumentsGetter); - return true; - } - - // Compute length of parameters. - if (propertyName == exec->propertyNames().length) { - slot.setCustom(this, lengthGetter); - return true; - } - - if (propertyName == exec->propertyNames().caller) { - slot.setCustom(this, callerGetter); - return true; - } - - return InternalFunctionImp::getOwnPropertySlot(exec, propertyName, slot); -} - -void FunctionImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) -{ - if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length) - return; - InternalFunctionImp::put(exec, propertyName, value, attr); -} - -bool FunctionImp::deleteProperty(ExecState* exec, const Identifier& propertyName) -{ - if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length) - return false; - return InternalFunctionImp::deleteProperty(exec, propertyName); -} - -/* Returns the parameter name corresponding to the given index. eg: - * function f1(x, y, z): getParameterName(0) --> x - * - * If a name appears more than once, only the last index at which - * it appears associates with it. eg: - * function f2(x, x): getParameterName(0) --> null - */ -Identifier FunctionImp::getParameterName(int index) -{ - Vector& parameters = body->parameters(); - - if (static_cast(index) >= body->parameters().size()) - return CommonIdentifiers::shared()->nullIdentifier; - - Identifier name = parameters[index]; - - // Are there any subsequent parameters with the same name? - size_t size = parameters.size(); - for (size_t i = index + 1; i < size; ++i) - if (parameters[i] == name) - return CommonIdentifiers::shared()->nullIdentifier; - - return name; -} - -// ECMA 13.2.2 [[Construct]] -JSObject* FunctionImp::construct(ExecState* exec, const List& args) -{ - JSObject* proto; - JSValue* p = get(exec, exec->propertyNames().prototype); - if (p->isObject()) - proto = static_cast(p); - else - proto = exec->lexicalGlobalObject()->objectPrototype(); - - JSObject* obj(new JSObject(proto)); - - JSValue* res = call(exec,obj,args); - - if (res->isObject()) - return static_cast(res); - else - return obj; -} - -// ------------------------------ IndexToNameMap --------------------------------- - -// We map indexes in the arguments array to their corresponding argument names. -// Example: function f(x, y, z): arguments[0] = x, so we map 0 to Identifier("x"). - -// Once we have an argument name, we can get and set the argument's value in the -// activation object. - -// We use Identifier::null to indicate that a given argument's value -// isn't stored in the activation object. - -IndexToNameMap::IndexToNameMap(FunctionImp* func, const List& args) -{ - _map = new Identifier[args.size()]; - this->size = args.size(); - - unsigned i = 0; - List::const_iterator end = args.end(); - for (List::const_iterator it = args.begin(); it != end; ++i, ++it) - _map[i] = func->getParameterName(i); // null if there is no corresponding parameter -} - -IndexToNameMap::~IndexToNameMap() -{ - delete [] _map; -} - -bool IndexToNameMap::isMapped(const Identifier& index) const -{ - bool indexIsNumber; - unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber); - - if (!indexIsNumber) - return false; - - if (indexAsNumber >= size) - return false; - - if (_map[indexAsNumber].isNull()) - return false; - - return true; -} - -void IndexToNameMap::unMap(const Identifier& index) -{ - bool indexIsNumber; - unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber); - - ASSERT(indexIsNumber && indexAsNumber < size); - - _map[indexAsNumber] = CommonIdentifiers::shared()->nullIdentifier; -} - -Identifier& IndexToNameMap::operator[](const Identifier& index) -{ - bool indexIsNumber; - unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber); - - ASSERT(indexIsNumber && indexAsNumber < size); - - return _map[indexAsNumber]; -} - -// ------------------------------ Arguments --------------------------------- - -const ClassInfo Arguments::info = { "Arguments", 0, 0 }; - -// ECMA 10.1.8 -Arguments::Arguments(ExecState* exec, FunctionImp* func, const List& args, ActivationImp* act) - : JSObject(exec->lexicalGlobalObject()->objectPrototype()) - , _activationObject(act) - , indexToNameMap(func, args) -{ - putDirect(exec->propertyNames().callee, func, DontEnum); - putDirect(exec->propertyNames().length, args.size(), DontEnum); - - int i = 0; - List::const_iterator end = args.end(); - for (List::const_iterator it = args.begin(); it != end; ++it, ++i) { - Identifier name = Identifier::from(i); - if (!indexToNameMap.isMapped(name)) - putDirect(name, *it, DontEnum); - } -} - -void Arguments::mark() -{ - JSObject::mark(); - if (_activationObject && !_activationObject->marked()) - _activationObject->mark(); -} - -JSValue* Arguments::mappedIndexGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) -{ - Arguments* thisObj = static_cast(slot.slotBase()); - return thisObj->_activationObject->get(exec, thisObj->indexToNameMap[propertyName]); -} - -bool Arguments::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - if (indexToNameMap.isMapped(propertyName)) { - slot.setCustom(this, mappedIndexGetter); - return true; - } - - return JSObject::getOwnPropertySlot(exec, propertyName, slot); -} - -void Arguments::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) -{ - if (indexToNameMap.isMapped(propertyName)) { - _activationObject->put(exec, indexToNameMap[propertyName], value, attr); - } else { - JSObject::put(exec, propertyName, value, attr); - } -} - -bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName) -{ - if (indexToNameMap.isMapped(propertyName)) { - indexToNameMap.unMap(propertyName); - return true; - } else { - return JSObject::deleteProperty(exec, propertyName); - } -} - -// ------------------------------ ActivationImp -------------------------------- - -const ClassInfo ActivationImp::info = { "Activation", 0, 0 }; - -ActivationImp::ActivationImp(const ActivationData& oldData, bool leaveRelic) -{ - JSVariableObject::d = new ActivationData(oldData); - d()->leftRelic = leaveRelic; -} - -ActivationImp::~ActivationImp() -{ - if (!d()->isOnStack) - delete d(); -} - -void ActivationImp::init(ExecState* exec) -{ - d()->symbolTable = &exec->function()->body->symbolTable(); - d()->exec = exec; - d()->function = exec->function(); - d()->argumentsObject = 0; -} - -JSValue* ActivationImp::argumentsGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot) -{ - ActivationImp* thisObj = static_cast(slot.slotBase()); - - if (!thisObj->d()->argumentsObject) - thisObj->createArgumentsObject(exec); - - return thisObj->d()->argumentsObject; -} - -PropertySlot::GetValueFunc ActivationImp::getArgumentsGetter() -{ - return ActivationImp::argumentsGetter; -} - -bool ActivationImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - if (symbolTableGet(propertyName, slot)) - return true; - - if (JSValue** location = getDirectLocation(propertyName)) { - slot.setValueSlot(this, location); - return true; - } - - // Only return the built-in arguments object if it wasn't overridden above. - if (propertyName == exec->propertyNames().arguments) { - for (ExecState* e = exec; e; e = e->callingExecState()) - if (e->function() == d()->function) { - e->dynamicGlobalObject()->tearOffActivation(e, e != exec); - ActivationImp* newActivation = e->activationObject(); - slot.setCustom(newActivation, newActivation->getArgumentsGetter()); - return true; - } - - slot.setCustom(this, getArgumentsGetter()); - return true; - } - - // We don't call through to JSObject because there's no way to give an - // activation object getter properties or a prototype. - ASSERT(!_prop.hasGetterSetterProperties()); - ASSERT(prototype() == jsNull()); - return false; -} - -bool ActivationImp::deleteProperty(ExecState* exec, const Identifier& propertyName) -{ - if (propertyName == exec->propertyNames().arguments) - return false; - - return JSVariableObject::deleteProperty(exec, propertyName); -} - -void ActivationImp::put(ExecState*, const Identifier& propertyName, JSValue* value, int attr) -{ - // If any bits other than DontDelete are set, then we bypass the read-only check. - bool checkReadOnly = !(attr & ~DontDelete); - if (symbolTablePut(propertyName, value, checkReadOnly)) - return; - - // We don't call through to JSObject because __proto__ and getter/setter - // properties are non-standard extensions that other implementations do not - // expose in the activation object. - ASSERT(!_prop.hasGetterSetterProperties()); - _prop.put(propertyName, value, attr, checkReadOnly); -} - -void ActivationImp::markChildren() -{ - LocalStorage& localStorage = d()->localStorage; - size_t size = localStorage.size(); - - for (size_t i = 0; i < size; ++i) { - JSValue* value = localStorage[i].value; - - if (!value->marked()) - value->mark(); - } - - if (!d()->function->marked()) - d()->function->mark(); - - if (d()->argumentsObject && !d()->argumentsObject->marked()) - d()->argumentsObject->mark(); -} - -void ActivationImp::mark() -{ - JSObject::mark(); - markChildren(); -} - -void ActivationImp::createArgumentsObject(ExecState* exec) -{ - // Since "arguments" is only accessible while a function is being called, - // we can retrieve our argument list from the ExecState for our function - // call instead of storing the list ourselves. - d()->argumentsObject = new Arguments(exec, d()->exec->function(), *d()->exec->arguments(), this); -} - -ActivationImp::ActivationData::ActivationData(const ActivationData& old) - : JSVariableObjectData(old) - , exec(old.exec) - , function(old.function) - , argumentsObject(old.argumentsObject) - , isOnStack(false) -{ -} - -// ------------------------------ Global Functions ----------------------------------- - -static JSValue* encode(ExecState* exec, const List& args, const char* do_not_escape) -{ - UString r = "", s, str = args[0]->toString(exec); - CString cstr = str.UTF8String(true); - if (!cstr.c_str()) - return throwError(exec, URIError, "String contained an illegal UTF-16 sequence."); - const char* p = cstr.c_str(); - for (size_t k = 0; k < cstr.size(); k++, p++) { - char c = *p; - if (c && strchr(do_not_escape, c)) { - r.append(c); - } else { - char tmp[4]; - snprintf(tmp, sizeof(tmp), "%%%02X", (unsigned char)c); - r += tmp; - } - } - return jsString(r); -} - -static JSValue* decode(ExecState* exec, const List& args, const char* do_not_unescape, bool strict) -{ - UString s = "", str = args[0]->toString(exec); - int k = 0, len = str.size(); - const UChar* d = str.data(); - UChar u; - while (k < len) { - const UChar* p = d + k; - UChar c = *p; - if (c == '%') { - int charLen = 0; - if (k <= len - 3 && isASCIIHexDigit(p[1].uc) && isASCIIHexDigit(p[2].uc)) { - const char b0 = Lexer::convertHex(p[1].uc, p[2].uc); - const int sequenceLen = UTF8SequenceLength(b0); - if (sequenceLen != 0 && k <= len - sequenceLen * 3) { - charLen = sequenceLen * 3; - char sequence[5]; - sequence[0] = b0; - for (int i = 1; i < sequenceLen; ++i) { - const UChar* q = p + i * 3; - if (q[0] == '%' && isASCIIHexDigit(q[1].uc) && isASCIIHexDigit(q[2].uc)) - sequence[i] = Lexer::convertHex(q[1].uc, q[2].uc); - else { - charLen = 0; - break; - } - } - if (charLen != 0) { - sequence[sequenceLen] = 0; - const int character = decodeUTF8Sequence(sequence); - if (character < 0 || character >= 0x110000) { - charLen = 0; - } else if (character >= 0x10000) { - // Convert to surrogate pair. - s.append(static_cast(0xD800 | ((character - 0x10000) >> 10))); - u = static_cast(0xDC00 | ((character - 0x10000) & 0x3FF)); - } else { - u = static_cast(character); - } - } - } - } - if (charLen == 0) { - if (strict) - return throwError(exec, URIError); - // The only case where we don't use "strict" mode is the "unescape" function. - // For that, it's good to support the wonky "%u" syntax for compatibility with WinIE. - if (k <= len - 6 && p[1] == 'u' - && isASCIIHexDigit(p[2].uc) && isASCIIHexDigit(p[3].uc) - && isASCIIHexDigit(p[4].uc) && isASCIIHexDigit(p[5].uc)) { - charLen = 6; - u = Lexer::convertUnicode(p[2].uc, p[3].uc, p[4].uc, p[5].uc); - } - } - if (charLen && (u.uc == 0 || u.uc >= 128 || !strchr(do_not_unescape, u.low()))) { - c = u; - k += charLen - 1; - } - } - k++; - s.append(c); - } - return jsString(s); -} - -static bool isStrWhiteSpace(unsigned short c) -{ - switch (c) { - case 0x0009: - case 0x000A: - case 0x000B: - case 0x000C: - case 0x000D: - case 0x0020: - case 0x00A0: - case 0x2028: - case 0x2029: - return true; - default: - return isSeparatorSpace(c); - } -} - -static int parseDigit(unsigned short c, int radix) -{ - int digit = -1; - - if (c >= '0' && c <= '9') { - digit = c - '0'; - } else if (c >= 'A' && c <= 'Z') { - digit = c - 'A' + 10; - } else if (c >= 'a' && c <= 'z') { - digit = c - 'a' + 10; - } - - if (digit >= radix) - return -1; - return digit; -} - -double parseIntOverflow(const char* s, int length, int radix) -{ - double number = 0.0; - double radixMultiplier = 1.0; - - for (const char* p = s + length - 1; p >= s; p--) { - if (radixMultiplier == Inf) { - if (*p != '0') { - number = Inf; - break; - } - } else { - int digit = parseDigit(*p, radix); - number += digit * radixMultiplier; - } - - radixMultiplier *= radix; - } - - return number; -} - -static double parseInt(const UString& s, int radix) -{ - int length = s.size(); - int p = 0; - - while (p < length && isStrWhiteSpace(s[p].uc)) { - ++p; - } - - double sign = 1; - if (p < length) { - if (s[p] == '+') { - ++p; - } else if (s[p] == '-') { - sign = -1; - ++p; - } - } - - if ((radix == 0 || radix == 16) && length - p >= 2 && s[p] == '0' && (s[p + 1] == 'x' || s[p + 1] == 'X')) { - radix = 16; - p += 2; - } else if (radix == 0) { - if (p < length && s[p] == '0') - radix = 8; - else - radix = 10; - } - - if (radix < 2 || radix > 36) - return NaN; - - int firstDigitPosition = p; - bool sawDigit = false; - double number = 0; - while (p < length) { - int digit = parseDigit(s[p].uc, radix); - if (digit == -1) - break; - sawDigit = true; - number *= radix; - number += digit; - ++p; - } - - if (number >= mantissaOverflowLowerBound) { - if (radix == 10) - number = kjs_strtod(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), 0); - else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32) - number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), p - firstDigitPosition, radix); - } - - if (!sawDigit) - return NaN; - - return sign * number; -} - -static double parseFloat(const UString& s) -{ - // Check for 0x prefix here, because toDouble allows it, but we must treat it as 0. - // Need to skip any whitespace and then one + or - sign. - int length = s.size(); - int p = 0; - while (p < length && isStrWhiteSpace(s[p].uc)) { - ++p; - } - if (p < length && (s[p] == '+' || s[p] == '-')) { - ++p; - } - if (length - p >= 2 && s[p] == '0' && (s[p + 1] == 'x' || s[p + 1] == 'X')) { - return 0; - } - - return s.toDouble( true /*tolerant*/, false /* NaN for empty string */ ); -} - -JSValue* globalFuncEval(ExecState* exec, JSObject* thisObj, const List& args) -{ - JSValue* x = args[0]; - if (!x->isString()) - return x; - - UString s = x->toString(exec); - - int errLine; - UString errMsg; - - SourceCode source = makeSource(s); - RefPtr evalNode = parser().parse(source, &errLine, &errMsg); - - // debugger code removed - - // No program node means a syntax occurred - if (!evalNode) - return throwError(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), NULL); - - bool switchGlobal = thisObj && thisObj != exec->dynamicGlobalObject() && thisObj->isGlobalObject(); - - // enter a new execution context - exec->dynamicGlobalObject()->tearOffActivation(exec); - JSGlobalObject* globalObject = switchGlobal ? static_cast(thisObj) : exec->dynamicGlobalObject(); - EvalExecState newExec(globalObject, evalNode.get(), exec); - - if (switchGlobal) { - newExec.pushScope(thisObj); - newExec.setVariableObject(static_cast(thisObj)); - } - JSValue* value = evalNode->execute(&newExec); - if (switchGlobal) - newExec.popScope(); - - if (newExec.completionType() == Throw) { - exec->setException(value); - return value; - } - - return value ? value : jsUndefined(); -} - -JSValue* globalFuncParseInt(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(parseInt(args[0]->toString(exec), args[1]->toInt32(exec))); -} - -JSValue* globalFuncParseFloat(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(parseFloat(args[0]->toString(exec))); -} - -JSValue* globalFuncIsNaN(ExecState* exec, JSObject*, const List& args) -{ - return jsBoolean(isnan(args[0]->toNumber(exec))); -} - -JSValue* globalFuncIsFinite(ExecState* exec, JSObject*, const List& args) -{ - double n = args[0]->toNumber(exec); - return jsBoolean(!isnan(n) && !isinf(n)); -} - -JSValue* globalFuncDecodeURI(ExecState* exec, JSObject*, const List& args) -{ - static const char do_not_unescape_when_decoding_URI[] = - "#$&+,/:;=?@"; - - return decode(exec, args, do_not_unescape_when_decoding_URI, true); -} - -JSValue* globalFuncDecodeURIComponent(ExecState* exec, JSObject*, const List& args) -{ - return decode(exec, args, "", true); -} - -JSValue* globalFuncEncodeURI(ExecState* exec, JSObject*, const List& args) -{ - static const char do_not_escape_when_encoding_URI[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789" - "!#$&'()*+,-./:;=?@_~"; - - return encode(exec, args, do_not_escape_when_encoding_URI); -} - -JSValue* globalFuncEncodeURIComponent(ExecState* exec, JSObject*, const List& args) -{ - static const char do_not_escape_when_encoding_URI_component[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789" - "!'()*-._~"; - - return encode(exec, args, do_not_escape_when_encoding_URI_component); -} - -JSValue* globalFuncEscape(ExecState* exec, JSObject*, const List& args) -{ - static const char do_not_escape[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789" - "*+-./@_"; - - UString r = "", s, str = args[0]->toString(exec); - const UChar* c = str.data(); - for (int k = 0; k < str.size(); k++, c++) { - int u = c->uc; - if (u > 255) { - char tmp[7]; - snprintf(tmp, sizeof(tmp), "%%u%04X", u); - s = UString(tmp); - } else if (u != 0 && strchr(do_not_escape, (char)u)) - s = UString(c, 1); - else { - char tmp[4]; - snprintf(tmp, sizeof(tmp), "%%%02X", u); - s = UString(tmp); - } - r += s; - } - - return jsString(r); -} - -JSValue* globalFuncUnescape(ExecState* exec, JSObject*, const List& args) -{ - UString s = "", str = args[0]->toString(exec); - int k = 0, len = str.size(); - while (k < len) { - const UChar* c = str.data() + k; - UChar u; - if (*c == UChar('%') && k <= len - 6 && *(c + 1) == UChar('u')) { - if (Lexer::isHexDigit((c + 2)->uc) && Lexer::isHexDigit((c + 3)->uc) && Lexer::isHexDigit((c + 4)->uc) && Lexer::isHexDigit((c + 5)->uc)) { - u = Lexer::convertUnicode((c + 2)->uc, (c + 3)->uc, (c + 4)->uc, (c + 5)->uc); - c = &u; - k += 5; - } - } else if (*c == UChar('%') && k <= len - 3 && Lexer::isHexDigit((c + 1)->uc) && Lexer::isHexDigit((c + 2)->uc)) { - u = UChar(Lexer::convertHex((c+1)->uc, (c+2)->uc)); - c = &u; - k += 2; - } - k++; - s += UString(c, 1); - } - - return jsString(s); -} - -#ifndef NDEBUG -JSValue* globalFuncKJSPrint(ExecState* exec, JSObject*, const List& args) -{ - puts(args[0]->toString(exec).ascii()); - return jsUndefined(); -} -#endif - -// ------------------------------ PrototypeFunction ------------------------------- - -PrototypeFunction::PrototypeFunction(ExecState* exec, int len, const Identifier& name, JSMemberFunction function) - : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name) - , m_function(function) -{ - ASSERT_ARG(function, function); - putDirect(exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum); -} - -PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function) - : InternalFunctionImp(functionPrototype, name) - , m_function(function) -{ - ASSERT_ARG(function, function); - putDirect(exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum); -} - -JSValue* PrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) -{ - return m_function(exec, thisObj, args); -} - -} // namespace KJS diff --git a/kjs/function.h b/kjs/function.h deleted file mode 100644 index 49cf61b..0000000 --- a/kjs/function.h +++ /dev/null @@ -1,159 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2006, 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) - * Copyright (C) 2007 Maks Orlovich - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_FUNCTION_H -#define KJS_FUNCTION_H - -#include "JSVariableObject.h" -#include "LocalStorage.h" -#include "SymbolTable.h" -#include "nodes.h" -#include "object.h" - -namespace KJS { - - class ActivationImp; - class FunctionBodyNode; - class FunctionPrototype; - class JSGlobalObject; - - class InternalFunctionImp : public JSObject { - public: - InternalFunctionImp(); - InternalFunctionImp(FunctionPrototype*, const Identifier&); - - virtual bool implementsCall() const; - virtual JSValue* callAsFunction(ExecState*, JSObject* thisObjec, const List& args) = 0; - virtual bool implementsHasInstance() const; - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - const Identifier& functionName() const { return m_name; } - - private: - Identifier m_name; - }; - - class FunctionImp : public InternalFunctionImp { - friend class ActivationImp; - public: - FunctionImp(ExecState*, const Identifier& name, FunctionBodyNode*, const ScopeChain&); - - virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None); - virtual bool deleteProperty(ExecState*, const Identifier& propertyName); - - virtual bool implementsConstruct() const { return true; } - virtual JSObject* construct(ExecState*, const List& args); - - virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List& args); - - // Note: unlike body->paramName, this returns Identifier::null for parameters - // that will never get set, due to later param having the same name - Identifier getParameterName(int index); - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - - RefPtr body; - - void setScope(const ScopeChain& s) { _scope = s; } - const ScopeChain& scope() const { return _scope; } - - virtual void mark(); - - private: - ScopeChain _scope; - - static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); - static JSValue* callerGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); - static JSValue* lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); - }; - - class IndexToNameMap { - public: - IndexToNameMap(FunctionImp*, const List& args); - ~IndexToNameMap(); - - Identifier& operator[](const Identifier& index); - bool isMapped(const Identifier& index) const; - void unMap(const Identifier& index); - - private: - unsigned size; - Identifier* _map; - }; - - class Arguments : public JSObject { - public: - Arguments(ExecState*, FunctionImp* func, const List& args, ActivationImp* act); - virtual void mark(); - virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None); - virtual bool deleteProperty(ExecState*, const Identifier& propertyName); - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - private: - static JSValue* mappedIndexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot); - - ActivationImp* _activationObject; - mutable IndexToNameMap indexToNameMap; - }; - - class PrototypeFunction : public InternalFunctionImp { - public: - typedef KJS::JSValue* (*JSMemberFunction)(ExecState*, JSObject*, const List&); - - PrototypeFunction(ExecState*, int len, const Identifier&, JSMemberFunction); - PrototypeFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, JSMemberFunction); - - virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List&); - - private: - const JSMemberFunction m_function; - }; - - - // Global Functions - JSValue* globalFuncEval(ExecState*, JSObject*, const List&); - JSValue* globalFuncParseInt(ExecState*, JSObject*, const List&); - JSValue* globalFuncParseFloat(ExecState*, JSObject*, const List&); - JSValue* globalFuncIsNaN(ExecState*, JSObject*, const List&); - JSValue* globalFuncIsFinite(ExecState*, JSObject*, const List&); - JSValue* globalFuncDecodeURI(ExecState*, JSObject*, const List&); - JSValue* globalFuncDecodeURIComponent(ExecState*, JSObject*, const List&); - JSValue* globalFuncEncodeURI(ExecState*, JSObject*, const List&); - JSValue* globalFuncEncodeURIComponent(ExecState*, JSObject*, const List&); - JSValue* globalFuncEscape(ExecState*, JSObject*, const List&); - JSValue* globalFuncUnescape(ExecState*, JSObject*, const List&); -#ifndef NDEBUG - JSValue* globalFuncKJSPrint(ExecState*, JSObject*, const List&); -#endif - - static const double mantissaOverflowLowerBound = 9007199254740992.0; - double parseIntOverflow(const char*, int length, int radix); - -} // namespace - -#endif diff --git a/kjs/function_object.cpp b/kjs/function_object.cpp deleted file mode 100644 index 38b72f2..0000000 --- a/kjs/function_object.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "function_object.h" - -#include "JSGlobalObject.h" -#include "Parser.h" -#include "array_object.h" -#include "debugger.h" -#include "function.h" -#include "internal.h" -#include "lexer.h" -#include "nodes.h" -#include "object.h" -#include -#include -#include - -namespace KJS { - -// ------------------------------ FunctionPrototype ------------------------- - -static JSValue* functionProtoFuncToString(ExecState*, JSObject*, const List&); -static JSValue* functionProtoFuncApply(ExecState*, JSObject*, const List&); -static JSValue* functionProtoFuncCall(ExecState*, JSObject*, const List&); - -FunctionPrototype::FunctionPrototype(ExecState* exec) -{ - static const Identifier* applyPropertyName = new Identifier("apply"); - static const Identifier* callPropertyName = new Identifier("call"); - - putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum); - - putDirectFunction(new PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum); - putDirectFunction(new PrototypeFunction(exec, this, 2, *applyPropertyName, functionProtoFuncApply), DontEnum); - putDirectFunction(new PrototypeFunction(exec, this, 1, *callPropertyName, functionProtoFuncCall), DontEnum); -} - -// ECMA 15.3.4 -JSValue* FunctionPrototype::callAsFunction(ExecState*, JSObject*, const List&) -{ - return jsUndefined(); -} - -// Functions - -JSValue* functionProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj || !thisObj->inherits(&InternalFunctionImp::info)) { -#ifndef NDEBUG - fprintf(stderr,"attempted toString() call on null or non-function object\n"); -#endif - return throwError(exec, TypeError); - } - - if (thisObj->inherits(&FunctionImp::info)) { - FunctionImp* fi = static_cast(thisObj); - return jsString("function " + fi->functionName().ustring() + "(" + fi->body->paramString() + ") " + fi->body->toString()); - } - - return jsString("function " + static_cast(thisObj)->functionName().ustring() + "() {\n [native code]\n}"); -} - -JSValue* functionProtoFuncApply(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!thisObj->implementsCall()) - return throwError(exec, TypeError); - - JSValue* thisArg = args[0]; - JSValue* argArray = args[1]; - - JSObject* applyThis; - if (thisArg->isUndefinedOrNull()) - applyThis = exec->dynamicGlobalObject(); - else - applyThis = thisArg->toObject(exec); - - List applyArgs; - if (!argArray->isUndefinedOrNull()) { - if (argArray->isObject() && - (static_cast(argArray)->inherits(&ArrayInstance::info) || - static_cast(argArray)->inherits(&Arguments::info))) { - - JSObject* argArrayObj = static_cast(argArray); - unsigned int length = argArrayObj->get(exec, exec->propertyNames().length)->toUInt32(exec); - for (unsigned int i = 0; i < length; i++) - applyArgs.append(argArrayObj->get(exec, i)); - } else - return throwError(exec, TypeError); - } - - return thisObj->call(exec, applyThis, applyArgs); -} - -JSValue* functionProtoFuncCall(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!thisObj->implementsCall()) - return throwError(exec, TypeError); - - JSValue* thisArg = args[0]; - - JSObject* callThis; - if (thisArg->isUndefinedOrNull()) - callThis = exec->dynamicGlobalObject(); - else - callThis = thisArg->toObject(exec); - - List argsTail; - args.getSlice(1, argsTail); - return thisObj->call(exec, callThis, argsTail); -} - -// ------------------------------ FunctionObjectImp ---------------------------- - -FunctionObjectImp::FunctionObjectImp(ExecState* exec, FunctionPrototype* functionPrototype) - : InternalFunctionImp(functionPrototype, functionPrototype->classInfo()->className) -{ - putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly); - - // Number of arguments for constructor - putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); -} - -bool FunctionObjectImp::implementsConstruct() const -{ - return true; -} - -// ECMA 15.3.2 The Function Constructor -JSObject* FunctionObjectImp::construct(ExecState* exec, const List& args, const Identifier& functionName, const UString& sourceURL, int lineNumber) -{ - UString p(""); - UString body; - int argsSize = args.size(); - if (argsSize == 0) - body = ""; - else if (argsSize == 1) - body = args[0]->toString(exec); - else { - p = args[0]->toString(exec); - for (int k = 1; k < argsSize - 1; k++) - p += "," + args[k]->toString(exec); - body = args[argsSize - 1]->toString(exec); - } - - // parse the source code - int errLine; - UString errMsg; - SourceCode source = makeSource(body, sourceURL, lineNumber); - RefPtr functionBody = parser().parse(source, &errLine, &errMsg); - - // debugger code removed - - // No program node == syntax error - throw a syntax error - if (!functionBody) - // We can't return a Completion(Throw) here, so just set the exception - // and return it - return throwError(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url()); - - ScopeChain scopeChain; - scopeChain.push(exec->lexicalGlobalObject()); - - FunctionImp* fimp = new FunctionImp(exec, functionName, functionBody.get(), scopeChain); - - // parse parameter list. throw syntax error on illegal identifiers - int len = p.size(); - const UChar* c = p.data(); - int i = 0, params = 0; - UString param; - while (i < len) { - while (*c == ' ' && i < len) - c++, i++; - if (Lexer::isIdentStart(c->uc)) { // else error - param = UString(c, 1); - c++, i++; - while (i < len && (Lexer::isIdentPart(c->uc))) { - param += UString(c, 1); - c++, i++; - } - while (i < len && *c == ' ') - c++, i++; - if (i == len) { - functionBody->parameters().append(Identifier(param)); - params++; - break; - } else if (*c == ',') { - functionBody->parameters().append(Identifier(param)); - params++; - c++, i++; - continue; - } // else error - } - return throwError(exec, SyntaxError, "Syntax error in parameter list"); - } - - List consArgs; - - JSObject* objCons = exec->lexicalGlobalObject()->objectConstructor(); - JSObject* prototype = objCons->construct(exec, exec->emptyList()); - prototype->putDirect(exec->propertyNames().constructor, fimp, DontEnum | DontDelete | ReadOnly); - fimp->putDirect(exec->propertyNames().prototype, prototype, Internal | DontDelete); - return fimp; -} - -// ECMA 15.3.2 The Function Constructor -JSObject* FunctionObjectImp::construct(ExecState* exec, const List& args) -{ - return construct(exec, args, "anonymous", UString(), 0); -} - -// ECMA 15.3.1 The Function Constructor Called as a Function -JSValue* FunctionObjectImp::callAsFunction(ExecState* exec, JSObject*, const List& args) -{ - return construct(exec, args); -} - -} // namespace KJS diff --git a/kjs/function_object.h b/kjs/function_object.h deleted file mode 100644 index cd0fe3e..0000000 --- a/kjs/function_object.h +++ /dev/null @@ -1,61 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef FUNCTION_OBJECT_H_ -#define FUNCTION_OBJECT_H_ - -#include "object_object.h" -#include "function.h" - -namespace KJS { - - /** - * @internal - * - * The initial value of Function.prototype (and thus all objects created - * with the Function constructor) - */ - class FunctionPrototype : public InternalFunctionImp { - public: - FunctionPrototype(ExecState*); - - virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); - }; - - /** - * @internal - * - * The initial value of the the global variable's "Function" property - */ - class FunctionObjectImp : public InternalFunctionImp { - public: - FunctionObjectImp(ExecState*, FunctionPrototype*); - - virtual bool implementsConstruct() const; - virtual JSObject* construct(ExecState*, const List&); - virtual JSObject* construct(ExecState*, const List&, const Identifier& functionName, const UString& sourceURL, int lineNumber); - virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); - }; - -} // namespace KJS - -#endif // _FUNCTION_OBJECT_H_ diff --git a/kjs/grammar.y b/kjs/grammar.y deleted file mode 100644 index 4252d02..0000000 --- a/kjs/grammar.y +++ /dev/null @@ -1,1844 +0,0 @@ -%{ - -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2007 Eric Seidel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" - -#include -#include -#include "value.h" -#include "object.h" -#include "types.h" -#include "nodes.h" -#include "lexer.h" -#include "internal.h" -#include "CommonIdentifiers.h" -#include "NodeInfo.h" -#include "Parser.h" -#include - -// Not sure why, but yacc doesn't add this define along with the others. -#define yylloc kjsyylloc - -#define YYMAXDEPTH 10000 -#define YYENABLE_NLS 0 - -/* default values for bison */ -#define YYDEBUG 0 // Set to 1 to debug a parse error. -#define kjsyydebug 0 // Set to 1 to debug a parse error. -#if !PLATFORM(DARWIN) - // avoid triggering warnings in older bison -#define YYERROR_VERBOSE -#endif - -extern int kjsyylex(); -int kjsyyerror(const char *); -static bool allowAutomaticSemicolon(); - -#define AUTO_SEMICOLON do { if (!allowAutomaticSemicolon()) YYABORT; } while (0) -#define DBG(l, s, e) (l)->setLoc((s).first_line, (e).last_line) - -using namespace KJS; -using namespace std; - -static AddNode* makeAddNode(ExpressionNode*, ExpressionNode*); -static LessNode* makeLessNode(ExpressionNode*, ExpressionNode*); -static ExpressionNode* makeAssignNode(ExpressionNode* loc, Operator, ExpressionNode* expr); -static ExpressionNode* makePrefixNode(ExpressionNode* expr, Operator); -static ExpressionNode* makePostfixNode(ExpressionNode* expr, Operator); -static PropertyNode* makeGetterOrSetterPropertyNode(const Identifier &getOrSet, const Identifier& name, ParameterNode*, FunctionBodyNode*, const SourceCode&); -static ExpressionNode* makeFunctionCallNode(ExpressionNode* func, ArgumentsNode*); -static ExpressionNode* makeTypeOfNode(ExpressionNode*); -static ExpressionNode* makeDeleteNode(ExpressionNode*); -static ExpressionNode* makeNegateNode(ExpressionNode*); -static NumberNode* makeNumberNode(double); -static StatementNode* makeVarStatementNode(ExpressionNode*); -static ExpressionNode* combineVarInitializers(ExpressionNode* list, AssignResolveNode* init); - - -#if COMPILER(MSVC) - -#pragma warning(disable: 4065) -#pragma warning(disable: 4244) -#pragma warning(disable: 4702) - -// At least some of the time, the declarations of malloc and free that bison -// generates are causing warnings. A way to avoid this is to explicitly define -// the macros so that bison doesn't try to declare malloc and free. -#define YYMALLOC malloc -#define YYFREE free - -#endif - -template NodeInfo createNodeInfo(T node, ParserRefCountedData* varDecls, - ParserRefCountedData* funcDecls) -{ - NodeInfo result = {node, varDecls, funcDecls}; - return result; -} - -template T mergeDeclarationLists(T decls1, T decls2) -{ - // decls1 or both are null - if (!decls1) - return decls2; - // only decls1 is non-null - if (!decls2) - return decls1; - - // Both are non-null - decls1->data.append(decls2->data); - - // We manually release the declaration lists to avoid accumulating many many - // unused heap allocated vectors - decls2->ref(); - decls2->deref(); - return decls1; -} - -static void appendToVarDeclarationList(ParserRefCountedData*& varDecls, const Identifier& ident, unsigned attrs) -{ - if (!varDecls) - varDecls = new ParserRefCountedData; - - varDecls->data.append(make_pair(ident, attrs)); - -} - -static inline void appendToVarDeclarationList(ParserRefCountedData*& varDecls, ConstDeclNode* decl) -{ - unsigned attrs = DeclarationStacks::IsConstant; - if (decl->m_init) - attrs |= DeclarationStacks::HasInitializer; - appendToVarDeclarationList(varDecls, decl->m_ident, attrs); -} - -%} - -%union { - int intValue; - double doubleValue; - UString* string; - Identifier* ident; - - // expression subtrees - ExpressionNode* expressionNode; - FuncDeclNode* funcDeclNode; - PropertyNode* propertyNode; - ArgumentsNode* argumentsNode; - ConstDeclNode* constDeclNode; - CaseBlockNodeInfo caseBlockNode; - CaseClauseNodeInfo caseClauseNode; - FuncExprNode* funcExprNode; - - // statement nodes - StatementNodeInfo statementNode; - FunctionBodyNode* functionBodyNode; - ProgramNode* programNode; - - SourceElementsInfo sourceElements; - PropertyList propertyList; - ArgumentList argumentList; - VarDeclListInfo varDeclList; - ConstDeclListInfo constDeclList; - ClauseListInfo clauseList; - ElementList elementList; - ParameterList parameterList; - - Operator op; -} - -%start Program - -/* literals */ -%token NULLTOKEN TRUETOKEN FALSETOKEN - -/* keywords */ -%token BREAK CASE DEFAULT FOR NEW VAR CONSTTOKEN CONTINUE -%token FUNCTION RETURN VOIDTOKEN DELETETOKEN -%token IF THISTOKEN DO WHILE INTOKEN INSTANCEOF TYPEOF -%token SWITCH WITH RESERVED -%token THROW TRY CATCH FINALLY -%token DEBUGGER - -/* give an if without an else higher precedence than an else to resolve the ambiguity */ -%nonassoc IF_WITHOUT_ELSE -%nonassoc ELSE - -/* punctuators */ -%token EQEQ NE /* == and != */ -%token STREQ STRNEQ /* === and !== */ -%token LE GE /* < and > */ -%token OR AND /* || and && */ -%token PLUSPLUS MINUSMINUS /* ++ and -- */ -%token LSHIFT /* << */ -%token RSHIFT URSHIFT /* >> and >>> */ -%token PLUSEQUAL MINUSEQUAL /* += and -= */ -%token MULTEQUAL DIVEQUAL /* *= and /= */ -%token LSHIFTEQUAL /* <<= */ -%token RSHIFTEQUAL URSHIFTEQUAL /* >>= and >>>= */ -%token ANDEQUAL MODEQUAL /* &= and %= */ -%token XOREQUAL OREQUAL /* ^= and |= */ -%token OPENBRACE /* { (with char offset) */ -%token CLOSEBRACE /* { (with char offset) */ - -/* terminal types */ -%token NUMBER -%token STRING -%token IDENT - -/* automatically inserted semicolon */ -%token AUTOPLUSPLUS AUTOMINUSMINUS - -/* non-terminal types */ -%type Literal ArrayLiteral - -%type PrimaryExpr PrimaryExprNoBrace -%type MemberExpr MemberExprNoBF /* BF => brace or function */ -%type NewExpr NewExprNoBF -%type CallExpr CallExprNoBF -%type LeftHandSideExpr LeftHandSideExprNoBF -%type PostfixExpr PostfixExprNoBF -%type UnaryExpr UnaryExprNoBF UnaryExprCommon -%type MultiplicativeExpr MultiplicativeExprNoBF -%type AdditiveExpr AdditiveExprNoBF -%type ShiftExpr ShiftExprNoBF -%type RelationalExpr RelationalExprNoIn RelationalExprNoBF -%type EqualityExpr EqualityExprNoIn EqualityExprNoBF -%type BitwiseANDExpr BitwiseANDExprNoIn BitwiseANDExprNoBF -%type BitwiseXORExpr BitwiseXORExprNoIn BitwiseXORExprNoBF -%type BitwiseORExpr BitwiseORExprNoIn BitwiseORExprNoBF -%type LogicalANDExpr LogicalANDExprNoIn LogicalANDExprNoBF -%type LogicalORExpr LogicalORExprNoIn LogicalORExprNoBF -%type ConditionalExpr ConditionalExprNoIn ConditionalExprNoBF -%type AssignmentExpr AssignmentExprNoIn AssignmentExprNoBF -%type Expr ExprNoIn ExprNoBF - -%type ExprOpt ExprNoInOpt - -%type Statement Block -%type VariableStatement ConstStatement EmptyStatement ExprStatement -%type IfStatement IterationStatement ContinueStatement -%type BreakStatement ReturnStatement WithStatement -%type SwitchStatement LabelledStatement -%type ThrowStatement TryStatement -%type DebuggerStatement -%type SourceElement - -%type Initializer InitializerNoIn -%type FunctionDeclaration -%type FunctionExpr -%type FunctionBody -%type SourceElements -%type FormalParameterList -%type AssignmentOperator -%type Arguments -%type ArgumentList -%type VariableDeclarationList VariableDeclarationListNoIn -%type ConstDeclarationList -%type ConstDeclaration -%type CaseBlock -%type CaseClause DefaultClause -%type CaseClauses CaseClausesOpt -%type Elision ElisionOpt -%type ElementList -%type Property -%type PropertyList -%% - -Literal: - NULLTOKEN { $$ = new NullNode; } - | TRUETOKEN { $$ = new TrueNode; } - | FALSETOKEN { $$ = new FalseNode; } - | NUMBER { $$ = makeNumberNode($1); } - | STRING { $$ = new StringNode($1); } - | '/' /* regexp */ { - Lexer& l = lexer(); - if (!l.scanRegExp()) - YYABORT; - $$ = new RegExpNode(l.pattern(), l.flags()); - } - | DIVEQUAL /* regexp with /= */ { - Lexer& l = lexer(); - if (!l.scanRegExp()) - YYABORT; - $$ = new RegExpNode("=" + l.pattern(), l.flags()); - } -; - -Property: - IDENT ':' AssignmentExpr { $$ = new PropertyNode(*$1, $3, PropertyNode::Constant); } - | STRING ':' AssignmentExpr { $$ = new PropertyNode(Identifier(*$1), $3, PropertyNode::Constant); } - | NUMBER ':' AssignmentExpr { $$ = new PropertyNode(Identifier(UString::from($1)), $3, PropertyNode::Constant); } - | IDENT IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = makeGetterOrSetterPropertyNode(*$1, *$2, 0, $6, lexer().sourceCode($5, $7, @5.first_line)); DBG($6, @5, @7); if (!$$) YYABORT; } - | IDENT IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE - { $$ = makeGetterOrSetterPropertyNode(*$1, *$2, $4.head, $7, lexer().sourceCode($6, $8, @6.first_line)); DBG($7, @6, @8); if (!$$) YYABORT; } -; - -PropertyList: - Property { $$.head = new PropertyListNode($1); - $$.tail = $$.head; } - | PropertyList ',' Property { $$.head = $1.head; - $$.tail = new PropertyListNode($3, $1.tail); } -; - -PrimaryExpr: - PrimaryExprNoBrace - | OPENBRACE CLOSEBRACE { $$ = new ObjectLiteralNode(); } - | OPENBRACE PropertyList CLOSEBRACE { $$ = new ObjectLiteralNode($2.head); } - /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */ - | OPENBRACE PropertyList ',' CLOSEBRACE { $$ = new ObjectLiteralNode($2.head); } -; - -PrimaryExprNoBrace: - THISTOKEN { $$ = new ThisNode(); } - | Literal - | ArrayLiteral - | IDENT { $$ = new ResolveNode(*$1); } - | '(' Expr ')' { $$ = $2; } -; - -ArrayLiteral: - '[' ElisionOpt ']' { $$ = new ArrayNode($2); } - | '[' ElementList ']' { $$ = new ArrayNode($2.head); } - | '[' ElementList ',' ElisionOpt ']' { $$ = new ArrayNode($4, $2.head); } -; - -ElementList: - ElisionOpt AssignmentExpr { $$.head = new ElementNode($1, $2); - $$.tail = $$.head; } - | ElementList ',' ElisionOpt AssignmentExpr - { $$.head = $1.head; - $$.tail = new ElementNode($1.tail, $3, $4); } -; - -ElisionOpt: - /* nothing */ { $$ = 0; } - | Elision -; - -Elision: - ',' { $$ = 1; } - | Elision ',' { $$ = $1 + 1; } -; - -MemberExpr: - PrimaryExpr - | FunctionExpr { $$ = $1; } - | MemberExpr '[' Expr ']' { $$ = new BracketAccessorNode($1, $3); } - | MemberExpr '.' IDENT { $$ = new DotAccessorNode($1, *$3); } - | NEW MemberExpr Arguments { $$ = new NewExprNode($2, $3); } -; - -MemberExprNoBF: - PrimaryExprNoBrace - | MemberExprNoBF '[' Expr ']' { $$ = new BracketAccessorNode($1, $3); } - | MemberExprNoBF '.' IDENT { $$ = new DotAccessorNode($1, *$3); } - | NEW MemberExpr Arguments { $$ = new NewExprNode($2, $3); } -; - -NewExpr: - MemberExpr - | NEW NewExpr { $$ = new NewExprNode($2); } -; - -NewExprNoBF: - MemberExprNoBF - | NEW NewExpr { $$ = new NewExprNode($2); } -; - -CallExpr: - MemberExpr Arguments { $$ = makeFunctionCallNode($1, $2); } - | CallExpr Arguments { $$ = makeFunctionCallNode($1, $2); } - | CallExpr '[' Expr ']' { $$ = new BracketAccessorNode($1, $3); } - | CallExpr '.' IDENT { $$ = new DotAccessorNode($1, *$3); } -; - -CallExprNoBF: - MemberExprNoBF Arguments { $$ = makeFunctionCallNode($1, $2); } - | CallExprNoBF Arguments { $$ = makeFunctionCallNode($1, $2); } - | CallExprNoBF '[' Expr ']' { $$ = new BracketAccessorNode($1, $3); } - | CallExprNoBF '.' IDENT { $$ = new DotAccessorNode($1, *$3); } -; - -Arguments: - '(' ')' { $$ = new ArgumentsNode(); } - | '(' ArgumentList ')' { $$ = new ArgumentsNode($2.head); } -; - -ArgumentList: - AssignmentExpr { $$.head = new ArgumentListNode($1); - $$.tail = $$.head; } - | ArgumentList ',' AssignmentExpr { $$.head = $1.head; - $$.tail = new ArgumentListNode($1.tail, $3); } -; - -LeftHandSideExpr: - NewExpr - | CallExpr -; - -LeftHandSideExprNoBF: - NewExprNoBF - | CallExprNoBF -; - -PostfixExpr: - LeftHandSideExpr - | LeftHandSideExpr PLUSPLUS { $$ = makePostfixNode($1, OpPlusPlus); } - | LeftHandSideExpr MINUSMINUS { $$ = makePostfixNode($1, OpMinusMinus); } -; - -PostfixExprNoBF: - LeftHandSideExprNoBF - | LeftHandSideExprNoBF PLUSPLUS { $$ = makePostfixNode($1, OpPlusPlus); } - | LeftHandSideExprNoBF MINUSMINUS { $$ = makePostfixNode($1, OpMinusMinus); } -; - -UnaryExprCommon: - DELETETOKEN UnaryExpr { $$ = makeDeleteNode($2); } - | VOIDTOKEN UnaryExpr { $$ = new VoidNode($2); } - | TYPEOF UnaryExpr { $$ = makeTypeOfNode($2); } - | PLUSPLUS UnaryExpr { $$ = makePrefixNode($2, OpPlusPlus); } - | AUTOPLUSPLUS UnaryExpr { $$ = makePrefixNode($2, OpPlusPlus); } - | MINUSMINUS UnaryExpr { $$ = makePrefixNode($2, OpMinusMinus); } - | AUTOMINUSMINUS UnaryExpr { $$ = makePrefixNode($2, OpMinusMinus); } - | '+' UnaryExpr { $$ = new UnaryPlusNode($2); } - | '-' UnaryExpr { $$ = makeNegateNode($2); } - | '~' UnaryExpr { $$ = new BitwiseNotNode($2); } - | '!' UnaryExpr { $$ = new LogicalNotNode($2); } - -UnaryExpr: - PostfixExpr - | UnaryExprCommon -; - -UnaryExprNoBF: - PostfixExprNoBF - | UnaryExprCommon -; - -MultiplicativeExpr: - UnaryExpr - | MultiplicativeExpr '*' UnaryExpr { $$ = new MultNode($1, $3); } - | MultiplicativeExpr '/' UnaryExpr { $$ = new DivNode($1, $3); } - | MultiplicativeExpr '%' UnaryExpr { $$ = new ModNode($1, $3); } -; - -MultiplicativeExprNoBF: - UnaryExprNoBF - | MultiplicativeExprNoBF '*' UnaryExpr - { $$ = new MultNode($1, $3); } - | MultiplicativeExprNoBF '/' UnaryExpr - { $$ = new DivNode($1, $3); } - | MultiplicativeExprNoBF '%' UnaryExpr - { $$ = new ModNode($1, $3); } -; - -AdditiveExpr: - MultiplicativeExpr - | AdditiveExpr '+' MultiplicativeExpr { $$ = makeAddNode($1, $3); } - | AdditiveExpr '-' MultiplicativeExpr { $$ = new SubNode($1, $3); } -; - -AdditiveExprNoBF: - MultiplicativeExprNoBF - | AdditiveExprNoBF '+' MultiplicativeExpr - { $$ = makeAddNode($1, $3); } - | AdditiveExprNoBF '-' MultiplicativeExpr - { $$ = new SubNode($1, $3); } -; - -ShiftExpr: - AdditiveExpr - | ShiftExpr LSHIFT AdditiveExpr { $$ = new LeftShiftNode($1, $3); } - | ShiftExpr RSHIFT AdditiveExpr { $$ = new RightShiftNode($1, $3); } - | ShiftExpr URSHIFT AdditiveExpr { $$ = new UnsignedRightShiftNode($1, $3); } -; - -ShiftExprNoBF: - AdditiveExprNoBF - | ShiftExprNoBF LSHIFT AdditiveExpr { $$ = new LeftShiftNode($1, $3); } - | ShiftExprNoBF RSHIFT AdditiveExpr { $$ = new RightShiftNode($1, $3); } - | ShiftExprNoBF URSHIFT AdditiveExpr { $$ = new UnsignedRightShiftNode($1, $3); } -; - -RelationalExpr: - ShiftExpr - | RelationalExpr '<' ShiftExpr { $$ = makeLessNode($1, $3); } - | RelationalExpr '>' ShiftExpr { $$ = new GreaterNode($1, $3); } - | RelationalExpr LE ShiftExpr { $$ = new LessEqNode($1, $3); } - | RelationalExpr GE ShiftExpr { $$ = new GreaterEqNode($1, $3); } - | RelationalExpr INSTANCEOF ShiftExpr { $$ = new InstanceOfNode($1, $3); } - | RelationalExpr INTOKEN ShiftExpr { $$ = new InNode($1, $3); } -; - -RelationalExprNoIn: - ShiftExpr - | RelationalExprNoIn '<' ShiftExpr { $$ = makeLessNode($1, $3); } - | RelationalExprNoIn '>' ShiftExpr { $$ = new GreaterNode($1, $3); } - | RelationalExprNoIn LE ShiftExpr { $$ = new LessEqNode($1, $3); } - | RelationalExprNoIn GE ShiftExpr { $$ = new GreaterEqNode($1, $3); } - | RelationalExprNoIn INSTANCEOF ShiftExpr - { $$ = new InstanceOfNode($1, $3); } -; - -RelationalExprNoBF: - ShiftExprNoBF - | RelationalExprNoBF '<' ShiftExpr { $$ = makeLessNode($1, $3); } - | RelationalExprNoBF '>' ShiftExpr { $$ = new GreaterNode($1, $3); } - | RelationalExprNoBF LE ShiftExpr { $$ = new LessEqNode($1, $3); } - | RelationalExprNoBF GE ShiftExpr { $$ = new GreaterEqNode($1, $3); } - | RelationalExprNoBF INSTANCEOF ShiftExpr - { $$ = new InstanceOfNode($1, $3); } - | RelationalExprNoBF INTOKEN ShiftExpr { $$ = new InNode($1, $3); } -; - -EqualityExpr: - RelationalExpr - | EqualityExpr EQEQ RelationalExpr { $$ = new EqualNode($1, $3); } - | EqualityExpr NE RelationalExpr { $$ = new NotEqualNode($1, $3); } - | EqualityExpr STREQ RelationalExpr { $$ = new StrictEqualNode($1, $3); } - | EqualityExpr STRNEQ RelationalExpr { $$ = new NotStrictEqualNode($1, $3); } -; - -EqualityExprNoIn: - RelationalExprNoIn - | EqualityExprNoIn EQEQ RelationalExprNoIn - { $$ = new EqualNode($1, $3); } - | EqualityExprNoIn NE RelationalExprNoIn - { $$ = new NotEqualNode($1, $3); } - | EqualityExprNoIn STREQ RelationalExprNoIn - { $$ = new StrictEqualNode($1, $3); } - | EqualityExprNoIn STRNEQ RelationalExprNoIn - { $$ = new NotStrictEqualNode($1, $3); } -; - -EqualityExprNoBF: - RelationalExprNoBF - | EqualityExprNoBF EQEQ RelationalExpr - { $$ = new EqualNode($1, $3); } - | EqualityExprNoBF NE RelationalExpr { $$ = new NotEqualNode($1, $3); } - | EqualityExprNoBF STREQ RelationalExpr - { $$ = new StrictEqualNode($1, $3); } - | EqualityExprNoBF STRNEQ RelationalExpr - { $$ = new NotStrictEqualNode($1, $3); } -; - -BitwiseANDExpr: - EqualityExpr - | BitwiseANDExpr '&' EqualityExpr { $$ = new BitAndNode($1, $3); } -; - -BitwiseANDExprNoIn: - EqualityExprNoIn - | BitwiseANDExprNoIn '&' EqualityExprNoIn - { $$ = new BitAndNode($1, $3); } -; - -BitwiseANDExprNoBF: - EqualityExprNoBF - | BitwiseANDExprNoBF '&' EqualityExpr { $$ = new BitAndNode($1, $3); } -; - -BitwiseXORExpr: - BitwiseANDExpr - | BitwiseXORExpr '^' BitwiseANDExpr { $$ = new BitXOrNode($1, $3); } -; - -BitwiseXORExprNoIn: - BitwiseANDExprNoIn - | BitwiseXORExprNoIn '^' BitwiseANDExprNoIn - { $$ = new BitXOrNode($1, $3); } -; - -BitwiseXORExprNoBF: - BitwiseANDExprNoBF - | BitwiseXORExprNoBF '^' BitwiseANDExpr - { $$ = new BitXOrNode($1, $3); } -; - -BitwiseORExpr: - BitwiseXORExpr - | BitwiseORExpr '|' BitwiseXORExpr { $$ = new BitOrNode($1, $3); } -; - -BitwiseORExprNoIn: - BitwiseXORExprNoIn - | BitwiseORExprNoIn '|' BitwiseXORExprNoIn - { $$ = new BitOrNode($1, $3); } -; - -BitwiseORExprNoBF: - BitwiseXORExprNoBF - | BitwiseORExprNoBF '|' BitwiseXORExpr - { $$ = new BitOrNode($1, $3); } -; - -LogicalANDExpr: - BitwiseORExpr - | LogicalANDExpr AND BitwiseORExpr { $$ = new LogicalAndNode($1, $3); } -; - -LogicalANDExprNoIn: - BitwiseORExprNoIn - | LogicalANDExprNoIn AND BitwiseORExprNoIn - { $$ = new LogicalAndNode($1, $3); } -; - -LogicalANDExprNoBF: - BitwiseORExprNoBF - | LogicalANDExprNoBF AND BitwiseORExpr - { $$ = new LogicalAndNode($1, $3); } -; - -LogicalORExpr: - LogicalANDExpr - | LogicalORExpr OR LogicalANDExpr { $$ = new LogicalOrNode($1, $3); } -; - -LogicalORExprNoIn: - LogicalANDExprNoIn - | LogicalORExprNoIn OR LogicalANDExprNoIn - { $$ = new LogicalOrNode($1, $3); } -; - -LogicalORExprNoBF: - LogicalANDExprNoBF - | LogicalORExprNoBF OR LogicalANDExpr { $$ = new LogicalOrNode($1, $3); } -; - -ConditionalExpr: - LogicalORExpr - | LogicalORExpr '?' AssignmentExpr ':' AssignmentExpr - { $$ = new ConditionalNode($1, $3, $5); } -; - -ConditionalExprNoIn: - LogicalORExprNoIn - | LogicalORExprNoIn '?' AssignmentExprNoIn ':' AssignmentExprNoIn - { $$ = new ConditionalNode($1, $3, $5); } -; - -ConditionalExprNoBF: - LogicalORExprNoBF - | LogicalORExprNoBF '?' AssignmentExpr ':' AssignmentExpr - { $$ = new ConditionalNode($1, $3, $5); } -; - -AssignmentExpr: - ConditionalExpr - | LeftHandSideExpr AssignmentOperator AssignmentExpr - { $$ = makeAssignNode($1, $2, $3); } -; - -AssignmentExprNoIn: - ConditionalExprNoIn - | LeftHandSideExpr AssignmentOperator AssignmentExprNoIn - { $$ = makeAssignNode($1, $2, $3); } -; - -AssignmentExprNoBF: - ConditionalExprNoBF - | LeftHandSideExprNoBF AssignmentOperator AssignmentExpr - { $$ = makeAssignNode($1, $2, $3); } -; - -AssignmentOperator: - '=' { $$ = OpEqual; } - | PLUSEQUAL { $$ = OpPlusEq; } - | MINUSEQUAL { $$ = OpMinusEq; } - | MULTEQUAL { $$ = OpMultEq; } - | DIVEQUAL { $$ = OpDivEq; } - | LSHIFTEQUAL { $$ = OpLShift; } - | RSHIFTEQUAL { $$ = OpRShift; } - | URSHIFTEQUAL { $$ = OpURShift; } - | ANDEQUAL { $$ = OpAndEq; } - | XOREQUAL { $$ = OpXOrEq; } - | OREQUAL { $$ = OpOrEq; } - | MODEQUAL { $$ = OpModEq; } -; - -Expr: - AssignmentExpr - | Expr ',' AssignmentExpr { $$ = new CommaNode($1, $3); } -; - -ExprNoIn: - AssignmentExprNoIn - | ExprNoIn ',' AssignmentExprNoIn { $$ = new CommaNode($1, $3); } -; - -ExprNoBF: - AssignmentExprNoBF - | ExprNoBF ',' AssignmentExpr { $$ = new CommaNode($1, $3); } -; - -Statement: - Block - | VariableStatement - | ConstStatement - | EmptyStatement - | ExprStatement - | IfStatement - | IterationStatement - | ContinueStatement - | BreakStatement - | ReturnStatement - | WithStatement - | SwitchStatement - | LabelledStatement - | ThrowStatement - | TryStatement - | DebuggerStatement -; - -Block: - OPENBRACE CLOSEBRACE { $$ = createNodeInfo(new BlockNode(0), 0, 0); - DBG($$.m_node, @1, @2); } - | OPENBRACE SourceElements CLOSEBRACE { $$ = createNodeInfo(new BlockNode($2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations); - DBG($$.m_node, @1, @3); } -; - -VariableStatement: - VAR VariableDeclarationList ';' { $$ = createNodeInfo(makeVarStatementNode($2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations); - DBG($$.m_node, @1, @3); } - | VAR VariableDeclarationList error { $$ = createNodeInfo(makeVarStatementNode($2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations); - DBG($$.m_node, @1, @2); - AUTO_SEMICOLON; } -; - -VariableDeclarationList: - IDENT { $$.m_node = 0; - $$.m_varDeclarations = new ParserRefCountedData; - appendToVarDeclarationList($$.m_varDeclarations, *$1, 0); - $$.m_funcDeclarations = 0; - } - | IDENT Initializer { $$.m_node = new AssignResolveNode(*$1, $2); - $$.m_varDeclarations = new ParserRefCountedData; - appendToVarDeclarationList($$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer); - $$.m_funcDeclarations = 0; - } - | VariableDeclarationList ',' IDENT - { $$.m_node = $1.m_node; - $$.m_varDeclarations = $1.m_varDeclarations; - appendToVarDeclarationList($$.m_varDeclarations, *$3, 0); - $$.m_funcDeclarations = 0; - } - | VariableDeclarationList ',' IDENT Initializer - { $$.m_node = combineVarInitializers($1.m_node, new AssignResolveNode(*$3, $4)); - $$.m_varDeclarations = $1.m_varDeclarations; - appendToVarDeclarationList($$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer); - $$.m_funcDeclarations = 0; - } -; - -VariableDeclarationListNoIn: - IDENT { $$.m_node = 0; - $$.m_varDeclarations = new ParserRefCountedData; - appendToVarDeclarationList($$.m_varDeclarations, *$1, 0); - $$.m_funcDeclarations = 0; - } - | IDENT InitializerNoIn { $$.m_node = new AssignResolveNode(*$1, $2); - $$.m_varDeclarations = new ParserRefCountedData; - appendToVarDeclarationList($$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer); - $$.m_funcDeclarations = 0; - } - | VariableDeclarationListNoIn ',' IDENT - { $$.m_node = $1.m_node; - $$.m_varDeclarations = $1.m_varDeclarations; - appendToVarDeclarationList($$.m_varDeclarations, *$3, 0); - $$.m_funcDeclarations = 0; - } - | VariableDeclarationListNoIn ',' IDENT InitializerNoIn - { $$.m_node = combineVarInitializers($1.m_node, new AssignResolveNode(*$3, $4)); - $$.m_varDeclarations = $1.m_varDeclarations; - appendToVarDeclarationList($$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer); - $$.m_funcDeclarations = 0; - } -; - -ConstStatement: - CONSTTOKEN ConstDeclarationList ';' { $$ = createNodeInfo(new ConstStatementNode($2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations); - DBG($$.m_node, @1, @3); } - | CONSTTOKEN ConstDeclarationList error - { $$ = createNodeInfo(new ConstStatementNode($2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations); - DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } -; - -ConstDeclarationList: - ConstDeclaration { $$.m_node.head = $1; - $$.m_node.tail = $$.m_node.head; - $$.m_varDeclarations = new ParserRefCountedData; - appendToVarDeclarationList($$.m_varDeclarations, $1); - $$.m_funcDeclarations = 0; } - | ConstDeclarationList ',' ConstDeclaration - { $$.m_node.head = $1.m_node.head; - $1.m_node.tail->m_next = $3; - $$.m_node.tail = $3; - $$.m_varDeclarations = $1.m_varDeclarations; - appendToVarDeclarationList($$.m_varDeclarations, $3); - $$.m_funcDeclarations = 0; } -; - -ConstDeclaration: - IDENT { $$ = new ConstDeclNode(*$1, 0); } - | IDENT Initializer { $$ = new ConstDeclNode(*$1, $2); } -; - -Initializer: - '=' AssignmentExpr { $$ = $2; } -; - -InitializerNoIn: - '=' AssignmentExprNoIn { $$ = $2; } -; - -EmptyStatement: - ';' { $$ = createNodeInfo(new EmptyStatementNode(), 0, 0); } -; - -ExprStatement: - ExprNoBF ';' { $$ = createNodeInfo(new ExprStatementNode($1), 0, 0); - DBG($$.m_node, @1, @2); } - | ExprNoBF error { $$ = createNodeInfo(new ExprStatementNode($1), 0, 0); - DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } -; - -IfStatement: - IF '(' Expr ')' Statement %prec IF_WITHOUT_ELSE - { $$ = createNodeInfo(new IfNode($3, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations); - DBG($$.m_node, @1, @4); } - | IF '(' Expr ')' Statement ELSE Statement - { $$ = createNodeInfo(new IfElseNode($3, $5.m_node, $7.m_node), mergeDeclarationLists($5.m_varDeclarations, $7.m_varDeclarations), mergeDeclarationLists($5.m_funcDeclarations, $7.m_funcDeclarations)); - DBG($$.m_node, @1, @4); } -; - -IterationStatement: - DO Statement WHILE '(' Expr ')' ';' { $$ = createNodeInfo(new DoWhileNode($2.m_node, $5), $2.m_varDeclarations, $2.m_funcDeclarations); - DBG($$.m_node, @1, @3); } - | DO Statement WHILE '(' Expr ')' error { $$ = createNodeInfo(new DoWhileNode($2.m_node, $5), $2.m_varDeclarations, $2.m_funcDeclarations); - DBG($$.m_node, @1, @3); } // Always performs automatic semicolon insertion. - | WHILE '(' Expr ')' Statement { $$ = createNodeInfo(new WhileNode($3, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations); - DBG($$.m_node, @1, @4); } - | FOR '(' ExprNoInOpt ';' ExprOpt ';' ExprOpt ')' Statement - { $$ = createNodeInfo(new ForNode($3, $5, $7, $9.m_node, false), $9.m_varDeclarations, $9.m_funcDeclarations); - DBG($$.m_node, @1, @8); - } - | FOR '(' VAR VariableDeclarationListNoIn ';' ExprOpt ';' ExprOpt ')' Statement - { $$ = createNodeInfo(new ForNode($4.m_node, $6, $8, $10.m_node, true), - mergeDeclarationLists($4.m_varDeclarations, $10.m_varDeclarations), - mergeDeclarationLists($4.m_funcDeclarations, $10.m_funcDeclarations)); - DBG($$.m_node, @1, @9); } - | FOR '(' LeftHandSideExpr INTOKEN Expr ')' Statement - { - ExpressionNode* n = $3; - if (!n->isLocation()) - YYABORT; - $$ = createNodeInfo(new ForInNode(n, $5, $7.m_node), $7.m_varDeclarations, $7.m_funcDeclarations); - DBG($$.m_node, @1, @6); - } - | FOR '(' VAR IDENT INTOKEN Expr ')' Statement - { ForInNode *forIn = new ForInNode(*$4, 0, $6, $8.m_node); - appendToVarDeclarationList($8.m_varDeclarations, *$4, DeclarationStacks::HasInitializer); - $$ = createNodeInfo(forIn, $8.m_varDeclarations, $8.m_funcDeclarations); - DBG($$.m_node, @1, @7); } - | FOR '(' VAR IDENT InitializerNoIn INTOKEN Expr ')' Statement - { ForInNode *forIn = new ForInNode(*$4, $5, $7, $9.m_node); - appendToVarDeclarationList($9.m_varDeclarations, *$4, DeclarationStacks::HasInitializer); - $$ = createNodeInfo(forIn, $9.m_varDeclarations, $9.m_funcDeclarations); - DBG($$.m_node, @1, @8); } -; - -ExprOpt: - /* nothing */ { $$ = 0; } - | Expr -; - -ExprNoInOpt: - /* nothing */ { $$ = 0; } - | ExprNoIn -; - -ContinueStatement: - CONTINUE ';' { $$ = createNodeInfo(new ContinueNode(), 0, 0); - DBG($$.m_node, @1, @2); } - | CONTINUE error { $$ = createNodeInfo(new ContinueNode(), 0, 0); - DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } - | CONTINUE IDENT ';' { $$ = createNodeInfo(new ContinueNode(*$2), 0, 0); - DBG($$.m_node, @1, @3); } - | CONTINUE IDENT error { $$ = createNodeInfo(new ContinueNode(*$2), 0, 0); - DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } -; - -BreakStatement: - BREAK ';' { $$ = createNodeInfo(new BreakNode(), 0, 0); DBG($$.m_node, @1, @2); } - | BREAK error { $$ = createNodeInfo(new BreakNode(), 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } - | BREAK IDENT ';' { $$ = createNodeInfo(new BreakNode(*$2), 0, 0); DBG($$.m_node, @1, @3); } - | BREAK IDENT error { $$ = createNodeInfo(new BreakNode(*$2), 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } -; - -ReturnStatement: - RETURN ';' { $$ = createNodeInfo(new ReturnNode(0), 0, 0); DBG($$.m_node, @1, @2); } - | RETURN error { $$ = createNodeInfo(new ReturnNode(0), 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } - | RETURN Expr ';' { $$ = createNodeInfo(new ReturnNode($2), 0, 0); DBG($$.m_node, @1, @3); } - | RETURN Expr error { $$ = createNodeInfo(new ReturnNode($2), 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } -; - -WithStatement: - WITH '(' Expr ')' Statement { $$ = createNodeInfo(new WithNode($3, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations); - DBG($$.m_node, @1, @4); } -; - -SwitchStatement: - SWITCH '(' Expr ')' CaseBlock { $$ = createNodeInfo(new SwitchNode($3, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations); - DBG($$.m_node, @1, @4); } -; - -CaseBlock: - OPENBRACE CaseClausesOpt CLOSEBRACE { $$ = createNodeInfo(new CaseBlockNode($2.m_node.head, 0, 0), $2.m_varDeclarations, $2.m_funcDeclarations); } - | OPENBRACE CaseClausesOpt DefaultClause CaseClausesOpt CLOSEBRACE - { $$ = createNodeInfo(new CaseBlockNode($2.m_node.head, $3.m_node, $4.m_node.head), - mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $3.m_varDeclarations), $4.m_varDeclarations), - mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $3.m_funcDeclarations), $4.m_funcDeclarations)); } -; - -CaseClausesOpt: - /* nothing */ { $$.m_node.head = 0; $$.m_node.tail = 0; $$.m_varDeclarations = 0; $$.m_funcDeclarations = 0; } - | CaseClauses -; - -CaseClauses: - CaseClause { $$.m_node.head = new ClauseListNode($1.m_node); - $$.m_node.tail = $$.m_node.head; - $$.m_varDeclarations = $1.m_varDeclarations; - $$.m_funcDeclarations = $1.m_funcDeclarations; } - | CaseClauses CaseClause { $$.m_node.head = $1.m_node.head; - $$.m_node.tail = new ClauseListNode($1.m_node.tail, $2.m_node); - $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations); - $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations); - } -; - -CaseClause: - CASE Expr ':' { $$ = createNodeInfo(new CaseClauseNode($2), 0, 0); } - | CASE Expr ':' SourceElements { $$ = createNodeInfo(new CaseClauseNode($2, $4.m_node), $4.m_varDeclarations, $4.m_funcDeclarations); } -; - -DefaultClause: - DEFAULT ':' { $$ = createNodeInfo(new CaseClauseNode(0), 0, 0); } - | DEFAULT ':' SourceElements { $$ = createNodeInfo(new CaseClauseNode(0, $3.m_node), $3.m_varDeclarations, $3.m_funcDeclarations); } -; - -LabelledStatement: - IDENT ':' Statement { $3.m_node->pushLabel(*$1); - $$ = createNodeInfo(new LabelNode(*$1, $3.m_node), $3.m_varDeclarations, $3.m_funcDeclarations); } -; - -ThrowStatement: - THROW Expr ';' { $$ = createNodeInfo(new ThrowNode($2), 0, 0); DBG($$.m_node, @1, @3); } - | THROW Expr error { $$ = createNodeInfo(new ThrowNode($2), 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } -; - -TryStatement: - TRY Block FINALLY Block { $$ = createNodeInfo(new TryNode($2.m_node, CommonIdentifiers::shared()->nullIdentifier, 0, $4.m_node), - mergeDeclarationLists($2.m_varDeclarations, $4.m_varDeclarations), - mergeDeclarationLists($2.m_funcDeclarations, $4.m_funcDeclarations)); - DBG($$.m_node, @1, @2); } - | TRY Block CATCH '(' IDENT ')' Block { $$ = createNodeInfo(new TryNode($2.m_node, *$5, $7.m_node, 0), - mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), - mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations)); - DBG($$.m_node, @1, @2); } - | TRY Block CATCH '(' IDENT ')' Block FINALLY Block - { $$ = createNodeInfo(new TryNode($2.m_node, *$5, $7.m_node, $9.m_node), - mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), $9.m_varDeclarations), - mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations), $9.m_funcDeclarations)); - DBG($$.m_node, @1, @2); } -; - -DebuggerStatement: - DEBUGGER ';' { $$ = createNodeInfo(new EmptyStatementNode(), 0, 0); - DBG($$.m_node, @1, @2); } - | DEBUGGER error { $$ = createNodeInfo(new EmptyStatementNode(), 0, 0); - DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } -; - -FunctionDeclaration: - FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = new FuncDeclNode(*$2, $6, lexer().sourceCode($5, $7, @5.first_line)); DBG($6, @5, @7); } - | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE - { $$ = new FuncDeclNode(*$2, $7, lexer().sourceCode($6, $8, @6.first_line), $4.head); DBG($7, @6, @8); } -; - -FunctionExpr: - FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $5, lexer().sourceCode($4, $6, @4.first_line)); DBG($5, @4, @6); } - | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $6, lexer().sourceCode($5, $7, @5.first_line), $3.head); DBG($6, @5, @7); } - | FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = new FuncExprNode(*$2, $6, lexer().sourceCode($5, $7, @5.first_line)); DBG($6, @5, @7); } - | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = new FuncExprNode(*$2, $7, lexer().sourceCode($6, $8, @6.first_line), $4.head); DBG($7, @6, @8); } -; - -FormalParameterList: - IDENT { $$.head = new ParameterNode(*$1); - $$.tail = $$.head; } - | FormalParameterList ',' IDENT { $$.head = $1.head; - $$.tail = new ParameterNode($1.tail, *$3); } -; - -FunctionBody: - /* not in spec */ { $$ = FunctionBodyNode::create(); } - | SourceElements_NoNode { $$ = FunctionBodyNode::create(); } -; - -Program: - /* not in spec */ { parser().didFinishParsing(0, 0, 0, @0.last_line); } - | SourceElements { parser().didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations, @1.last_line); } -; - -SourceElements: - SourceElement { $$.m_node = new SourceElements; - $$.m_node->append($1.m_node); - $$.m_varDeclarations = $1.m_varDeclarations; - $$.m_funcDeclarations = $1.m_funcDeclarations; - } - | SourceElements SourceElement { $$.m_node->append($2.m_node); - $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations); - $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations); - } -; - -SourceElement: - FunctionDeclaration { $$ = createNodeInfo($1, 0, new ParserRefCountedData); $$.m_funcDeclarations->data.append($1); } - | Statement { $$ = $1; } -; - -// Start NoNodes - -Literal_NoNode: - NULLTOKEN - | TRUETOKEN - | FALSETOKEN - | NUMBER { } - | STRING { } - | '/' /* regexp */ { Lexer& l = lexer(); if (!l.scanRegExp()) YYABORT; } - | DIVEQUAL /* regexp with /= */ { Lexer& l = lexer(); if (!l.scanRegExp()) YYABORT; } -; - -Property_NoNode: - IDENT ':' AssignmentExpr_NoNode { } - | STRING ':' AssignmentExpr_NoNode { } - | NUMBER ':' AssignmentExpr_NoNode { } - | IDENT IDENT '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE { if (*$1 != "get" && *$1 != "set") YYABORT; } - | IDENT IDENT '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE { if (*$1 != "get" && *$1 != "set") YYABORT; } -; - -PropertyList_NoNode: - Property_NoNode - | PropertyList_NoNode ',' Property_NoNode -; - -PrimaryExpr_NoNode: - PrimaryExprNoBrace_NoNode - | OPENBRACE CLOSEBRACE { } - | OPENBRACE PropertyList_NoNode CLOSEBRACE { } - /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */ - | OPENBRACE PropertyList_NoNode ',' CLOSEBRACE { } -; - -PrimaryExprNoBrace_NoNode: - THISTOKEN - | Literal_NoNode - | ArrayLiteral_NoNode - | IDENT { } - | '(' Expr_NoNode ')' -; - -ArrayLiteral_NoNode: - '[' ElisionOpt_NoNode ']' - | '[' ElementList_NoNode ']' - | '[' ElementList_NoNode ',' ElisionOpt_NoNode ']' -; - -ElementList_NoNode: - ElisionOpt_NoNode AssignmentExpr_NoNode - | ElementList_NoNode ',' ElisionOpt_NoNode AssignmentExpr_NoNode -; - -ElisionOpt_NoNode: - /* nothing */ - | Elision_NoNode -; - -Elision_NoNode: - ',' - | Elision_NoNode ',' -; - -MemberExpr_NoNode: - PrimaryExpr_NoNode - | FunctionExpr_NoNode - | MemberExpr_NoNode '[' Expr_NoNode ']' - | MemberExpr_NoNode '.' IDENT - | NEW MemberExpr_NoNode Arguments_NoNode -; - -MemberExprNoBF_NoNode: - PrimaryExprNoBrace_NoNode - | MemberExprNoBF_NoNode '[' Expr_NoNode ']' - | MemberExprNoBF_NoNode '.' IDENT - | NEW MemberExpr_NoNode Arguments_NoNode -; - -NewExpr_NoNode: - MemberExpr_NoNode - | NEW NewExpr_NoNode -; - -NewExprNoBF_NoNode: - MemberExprNoBF_NoNode - | NEW NewExpr_NoNode -; - -CallExpr_NoNode: - MemberExpr_NoNode Arguments_NoNode - | CallExpr_NoNode Arguments_NoNode - | CallExpr_NoNode '[' Expr_NoNode ']' - | CallExpr_NoNode '.' IDENT -; - -CallExprNoBF_NoNode: - MemberExprNoBF_NoNode Arguments_NoNode - | CallExprNoBF_NoNode Arguments_NoNode - | CallExprNoBF_NoNode '[' Expr_NoNode ']' - | CallExprNoBF_NoNode '.' IDENT -; - -Arguments_NoNode: - '(' ')' - | '(' ArgumentList_NoNode ')' -; - -ArgumentList_NoNode: - AssignmentExpr_NoNode - | ArgumentList_NoNode ',' AssignmentExpr_NoNode -; - -LeftHandSideExpr_NoNode: - NewExpr_NoNode - | CallExpr_NoNode -; - -LeftHandSideExprNoBF_NoNode: - NewExprNoBF_NoNode - | CallExprNoBF_NoNode -; - -PostfixExpr_NoNode: - LeftHandSideExpr_NoNode - | LeftHandSideExpr_NoNode PLUSPLUS - | LeftHandSideExpr_NoNode MINUSMINUS -; - -PostfixExprNoBF_NoNode: - LeftHandSideExprNoBF_NoNode - | LeftHandSideExprNoBF_NoNode PLUSPLUS - | LeftHandSideExprNoBF_NoNode MINUSMINUS -; - -UnaryExprCommon_NoNode: - DELETETOKEN UnaryExpr_NoNode - | VOIDTOKEN UnaryExpr_NoNode - | TYPEOF UnaryExpr_NoNode - | PLUSPLUS UnaryExpr_NoNode - | AUTOPLUSPLUS UnaryExpr_NoNode - | MINUSMINUS UnaryExpr_NoNode - | AUTOMINUSMINUS UnaryExpr_NoNode - | '+' UnaryExpr_NoNode - | '-' UnaryExpr_NoNode - | '~' UnaryExpr_NoNode - | '!' UnaryExpr_NoNode - -UnaryExpr_NoNode: - PostfixExpr_NoNode - | UnaryExprCommon_NoNode -; - -UnaryExprNoBF_NoNode: - PostfixExprNoBF_NoNode - | UnaryExprCommon_NoNode -; - -MultiplicativeExpr_NoNode: - UnaryExpr_NoNode - | MultiplicativeExpr_NoNode '*' UnaryExpr_NoNode - | MultiplicativeExpr_NoNode '/' UnaryExpr_NoNode - | MultiplicativeExpr_NoNode '%' UnaryExpr_NoNode -; - -MultiplicativeExprNoBF_NoNode: - UnaryExprNoBF_NoNode - | MultiplicativeExprNoBF_NoNode '*' UnaryExpr_NoNode - | MultiplicativeExprNoBF_NoNode '/' UnaryExpr_NoNode - | MultiplicativeExprNoBF_NoNode '%' UnaryExpr_NoNode -; - -AdditiveExpr_NoNode: - MultiplicativeExpr_NoNode - | AdditiveExpr_NoNode '+' MultiplicativeExpr_NoNode - | AdditiveExpr_NoNode '-' MultiplicativeExpr_NoNode -; - -AdditiveExprNoBF_NoNode: - MultiplicativeExprNoBF_NoNode - | AdditiveExprNoBF_NoNode '+' MultiplicativeExpr_NoNode - | AdditiveExprNoBF_NoNode '-' MultiplicativeExpr_NoNode -; - -ShiftExpr_NoNode: - AdditiveExpr_NoNode - | ShiftExpr_NoNode LSHIFT AdditiveExpr_NoNode - | ShiftExpr_NoNode RSHIFT AdditiveExpr_NoNode - | ShiftExpr_NoNode URSHIFT AdditiveExpr_NoNode -; - -ShiftExprNoBF_NoNode: - AdditiveExprNoBF_NoNode - | ShiftExprNoBF_NoNode LSHIFT AdditiveExpr_NoNode - | ShiftExprNoBF_NoNode RSHIFT AdditiveExpr_NoNode - | ShiftExprNoBF_NoNode URSHIFT AdditiveExpr_NoNode -; - -RelationalExpr_NoNode: - ShiftExpr_NoNode - | RelationalExpr_NoNode '<' ShiftExpr_NoNode - | RelationalExpr_NoNode '>' ShiftExpr_NoNode - | RelationalExpr_NoNode LE ShiftExpr_NoNode - | RelationalExpr_NoNode GE ShiftExpr_NoNode - | RelationalExpr_NoNode INSTANCEOF ShiftExpr_NoNode - | RelationalExpr_NoNode INTOKEN ShiftExpr_NoNode -; - -RelationalExprNoIn_NoNode: - ShiftExpr_NoNode - | RelationalExprNoIn_NoNode '<' ShiftExpr_NoNode - | RelationalExprNoIn_NoNode '>' ShiftExpr_NoNode - | RelationalExprNoIn_NoNode LE ShiftExpr_NoNode - | RelationalExprNoIn_NoNode GE ShiftExpr_NoNode - | RelationalExprNoIn_NoNode INSTANCEOF ShiftExpr_NoNode -; - -RelationalExprNoBF_NoNode: - ShiftExprNoBF_NoNode - | RelationalExprNoBF_NoNode '<' ShiftExpr_NoNode - | RelationalExprNoBF_NoNode '>' ShiftExpr_NoNode - | RelationalExprNoBF_NoNode LE ShiftExpr_NoNode - | RelationalExprNoBF_NoNode GE ShiftExpr_NoNode - | RelationalExprNoBF_NoNode INSTANCEOF ShiftExpr_NoNode - | RelationalExprNoBF_NoNode INTOKEN ShiftExpr_NoNode -; - -EqualityExpr_NoNode: - RelationalExpr_NoNode - | EqualityExpr_NoNode EQEQ RelationalExpr_NoNode - | EqualityExpr_NoNode NE RelationalExpr_NoNode - | EqualityExpr_NoNode STREQ RelationalExpr_NoNode - | EqualityExpr_NoNode STRNEQ RelationalExpr_NoNode -; - -EqualityExprNoIn_NoNode: - RelationalExprNoIn_NoNode - | EqualityExprNoIn_NoNode EQEQ RelationalExprNoIn_NoNode - | EqualityExprNoIn_NoNode NE RelationalExprNoIn_NoNode - | EqualityExprNoIn_NoNode STREQ RelationalExprNoIn_NoNode - | EqualityExprNoIn_NoNode STRNEQ RelationalExprNoIn_NoNode -; - -EqualityExprNoBF_NoNode: - RelationalExprNoBF_NoNode - | EqualityExprNoBF_NoNode EQEQ RelationalExpr_NoNode - | EqualityExprNoBF_NoNode NE RelationalExpr_NoNode - | EqualityExprNoBF_NoNode STREQ RelationalExpr_NoNode - | EqualityExprNoBF_NoNode STRNEQ RelationalExpr_NoNode -; - -BitwiseANDExpr_NoNode: - EqualityExpr_NoNode - | BitwiseANDExpr_NoNode '&' EqualityExpr_NoNode -; - -BitwiseANDExprNoIn_NoNode: - EqualityExprNoIn_NoNode - | BitwiseANDExprNoIn_NoNode '&' EqualityExprNoIn_NoNode -; - -BitwiseANDExprNoBF_NoNode: - EqualityExprNoBF_NoNode - | BitwiseANDExprNoBF_NoNode '&' EqualityExpr_NoNode -; - -BitwiseXORExpr_NoNode: - BitwiseANDExpr_NoNode - | BitwiseXORExpr_NoNode '^' BitwiseANDExpr_NoNode -; - -BitwiseXORExprNoIn_NoNode: - BitwiseANDExprNoIn_NoNode - | BitwiseXORExprNoIn_NoNode '^' BitwiseANDExprNoIn_NoNode -; - -BitwiseXORExprNoBF_NoNode: - BitwiseANDExprNoBF_NoNode - | BitwiseXORExprNoBF_NoNode '^' BitwiseANDExpr_NoNode -; - -BitwiseORExpr_NoNode: - BitwiseXORExpr_NoNode - | BitwiseORExpr_NoNode '|' BitwiseXORExpr_NoNode -; - -BitwiseORExprNoIn_NoNode: - BitwiseXORExprNoIn_NoNode - | BitwiseORExprNoIn_NoNode '|' BitwiseXORExprNoIn_NoNode -; - -BitwiseORExprNoBF_NoNode: - BitwiseXORExprNoBF_NoNode - | BitwiseORExprNoBF_NoNode '|' BitwiseXORExpr_NoNode -; - -LogicalANDExpr_NoNode: - BitwiseORExpr_NoNode - | LogicalANDExpr_NoNode AND BitwiseORExpr_NoNode -; - -LogicalANDExprNoIn_NoNode: - BitwiseORExprNoIn_NoNode - | LogicalANDExprNoIn_NoNode AND BitwiseORExprNoIn_NoNode -; - -LogicalANDExprNoBF_NoNode: - BitwiseORExprNoBF_NoNode - | LogicalANDExprNoBF_NoNode AND BitwiseORExpr_NoNode -; - -LogicalORExpr_NoNode: - LogicalANDExpr_NoNode - | LogicalORExpr_NoNode OR LogicalANDExpr_NoNode -; - -LogicalORExprNoIn_NoNode: - LogicalANDExprNoIn_NoNode - | LogicalORExprNoIn_NoNode OR LogicalANDExprNoIn_NoNode -; - -LogicalORExprNoBF_NoNode: - LogicalANDExprNoBF_NoNode - | LogicalORExprNoBF_NoNode OR LogicalANDExpr_NoNode -; - -ConditionalExpr_NoNode: - LogicalORExpr_NoNode - | LogicalORExpr_NoNode '?' AssignmentExpr_NoNode ':' AssignmentExpr_NoNode -; - -ConditionalExprNoIn_NoNode: - LogicalORExprNoIn_NoNode - | LogicalORExprNoIn_NoNode '?' AssignmentExprNoIn_NoNode ':' AssignmentExprNoIn_NoNode -; - -ConditionalExprNoBF_NoNode: - LogicalORExprNoBF_NoNode - | LogicalORExprNoBF_NoNode '?' AssignmentExpr_NoNode ':' AssignmentExpr_NoNode -; - -AssignmentExpr_NoNode: - ConditionalExpr_NoNode - | LeftHandSideExpr_NoNode AssignmentOperator_NoNode AssignmentExpr_NoNode -; - -AssignmentExprNoIn_NoNode: - ConditionalExprNoIn_NoNode - | LeftHandSideExpr_NoNode AssignmentOperator_NoNode AssignmentExprNoIn_NoNode -; - -AssignmentExprNoBF_NoNode: - ConditionalExprNoBF_NoNode - | LeftHandSideExprNoBF_NoNode AssignmentOperator_NoNode AssignmentExpr_NoNode -; - -AssignmentOperator_NoNode: - '=' - | PLUSEQUAL - | MINUSEQUAL - | MULTEQUAL - | DIVEQUAL - | LSHIFTEQUAL - | RSHIFTEQUAL - | URSHIFTEQUAL - | ANDEQUAL - | XOREQUAL - | OREQUAL - | MODEQUAL -; - -Expr_NoNode: - AssignmentExpr_NoNode - | Expr_NoNode ',' AssignmentExpr_NoNode -; - -ExprNoIn_NoNode: - AssignmentExprNoIn_NoNode - | ExprNoIn_NoNode ',' AssignmentExprNoIn_NoNode -; - -ExprNoBF_NoNode: - AssignmentExprNoBF_NoNode - | ExprNoBF_NoNode ',' AssignmentExpr_NoNode -; - -Statement_NoNode: - Block_NoNode - | VariableStatement_NoNode - | ConstStatement_NoNode - | EmptyStatement_NoNode - | ExprStatement_NoNode - | IfStatement_NoNode - | IterationStatement_NoNode - | ContinueStatement_NoNode - | BreakStatement_NoNode - | ReturnStatement_NoNode - | WithStatement_NoNode - | SwitchStatement_NoNode - | LabelledStatement_NoNode - | ThrowStatement_NoNode - | TryStatement_NoNode - | DebuggerStatement_NoNode -; - -Block_NoNode: - OPENBRACE CLOSEBRACE { } - | OPENBRACE SourceElements_NoNode CLOSEBRACE { } -; - -VariableStatement_NoNode: - VAR VariableDeclarationList_NoNode ';' - | VAR VariableDeclarationList_NoNode error { AUTO_SEMICOLON; } -; - -VariableDeclarationList_NoNode: - IDENT { } - | IDENT Initializer_NoNode { } - | VariableDeclarationList_NoNode ',' IDENT - | VariableDeclarationList_NoNode ',' IDENT Initializer_NoNode -; - -VariableDeclarationListNoIn_NoNode: - IDENT { } - | IDENT InitializerNoIn_NoNode { } - | VariableDeclarationListNoIn_NoNode ',' IDENT - | VariableDeclarationListNoIn_NoNode ',' IDENT InitializerNoIn_NoNode -; - -ConstStatement_NoNode: - CONSTTOKEN ConstDeclarationList_NoNode ';' - | CONSTTOKEN ConstDeclarationList_NoNode error { AUTO_SEMICOLON; } -; - -ConstDeclarationList_NoNode: - ConstDeclaration_NoNode - | ConstDeclarationList_NoNode ',' ConstDeclaration_NoNode -; - -ConstDeclaration_NoNode: - IDENT { } - | IDENT Initializer_NoNode { } -; - -Initializer_NoNode: - '=' AssignmentExpr_NoNode -; - -InitializerNoIn_NoNode: - '=' AssignmentExprNoIn_NoNode -; - -EmptyStatement_NoNode: - ';' -; - -ExprStatement_NoNode: - ExprNoBF_NoNode ';' - | ExprNoBF_NoNode error { AUTO_SEMICOLON; } -; - -IfStatement_NoNode: - IF '(' Expr_NoNode ')' Statement_NoNode %prec IF_WITHOUT_ELSE - | IF '(' Expr_NoNode ')' Statement_NoNode ELSE Statement_NoNode -; - -IterationStatement_NoNode: - DO Statement_NoNode WHILE '(' Expr_NoNode ')' ';' - | DO Statement_NoNode WHILE '(' Expr_NoNode ')' error // Always performs automatic semicolon insertion - | WHILE '(' Expr_NoNode ')' Statement_NoNode - | FOR '(' ExprNoInOpt_NoNode ';' ExprOpt_NoNode ';' ExprOpt_NoNode ')' Statement_NoNode - | FOR '(' VAR VariableDeclarationListNoIn_NoNode ';' ExprOpt_NoNode ';' ExprOpt_NoNode ')' Statement_NoNode - | FOR '(' LeftHandSideExpr_NoNode INTOKEN Expr_NoNode ')' Statement_NoNode - | FOR '(' VAR IDENT INTOKEN Expr_NoNode ')' Statement_NoNode - | FOR '(' VAR IDENT InitializerNoIn_NoNode INTOKEN Expr_NoNode ')' Statement_NoNode -; - -ExprOpt_NoNode: - /* nothing */ - | Expr_NoNode -; - -ExprNoInOpt_NoNode: - /* nothing */ - | ExprNoIn_NoNode -; - -ContinueStatement_NoNode: - CONTINUE ';' - | CONTINUE error { AUTO_SEMICOLON; } - | CONTINUE IDENT ';' - | CONTINUE IDENT error { AUTO_SEMICOLON; } -; - -BreakStatement_NoNode: - BREAK ';' - | BREAK error { AUTO_SEMICOLON; } - | BREAK IDENT ';' - | BREAK IDENT error { AUTO_SEMICOLON; } -; - -ReturnStatement_NoNode: - RETURN ';' - | RETURN error { AUTO_SEMICOLON; } - | RETURN Expr_NoNode ';' - | RETURN Expr_NoNode error { AUTO_SEMICOLON; } -; - -WithStatement_NoNode: - WITH '(' Expr_NoNode ')' Statement_NoNode -; - -SwitchStatement_NoNode: - SWITCH '(' Expr_NoNode ')' CaseBlock_NoNode -; - -CaseBlock_NoNode: - OPENBRACE CaseClausesOpt_NoNode CLOSEBRACE { } - | OPENBRACE CaseClausesOpt_NoNode DefaultClause_NoNode CaseClausesOpt_NoNode CLOSEBRACE { } -; - -CaseClausesOpt_NoNode: - /* nothing */ - | CaseClauses_NoNode -; - -CaseClauses_NoNode: - CaseClause_NoNode - | CaseClauses_NoNode CaseClause_NoNode -; - -CaseClause_NoNode: - CASE Expr_NoNode ':' - | CASE Expr_NoNode ':' SourceElements_NoNode -; - -DefaultClause_NoNode: - DEFAULT ':' - | DEFAULT ':' SourceElements_NoNode -; - -LabelledStatement_NoNode: - IDENT ':' Statement_NoNode { } -; - -ThrowStatement_NoNode: - THROW Expr_NoNode ';' - | THROW Expr_NoNode error { AUTO_SEMICOLON; } -; - -TryStatement_NoNode: - TRY Block_NoNode FINALLY Block_NoNode - | TRY Block_NoNode CATCH '(' IDENT ')' Block_NoNode - | TRY Block_NoNode CATCH '(' IDENT ')' Block_NoNode FINALLY Block_NoNode -; - -DebuggerStatement_NoNode: - DEBUGGER ';' - | DEBUGGER error { AUTO_SEMICOLON; } -; - -FunctionDeclaration_NoNode: - FUNCTION IDENT '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE - | FUNCTION IDENT '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE -; - -FunctionExpr_NoNode: - FUNCTION '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE - | FUNCTION '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE - | FUNCTION IDENT '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE - | FUNCTION IDENT '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE -; - -FormalParameterList_NoNode: - IDENT { } - | FormalParameterList_NoNode ',' IDENT -; - -FunctionBody_NoNode: - /* not in spec */ - | SourceElements_NoNode -; - -SourceElements_NoNode: - SourceElement_NoNode - | SourceElements_NoNode SourceElement_NoNode -; - -SourceElement_NoNode: - FunctionDeclaration_NoNode - | Statement_NoNode -; - -// End NoNodes - -%% - -static AddNode* makeAddNode(ExpressionNode* left, ExpressionNode* right) -{ - JSType t1 = left->expectedReturnType(); - JSType t2 = right->expectedReturnType(); - - if (t1 == NumberType && t2 == NumberType) - return new AddNumbersNode(left, right); - if (t1 == StringType && t2 == StringType) - return new AddStringsNode(left, right); - if (t1 == StringType) - return new AddStringLeftNode(left, right); - if (t2 == StringType) - return new AddStringRightNode(left, right); - return new AddNode(left, right); -} - -static LessNode* makeLessNode(ExpressionNode* left, ExpressionNode* right) -{ - JSType t1 = left->expectedReturnType(); - JSType t2 = right->expectedReturnType(); - - if (t1 == StringType && t2 == StringType) - return new LessStringsNode(left, right); - - // There are certainly more efficient ways to do this type check if necessary - if (t1 == NumberType || t1 == BooleanType || t1 == UndefinedType || t1 == NullType || - t2 == NumberType || t2 == BooleanType || t2 == UndefinedType || t2 == NullType) - return new LessNumbersNode(left, right); - - // Neither is certain to be a number, nor were both certain to be strings, so we use the default (slow) implementation. - return new LessNode(left, right); -} - -static ExpressionNode* makeAssignNode(ExpressionNode* loc, Operator op, ExpressionNode* expr) -{ - if (!loc->isLocation()) - return new AssignErrorNode(loc, op, expr); - - if (loc->isResolveNode()) { - ResolveNode* resolve = static_cast(loc); - if (op == OpEqual) - return new AssignResolveNode(resolve->identifier(), expr); - else - return new ReadModifyResolveNode(resolve->identifier(), op, expr); - } - if (loc->isBracketAccessorNode()) { - BracketAccessorNode* bracket = static_cast(loc); - if (op == OpEqual) - return new AssignBracketNode(bracket->base(), bracket->subscript(), expr); - else - return new ReadModifyBracketNode(bracket->base(), bracket->subscript(), op, expr); - } - ASSERT(loc->isDotAccessorNode()); - DotAccessorNode* dot = static_cast(loc); - if (op == OpEqual) - return new AssignDotNode(dot->base(), dot->identifier(), expr); - return new ReadModifyDotNode(dot->base(), dot->identifier(), op, expr); -} - -static ExpressionNode* makePrefixNode(ExpressionNode* expr, Operator op) -{ - if (!expr->isLocation()) - return new PrefixErrorNode(expr, op); - - if (expr->isResolveNode()) { - ResolveNode* resolve = static_cast(expr); - if (op == OpPlusPlus) - return new PreIncResolveNode(resolve->identifier()); - else - return new PreDecResolveNode(resolve->identifier()); - } - if (expr->isBracketAccessorNode()) { - BracketAccessorNode* bracket = static_cast(expr); - if (op == OpPlusPlus) - return new PreIncBracketNode(bracket->base(), bracket->subscript()); - else - return new PreDecBracketNode(bracket->base(), bracket->subscript()); - } - ASSERT(expr->isDotAccessorNode()); - DotAccessorNode* dot = static_cast(expr); - if (op == OpPlusPlus) - return new PreIncDotNode(dot->base(), dot->identifier()); - return new PreDecDotNode(dot->base(), dot->identifier()); -} - -static ExpressionNode* makePostfixNode(ExpressionNode* expr, Operator op) -{ - if (!expr->isLocation()) - return new PostfixErrorNode(expr, op); - - if (expr->isResolveNode()) { - ResolveNode* resolve = static_cast(expr); - if (op == OpPlusPlus) - return new PostIncResolveNode(resolve->identifier()); - else - return new PostDecResolveNode(resolve->identifier()); - } - if (expr->isBracketAccessorNode()) { - BracketAccessorNode* bracket = static_cast(expr); - if (op == OpPlusPlus) - return new PostIncBracketNode(bracket->base(), bracket->subscript()); - else - return new PostDecBracketNode(bracket->base(), bracket->subscript()); - } - ASSERT(expr->isDotAccessorNode()); - DotAccessorNode* dot = static_cast(expr); - - if (op == OpPlusPlus) - return new PostIncDotNode(dot->base(), dot->identifier()); - return new PostDecDotNode(dot->base(), dot->identifier()); -} - -static ExpressionNode* makeFunctionCallNode(ExpressionNode* func, ArgumentsNode* args) -{ - if (!func->isLocation()) - return new FunctionCallValueNode(func, args); - if (func->isResolveNode()) { - ResolveNode* resolve = static_cast(func); - return new FunctionCallResolveNode(resolve->identifier(), args); - } - if (func->isBracketAccessorNode()) { - BracketAccessorNode* bracket = static_cast(func); - return new FunctionCallBracketNode(bracket->base(), bracket->subscript(), args); - } - ASSERT(func->isDotAccessorNode()); - DotAccessorNode* dot = static_cast(func); - return new FunctionCallDotNode(dot->base(), dot->identifier(), args); -} - -static ExpressionNode* makeTypeOfNode(ExpressionNode* expr) -{ - if (expr->isResolveNode()) { - ResolveNode* resolve = static_cast(expr); - return new TypeOfResolveNode(resolve->identifier()); - } - return new TypeOfValueNode(expr); -} - -static ExpressionNode* makeDeleteNode(ExpressionNode* expr) -{ - if (!expr->isLocation()) - return new DeleteValueNode(expr); - if (expr->isResolveNode()) { - ResolveNode* resolve = static_cast(expr); - return new DeleteResolveNode(resolve->identifier()); - } - if (expr->isBracketAccessorNode()) { - BracketAccessorNode* bracket = static_cast(expr); - return new DeleteBracketNode(bracket->base(), bracket->subscript()); - } - ASSERT(expr->isDotAccessorNode()); - DotAccessorNode* dot = static_cast(expr); - return new DeleteDotNode(dot->base(), dot->identifier()); -} - -static PropertyNode* makeGetterOrSetterPropertyNode(const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceCode& source) -{ - PropertyNode::Type type; - if (getOrSet == "get") - type = PropertyNode::Getter; - else if (getOrSet == "set") - type = PropertyNode::Setter; - else - return 0; - return new PropertyNode(name, new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, body, source, params), type); -} - -static ExpressionNode* makeNegateNode(ExpressionNode* n) -{ - if (n->isNumber()) { - NumberNode* number = static_cast(n); - - if (number->value() > 0.0) { - number->setValue(-number->value()); - return number; - } - } - - return new NegateNode(n); -} - -static NumberNode* makeNumberNode(double d) -{ - JSValue* value = JSImmediate::from(d); - if (value) - return new ImmediateNumberNode(value, d); - return new NumberNode(d); -} - -/* called by yyparse on error */ -int yyerror(const char *) -{ - return 1; -} - -/* may we automatically insert a semicolon ? */ -static bool allowAutomaticSemicolon() -{ - return yychar == CLOSEBRACE || yychar == 0 || lexer().prevTerminator(); -} - -static ExpressionNode* combineVarInitializers(ExpressionNode* list, AssignResolveNode* init) -{ - if (!list) - return init; - return new VarDeclCommaNode(list, init); -} - -// We turn variable declarations into either assignments or empty -// statements (which later get stripped out), because the actual -// declaration work is hoisted up to the start of the function body -static StatementNode* makeVarStatementNode(ExpressionNode* expr) -{ - if (!expr) - return new EmptyStatementNode(); - return new VarStatementNode(expr); -} - diff --git a/kjs/identifier.cpp b/kjs/identifier.cpp deleted file mode 100644 index 3fa01ad..0000000 --- a/kjs/identifier.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003 Apple Computer, Inc - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" - -#include "identifier.h" - -#include "JSLock.h" -#include // for placement new -#include // for strlen -#include -#include -#include - -namespace WTF { - - template struct DefaultHash; - template struct StrHash; - - template<> struct StrHash { - static unsigned hash(const KJS::UString::Rep *key) { return key->hash(); } - static bool equal(const KJS::UString::Rep *a, const KJS::UString::Rep *b) { return KJS::Identifier::equal(a, b); } - static const bool safeToCompareToEmptyOrDeleted = false; - }; - - template<> struct DefaultHash { - typedef StrHash Hash; - }; - -} - -namespace KJS { - -typedef HashSet IdentifierTable; -static IdentifierTable *table; - -static inline IdentifierTable& identifierTable() -{ - ASSERT(JSLock::lockCount() > 0); - - if (!table) - table = new IdentifierTable; - return *table; -} - - -bool Identifier::equal(const UString::Rep *r, const char *s) -{ - int length = r->len; - const UChar *d = r->data(); - for (int i = 0; i != length; ++i) - if (d[i].uc != (unsigned char)s[i]) - return false; - return s[length] == 0; -} - -bool Identifier::equal(const UString::Rep *r, const UChar *s, int length) -{ - if (r->len != length) - return false; - const UChar *d = r->data(); - for (int i = 0; i != length; ++i) - if (d[i].uc != s[i].uc) - return false; - return true; -} - -bool Identifier::equal(const UString::Rep *r, const UString::Rep *b) -{ - int length = r->len; - if (length != b->len) - return false; - const UChar *d = r->data(); - const UChar *s = b->data(); - for (int i = 0; i != length; ++i) - if (d[i].uc != s[i].uc) - return false; - return true; -} - -struct CStringTranslator -{ - static unsigned hash(const char *c) - { - return UString::Rep::computeHash(c); - } - - static bool equal(UString::Rep *r, const char *s) - { - return Identifier::equal(r, s); - } - - static void translate(UString::Rep*& location, const char *c, unsigned hash) - { - size_t length = strlen(c); - UChar *d = static_cast(fastMalloc(sizeof(UChar) * length)); - for (size_t i = 0; i != length; i++) - d[i] = c[i]; - - UString::Rep *r = UString::Rep::create(d, static_cast(length)).releaseRef(); - r->isIdentifier = 1; - r->rc = 0; - r->_hash = hash; - - location = r; - } -}; - -PassRefPtr Identifier::add(const char *c) -{ - if (!c) { - UString::Rep::null.hash(); - return &UString::Rep::null; - } - - if (!c[0]) { - UString::Rep::empty.hash(); - return &UString::Rep::empty; - } - - return *identifierTable().add(c).first; -} - -struct UCharBuffer { - const UChar *s; - unsigned int length; -}; - -struct UCharBufferTranslator -{ - static unsigned hash(const UCharBuffer& buf) - { - return UString::Rep::computeHash(buf.s, buf.length); - } - - static bool equal(UString::Rep *str, const UCharBuffer& buf) - { - return Identifier::equal(str, buf.s, buf.length); - } - - static void translate(UString::Rep *& location, const UCharBuffer& buf, unsigned hash) - { - UChar *d = static_cast(fastMalloc(sizeof(UChar) * buf.length)); - for (unsigned i = 0; i != buf.length; i++) - d[i] = buf.s[i]; - - UString::Rep *r = UString::Rep::create(d, buf.length).releaseRef(); - r->isIdentifier = 1; - r->rc = 0; - r->_hash = hash; - - location = r; - } -}; - -PassRefPtr Identifier::add(const UChar *s, int length) -{ - if (!length) { - UString::Rep::empty.hash(); - return &UString::Rep::empty; - } - - UCharBuffer buf = {s, length}; - return *identifierTable().add(buf).first; -} - -PassRefPtr Identifier::addSlowCase(UString::Rep *r) -{ - ASSERT(!r->isIdentifier); - - if (r->len == 0) { - UString::Rep::empty.hash(); - return &UString::Rep::empty; - } - - UString::Rep *result = *identifierTable().add(r).first; - if (result == r) - r->isIdentifier = true; - return result; -} - -void Identifier::remove(UString::Rep *r) -{ - identifierTable().remove(r); -} - -} // namespace KJS diff --git a/kjs/identifier.h b/kjs/identifier.h deleted file mode 100644 index fc43344..0000000 --- a/kjs/identifier.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_IDENTIFIER_H -#define KJS_IDENTIFIER_H - -#include "ustring.h" - -namespace KJS { - - class Identifier { - friend class PropertyMap; - public: - Identifier() { } - Identifier(const char* s) : _ustring(add(s)) { } - Identifier(const UChar* s, int length) : _ustring(add(s, length)) { } - explicit Identifier(UString::Rep* rep) : _ustring(add(rep)) { } - explicit Identifier(const UString& s) : _ustring(add(s.rep())) { } - - // Special constructor for cases where we overwrite an object in place. - Identifier(PlacementNewAdoptType) : _ustring(PlacementNewAdopt) { } - - const UString& ustring() const { return _ustring; } - DOM::DOMString domString() const; - - const UChar* data() const { return _ustring.data(); } - int size() const { return _ustring.size(); } - - const char* ascii() const { return _ustring.ascii(); } - - static Identifier from(unsigned y) { return Identifier(UString::from(y)); } - - bool isNull() const { return _ustring.isNull(); } - bool isEmpty() const { return _ustring.isEmpty(); } - - uint32_t toUInt32(bool* ok) const { return _ustring.toUInt32(ok); } - uint32_t toUInt32(bool* ok, bool tolerateEmptyString) const { return _ustring.toUInt32(ok, tolerateEmptyString); }; - uint32_t toStrictUInt32(bool* ok) const { return _ustring.toStrictUInt32(ok); } - unsigned toArrayIndex(bool* ok) const { return _ustring.toArrayIndex(ok); } - double toDouble() const { return _ustring.toDouble(); } - - friend bool operator==(const Identifier&, const Identifier&); - friend bool operator!=(const Identifier&, const Identifier&); - - friend bool operator==(const Identifier&, const char*); - - static void remove(UString::Rep* ); - - static bool equal(const UString::Rep*, const char*); - static bool equal(const UString::Rep*, const UChar*, int length); - static bool equal(const UString::Rep*, const UString::Rep*); - - private: - UString _ustring; - - static bool equal(const Identifier& a, const Identifier& b) - { return a._ustring.rep() == b._ustring.rep(); } - static bool equal(const Identifier& a, const char* b) - { return equal(a._ustring.rep(), b); } - - static PassRefPtr add(const char*); - static PassRefPtr add(const UChar*, int length); - static PassRefPtr add(UString::Rep* r) - { - if (r->isIdentifier) - return r; - return addSlowCase(r); - } - static PassRefPtr addSlowCase(UString::Rep *r); - }; - - inline bool operator==(const Identifier& a, const Identifier& b) - { return Identifier::equal(a, b); } - - inline bool operator!=(const Identifier& a, const Identifier& b) - { return !Identifier::equal(a, b); } - - inline bool operator==(const Identifier& a, const char* b) - { return Identifier::equal(a, b); } - -} // namespace KJS - -#endif // KJS_IDENTIFIER_H diff --git a/kjs/internal.cpp b/kjs/internal.cpp deleted file mode 100644 index 5482b48..0000000 --- a/kjs/internal.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (C) 1999-2002 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "internal.h" - -#include "ExecState.h" -#include "array_object.h" -#include "bool_object.h" -#include "collector.h" -#include "date_object.h" -#include "debugger.h" -#include "error_object.h" -#include "function_object.h" -#include "lexer.h" -#include "math_object.h" -#include "nodes.h" -#include "number_object.h" -#include "object.h" -#include "object_object.h" -#include "operations.h" -#include "regexp_object.h" -#include "string_object.h" -#include -#include -#include -#include -#include -#include - -namespace KJS { - -// ------------------------------ StringImp ------------------------------------ - -JSValue* StringImp::toPrimitive(ExecState*, JSType) const -{ - return const_cast(this); -} - -bool StringImp::getPrimitiveNumber(ExecState*, double& number, JSValue*& value) -{ - value = this; - number = val.toDouble(); - return false; -} - -bool StringImp::toBoolean(ExecState *) const -{ - return (val.size() > 0); -} - -double StringImp::toNumber(ExecState *) const -{ - return val.toDouble(); -} - -UString StringImp::toString(ExecState *) const -{ - return val; -} - -JSObject* StringImp::toObject(ExecState *exec) const -{ - return new StringInstance(exec->lexicalGlobalObject()->stringPrototype(), const_cast(this)); -} - -// ------------------------------ NumberImp ------------------------------------ - -JSValue* NumberImp::toPrimitive(ExecState*, JSType) const -{ - return const_cast(this); -} - -bool NumberImp::getPrimitiveNumber(ExecState*, double& number, JSValue*& value) -{ - number = val; - value = this; - return true; -} - -bool NumberImp::toBoolean(ExecState *) const -{ - return val < 0.0 || val > 0.0; // false for NaN -} - -double NumberImp::toNumber(ExecState *) const -{ - return val; -} - -UString NumberImp::toString(ExecState *) const -{ - if (val == 0.0) // +0.0 or -0.0 - return "0"; - return UString::from(val); -} - -JSObject *NumberImp::toObject(ExecState *exec) const -{ - List args; - args.append(const_cast(this)); - return static_cast(exec->lexicalGlobalObject()->numberConstructor()->construct(exec,args)); -} - -bool NumberImp::getUInt32(uint32_t& uint32) const -{ - uint32 = static_cast(val); - return uint32 == val; -} - -bool NumberImp::getTruncatedInt32(int32_t& int32) const -{ - if (!(val >= -2147483648.0 && val < 2147483648.0)) - return false; - int32 = static_cast(val); - return true; -} - -bool NumberImp::getTruncatedUInt32(uint32_t& uint32) const -{ - if (!(val >= 0.0 && val < 4294967296.0)) - return false; - uint32 = static_cast(val); - return true; -} - -// --------------------------- GetterSetterImp --------------------------------- -void GetterSetterImp::mark() -{ - JSCell::mark(); - - if (getter && !getter->marked()) - getter->mark(); - if (setter && !setter->marked()) - setter->mark(); -} - -JSValue* GetterSetterImp::toPrimitive(ExecState*, JSType) const -{ - ASSERT(false); - return jsNull(); -} - -bool GetterSetterImp::getPrimitiveNumber(ExecState*, double& number, JSValue*& value) -{ - ASSERT_NOT_REACHED(); - number = 0; - value = 0; - return true; -} - -bool GetterSetterImp::toBoolean(ExecState*) const -{ - ASSERT(false); - return false; -} - -double GetterSetterImp::toNumber(ExecState *) const -{ - ASSERT(false); - return 0.0; -} - -UString GetterSetterImp::toString(ExecState *) const -{ - ASSERT(false); - return UString::null(); -} - -JSObject *GetterSetterImp::toObject(ExecState *exec) const -{ - ASSERT(false); - return jsNull()->toObject(exec); -} - -// ------------------------------ LabelStack ----------------------------------- - -bool LabelStack::push(const Identifier &id) -{ - if (contains(id)) - return false; - - StackElem *newtos = new StackElem; - newtos->id = id; - newtos->prev = tos; - tos = newtos; - return true; -} - -bool LabelStack::contains(const Identifier &id) const -{ - if (id.isEmpty()) - return true; - - for (StackElem *curr = tos; curr; curr = curr->prev) - if (curr->id == id) - return true; - - return false; -} - -// ------------------------------ InternalFunctionImp -------------------------- - -const ClassInfo InternalFunctionImp::info = { "Function", 0, 0 }; - -InternalFunctionImp::InternalFunctionImp() -{ -} - -InternalFunctionImp::InternalFunctionImp(FunctionPrototype* funcProto, const Identifier& name) - : JSObject(funcProto) - , m_name(name) -{ -} - -bool InternalFunctionImp::implementsCall() const -{ - return true; -} - -bool InternalFunctionImp::implementsHasInstance() const -{ - return true; -} - -// ------------------------------ global functions ----------------------------- - -#ifndef NDEBUG -#include -void printInfo(ExecState *exec, const char *s, JSValue *o, int lineno) -{ - if (!o) - fprintf(stderr, "KJS: %s: (null)", s); - else { - JSValue *v = o; - - UString name; - switch (v->type()) { - case UnspecifiedType: - name = "Unspecified"; - break; - case UndefinedType: - name = "Undefined"; - break; - case NullType: - name = "Null"; - break; - case BooleanType: - name = "Boolean"; - break; - case StringType: - name = "String"; - break; - case NumberType: - name = "Number"; - break; - case ObjectType: - name = static_cast(v)->className(); - if (name.isNull()) - name = "(unknown class)"; - break; - case GetterSetterType: - name = "GetterSetter"; - break; - } - UString vString = v->toString(exec); - if ( vString.size() > 50 ) - vString = vString.substr( 0, 50 ) + "..."; - // Can't use two UString::ascii() in the same fprintf call - CString tempString( vString.cstring() ); - - fprintf(stderr, "KJS: %s: %s : %s (%p)", - s, tempString.c_str(), name.ascii(), (void*)v); - - if (lineno >= 0) - fprintf(stderr, ", line %d\n",lineno); - else - fprintf(stderr, "\n"); - } -} -#endif - -} diff --git a/kjs/internal.h b/kjs/internal.h deleted file mode 100644 index 51438b3..0000000 --- a/kjs/internal.h +++ /dev/null @@ -1,122 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef INTERNAL_H -#define INTERNAL_H - -#include "JSType.h" -#include "object.h" -#include "protect.h" -#include "scope_chain.h" -#include "types.h" -#include "ustring.h" - -#include - -#define I18N_NOOP(s) s - -namespace KJS { - - class FunctionPrototype; - - // --------------------------------------------------------------------------- - // Primitive impls - // --------------------------------------------------------------------------- - - class StringImp : public JSCell { - public: - StringImp(const UString& v) : val(v) { Collector::reportExtraMemoryCost(v.cost()); } - enum HasOtherOwnerType { HasOtherOwner }; - StringImp(const UString& value, HasOtherOwnerType) : val(value) { } - const UString& value() const { return val; } - - private: - virtual JSType type() const { return StringType; } - - virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const; - virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); - virtual bool toBoolean(ExecState *exec) const; - virtual double toNumber(ExecState *exec) const; - virtual JSObject *toObject(ExecState *exec) const; - virtual UString toString(ExecState*) const; - - UString val; - }; - - class NumberImp : public JSCell { - friend class ConstantValues; - friend JSValue *jsNumberCell(double); - public: - double value() const { return val; } - - virtual JSType type() const { return NumberType; } - - virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const; - virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); - virtual bool toBoolean(ExecState *exec) const; - virtual double toNumber(ExecState *exec) const; - virtual UString toString(ExecState *exec) const; - virtual JSObject *toObject(ExecState *exec) const; - - void* operator new(size_t size) - { - return Collector::allocateNumber(size); - } - private: - NumberImp(double v) : val(v) { } - - virtual bool getUInt32(uint32_t&) const; - virtual bool getTruncatedInt32(int32_t&) const; - virtual bool getTruncatedUInt32(uint32_t&) const; - - double val; - }; - - - // --------------------------------------------------------------------------- - // Evaluation - // --------------------------------------------------------------------------- - - struct AttachedGlobalObject; - class DebuggerImp { - public: - - DebuggerImp() { - globalObjects = 0; - isAborted = false; - } - - void abort() { isAborted = true; } - bool aborted() const { return isAborted; } - - AttachedGlobalObject* globalObjects; - bool isAborted; - }; - -#ifndef NDEBUG - void printInfo(ExecState *exec, const char *s, JSValue *, int lineno = -1); -#endif - -} // namespace - -#endif // INTERNAL_H diff --git a/kjs/interpreter.cpp b/kjs/interpreter.cpp deleted file mode 100644 index 1ef21cf..0000000 --- a/kjs/interpreter.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2007 Apple Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "interpreter.h" - -#include "ExecState.h" -#include "JSGlobalObject.h" -#include "Parser.h" -#include "SavedBuiltins.h" -#include "array_object.h" -#include "bool_object.h" -#include "collector.h" -#include "date_object.h" -#include "debugger.h" -#include "error_object.h" -#include "function_object.h" -#include "internal.h" -#include "math_object.h" -#include "nodes.h" -#include "number_object.h" -#include "object.h" -#include "object_object.h" -#include "operations.h" -#include "regexp_object.h" -#include "runtime.h" -#include "string_object.h" -#include "types.h" -#include "value.h" -#include -#include -#include - -namespace KJS { - -Completion Interpreter::checkSyntax(ExecState* exec, const SourceCode& source) -{ - JSLock lock; - - int errLine; - UString errMsg; - RefPtr progNode = parser().parse(source, &errLine, &errMsg); - if (!progNode) - return Completion(Throw, Error::create(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url())); - return Completion(Normal); -} - -Completion Interpreter::evaluate(ExecState* exec, const SourceCode& source, JSValue* thisV) -{ - JSLock lock; - - JSGlobalObject* globalObject = exec->dynamicGlobalObject(); - - if (globalObject->recursion() >= 20) - return Completion(Throw, Error::create(exec, GeneralError, "Recursion too deep")); - - // parse the source code - int errLine; - UString errMsg; - RefPtr progNode = parser().parse(source, &errLine, &errMsg); - - // removed debugger support - - // no program node means a syntax error occurred - if (!progNode) - return Completion(Throw, Error::create(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url())); - - exec->clearException(); - - globalObject->incRecursion(); - - JSObject* thisObj = globalObject; - - // "this" must be an object... use same rules as Function.prototype.apply() - if (thisV && !thisV->isUndefinedOrNull()) - thisObj = thisV->toObject(exec); - - Completion res; - if (exec->hadException()) - // the thisV->toObject() conversion above might have thrown an exception - if so, propagate it - res = Completion(Throw, exec->exception()); - else { - // execute the code - InterpreterExecState newExec(globalObject, thisObj, progNode.get()); - JSValue* value = progNode->execute(&newExec); - res = Completion(newExec.completionType(), value); - } - - globalObject->decRecursion(); - - if (shouldPrintExceptions() && res.complType() == Throw) { - JSLock lock; - ExecState* exec = globalObject->globalExec(); - CString f = source.provider()->url().UTF8String(); - CString message = res.value()->toObject(exec)->toString(exec).UTF8String(); - int line = res.value()->toObject(exec)->get(exec, "line")->toUInt32(exec); -#if PLATFORM(WIN_OS) - printf("%s line %d: %s\n", f.c_str(), line, message.c_str()); -#else - printf("[%d] %s line %d: %s\n", getpid(), f.c_str(), line, message.c_str()); -#endif - } - - return res; -} - -static bool printExceptions = false; - -bool Interpreter::shouldPrintExceptions() -{ - return printExceptions; -} - -void Interpreter::setShouldPrintExceptions(bool print) -{ - printExceptions = print; -} - -} // namespace KJS diff --git a/kjs/interpreter.h b/kjs/interpreter.h deleted file mode 100644 index 0e67c6f..0000000 --- a/kjs/interpreter.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_Interpreter_h -#define KJS_Interpreter_h - -#include - -namespace KJS { - - class Completion; - class ExecState; - class JSValue; - class SourceCode; - class UString; - - struct UChar; - - class Interpreter { - public: - /** - * Parses the supplied ECMAScript code and checks for syntax errors. - * - * @param code The code to check - * @return A normal completion if there were no syntax errors in the code, - * otherwise a throw completion with the syntax error as its value. - */ - static Completion checkSyntax(ExecState*, const SourceCode&); - - /** - * Evaluates the supplied ECMAScript code. - * - * Since this method returns a Completion, you should check the type of - * completion to detect an error or before attempting to access the returned - * value. For example, if an error occurs during script execution and is not - * caught by the script, the completion type will be Throw. - * - * If the supplied code is invalid, a SyntaxError will be thrown. - * - * @param code The code to evaluate - * @param thisV The value to pass in as the "this" value for the script - * execution. This should either be jsNull() or an Object. - * @return A completion object representing the result of the execution. - */ - static Completion evaluate(ExecState*, const SourceCode&, JSValue* thisV = 0); - - static bool shouldPrintExceptions(); - static void setShouldPrintExceptions(bool); - }; - -} // namespace KJS - -#endif // KJS_Interpreter_h diff --git a/kjs/lexer.cpp b/kjs/lexer.cpp deleted file mode 100644 index 18a117f..0000000 --- a/kjs/lexer.cpp +++ /dev/null @@ -1,919 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2006, 2007, 2008 Apple Inc. All Rights Reserved. - * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "lexer.h" - -#include "dtoa.h" -#include "function.h" -#include "nodes.h" -#include "NodeInfo.h" -#include -#include -#include -#include -#include - -using namespace WTF; -using namespace Unicode; - -// we can't specify the namespace in yacc's C output, so do it here -using namespace KJS; - -#ifndef KDE_USE_FINAL -#include "grammar.h" -#endif - -#include "lookup.h" -#include "lexer.lut.h" - -extern YYLTYPE kjsyylloc; // global bison variable holding token info - -// a bridge for yacc from the C world to C++ -int kjsyylex() -{ - return lexer().lex(); -} - -namespace KJS { - -static bool isDecimalDigit(int); - -static const size_t initialReadBufferCapacity = 32; -static const size_t initialStringTableCapacity = 64; - -Lexer& lexer() -{ - ASSERT(JSLock::currentThreadIsHoldingLock()); - - // FIXME: We'd like to avoid calling new here, but we don't currently - // support tearing down the Lexer at app quit time, since that would involve - // tearing down its UString data members without holding the JSLock. - static Lexer* staticLexer = new Lexer; - return *staticLexer; -} - -Lexer::Lexer() - : yylineno(1) - , restrKeyword(false) - , eatNextIdentifier(false) - , stackToken(-1) - , lastToken(-1) - , pos(0) - , code(0) - , length(0) - , atLineStart(true) - , current(0) - , next1(0) - , next2(0) - , next3(0) - , m_currentOffset(0) - , m_nextOffset1(0) - , m_nextOffset2(0) - , m_nextOffset3(0) -{ - m_buffer8.reserveCapacity(initialReadBufferCapacity); - m_buffer16.reserveCapacity(initialReadBufferCapacity); - m_strings.reserveCapacity(initialStringTableCapacity); - m_identifiers.reserveCapacity(initialStringTableCapacity); -} - -void Lexer::setCode(const SourceCode& source) -{ - yylineno = source.firstLine(); - restrKeyword = false; - delimited = false; - eatNextIdentifier = false; - stackToken = -1; - lastToken = -1; - pos = 0; - m_source = &source; - code = source.provider()->data() + source.startOffset(); - length = source.length(); - skipLF = false; - skipCR = false; - error = false; - atLineStart = true; - - // read first characters - shift(4); -} - -void Lexer::shift(unsigned p) -{ - // ECMA-262 calls for stripping Cf characters here, but we only do this for BOM, - // see . - - while (p--) { - current = next1; - next1 = next2; - next2 = next3; - m_currentOffset = m_nextOffset1; - m_nextOffset1 = m_nextOffset2; - m_nextOffset2 = m_nextOffset3; - do { - if (pos >= length) { - m_nextOffset3 = pos; - pos++; - next3 = -1; - break; - } - m_nextOffset3 = pos; - next3 = code[pos++].uc; - } while (next3 == 0xFEFF); - } -} - -// called on each new line -void Lexer::nextLine() -{ - yylineno++; - atLineStart = true; -} - -void Lexer::setDone(State s) -{ - state = s; - done = true; -} - -int Lexer::lex() -{ - int token = 0; - state = Start; - unsigned short stringType = 0; // either single or double quotes - m_buffer8.clear(); - m_buffer16.clear(); - done = false; - terminator = false; - skipLF = false; - skipCR = false; - - // did we push a token on the stack previously ? - // (after an automatic semicolon insertion) - if (stackToken >= 0) { - setDone(Other); - token = stackToken; - stackToken = 0; - } - - int startOffset = m_currentOffset; - while (!done) { - if (skipLF && current != '\n') // found \r but not \n afterwards - skipLF = false; - if (skipCR && current != '\r') // found \n but not \r afterwards - skipCR = false; - if (skipLF || skipCR) // found \r\n or \n\r -> eat the second one - { - skipLF = false; - skipCR = false; - shift(1); - } - switch (state) { - case Start: - startOffset = m_currentOffset; - if (isWhiteSpace()) { - // do nothing - } else if (current == '/' && next1 == '/') { - shift(1); - state = InSingleLineComment; - } else if (current == '/' && next1 == '*') { - shift(1); - state = InMultiLineComment; - } else if (current == -1) { - if (!terminator && !delimited) { - // automatic semicolon insertion if program incomplete - token = ';'; - stackToken = 0; - setDone(Other); - } else - setDone(Eof); - } else if (isLineTerminator()) { - nextLine(); - terminator = true; - if (restrKeyword) { - token = ';'; - setDone(Other); - } - } else if (current == '"' || current == '\'') { - state = InString; - stringType = static_cast(current); - } else if (isIdentStart(current)) { - record16(current); - state = InIdentifierOrKeyword; - } else if (current == '\\') { - state = InIdentifierStartUnicodeEscapeStart; - } else if (current == '0') { - record8(current); - state = InNum0; - } else if (isDecimalDigit(current)) { - record8(current); - state = InNum; - } else if (current == '.' && isDecimalDigit(next1)) { - record8(current); - state = InDecimal; - // - } else if (atLineStart && current == '-' && next1 == '-' && next2 == '>') { - shift(2); - state = InSingleLineComment; - } else { - token = matchPunctuator(kjsyylval.intValue, current, next1, next2, next3); - if (token != -1) { - setDone(Other); - } else { - // cerr << "encountered unknown character" << endl; - setDone(Bad); - } - } - break; - case InString: - if (current == stringType) { - shift(1); - setDone(String); - } else if (isLineTerminator() || current == -1) { - setDone(Bad); - } else if (current == '\\') { - state = InEscapeSequence; - } else { - record16(current); - } - break; - // Escape Sequences inside of strings - case InEscapeSequence: - if (isOctalDigit(current)) { - if (current >= '0' && current <= '3' && - isOctalDigit(next1) && isOctalDigit(next2)) { - record16(convertOctal(current, next1, next2)); - shift(2); - state = InString; - } else if (isOctalDigit(current) && isOctalDigit(next1)) { - record16(convertOctal('0', current, next1)); - shift(1); - state = InString; - } else if (isOctalDigit(current)) { - record16(convertOctal('0', '0', current)); - state = InString; - } else { - setDone(Bad); - } - } else if (current == 'x') - state = InHexEscape; - else if (current == 'u') - state = InUnicodeEscape; - else if (isLineTerminator()) { - nextLine(); - state = InString; - } else { - record16(singleEscape(static_cast(current))); - state = InString; - } - break; - case InHexEscape: - if (isHexDigit(current) && isHexDigit(next1)) { - state = InString; - record16(convertHex(current, next1)); - shift(1); - } else if (current == stringType) { - record16('x'); - shift(1); - setDone(String); - } else { - record16('x'); - record16(current); - state = InString; - } - break; - case InUnicodeEscape: - if (isHexDigit(current) && isHexDigit(next1) && isHexDigit(next2) && isHexDigit(next3)) { - record16(convertUnicode(current, next1, next2, next3)); - shift(3); - state = InString; - } else if (current == stringType) { - record16('u'); - shift(1); - setDone(String); - } else { - setDone(Bad); - } - break; - case InSingleLineComment: - if (isLineTerminator()) { - nextLine(); - terminator = true; - if (restrKeyword) { - token = ';'; - setDone(Other); - } else - state = Start; - } else if (current == -1) { - setDone(Eof); - } - break; - case InMultiLineComment: - if (current == -1) { - setDone(Bad); - } else if (isLineTerminator()) { - nextLine(); - } else if (current == '*' && next1 == '/') { - state = Start; - shift(1); - } - break; - case InIdentifierOrKeyword: - case InIdentifier: - if (isIdentPart(current)) - record16(current); - else if (current == '\\') - state = InIdentifierPartUnicodeEscapeStart; - else - setDone(state == InIdentifierOrKeyword ? IdentifierOrKeyword : Identifier); - break; - case InNum0: - if (current == 'x' || current == 'X') { - record8(current); - state = InHex; - } else if (current == '.') { - record8(current); - state = InDecimal; - } else if (current == 'e' || current == 'E') { - record8(current); - state = InExponentIndicator; - } else if (isOctalDigit(current)) { - record8(current); - state = InOctal; - } else if (isDecimalDigit(current)) { - record8(current); - state = InDecimal; - } else { - setDone(Number); - } - break; - case InHex: - if (isHexDigit(current)) { - record8(current); - } else { - setDone(Hex); - } - break; - case InOctal: - if (isOctalDigit(current)) { - record8(current); - } - else if (isDecimalDigit(current)) { - record8(current); - state = InDecimal; - } else - setDone(Octal); - break; - case InNum: - if (isDecimalDigit(current)) { - record8(current); - } else if (current == '.') { - record8(current); - state = InDecimal; - } else if (current == 'e' || current == 'E') { - record8(current); - state = InExponentIndicator; - } else - setDone(Number); - break; - case InDecimal: - if (isDecimalDigit(current)) { - record8(current); - } else if (current == 'e' || current == 'E') { - record8(current); - state = InExponentIndicator; - } else - setDone(Number); - break; - case InExponentIndicator: - if (current == '+' || current == '-') { - record8(current); - } else if (isDecimalDigit(current)) { - record8(current); - state = InExponent; - } else - setDone(Bad); - break; - case InExponent: - if (isDecimalDigit(current)) { - record8(current); - } else - setDone(Number); - break; - case InIdentifierStartUnicodeEscapeStart: - if (current == 'u') - state = InIdentifierStartUnicodeEscape; - else - setDone(Bad); - break; - case InIdentifierPartUnicodeEscapeStart: - if (current == 'u') - state = InIdentifierPartUnicodeEscape; - else - setDone(Bad); - break; - case InIdentifierStartUnicodeEscape: - if (!isHexDigit(current) || !isHexDigit(next1) || !isHexDigit(next2) || !isHexDigit(next3)) { - setDone(Bad); - break; - } - token = convertUnicode(current, next1, next2, next3).uc; - shift(3); - if (!isIdentStart(token)) { - setDone(Bad); - break; - } - record16(token); - state = InIdentifier; - break; - case InIdentifierPartUnicodeEscape: - if (!isHexDigit(current) || !isHexDigit(next1) || !isHexDigit(next2) || !isHexDigit(next3)) { - setDone(Bad); - break; - } - token = convertUnicode(current, next1, next2, next3).uc; - shift(3); - if (!isIdentPart(token)) { - setDone(Bad); - break; - } - record16(token); - state = InIdentifier; - break; - default: - ASSERT(!"Unhandled state in switch statement"); - } - - // move on to the next character - if (!done) - shift(1); - if (state != Start && state != InSingleLineComment) - atLineStart = false; - } - - // no identifiers allowed directly after numeric literal, e.g. "3in" is bad - if ((state == Number || state == Octal || state == Hex) && isIdentStart(current)) - state = Bad; - - // terminate string - m_buffer8.append('\0'); - -#ifdef KJS_DEBUG_LEX - fprintf(stderr, "line: %d ", lineNo()); - fprintf(stderr, "yytext (%x): ", m_buffer8[0]); - fprintf(stderr, "%s ", buffer8.data()); -#endif - - double dval = 0; - if (state == Number) { - dval = kjs_strtod(m_buffer8.data(), 0L); - } else if (state == Hex) { // scan hex numbers - const char* p = m_buffer8.data() + 2; - while (char c = *p++) { - dval *= 16; - dval += convertHex(c); - } - - if (dval >= mantissaOverflowLowerBound) - dval = parseIntOverflow(m_buffer8.data() + 2, p - (m_buffer8.data() + 3), 16); - - state = Number; - } else if (state == Octal) { // scan octal number - const char* p = m_buffer8.data() + 1; - while (char c = *p++) { - dval *= 8; - dval += c - '0'; - } - - if (dval >= mantissaOverflowLowerBound) - dval = parseIntOverflow(m_buffer8.data() + 1, p - (m_buffer8.data() + 2), 8); - - state = Number; - } - -#ifdef KJS_DEBUG_LEX - switch (state) { - case Eof: - printf("(EOF)\n"); - break; - case Other: - printf("(Other)\n"); - break; - case Identifier: - printf("(Identifier)/(Keyword)\n"); - break; - case String: - printf("(String)\n"); - break; - case Number: - printf("(Number)\n"); - break; - default: - printf("(unknown)"); - } -#endif - - if (state != Identifier && eatNextIdentifier) - eatNextIdentifier = false; - - restrKeyword = false; - delimited = false; - kjsyylloc.first_line = yylineno; // ??? - kjsyylloc.last_line = yylineno; - - switch (state) { - case Eof: - token = 0; - break; - case Other: - if(token == '}' || token == ';') { - delimited = true; - } - break; - case IdentifierOrKeyword: - if ((token = Lookup::find(&mainTable, m_buffer16.data(), m_buffer16.size())) < 0) { - case Identifier: - // Lookup for keyword failed, means this is an identifier - // Apply anonymous-function hack below (eat the identifier) - if (eatNextIdentifier) { - eatNextIdentifier = false; - token = lex(); - break; - } - kjsyylval.ident = makeIdentifier(m_buffer16); - token = IDENT; - break; - } - - eatNextIdentifier = false; - // Hack for "f = function somename() { ... }", too hard to get into the grammar - if (token == FUNCTION && lastToken == '=' ) - eatNextIdentifier = true; - - if (token == CONTINUE || token == BREAK || - token == RETURN || token == THROW) - restrKeyword = true; - break; - case String: - kjsyylval.string = makeUString(m_buffer16); - token = STRING; - break; - case Number: - kjsyylval.doubleValue = dval; - token = NUMBER; - break; - case Bad: -#ifdef KJS_DEBUG_LEX - fprintf(stderr, "yylex: ERROR.\n"); -#endif - error = true; - return -1; - default: - ASSERT(!"unhandled numeration value in switch"); - error = true; - return -1; - } - lastToken = token; - return token; -} - -bool Lexer::isWhiteSpace() const -{ - return current == '\t' || current == 0x0b || current == 0x0c || isSeparatorSpace(current); -} - -bool Lexer::isLineTerminator() -{ - bool cr = (current == '\r'); - bool lf = (current == '\n'); - if (cr) - skipLF = true; - else if (lf) - skipCR = true; - return cr || lf || current == 0x2028 || current == 0x2029; -} - -bool Lexer::isIdentStart(int c) -{ - return (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other)) - || c == '$' || c == '_'; -} - -bool Lexer::isIdentPart(int c) -{ - return (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other - | Mark_NonSpacing | Mark_SpacingCombining | Number_DecimalDigit | Punctuation_Connector)) - || c == '$' || c == '_'; -} - -static bool isDecimalDigit(int c) -{ - return (c >= '0' && c <= '9'); -} - -bool Lexer::isHexDigit(int c) -{ - return (c >= '0' && c <= '9' || - c >= 'a' && c <= 'f' || - c >= 'A' && c <= 'F'); -} - -bool Lexer::isOctalDigit(int c) -{ - return (c >= '0' && c <= '7'); -} - -int Lexer::matchPunctuator(int& charPos, int c1, int c2, int c3, int c4) -{ - if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') { - shift(4); - return URSHIFTEQUAL; - } else if (c1 == '=' && c2 == '=' && c3 == '=') { - shift(3); - return STREQ; - } else if (c1 == '!' && c2 == '=' && c3 == '=') { - shift(3); - return STRNEQ; - } else if (c1 == '>' && c2 == '>' && c3 == '>') { - shift(3); - return URSHIFT; - } else if (c1 == '<' && c2 == '<' && c3 == '=') { - shift(3); - return LSHIFTEQUAL; - } else if (c1 == '>' && c2 == '>' && c3 == '=') { - shift(3); - return RSHIFTEQUAL; - } else if (c1 == '<' && c2 == '=') { - shift(2); - return LE; - } else if (c1 == '>' && c2 == '=') { - shift(2); - return GE; - } else if (c1 == '!' && c2 == '=') { - shift(2); - return NE; - } else if (c1 == '+' && c2 == '+') { - shift(2); - if (terminator) - return AUTOPLUSPLUS; - else - return PLUSPLUS; - } else if (c1 == '-' && c2 == '-') { - shift(2); - if (terminator) - return AUTOMINUSMINUS; - else - return MINUSMINUS; - } else if (c1 == '=' && c2 == '=') { - shift(2); - return EQEQ; - } else if (c1 == '+' && c2 == '=') { - shift(2); - return PLUSEQUAL; - } else if (c1 == '-' && c2 == '=') { - shift(2); - return MINUSEQUAL; - } else if (c1 == '*' && c2 == '=') { - shift(2); - return MULTEQUAL; - } else if (c1 == '/' && c2 == '=') { - shift(2); - return DIVEQUAL; - } else if (c1 == '&' && c2 == '=') { - shift(2); - return ANDEQUAL; - } else if (c1 == '^' && c2 == '=') { - shift(2); - return XOREQUAL; - } else if (c1 == '%' && c2 == '=') { - shift(2); - return MODEQUAL; - } else if (c1 == '|' && c2 == '=') { - shift(2); - return OREQUAL; - } else if (c1 == '<' && c2 == '<') { - shift(2); - return LSHIFT; - } else if (c1 == '>' && c2 == '>') { - shift(2); - return RSHIFT; - } else if (c1 == '&' && c2 == '&') { - shift(2); - return AND; - } else if (c1 == '|' && c2 == '|') { - shift(2); - return OR; - } - - switch(c1) { - case '=': - case '>': - case '<': - case ',': - case '!': - case '~': - case '?': - case ':': - case '.': - case '+': - case '-': - case '*': - case '/': - case '&': - case '|': - case '^': - case '%': - case '(': - case ')': - case '[': - case ']': - case ';': - shift(1); - return static_cast(c1); - case '{': - charPos = pos - 4; - shift(1); - return OPENBRACE; - case '}': - charPos = pos - 4; - shift(1); - return CLOSEBRACE; - default: - return -1; - } -} - -unsigned short Lexer::singleEscape(unsigned short c) -{ - switch(c) { - case 'b': - return 0x08; - case 't': - return 0x09; - case 'n': - return 0x0A; - case 'v': - return 0x0B; - case 'f': - return 0x0C; - case 'r': - return 0x0D; - case '"': - return 0x22; - case '\'': - return 0x27; - case '\\': - return 0x5C; - default: - return c; - } -} - -unsigned short Lexer::convertOctal(int c1, int c2, int c3) -{ - return static_cast((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0'); -} - -unsigned char Lexer::convertHex(int c) -{ - if (c >= '0' && c <= '9') - return static_cast(c - '0'); - if (c >= 'a' && c <= 'f') - return static_cast(c - 'a' + 10); - return static_cast(c - 'A' + 10); -} - -unsigned char Lexer::convertHex(int c1, int c2) -{ - return ((convertHex(c1) << 4) + convertHex(c2)); -} - -KJS::UChar Lexer::convertUnicode(int c1, int c2, int c3, int c4) -{ - return KJS::UChar((convertHex(c1) << 4) + convertHex(c2), - (convertHex(c3) << 4) + convertHex(c4)); -} - -void Lexer::record8(int c) -{ - ASSERT(c >= 0); - ASSERT(c <= 0xff); - m_buffer8.append(static_cast(c)); -} - -void Lexer::record16(int c) -{ - ASSERT(c >= 0); - ASSERT(c <= USHRT_MAX); - record16(UChar(static_cast(c))); -} - -void Lexer::record16(KJS::UChar c) -{ - m_buffer16.append(c); -} - -bool Lexer::scanRegExp() -{ - m_buffer16.clear(); - bool lastWasEscape = false; - bool inBrackets = false; - - while (1) { - if (isLineTerminator() || current == -1) - return false; - else if (current != '/' || lastWasEscape == true || inBrackets == true) - { - // keep track of '[' and ']' - if (!lastWasEscape) { - if ( current == '[' && !inBrackets ) - inBrackets = true; - if ( current == ']' && inBrackets ) - inBrackets = false; - } - record16(current); - lastWasEscape = - !lastWasEscape && (current == '\\'); - } else { // end of regexp - m_pattern = UString(m_buffer16); - m_buffer16.clear(); - shift(1); - break; - } - shift(1); - } - - while (isIdentPart(current)) { - record16(current); - shift(1); - } - m_flags = UString(m_buffer16); - - return true; -} - -void Lexer::clear() -{ - deleteAllValues(m_strings); - Vector newStrings; - newStrings.reserveCapacity(initialStringTableCapacity); - m_strings.swap(newStrings); - - deleteAllValues(m_identifiers); - Vector newIdentifiers; - newIdentifiers.reserveCapacity(initialStringTableCapacity); - m_identifiers.swap(newIdentifiers); - - Vector newBuffer8; - newBuffer8.reserveCapacity(initialReadBufferCapacity); - m_buffer8.swap(newBuffer8); - - Vector newBuffer16; - newBuffer16.reserveCapacity(initialReadBufferCapacity); - m_buffer16.swap(newBuffer16); - - m_pattern = 0; - m_flags = 0; -} - -Identifier* Lexer::makeIdentifier(const Vector& buffer) -{ - KJS::Identifier* identifier = new KJS::Identifier(buffer.data(), buffer.size()); - m_identifiers.append(identifier); - return identifier; -} - -UString* Lexer::makeUString(const Vector& buffer) -{ - UString* string = new UString(buffer); - m_strings.append(string); - return string; -} - -} // namespace KJS diff --git a/kjs/lexer.h b/kjs/lexer.h deleted file mode 100644 index 69b68b8..0000000 --- a/kjs/lexer.h +++ /dev/null @@ -1,163 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2007 Apple Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef Lexer_h -#define Lexer_h - -#include "SourceCode.h" -#include "ustring.h" -#include - -namespace KJS { - - class Identifier; - class RegExp; - - class Lexer : Noncopyable { - public: - void setCode(const SourceCode&); - int lex(); - - int lineNo() const { return yylineno; } - - bool prevTerminator() const { return terminator; } - - enum State { Start, - IdentifierOrKeyword, - Identifier, - InIdentifierOrKeyword, - InIdentifier, - InIdentifierStartUnicodeEscapeStart, - InIdentifierStartUnicodeEscape, - InIdentifierPartUnicodeEscapeStart, - InIdentifierPartUnicodeEscape, - InSingleLineComment, - InMultiLineComment, - InNum, - InNum0, - InHex, - InOctal, - InDecimal, - InExponentIndicator, - InExponent, - Hex, - Octal, - Number, - String, - Eof, - InString, - InEscapeSequence, - InHexEscape, - InUnicodeEscape, - Other, - Bad }; - - bool scanRegExp(); - const UString& pattern() const { return m_pattern; } - const UString& flags() const { return m_flags; } - - static unsigned char convertHex(int); - static unsigned char convertHex(int c1, int c2); - static UChar convertUnicode(int c1, int c2, int c3, int c4); - static bool isIdentStart(int); - static bool isIdentPart(int); - static bool isHexDigit(int); - - bool sawError() const { return error; } - - void clear(); - SourceCode sourceCode(int openBrace, int closeBrace, int firstLine) - { - // The SourceCode constructor adds 1 to the line number to account for - // all of the callers in WebCore that use zero-based line numbers, so - // we regrettably subtract 1 here to deal with that. - return SourceCode(m_source->provider(), m_source->startOffset() + openBrace + 1, m_source->startOffset() + closeBrace, firstLine - 1); - } - - private: - friend Lexer& lexer(); - Lexer(); - - int yylineno; - bool done; - Vector m_buffer8; - Vector m_buffer16; - bool terminator; - bool restrKeyword; - // encountered delimiter like "'" and "}" on last run - bool delimited; - bool skipLF; - bool skipCR; - bool eatNextIdentifier; - int stackToken; - int lastToken; - - State state; - void setDone(State); - unsigned int pos; - void shift(unsigned int p); - void nextLine(); - int lookupKeyword(const char *); - - bool isWhiteSpace() const; - bool isLineTerminator(); - static bool isOctalDigit(int); - - int matchPunctuator(int& charPos, int c1, int c2, int c3, int c4); - static unsigned short singleEscape(unsigned short); - static unsigned short convertOctal(int c1, int c2, int c3); - - void record8(int); - void record16(int); - void record16(UChar); - - KJS::Identifier* makeIdentifier(const Vector& buffer); - UString* makeUString(const Vector& buffer); - - const SourceCode* m_source; - const UChar* code; - unsigned int length; - int yycolumn; - int atLineStart; - bool error; - - // current and following unicode characters (int to allow for -1 for end-of-file marker) - int current, next1, next2, next3; - - int m_currentOffset; - int m_nextOffset1; - int m_nextOffset2; - int m_nextOffset3; - - Vector m_strings; - Vector m_identifiers; - - UString m_pattern; - UString m_flags; - }; - - Lexer& lexer(); // Returns the singletone JavaScript lexer. - -} // namespace KJS - -#endif // Lexer_h diff --git a/kjs/list.h b/kjs/list.h deleted file mode 100644 index 6a43e08..0000000 --- a/kjs/list.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2007 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_LIST_H -#define KJS_LIST_H - -#include -#include -#include -#include - -namespace KJS { - - class JSValue; - class List; - - class List : Noncopyable { - private: - typedef Vector VectorType; - typedef HashSet ListSet; - - public: - typedef VectorType::iterator iterator; - typedef VectorType::const_iterator const_iterator; - - List() - : m_isInMarkSet(false) - { - } - - ~List() - { - if (m_isInMarkSet) - markSet().remove(this); - } - - size_t size() const { return m_vector.size(); } - bool isEmpty() const { return m_vector.isEmpty(); } - - JSValue* at(size_t i) const - { - if (i < m_vector.size()) - return m_vector.at(i); - return jsUndefined(); - } - - JSValue* operator[](int i) const { return at(i); } - - void clear() { m_vector.clear(); } - - void append(JSValue* v) - { - if (m_vector.size() < m_vector.capacity()) - m_vector.uncheckedAppend(v); - else - // Putting the slow "expand and append" case all in one - // function measurably improves the performance of the fast - // "just append" case. - expandAndAppend(v); - } - - void getSlice(int startIndex, List& result) const; - - iterator begin() { return m_vector.begin(); } - iterator end() { return m_vector.end(); } - - const_iterator begin() const { return m_vector.begin(); } - const_iterator end() const { return m_vector.end(); } - - static void markProtectedLists() - { - if (!markSet().size()) - return; - markProtectedListsSlowCase(); - } - - private: - static ListSet& markSet(); - static void markProtectedListsSlowCase(); - - void expandAndAppend(JSValue*); - - VectorType m_vector; - bool m_isInMarkSet; - - private: - // Prohibits new / delete, which would break GC. - void* operator new(size_t); - void operator delete(void*); - - void* operator new[](size_t); - void operator delete[](void*); - - void* operator new(size_t, void*); - void operator delete(void*, size_t); - }; - -} // namespace KJS - -#endif // KJS_LIST_H diff --git a/kjs/lookup.cpp b/kjs/lookup.cpp deleted file mode 100644 index 95dc5cb..0000000 --- a/kjs/lookup.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "lookup.h" - -#include - -namespace KJS { - -static inline bool keysMatch(const UChar* c, unsigned len, const char* s) -{ - // FIXME: This can run off the end of |s| if |c| has a U+0000 character in it. - const char* end = s + len; - for (; s != end; c++, s++) - if (c->uc != *s) - return false; - return *s == 0; -} - -static inline const HashEntry* findEntry(const struct HashTable* table, unsigned int hash, - const UChar* c, unsigned int len) -{ - ASSERT(table->type == 3); - - const HashEntry* e = &table->entries[hash & table->hashSizeMask]; - - if (!e->s) - return 0; - - do { - // compare strings - if (keysMatch(c, len, e->s)) - return e; - - // try next bucket - e = e->next; - } while (e); - return 0; -} - -const HashEntry* Lookup::findEntry(const struct HashTable* table, const Identifier& s) -{ - return KJS::findEntry(table, s.ustring().rep()->computedHash(), s.data(), s.size()); -} - -int Lookup::find(const struct HashTable *table, const UChar *c, unsigned int len) -{ - const HashEntry *entry = KJS::findEntry(table, UString::Rep::computeHash(c, len), c, len); - if (entry) - return entry->value.intValue; - return -1; -} - -int Lookup::find(const struct HashTable* table, const Identifier& s) -{ - const HashEntry* entry = KJS::findEntry(table, s.ustring().rep()->computedHash(), s.data(), s.size()); - if (entry) - return entry->value.intValue; - return -1; -} - -} diff --git a/kjs/lookup.h b/kjs/lookup.h deleted file mode 100644 index 199c9d9..0000000 --- a/kjs/lookup.h +++ /dev/null @@ -1,342 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef KJS_lookup_h -#define KJS_lookup_h - -#include "ExecState.h" -#include "function.h" -#include "identifier.h" -#include "JSGlobalObject.h" -#include "object.h" -#include -#include - -namespace KJS { - - /** - * An entry in a hash table. - */ - struct HashEntry { - /** - * s is the key (e.g. a property name) - */ - const char* s; - - /** - * value is the result value (enum value for properties and a function pointer to a constructor factory for functions) - */ - union { - intptr_t intValue; - PrototypeFunction::JSMemberFunction functionValue; - } value; - - /** - * attr is a set for flags (e.g. the property flags, see object.h) - */ - unsigned char attr; - /** - * params is another number. For property hashtables, it is used to - * denote the number of argument of the function - */ - short int params; - /** - * next is the pointer to the next entry for the same hash value - */ - const HashEntry* next; - }; - - /** - * A hash table - * Usually the hashtable is generated by the create_hash_table script, from a .table file. - * - * The implementation uses an array of entries, "size" is the total size of that array. - * The entries between 0 and hashSize-1 are the entry points - * for each hash value, and the entries between hashSize and size-1 - * are the overflow entries for the hash values that need one. - * The "next" pointer of the entry links entry points to overflow entries, - * and links overflow entries between them. - */ - struct HashTable { - /** - * type is a version number. Currently always 2 - */ - int type; - /** - * size is the total number of entries in the hashtable, including the null entries, - * i.e. the size of the "entries" array. - * Used to iterate over all entries in the table - */ - int size; - /** - * pointer to the array of entries - * Mind that some entries in the array are null (0,0,0,0). - */ - const HashEntry* entries; - /** - * the maximum value for the hash minus 1. Always smaller than size. - */ - int hashSizeMask; - }; - - /** - * @short Fast keyword lookup. - */ - class Lookup { - public: - /** - * Find an entry in the table, and return its value (i.e. the value field of HashEntry) - */ - static int find(const struct HashTable*, const Identifier&); - static int find(const struct HashTable*, const UChar*, unsigned int len); - - /** - * Find an entry in the table, and return the entry - * This variant gives access to the other attributes of the entry, - * especially the attr field. - */ - static const HashEntry* findEntry(const struct HashTable*, const Identifier&); - - }; - - class ExecState; - class UString; - /** - * @internal - * Helper for getStaticFunctionSlot and getStaticPropertySlot - */ - inline JSValue* staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot) - { - // Look for cached value in dynamic map of properties (in JSObject) - JSObject* thisObj = slot.slotBase(); - JSValue* cachedVal = thisObj->getDirect(propertyName); - if (cachedVal) - return cachedVal; - - const HashEntry* entry = slot.staticEntry(); - JSValue* val = new PrototypeFunction(exec, entry->params, propertyName, entry->value.functionValue); - thisObj->putDirect(propertyName, val, entry->attr); - return val; - } - - /** - * @internal - * Helper for getStaticValueSlot and getStaticPropertySlot - */ - template - inline JSValue* staticValueGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot) - { - ThisImp* thisObj = static_cast(slot.slotBase()); - const HashEntry* entry = slot.staticEntry(); - return thisObj->getValueProperty(exec, entry->value.intValue); - } - - /** - * Helper method for property lookups - * - * This method does it all (looking in the hashtable, checking for function - * overrides, creating the function or retrieving from cache, calling - * getValueProperty in case of a non-function property, forwarding to parent if - * unknown property). - * - * Template arguments: - * @param FuncImp the class which implements this object's functions - * @param ThisImp the class of "this". It must implement the getValueProperty(exec,token) method, - * for non-function properties. - * @param ParentImp the class of the parent, to propagate the lookup. - * - * Method arguments: - * @param exec execution state, as usual - * @param propertyName the property we're looking for - * @param table the static hashtable for this class - * @param thisObj "this" - */ - template - inline bool getStaticPropertySlot(ExecState* exec, const HashTable* table, - ThisImp* thisObj, const Identifier& propertyName, PropertySlot& slot) - { - const HashEntry* entry = Lookup::findEntry(table, propertyName); - - if (!entry) // not found, forward to parent - return thisObj->ParentImp::getOwnPropertySlot(exec, propertyName, slot); - - if (entry->attr & Function) - slot.setStaticEntry(thisObj, entry, staticFunctionGetter); - else - slot.setStaticEntry(thisObj, entry, staticValueGetter); - - return true; - } - - /** - * Simplified version of getStaticPropertySlot in case there are only functions. - * Using this instead of getStaticPropertySlot allows 'this' to avoid implementing - * a dummy getValueProperty. - */ - template - inline bool getStaticFunctionSlot(ExecState* exec, const HashTable* table, - JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot) - { - const HashEntry* entry = Lookup::findEntry(table, propertyName); - - if (!entry) // not found, forward to parent - return static_cast(thisObj)->ParentImp::getOwnPropertySlot(exec, propertyName, slot); - - ASSERT(entry->attr & Function); - - slot.setStaticEntry(thisObj, entry, staticFunctionGetter); - return true; - } - - /** - * Simplified version of getStaticPropertySlot in case there are no functions, only "values". - * Using this instead of getStaticPropertySlot removes the need for a FuncImp class. - */ - template - inline bool getStaticValueSlot(ExecState* exec, const HashTable* table, - ThisImp* thisObj, const Identifier& propertyName, PropertySlot& slot) - { - const HashEntry* entry = Lookup::findEntry(table, propertyName); - - if (!entry) // not found, forward to parent - return thisObj->ParentImp::getOwnPropertySlot(exec, propertyName, slot); - - ASSERT(!(entry->attr & Function)); - - slot.setStaticEntry(thisObj, entry, staticValueGetter); - return true; - } - - /** - * This one is for "put". - * It looks up a hash entry for the property to be set. If an entry - * is found it sets the value and returns true, else it returns false. - */ - template - inline bool lookupPut(ExecState* exec, const Identifier& propertyName, - JSValue* value, int attr, - const HashTable* table, ThisImp* thisObj) - { - const HashEntry* entry = Lookup::findEntry(table, propertyName); - - if (!entry) - return false; - - if (entry->attr & Function) // function: put as override property - thisObj->JSObject::put(exec, propertyName, value, attr); - else if (!(entry->attr & ReadOnly)) - thisObj->putValueProperty(exec, entry->value.intValue, value, attr); - - return true; - } - - /** - * This one is for "put". - * It calls lookupPut() to set the value. If that call - * returns false (meaning no entry in the hash table was found), - * then it calls put() on the ParentImp class. - */ - template - inline void lookupPut(ExecState* exec, const Identifier& propertyName, - JSValue* value, int attr, - const HashTable* table, ThisImp* thisObj) - { - if (!lookupPut(exec, propertyName, value, attr, table, thisObj)) - thisObj->ParentImp::put(exec, propertyName, value, attr); // not found: forward to parent - } - - /** - * This template method retrieves or create an object that is unique - * (for a given global object) The first time this is called (for a given - * property name), the Object will be constructed, and set as a property - * of the global object. Later calls will simply retrieve that cached object. - * Note that the object constructor must take 1 argument, exec. - */ - template - inline JSObject* cacheGlobalObject(ExecState* exec, const Identifier& propertyName) - { - JSGlobalObject* globalObject = exec->lexicalGlobalObject(); - JSValue* obj = globalObject->getDirect(propertyName); - if (obj) { - ASSERT(obj->isObject()); - return static_cast(obj); - } - JSObject* newObject = new ClassCtor(exec); - globalObject->putDirect(propertyName, newObject, Internal | DontEnum); - return newObject; - } - -} // namespace - -/** - * Helpers to define prototype objects (each of which simply implements - * the functions for a type of objects). - * Sorry for this not being very readable, but it actually saves much copy-n-paste. - * ParentPrototype is not our base class, it's the object we use as fallback. - * The reason for this is that there should only be ONE DOMNode.hasAttributes (e.g.), - * not one in each derived class. So we link the (unique) prototypes between them. - * - * Using those macros is very simple: define the hashtable (e.g. "DOMNodePrototypeTable"), then - * KJS_DEFINE_PROTOTYPE(DOMNodePrototype) - * KJS_IMPLEMENT_PROTOTYPE("DOMNode", DOMNodePrototype, DOMNodePrototypeFunction) - * and use DOMNodePrototype::self(exec) as prototype in the DOMNode constructor. - * If the prototype has a "parent prototype", e.g. DOMElementPrototype falls back on DOMNodePrototype, - * then the first line will use KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE, with DOMNodePrototype as the second argument. - */ - -// These macros assume that a prototype's only properties are functions -#define KJS_DEFINE_PROTOTYPE(ClassPrototype) \ - class ClassPrototype : public KJS::JSObject { \ - public: \ - static KJS::JSObject* self(KJS::ExecState* exec); \ - virtual const KJS::ClassInfo* classInfo() const { return &info; } \ - static const KJS::ClassInfo info; \ - bool getOwnPropertySlot(KJS::ExecState* , const KJS::Identifier&, KJS::PropertySlot&); \ - ClassPrototype(KJS::ExecState* exec) \ - : KJS::JSObject(exec->lexicalGlobalObject()->objectPrototype()) { } \ - \ - }; - -#define KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(ClassPrototype, ClassPrototypePrototype) \ - class ClassPrototype : public KJS::JSObject { \ - public: \ - static KJS::JSObject* self(KJS::ExecState* exec); \ - virtual const KJS::ClassInfo* classInfo() const { return &info; } \ - static const KJS::ClassInfo info; \ - bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&); \ - ClassPrototype(KJS::ExecState* exec) \ - : KJS::JSObject(ClassPrototypePrototype::self(exec)) { } \ - \ - }; - -#define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassPrototype) \ - const ClassInfo ClassPrototype::info = { ClassName"Prototype", 0, &ClassPrototype##Table }; \ - JSObject* ClassPrototype::self(ExecState* exec) \ - { \ - static Identifier* prototypeIdentifier = new Identifier("[[" ClassName ".prototype]]"); \ - return KJS::cacheGlobalObject(exec, *prototypeIdentifier); \ - } \ - bool ClassPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) \ - { \ - return getStaticFunctionSlot(exec, &ClassPrototype##Table, this, propertyName, slot); \ - } - -#endif // KJS_lookup_h diff --git a/kjs/math_object.cpp b/kjs/math_object.cpp deleted file mode 100644 index 805efda..0000000 --- a/kjs/math_object.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2007, 2008 Apple Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "math_object.h" -#include "math_object.lut.h" - -#include "operations.h" -#include -#include -#include - -namespace KJS { - -// ------------------------------ MathObjectImp -------------------------------- - -const ClassInfo MathObjectImp::info = { "Math", 0, &mathTable }; - -/* Source for math_object.lut.h -@begin mathTable 21 - E MathObjectImp::Euler DontEnum|DontDelete|ReadOnly - LN2 MathObjectImp::Ln2 DontEnum|DontDelete|ReadOnly - LN10 MathObjectImp::Ln10 DontEnum|DontDelete|ReadOnly - LOG2E MathObjectImp::Log2E DontEnum|DontDelete|ReadOnly - LOG10E MathObjectImp::Log10E DontEnum|DontDelete|ReadOnly - PI MathObjectImp::Pi DontEnum|DontDelete|ReadOnly - SQRT1_2 MathObjectImp::Sqrt1_2 DontEnum|DontDelete|ReadOnly - SQRT2 MathObjectImp::Sqrt2 DontEnum|DontDelete|ReadOnly - abs mathProtoFuncAbs DontEnum|Function 1 - acos mathProtoFuncACos DontEnum|Function 1 - asin mathProtoFuncASin DontEnum|Function 1 - atan mathProtoFuncATan DontEnum|Function 1 - atan2 mathProtoFuncATan2 DontEnum|Function 2 - ceil mathProtoFuncCeil DontEnum|Function 1 - cos mathProtoFuncCos DontEnum|Function 1 - exp mathProtoFuncExp DontEnum|Function 1 - floor mathProtoFuncFloor DontEnum|Function 1 - log mathProtoFuncLog DontEnum|Function 1 - max mathProtoFuncMax DontEnum|Function 2 - min mathProtoFuncMin DontEnum|Function 2 - pow mathProtoFuncPow DontEnum|Function 2 - random mathProtoFuncRandom DontEnum|Function 0 - round mathProtoFuncRound DontEnum|Function 1 - sin mathProtoFuncSin DontEnum|Function 1 - sqrt mathProtoFuncSqrt DontEnum|Function 1 - tan mathProtoFuncTan DontEnum|Function 1 -@end -*/ - -MathObjectImp::MathObjectImp(ExecState*, ObjectPrototype* objectPrototype) - : JSObject(objectPrototype) -{ -} - -// ECMA 15.8 - -bool MathObjectImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot &slot) -{ - return getStaticPropertySlot(exec, &mathTable, this, propertyName, slot); -} - -JSValue* MathObjectImp::getValueProperty(ExecState*, int token) const -{ - switch (token) { - case Euler: - return jsNumber(exp(1.0)); - case Ln2: - return jsNumber(log(2.0)); - case Ln10: - return jsNumber(log(10.0)); - case Log2E: - return jsNumber(1.0 / log(2.0)); - case Log10E: - return jsNumber(1.0 / log(10.0)); - case Pi: - return jsNumber(piDouble); - case Sqrt1_2: - return jsNumber(sqrt(0.5)); - case Sqrt2: - return jsNumber(sqrt(2.0)); - } - - ASSERT_NOT_REACHED(); - return 0; -} - -// ------------------------------ Functions -------------------------------- - -JSValue* mathProtoFuncAbs(ExecState* exec, JSObject*, const List& args) -{ - double arg = args[0]->toNumber(exec); - return signbit(arg) ? jsNumber(-arg) : jsNumber(arg); -} - -JSValue* mathProtoFuncACos(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(acos(args[0]->toNumber(exec))); -} - -JSValue* mathProtoFuncASin(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(asin(args[0]->toNumber(exec))); -} - -JSValue* mathProtoFuncATan(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(atan(args[0]->toNumber(exec))); -} - -JSValue* mathProtoFuncATan2(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(atan2(args[0]->toNumber(exec), args[1]->toNumber(exec))); -} - -JSValue* mathProtoFuncCeil(ExecState* exec, JSObject*, const List& args) -{ - double arg = args[0]->toNumber(exec); - if (signbit(arg) && arg > -1.0) - return jsNumber(-0.0); - return jsNumber(ceil(arg)); -} - -JSValue* mathProtoFuncCos(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(cos(args[0]->toNumber(exec))); -} - -JSValue* mathProtoFuncExp(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(exp(args[0]->toNumber(exec))); -} - -JSValue* mathProtoFuncFloor(ExecState* exec, JSObject*, const List& args) -{ - double arg = args[0]->toNumber(exec); - if (signbit(arg) && arg == 0.0) - return jsNumber(-0.0); - return jsNumber(floor(arg)); -} - -JSValue* mathProtoFuncLog(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(log(args[0]->toNumber(exec))); -} - -JSValue* mathProtoFuncMax(ExecState* exec, JSObject*, const List& args) -{ - unsigned argsCount = args.size(); - double result = -Inf; - for (unsigned k = 0; k < argsCount; ++k) { - double val = args[k]->toNumber(exec); - if (isnan(val)) { - result = NaN; - break; - } - if (val > result || (val == 0 && result == 0 && !signbit(val))) - result = val; - } - return jsNumber(result); -} - -JSValue* mathProtoFuncMin(ExecState* exec, JSObject*, const List& args) -{ - unsigned argsCount = args.size(); - double result = +Inf; - for (unsigned k = 0; k < argsCount; ++k) { - double val = args[k]->toNumber(exec); - if (isnan(val)) { - result = NaN; - break; - } - if (val < result || (val == 0 && result == 0 && signbit(val))) - result = val; - } - return jsNumber(result); -} - -JSValue* mathProtoFuncPow(ExecState* exec, JSObject*, const List& args) -{ - // ECMA 15.8.2.1.13 - - double arg = args[0]->toNumber(exec); - double arg2 = args[1]->toNumber(exec); - - if (isnan(arg2)) - return jsNumber(NaN); - if (isinf(arg2) && fabs(arg) == 1) - return jsNumber(NaN); - return jsNumber(pow(arg, arg2)); -} - -static bool didInitRandom; - -JSValue* mathProtoFuncRandom(ExecState*, JSObject*, const List&) -{ - if (!didInitRandom) { - wtf_random_init(); - didInitRandom = true; - } - return jsNumber(wtf_random()); -} - -JSValue* mathProtoFuncRound(ExecState* exec, JSObject*, const List& args) -{ - double arg = args[0]->toNumber(exec); - if (signbit(arg) && arg >= -0.5) - return jsNumber(-0.0); - return jsNumber(floor(arg + 0.5)); -} - -JSValue* mathProtoFuncSin(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(sin(args[0]->toNumber(exec))); -} - -JSValue* mathProtoFuncSqrt(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(sqrt(args[0]->toNumber(exec))); -} - -JSValue* mathProtoFuncTan(ExecState* exec, JSObject*, const List& args) -{ - return jsNumber(tan(args[0]->toNumber(exec))); -} - -} // namespace KJS diff --git a/kjs/math_object.h b/kjs/math_object.h deleted file mode 100644 index 72e442f..0000000 --- a/kjs/math_object.h +++ /dev/null @@ -1,65 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef MATH_OBJECT_H_ -#define MATH_OBJECT_H_ - -#include "function_object.h" -#include "lookup.h" - -namespace KJS { - - class MathObjectImp : public JSObject { - public: - MathObjectImp(ExecState*, ObjectPrototype*); - - bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - JSValue* getValueProperty(ExecState*, int token) const; - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - - enum { Euler, Ln2, Ln10, Log2E, Log10E, Pi, Sqrt1_2, Sqrt2 }; - }; - - // Functions - JSValue* mathProtoFuncAbs(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncACos(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncASin(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncATan(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncATan2(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncCeil(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncCos(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncExp(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncFloor(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncLog(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncMax(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncMin(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncPow(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncRandom(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncRound(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncSin(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncSqrt(ExecState*, JSObject*, const List&); - JSValue* mathProtoFuncTan(ExecState*, JSObject*, const List&); - -} // namespace KJS - -#endif // MATH_OBJECT_H_ diff --git a/kjs/nodes.cpp b/kjs/nodes.cpp deleted file mode 100644 index 568e69f..0000000 --- a/kjs/nodes.cpp +++ /dev/null @@ -1,4761 +0,0 @@ -/* -* Copyright (C) 1999-2002 Harri Porten (porten@kde.org) -* Copyright (C) 2001 Peter Kelly (pmk@post.com) -* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. -* Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) -* Copyright (C) 2007 Maks Orlovich -* Copyright (C) 2007 Eric Seidel -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Library General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Library General Public License for more details. -* -* You should have received a copy of the GNU Library General Public License -* along with this library; see the file COPYING.LIB. If not, write to -* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301, USA. -* -*/ - -#include "config.h" -#include "nodes.h" - -#include "ExecState.h" -#include "JSGlobalObject.h" -#include "Parser.h" -#include "PropertyNameArray.h" -#include "array_object.h" -#include "debugger.h" -#include "function_object.h" -#include "lexer.h" -#include "operations.h" -#include "regexp_object.h" -#include -#include -#include -#include -#include - -namespace KJS { - -class FunctionBodyNodeWithDebuggerHooks : public FunctionBodyNode { -public: - FunctionBodyNodeWithDebuggerHooks(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; -}; - -#define KJS_CHECKEXCEPTION \ -if (exec->hadException()) \ - return rethrowException(exec); - -#define KJS_CHECKEXCEPTIONVALUE \ -if (exec->hadException()) { \ - handleException(exec); \ - return jsUndefined(); \ -} - -#define KJS_CHECKEXCEPTIONNUMBER \ -if (exec->hadException()) { \ - handleException(exec); \ - return 0; \ -} - -#define KJS_CHECKEXCEPTIONBOOLEAN \ -if (exec->hadException()) { \ - handleException(exec); \ - return false; \ -} - -#define KJS_CHECKEXCEPTIONVOID \ -if (exec->hadException()) { \ - handleException(exec); \ - return; \ -} - -#if !ASSERT_DISABLED -static inline bool canSkipLookup(ExecState* exec, const Identifier& ident) -{ - // Static lookup in EvalCode is impossible because variables aren't DontDelete. - // Static lookup in GlobalCode may be possible, but we haven't implemented support for it yet. - if (exec->codeType() != FunctionCode) - return false; - - // Static lookup is impossible when something dynamic has been added to the front of the scope chain. - if (exec->variableObject() != exec->scopeChain().top()) - return false; - - // Static lookup is impossible if the symbol isn't statically declared. - if (!exec->variableObject()->symbolTable().contains(ident.ustring().rep())) - return false; - - return true; -} -#endif - -static inline bool isConstant(const LocalStorage& localStorage, size_t index) -{ - ASSERT(index < localStorage.size()); - return localStorage[index].attributes & ReadOnly; -} - -// ------------------------------ Node ----------------------------------------- - -#ifndef NDEBUG -#ifndef LOG_CHANNEL_PREFIX -#define LOG_CHANNEL_PREFIX Log -#endif -static WTFLogChannel LogKJSNodeLeaks = { 0x00000000, "", WTFLogChannelOn }; - -struct ParserRefCountedCounter { - static unsigned count; - ParserRefCountedCounter() - { - if (count) - LOG(KJSNodeLeaks, "LEAK: %u KJS::Node\n", count); - } -}; -unsigned ParserRefCountedCounter::count = 0; -static ParserRefCountedCounter parserRefCountedCounter; -#endif - -static HashSet* newTrackedObjects; -static HashCountedSet* trackedObjectExtraRefCounts; - -ParserRefCounted::ParserRefCounted() -{ -#ifndef NDEBUG - ++ParserRefCountedCounter::count; -#endif - if (!newTrackedObjects) - newTrackedObjects = new HashSet; - newTrackedObjects->add(this); - ASSERT(newTrackedObjects->contains(this)); -} - -ParserRefCounted::~ParserRefCounted() -{ -#ifndef NDEBUG - --ParserRefCountedCounter::count; -#endif -} - -void ParserRefCounted::ref() -{ - // bumping from 0 to 1 is just removing from the new nodes set - if (newTrackedObjects) { - HashSet::iterator it = newTrackedObjects->find(this); - if (it != newTrackedObjects->end()) { - newTrackedObjects->remove(it); - ASSERT(!trackedObjectExtraRefCounts || !trackedObjectExtraRefCounts->contains(this)); - return; - } - } - - ASSERT(!newTrackedObjects || !newTrackedObjects->contains(this)); - - if (!trackedObjectExtraRefCounts) - trackedObjectExtraRefCounts = new HashCountedSet; - trackedObjectExtraRefCounts->add(this); -} - -void ParserRefCounted::deref() -{ - ASSERT(!newTrackedObjects || !newTrackedObjects->contains(this)); - - if (!trackedObjectExtraRefCounts) { - delete this; - return; - } - - HashCountedSet::iterator it = trackedObjectExtraRefCounts->find(this); - if (it == trackedObjectExtraRefCounts->end()) - delete this; - else - trackedObjectExtraRefCounts->remove(it); -} - -unsigned ParserRefCounted::refcount() -{ - if (newTrackedObjects && newTrackedObjects->contains(this)) { - ASSERT(!trackedObjectExtraRefCounts || !trackedObjectExtraRefCounts->contains(this)); - return 0; - } - - ASSERT(!newTrackedObjects || !newTrackedObjects->contains(this)); - - if (!trackedObjectExtraRefCounts) - return 1; - - return 1 + trackedObjectExtraRefCounts->count(this); -} - -void ParserRefCounted::deleteNewObjects() -{ - if (!newTrackedObjects) - return; - -#ifndef NDEBUG - HashSet::iterator end = newTrackedObjects->end(); - for (HashSet::iterator it = newTrackedObjects->begin(); it != end; ++it) - ASSERT(!trackedObjectExtraRefCounts || !trackedObjectExtraRefCounts->contains(*it)); -#endif - deleteAllValues(*newTrackedObjects); - delete newTrackedObjects; - newTrackedObjects = 0; -} - -Node::Node() - : m_expectedReturnType(ObjectType) -{ - m_line = lexer().lineNo(); -} - -Node::Node(JSType expectedReturn) - : m_expectedReturnType(expectedReturn) -{ - m_line = lexer().lineNo(); -} - -double ExpressionNode::evaluateToNumber(ExecState* exec) -{ - JSValue* value = evaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return value->toNumber(exec); -} - -bool ExpressionNode::evaluateToBoolean(ExecState* exec) -{ - JSValue* value = evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return value->toBoolean(exec); -} - -int32_t ExpressionNode::evaluateToInt32(ExecState* exec) -{ - JSValue* value = evaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return value->toInt32(exec); -} - -uint32_t ExpressionNode::evaluateToUInt32(ExecState* exec) -{ - JSValue* value = evaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return value->toUInt32(exec); -} - -static void substitute(UString& string, const UString& substring) KJS_FAST_CALL; -static void substitute(UString& string, const UString& substring) -{ - int position = string.find("%s"); - ASSERT(position != -1); - UString newString = string.substr(0, position); - newString.append(substring); - newString.append(string.substr(position + 2)); - string = newString; -} - -static inline int currentSourceID(ExecState* exec) KJS_FAST_CALL; -static inline int currentSourceID(ExecState* exec) -{ - return exec->scopeNode()->sourceID(); -} - -static inline const UString& currentSourceURL(ExecState* exec) KJS_FAST_CALL; -static inline const UString& currentSourceURL(ExecState* exec) -{ - return exec->scopeNode()->sourceURL(); -} - -JSValue* Node::setInterruptedCompletion(ExecState* exec) -{ - return exec->setInterruptedCompletion(Error::create(exec, TimeoutError, "JavaScript execution exceeded timeout.", lineNo(), currentSourceID(exec), currentSourceURL(exec))); -} - -JSValue* Node::setErrorCompletion(ExecState* exec, ErrorType e, const char* msg) -{ - return exec->setThrowCompletion(Error::create(exec, e, msg, lineNo(), currentSourceID(exec), currentSourceURL(exec))); -} - -JSValue* Node::setErrorCompletion(ExecState* exec, ErrorType e, const char* msg, const Identifier& ident) -{ - UString message = msg; - substitute(message, ident.ustring()); - return exec->setThrowCompletion(Error::create(exec, e, message, lineNo(), currentSourceID(exec), currentSourceURL(exec))); -} - -JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg) -{ - return KJS::throwError(exec, e, msg, lineNo(), currentSourceID(exec), currentSourceURL(exec)); -} - -JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, const char* string) -{ - UString message = msg; - substitute(message, string); - return KJS::throwError(exec, e, message, lineNo(), currentSourceID(exec), currentSourceURL(exec)); -} - -JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, JSValue* v, Node* expr) -{ - UString message = msg; - substitute(message, v->toString(exec)); - substitute(message, expr->toString()); - return KJS::throwError(exec, e, message, lineNo(), currentSourceID(exec), currentSourceURL(exec)); -} - -JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, const Identifier& label) -{ - UString message = msg; - substitute(message, label.ustring()); - return KJS::throwError(exec, e, message, lineNo(), currentSourceID(exec), currentSourceURL(exec)); -} - -JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, JSValue* v, Node* e1, Node* e2) -{ - UString message = msg; - substitute(message, v->toString(exec)); - substitute(message, e1->toString()); - substitute(message, e2->toString()); - return KJS::throwError(exec, e, message, lineNo(), currentSourceID(exec), currentSourceURL(exec)); -} - -JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, JSValue* v, Node* expr, const Identifier& label) -{ - UString message = msg; - substitute(message, v->toString(exec)); - substitute(message, expr->toString()); - substitute(message, label.ustring()); - return KJS::throwError(exec, e, message, lineNo(), currentSourceID(exec), currentSourceURL(exec)); -} - -JSValue* Node::throwError(ExecState* exec, ErrorType e, const char* msg, JSValue* v, const Identifier& label) -{ - UString message = msg; - substitute(message, v->toString(exec)); - substitute(message, label.ustring()); - return KJS::throwError(exec, e, message, lineNo(), currentSourceID(exec), currentSourceURL(exec)); -} - -JSValue* Node::throwUndefinedVariableError(ExecState* exec, const Identifier& ident) -{ - return throwError(exec, ReferenceError, "Can't find variable: %s", ident); -} - -void Node::handleException(ExecState* exec) -{ - handleException(exec, exec->exception()); -} - -void Node::handleException(ExecState* exec, JSValue* exceptionValue) -{ - if (exceptionValue->isObject()) { - JSObject* exception = static_cast(exceptionValue); - if (!exception->hasProperty(exec, "line") && !exception->hasProperty(exec, "sourceURL")) { - exception->put(exec, "line", jsNumber(m_line)); - exception->put(exec, "sourceURL", jsString(currentSourceURL(exec))); - } - } - Debugger* dbg = exec->dynamicGlobalObject()->debugger(); - if (dbg && !dbg->hasHandledException(exec, exceptionValue)) { - bool cont = dbg->exception(exec, currentSourceID(exec), m_line, exceptionValue); - if (!cont) - dbg->imp()->abort(); - } -} - -NEVER_INLINE JSValue* Node::rethrowException(ExecState* exec) -{ - JSValue* exception = exec->exception(); - exec->clearException(); - handleException(exec, exception); - return exec->setThrowCompletion(exception); -} - -// ------------------------------ StatementNode -------------------------------- - -StatementNode::StatementNode() - : m_lastLine(-1) -{ - m_line = -1; -} - -void StatementNode::setLoc(int firstLine, int lastLine) -{ - m_line = firstLine; - m_lastLine = lastLine; -} - -// ------------------------------ SourceElements -------------------------------- - -void SourceElements::append(PassRefPtr statement) -{ - if (statement->isEmptyStatement()) - return; - - if (Debugger::debuggersPresent) - m_statements.append(new BreakpointCheckStatement(statement)); - else - m_statements.append(statement); -} - -// ------------------------------ BreakpointCheckStatement -------------------------------- - -BreakpointCheckStatement::BreakpointCheckStatement(PassRefPtr statement) - : m_statement(statement) -{ - ASSERT(m_statement); -} - -JSValue* BreakpointCheckStatement::execute(ExecState* exec) -{ - if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) - if (!debugger->atStatement(exec, currentSourceID(exec), m_statement->firstLine(), m_statement->lastLine())) - return exec->setNormalCompletion(); - return m_statement->execute(exec); -} - -void BreakpointCheckStatement::streamTo(SourceStream& stream) -{ - m_statement->streamTo(stream); -} - -void BreakpointCheckStatement::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_statement.get()); -} - -// ------------------------------ NullNode ------------------------------------- - -JSValue* NullNode::evaluate(ExecState* ) -{ - return jsNull(); -} - -// ------------------------------ FalseNode ---------------------------------- - -JSValue* FalseNode::evaluate(ExecState*) -{ - return jsBoolean(false); -} - -// ------------------------------ TrueNode ---------------------------------- - -JSValue* TrueNode::evaluate(ExecState*) -{ - return jsBoolean(true); -} - -// ------------------------------ NumberNode ----------------------------------- - -JSValue* NumberNode::evaluate(ExecState*) -{ - // Number nodes are only created when the number can't fit in a JSImmediate, so no need to check again. - return jsNumberCell(m_double); -} - -double NumberNode::evaluateToNumber(ExecState*) -{ - return m_double; -} - -bool NumberNode::evaluateToBoolean(ExecState*) -{ - return m_double < 0.0 || m_double > 0.0; // false for NaN as well as 0 -} - -int32_t NumberNode::evaluateToInt32(ExecState*) -{ - return JSValue::toInt32(m_double); -} - -uint32_t NumberNode::evaluateToUInt32(ExecState*) -{ - return JSValue::toUInt32(m_double); -} - -// ------------------------------ ImmediateNumberNode ----------------------------------- - -JSValue* ImmediateNumberNode::evaluate(ExecState*) -{ - return m_value; -} - -int32_t ImmediateNumberNode::evaluateToInt32(ExecState*) -{ - return JSImmediate::getTruncatedInt32(m_value); -} - -uint32_t ImmediateNumberNode::evaluateToUInt32(ExecState*) -{ - uint32_t i; - if (JSImmediate::getTruncatedUInt32(m_value, i)) - return i; - bool ok; - return JSValue::toUInt32SlowCase(m_double, ok); -} - -// ------------------------------ StringNode ----------------------------------- - -JSValue* StringNode::evaluate(ExecState*) -{ - return jsOwnedString(m_value); -} - -double StringNode::evaluateToNumber(ExecState*) -{ - return m_value.toDouble(); -} - -bool StringNode::evaluateToBoolean(ExecState*) -{ - return !m_value.isEmpty(); -} - -// ------------------------------ RegExpNode ----------------------------------- - -JSValue* RegExpNode::evaluate(ExecState* exec) -{ - return exec->lexicalGlobalObject()->regExpConstructor()->createRegExpImp(exec, m_regExp); -} - -// ------------------------------ ThisNode ------------------------------------- - -// ECMA 11.1.1 -JSValue* ThisNode::evaluate(ExecState* exec) -{ - return exec->thisValue(); -} - -// ------------------------------ ResolveNode ---------------------------------- - -// ECMA 11.1.2 & 10.1.4 -JSValue* ResolveNode::inlineEvaluate(ExecState* exec) -{ - // Check for missed optimization opportunity. - ASSERT(!canSkipLookup(exec, m_ident)); - - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // we must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - do { - JSObject* o = *iter; - - if (o->getPropertySlot(exec, m_ident, slot)) - return slot.getValue(exec, o, m_ident); - - ++iter; - } while (iter != end); - - return throwUndefinedVariableError(exec, m_ident); -} - -JSValue* ResolveNode::evaluate(ExecState* exec) -{ - return inlineEvaluate(exec); -} - -double ResolveNode::evaluateToNumber(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toNumber(exec); -} - -bool ResolveNode::evaluateToBoolean(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return v->toBoolean(exec); -} - -int32_t ResolveNode::evaluateToInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toInt32(exec); -} - -uint32_t ResolveNode::evaluateToUInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toUInt32(exec); -} - -void ResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage&, NodeStack&) -{ - size_t index = symbolTable.get(m_ident.ustring().rep()); - if (index != missingSymbolMarker()) - new (this) LocalVarAccessNode(index); -} - -JSValue* LocalVarAccessNode::inlineEvaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - return exec->localStorage()[m_index].value; -} - -JSValue* LocalVarAccessNode::evaluate(ExecState* exec) -{ - return inlineEvaluate(exec); -} - -double LocalVarAccessNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluate(exec)->toNumber(exec); -} - -bool LocalVarAccessNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluate(exec)->toBoolean(exec); -} - -int32_t LocalVarAccessNode::evaluateToInt32(ExecState* exec) -{ - return inlineEvaluate(exec)->toInt32(exec); -} - -uint32_t LocalVarAccessNode::evaluateToUInt32(ExecState* exec) -{ - return inlineEvaluate(exec)->toUInt32(exec); -} - -// ------------------------------ ElementNode ---------------------------------- - -void ElementNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_next) - nodeStack.append(m_next.get()); - ASSERT(m_node); - nodeStack.append(m_node.get()); -} - -// ECMA 11.1.4 -JSValue* ElementNode::evaluate(ExecState* exec) -{ - JSObject* array = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()); - int length = 0; - for (ElementNode* n = this; n; n = n->m_next.get()) { - JSValue* val = n->m_node->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - length += n->m_elision; - array->put(exec, length++, val); - } - return array; -} - -// ------------------------------ ArrayNode ------------------------------------ - -void ArrayNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_element) - nodeStack.append(m_element.get()); -} - -// ECMA 11.1.4 -JSValue* ArrayNode::evaluate(ExecState* exec) -{ - JSObject* array; - int length; - - if (m_element) { - array = static_cast(m_element->evaluate(exec)); - KJS_CHECKEXCEPTIONVALUE - length = m_optional ? array->get(exec, exec->propertyNames().length)->toInt32(exec) : 0; - } else { - JSValue* newArr = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, exec->emptyList()); - array = static_cast(newArr); - length = 0; - } - - if (m_optional) - array->put(exec, exec->propertyNames().length, jsNumber(m_elision + length)); - - return array; -} - -// ------------------------------ ObjectLiteralNode ---------------------------- - -void ObjectLiteralNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_list) - nodeStack.append(m_list.get()); -} - -// ECMA 11.1.5 -JSValue* ObjectLiteralNode::evaluate(ExecState* exec) -{ - if (m_list) - return m_list->evaluate(exec); - - return exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList()); -} - -// ------------------------------ PropertyListNode ----------------------------- - -void PropertyListNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_next) - nodeStack.append(m_next.get()); - nodeStack.append(m_node.get()); -} - -// ECMA 11.1.5 -JSValue* PropertyListNode::evaluate(ExecState* exec) -{ - JSObject* obj = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList()); - - for (PropertyListNode* p = this; p; p = p->m_next.get()) { - JSValue* v = p->m_node->m_assign->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - switch (p->m_node->m_type) { - case PropertyNode::Getter: - ASSERT(v->isObject()); - obj->defineGetter(exec, p->m_node->name(), static_cast(v)); - break; - case PropertyNode::Setter: - ASSERT(v->isObject()); - obj->defineSetter(exec, p->m_node->name(), static_cast(v)); - break; - case PropertyNode::Constant: - obj->put(exec, p->m_node->name(), v); - break; - } - } - - return obj; -} - -// ------------------------------ PropertyNode ----------------------------- - -void PropertyNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_assign.get()); -} - -// ECMA 11.1.5 -JSValue* PropertyNode::evaluate(ExecState*) -{ - ASSERT(false); - return jsNull(); -} - -// ------------------------------ BracketAccessorNode -------------------------------- - -void BracketAccessorNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_subscript.get()); - nodeStack.append(m_base.get()); -} - -// ECMA 11.2.1a -JSValue* BracketAccessorNode::inlineEvaluate(ExecState* exec) -{ - JSValue* v1 = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* v2 = m_subscript->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSObject* o = v1->toObject(exec); - uint32_t i; - if (v2->getUInt32(i)) - return o->get(exec, i); - return o->get(exec, Identifier(v2->toString(exec))); -} - -JSValue* BracketAccessorNode::evaluate(ExecState* exec) -{ - return inlineEvaluate(exec); -} - -double BracketAccessorNode::evaluateToNumber(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toNumber(exec); -} - -bool BracketAccessorNode::evaluateToBoolean(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return v->toBoolean(exec); -} - -int32_t BracketAccessorNode::evaluateToInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toInt32(exec); -} - -uint32_t BracketAccessorNode::evaluateToUInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toUInt32(exec); -} - -// ------------------------------ DotAccessorNode -------------------------------- - -void DotAccessorNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_base.get()); -} - -// ECMA 11.2.1b -JSValue* DotAccessorNode::inlineEvaluate(ExecState* exec) -{ - JSValue* v = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - return v->toObject(exec)->get(exec, m_ident); -} - -JSValue* DotAccessorNode::evaluate(ExecState* exec) -{ - return inlineEvaluate(exec); -} - -double DotAccessorNode::evaluateToNumber(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toNumber(exec); -} - -bool DotAccessorNode::evaluateToBoolean(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return v->toBoolean(exec); -} - -int32_t DotAccessorNode::evaluateToInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toInt32(exec); -} - -uint32_t DotAccessorNode::evaluateToUInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toUInt32(exec); -} - -// ------------------------------ ArgumentListNode ----------------------------- - -void ArgumentListNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_next) - nodeStack.append(m_next.get()); - ASSERT(m_expr); - nodeStack.append(m_expr.get()); -} - -// ECMA 11.2.4 -void ArgumentListNode::evaluateList(ExecState* exec, List& list) -{ - for (ArgumentListNode* n = this; n; n = n->m_next.get()) { - JSValue* v = n->m_expr->evaluate(exec); - KJS_CHECKEXCEPTIONVOID - list.append(v); - } -} - -// ------------------------------ ArgumentsNode -------------------------------- - -void ArgumentsNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_listNode) - nodeStack.append(m_listNode.get()); -} - -// ------------------------------ NewExprNode ---------------------------------- - -void NewExprNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_args) - nodeStack.append(m_args.get()); - nodeStack.append(m_expr.get()); -} - -// ECMA 11.2.2 - -JSValue* NewExprNode::inlineEvaluate(ExecState* exec) -{ - JSValue* v = m_expr->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - List argList; - if (m_args) { - m_args->evaluateList(exec, argList); - KJS_CHECKEXCEPTIONVALUE - } - - if (!v->isObject()) - return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with new.", v, m_expr.get()); - - JSObject* constr = static_cast(v); - if (!constr->implementsConstruct()) - return throwError(exec, TypeError, "Value %s (result of expression %s) is not a constructor. Cannot be used with new.", v, m_expr.get()); - - return constr->construct(exec, argList); -} - -JSValue* NewExprNode::evaluate(ExecState* exec) -{ - return inlineEvaluate(exec); -} - -double NewExprNode::evaluateToNumber(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toNumber(exec); -} - -bool NewExprNode::evaluateToBoolean(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return v->toBoolean(exec); -} - -int32_t NewExprNode::evaluateToInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toInt32(exec); -} - -uint32_t NewExprNode::evaluateToUInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toUInt32(exec); -} - -void FunctionCallValueNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_args.get()); - nodeStack.append(m_expr.get()); -} - -// ECMA 11.2.3 -JSValue* FunctionCallValueNode::evaluate(ExecState* exec) -{ - JSValue* v = m_expr->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - if (!v->isObject()) { - return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, m_expr.get()); - } - - JSObject* func = static_cast(v); - - if (!func->implementsCall()) { - return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, m_expr.get()); - } - - List argList; - m_args->evaluateList(exec, argList); - KJS_CHECKEXCEPTIONVALUE - - JSObject* thisObj = exec->dynamicGlobalObject(); - - return func->call(exec, thisObj, argList); -} - -void FunctionCallResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_args.get()); - - size_t index = symbolTable.get(m_ident.ustring().rep()); - if (index != missingSymbolMarker()) - new (this) LocalVarFunctionCallNode(index); -} - -// ECMA 11.2.3 -JSValue* FunctionCallResolveNode::inlineEvaluate(ExecState* exec) -{ - // Check for missed optimization opportunity. - ASSERT(!canSkipLookup(exec, m_ident)); - - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // we must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - JSObject* base; - do { - base = *iter; - if (base->getPropertySlot(exec, m_ident, slot)) { - JSValue* v = slot.getValue(exec, base, m_ident); - KJS_CHECKEXCEPTIONVALUE - - if (!v->isObject()) - return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, m_ident); - - JSObject* func = static_cast(v); - - if (!func->implementsCall()) - return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, m_ident); - - List argList; - m_args->evaluateList(exec, argList); - KJS_CHECKEXCEPTIONVALUE - - JSObject* thisObj = base; - // ECMA 11.2.3 says that in this situation the this value should be null. - // However, section 10.2.3 says that in the case where the value provided - // by the caller is null, the global object should be used. It also says - // that the section does not apply to internal functions, but for simplicity - // of implementation we use the global object anyway here. This guarantees - // that in host objects you always get a valid object for this. - if (thisObj->isActivationObject()) - thisObj = exec->dynamicGlobalObject(); - - return func->call(exec, thisObj, argList); - } - ++iter; - } while (iter != end); - - return throwUndefinedVariableError(exec, m_ident); -} - -JSValue* FunctionCallResolveNode::evaluate(ExecState* exec) -{ - return inlineEvaluate(exec); -} - -double FunctionCallResolveNode::evaluateToNumber(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toNumber(exec); -} - -bool FunctionCallResolveNode::evaluateToBoolean(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return v->toBoolean(exec); -} - -int32_t FunctionCallResolveNode::evaluateToInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toInt32(exec); -} - -uint32_t FunctionCallResolveNode::evaluateToUInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toUInt32(exec); -} - -JSValue* LocalVarFunctionCallNode::inlineEvaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - - JSValue* v = exec->localStorage()[m_index].value; - - if (!v->isObject()) - return throwError(exec, TypeError, "Value %s (result of expression %s) is not object.", v, m_ident); - - JSObject* func = static_cast(v); - if (!func->implementsCall()) - return throwError(exec, TypeError, "Object %s (result of expression %s) does not allow calls.", v, m_ident); - - List argList; - m_args->evaluateList(exec, argList); - KJS_CHECKEXCEPTIONVALUE - - return func->call(exec, exec->dynamicGlobalObject(), argList); -} - -JSValue* LocalVarFunctionCallNode::evaluate(ExecState* exec) -{ - return inlineEvaluate(exec); -} - -double LocalVarFunctionCallNode::evaluateToNumber(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toNumber(exec); -} - -bool LocalVarFunctionCallNode::evaluateToBoolean(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return v->toBoolean(exec); -} - -int32_t LocalVarFunctionCallNode::evaluateToInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toInt32(exec); -} - -uint32_t LocalVarFunctionCallNode::evaluateToUInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toUInt32(exec); -} - -void FunctionCallBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_args.get()); - nodeStack.append(m_subscript.get()); - nodeStack.append(m_base.get()); -} - -// ECMA 11.2.3 -JSValue* FunctionCallBracketNode::evaluate(ExecState* exec) -{ - JSValue* baseVal = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSValue* subscriptVal = m_subscript->evaluate(exec); - - JSObject* baseObj = baseVal->toObject(exec); - uint32_t i; - PropertySlot slot; - - JSValue* funcVal; - if (subscriptVal->getUInt32(i)) { - if (baseObj->getPropertySlot(exec, i, slot)) - funcVal = slot.getValue(exec, baseObj, i); - else - funcVal = jsUndefined(); - } else { - Identifier ident(subscriptVal->toString(exec)); - if (baseObj->getPropertySlot(exec, ident, slot)) - funcVal = baseObj->get(exec, ident); - else - funcVal = jsUndefined(); - } - - KJS_CHECKEXCEPTIONVALUE - - if (!funcVal->isObject()) - return throwError(exec, TypeError, "Value %s (result of expression %s[%s]) is not object.", funcVal, m_base.get(), m_subscript.get()); - - JSObject* func = static_cast(funcVal); - - if (!func->implementsCall()) - return throwError(exec, TypeError, "Object %s (result of expression %s[%s]) does not allow calls.", funcVal, m_base.get(), m_subscript.get()); - - List argList; - m_args->evaluateList(exec, argList); - KJS_CHECKEXCEPTIONVALUE - - JSObject* thisObj = baseObj; - ASSERT(thisObj); - ASSERT(thisObj->isObject()); - ASSERT(!thisObj->isActivationObject()); - - return func->call(exec, thisObj, argList); -} - -static const char* dotExprNotAnObjectString() KJS_FAST_CALL; -static const char* dotExprNotAnObjectString() -{ - return "Value %s (result of expression %s.%s) is not object."; -} - -static const char* dotExprDoesNotAllowCallsString() KJS_FAST_CALL; -static const char* dotExprDoesNotAllowCallsString() -{ - return "Object %s (result of expression %s.%s) does not allow calls."; -} - -void FunctionCallDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_args.get()); - nodeStack.append(m_base.get()); -} - -// ECMA 11.2.3 -JSValue* FunctionCallDotNode::inlineEvaluate(ExecState* exec) -{ - JSValue* baseVal = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSObject* baseObj = baseVal->toObject(exec); - PropertySlot slot; - JSValue* funcVal = baseObj->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, baseObj, m_ident) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - if (!funcVal->isObject()) - return throwError(exec, TypeError, dotExprNotAnObjectString(), funcVal, m_base.get(), m_ident); - - JSObject* func = static_cast(funcVal); - - if (!func->implementsCall()) - return throwError(exec, TypeError, dotExprDoesNotAllowCallsString(), funcVal, m_base.get(), m_ident); - - List argList; - m_args->evaluateList(exec, argList); - KJS_CHECKEXCEPTIONVALUE - - JSObject* thisObj = baseObj; - ASSERT(thisObj); - ASSERT(thisObj->isObject()); - ASSERT(!thisObj->isActivationObject()); - - return func->call(exec, thisObj, argList); -} - -JSValue* FunctionCallDotNode::evaluate(ExecState* exec) -{ - return inlineEvaluate(exec); -} - -double FunctionCallDotNode::evaluateToNumber(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toNumber(exec); -} - -bool FunctionCallDotNode::evaluateToBoolean(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return v->toBoolean(exec); -} - -int32_t FunctionCallDotNode::evaluateToInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toInt32(exec); -} - -uint32_t FunctionCallDotNode::evaluateToUInt32(ExecState* exec) -{ - JSValue* v = inlineEvaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - return v->toUInt32(exec); -} - -// ECMA 11.3 - -// ------------------------------ PostfixResolveNode ---------------------------------- - -// Increment -void PostIncResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack&) -{ - size_t index = symbolTable.get(m_ident.ustring().rep()); - if (index != missingSymbolMarker()) { - if (isConstant(localStorage, index)) - new (this) PostIncConstNode(index); - else - new (this) PostIncLocalVarNode(index); - } -} - -JSValue* PostIncResolveNode::evaluate(ExecState* exec) -{ - // Check for missed optimization opportunity. - ASSERT(!canSkipLookup(exec, m_ident)); - - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // we must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - do { - if ((*iter)->getPropertySlot(exec, m_ident, slot)) { - // If m_ident is 'arguments', the base->getPropertySlot() may cause - // base (which must be an ActivationImp in such this case) to be torn - // off from the activation stack, in which case we need to get it again - // from the ScopeChainIterator. - - JSObject* base = *iter; - JSValue* v = slot.getValue(exec, base, m_ident)->toJSNumber(exec); - base->put(exec, m_ident, jsNumber(v->toNumber(exec) + 1)); - return v; - } - - ++iter; - } while (iter != end); - - return throwUndefinedVariableError(exec, m_ident); -} - -void PostIncResolveNode::optimizeForUnnecessaryResult() -{ - new (this) PreIncResolveNode(PlacementNewAdopt); -} - -JSValue* PostIncLocalVarNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - - JSValue** slot = &exec->localStorage()[m_index].value; - JSValue* v = (*slot)->toJSNumber(exec); - *slot = jsNumber(v->toNumber(exec) + 1); - return v; -} - -void PostIncLocalVarNode::optimizeForUnnecessaryResult() -{ - new (this) PreIncLocalVarNode(m_index); -} - -// Decrement -void PostDecResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack&) -{ - size_t index = symbolTable.get(m_ident.ustring().rep()); - if (index != missingSymbolMarker()) { - if (isConstant(localStorage, index)) - new (this) PostDecConstNode(index); - else - new (this) PostDecLocalVarNode(index); - } -} - -JSValue* PostDecResolveNode::evaluate(ExecState* exec) -{ - // Check for missed optimization opportunity. - ASSERT(!canSkipLookup(exec, m_ident)); - - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // we must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - do { - if ((*iter)->getPropertySlot(exec, m_ident, slot)) { - // See the comment in PostIncResolveNode::evaluate(). - - JSObject* base = *iter; - JSValue* v = slot.getValue(exec, base, m_ident)->toJSNumber(exec); - base->put(exec, m_ident, jsNumber(v->toNumber(exec) - 1)); - return v; - } - - ++iter; - } while (iter != end); - - return throwUndefinedVariableError(exec, m_ident); -} - -void PostDecResolveNode::optimizeForUnnecessaryResult() -{ - new (this) PreDecResolveNode(PlacementNewAdopt); -} - -JSValue* PostDecLocalVarNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - - JSValue** slot = &exec->localStorage()[m_index].value; - JSValue* v = (*slot)->toJSNumber(exec); - *slot = jsNumber(v->toNumber(exec) - 1); - return v; -} - -double PostDecLocalVarNode::inlineEvaluateToNumber(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - - JSValue** slot = &exec->localStorage()[m_index].value; - double n = (*slot)->toNumber(exec); - *slot = jsNumber(n - 1); - return n; -} - -double PostDecLocalVarNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToNumber(exec); -} - -bool PostDecLocalVarNode::evaluateToBoolean(ExecState* exec) -{ - double result = inlineEvaluateToNumber(exec); - return result > 0.0 || 0.0 > result; // NaN produces false as well -} - -int32_t PostDecLocalVarNode::evaluateToInt32(ExecState* exec) -{ - return JSValue::toInt32(inlineEvaluateToNumber(exec)); -} - -uint32_t PostDecLocalVarNode::evaluateToUInt32(ExecState* exec) -{ - return JSValue::toUInt32(inlineEvaluateToNumber(exec)); -} - -void PostDecLocalVarNode::optimizeForUnnecessaryResult() -{ - new (this) PreDecLocalVarNode(m_index); -} - -// ------------------------------ PostfixBracketNode ---------------------------------- - -void PostfixBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_subscript.get()); - nodeStack.append(m_base.get()); -} - -JSValue* PostIncBracketNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* subscript = m_subscript->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSObject* base = baseValue->toObject(exec); - - uint32_t propertyIndex; - if (subscript->getUInt32(propertyIndex)) { - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, propertyIndex, slot) ? slot.getValue(exec, base, propertyIndex) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - JSValue* v2 = v->toJSNumber(exec); - base->put(exec, propertyIndex, jsNumber(v2->toNumber(exec) + 1)); - - return v2; - } - - Identifier propertyName(subscript->toString(exec)); - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, propertyName, slot) ? slot.getValue(exec, base, propertyName) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - JSValue* v2 = v->toJSNumber(exec); - base->put(exec, propertyName, jsNumber(v2->toNumber(exec) + 1)); - return v2; -} - -JSValue* PostDecBracketNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* subscript = m_subscript->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSObject* base = baseValue->toObject(exec); - - uint32_t propertyIndex; - if (subscript->getUInt32(propertyIndex)) { - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, propertyIndex, slot) ? slot.getValue(exec, base, propertyIndex) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - JSValue* v2 = v->toJSNumber(exec); - base->put(exec, propertyIndex, jsNumber(v2->toNumber(exec) - 1)); - return v2; - } - - Identifier propertyName(subscript->toString(exec)); - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, propertyName, slot) ? slot.getValue(exec, base, propertyName) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - JSValue* v2 = v->toJSNumber(exec); - base->put(exec, propertyName, jsNumber(v2->toNumber(exec) - 1)); - return v2; -} - -// ------------------------------ PostfixDotNode ---------------------------------- - -void PostfixDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_base.get()); -} - -JSValue* PostIncDotNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSObject* base = baseValue->toObject(exec); - - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, base, m_ident) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - JSValue* v2 = v->toJSNumber(exec); - base->put(exec, m_ident, jsNumber(v2->toNumber(exec) + 1)); - return v2; -} - -JSValue* PostDecDotNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSObject* base = baseValue->toObject(exec); - - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, base, m_ident) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - JSValue* v2 = v->toJSNumber(exec); - base->put(exec, m_ident, jsNumber(v2->toNumber(exec) - 1)); - return v2; -} - -// ------------------------------ PostfixErrorNode ----------------------------------- - -JSValue* PostfixErrorNode::evaluate(ExecState* exec) -{ - throwError(exec, ReferenceError, "Postfix %s operator applied to value that is not a reference.", - m_operator == OpPlusPlus ? "++" : "--"); - handleException(exec); - return jsUndefined(); -} - -// ------------------------------ DeleteResolveNode ----------------------------------- - -void DeleteResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage&, NodeStack&) -{ - size_t index = symbolTable.get(m_ident.ustring().rep()); - if (index != missingSymbolMarker()) - new (this) LocalVarDeleteNode(); -} - -// ECMA 11.4.1 - -JSValue* DeleteResolveNode::evaluate(ExecState* exec) -{ - // Check for missed optimization opportunity. - ASSERT(!canSkipLookup(exec, m_ident)); - - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // We must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - JSObject* base; - do { - base = *iter; - if (base->getPropertySlot(exec, m_ident, slot)) - return jsBoolean(base->deleteProperty(exec, m_ident)); - - ++iter; - } while (iter != end); - - return jsBoolean(true); -} - -JSValue* LocalVarDeleteNode::evaluate(ExecState*) -{ - return jsBoolean(false); -} - -// ------------------------------ DeleteBracketNode ----------------------------------- - -void DeleteBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_subscript.get()); - nodeStack.append(m_base.get()); -} - -JSValue* DeleteBracketNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* subscript = m_subscript->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSObject* base = baseValue->toObject(exec); - - uint32_t propertyIndex; - if (subscript->getUInt32(propertyIndex)) - return jsBoolean(base->deleteProperty(exec, propertyIndex)); - - Identifier propertyName(subscript->toString(exec)); - return jsBoolean(base->deleteProperty(exec, propertyName)); -} - -// ------------------------------ DeleteDotNode ----------------------------------- - -void DeleteDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_base.get()); -} - -JSValue* DeleteDotNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - JSObject* base = baseValue->toObject(exec); - KJS_CHECKEXCEPTIONVALUE - - return jsBoolean(base->deleteProperty(exec, m_ident)); -} - -// ------------------------------ DeleteValueNode ----------------------------------- - -void DeleteValueNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr.get()); -} - -JSValue* DeleteValueNode::evaluate(ExecState* exec) -{ - m_expr->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - // delete on a non-location expression ignores the value and returns true - return jsBoolean(true); -} - -// ------------------------------ VoidNode ------------------------------------- - -void VoidNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr.get()); -} - -// ECMA 11.4.2 -JSValue* VoidNode::evaluate(ExecState* exec) -{ - m_expr->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - return jsUndefined(); -} - -// ECMA 11.4.3 - -// ------------------------------ TypeOfValueNode ----------------------------------- - -void TypeOfValueNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr.get()); -} - -static JSValue* typeStringForValue(JSValue* v) KJS_FAST_CALL; -static JSValue* typeStringForValue(JSValue* v) -{ - switch (v->type()) { - case UndefinedType: - return jsString("undefined"); - case NullType: - return jsString("object"); - case BooleanType: - return jsString("boolean"); - case NumberType: - return jsString("number"); - case StringType: - return jsString("string"); - default: - if (v->isObject()) { - // Return "undefined" for objects that should be treated - // as null when doing comparisons. - if (static_cast(v)->masqueradeAsUndefined()) - return jsString("undefined"); - else if (static_cast(v)->implementsCall()) - return jsString("function"); - } - - return jsString("object"); - } -} - -void TypeOfResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage&, NodeStack&) -{ - size_t index = symbolTable.get(m_ident.ustring().rep()); - if (index != missingSymbolMarker()) - new (this) LocalVarTypeOfNode(index); -} - -JSValue* LocalVarTypeOfNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - - return typeStringForValue(exec->localStorage()[m_index].value); -} - -JSValue* TypeOfResolveNode::evaluate(ExecState* exec) -{ - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // We must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - JSObject* base; - do { - base = *iter; - if (base->getPropertySlot(exec, m_ident, slot)) { - JSValue* v = slot.getValue(exec, base, m_ident); - return typeStringForValue(v); - } - - ++iter; - } while (iter != end); - - return jsString("undefined"); -} - -// ------------------------------ TypeOfValueNode ----------------------------------- - -JSValue* TypeOfValueNode::evaluate(ExecState* exec) -{ - JSValue* v = m_expr->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - return typeStringForValue(v); -} - -// ECMA 11.4.4 and 11.4.5 - -// ------------------------------ PrefixResolveNode ---------------------------------- - -void PreIncResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack&) -{ - size_t index = symbolTable.get(m_ident.ustring().rep()); - if (index != missingSymbolMarker()) { - if (isConstant(localStorage, index)) - new (this) PreIncConstNode(index); - else - new (this) PreIncLocalVarNode(index); - } -} - -JSValue* PreIncLocalVarNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - JSValue** slot = &exec->localStorage()[m_index].value; - - double n = (*slot)->toNumber(exec); - JSValue* n2 = jsNumber(n + 1); - *slot = n2; - return n2; -} - -JSValue* PreIncResolveNode::evaluate(ExecState* exec) -{ - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // we must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - do { - if ((*iter)->getPropertySlot(exec, m_ident, slot)) { - // See the comment in PostIncResolveNode::evaluate(). - - JSObject* base = *iter; - JSValue* v = slot.getValue(exec, base, m_ident); - - double n = v->toNumber(exec); - JSValue* n2 = jsNumber(n + 1); - base->put(exec, m_ident, n2); - - return n2; - } - - ++iter; - } while (iter != end); - - return throwUndefinedVariableError(exec, m_ident); -} - -void PreDecResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack&) -{ - size_t index = symbolTable.get(m_ident.ustring().rep()); - if (index != missingSymbolMarker()) { - if (isConstant(localStorage, index)) - new (this) PreDecConstNode(index); - else - new (this) PreDecLocalVarNode(index); - } -} - -JSValue* PreDecLocalVarNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - JSValue** slot = &exec->localStorage()[m_index].value; - - double n = (*slot)->toNumber(exec); - JSValue* n2 = jsNumber(n - 1); - *slot = n2; - return n2; -} - -JSValue* PreDecResolveNode::evaluate(ExecState* exec) -{ - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // we must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - do { - if ((*iter)->getPropertySlot(exec, m_ident, slot)) { - // See the comment in PostIncResolveNode::evaluate(). - - JSObject* base = *iter; - JSValue* v = slot.getValue(exec, base, m_ident); - - double n = v->toNumber(exec); - JSValue* n2 = jsNumber(n - 1); - base->put(exec, m_ident, n2); - - return n2; - } - - ++iter; - } while (iter != end); - - return throwUndefinedVariableError(exec, m_ident); -} - -// ------------------------------ PreIncConstNode ---------------------------------- - -JSValue* PreIncConstNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - return jsNumber(exec->localStorage()[m_index].value->toNumber(exec) + 1); -} - -// ------------------------------ PreDecConstNode ---------------------------------- - -JSValue* PreDecConstNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - return jsNumber(exec->localStorage()[m_index].value->toNumber(exec) - 1); -} - -// ------------------------------ PostIncConstNode ---------------------------------- - -JSValue* PostIncConstNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - return jsNumber(exec->localStorage()[m_index].value->toNumber(exec)); -} - -// ------------------------------ PostDecConstNode ---------------------------------- - -JSValue* PostDecConstNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - return jsNumber(exec->localStorage()[m_index].value->toNumber(exec)); -} - -// ------------------------------ PrefixBracketNode ---------------------------------- - -void PrefixBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_subscript.get()); - nodeStack.append(m_base.get()); -} - -JSValue* PreIncBracketNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* subscript = m_subscript->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSObject* base = baseValue->toObject(exec); - - uint32_t propertyIndex; - if (subscript->getUInt32(propertyIndex)) { - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, propertyIndex, slot) ? slot.getValue(exec, base, propertyIndex) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - JSValue* n2 = jsNumber(v->toNumber(exec) + 1); - base->put(exec, propertyIndex, n2); - - return n2; - } - - Identifier propertyName(subscript->toString(exec)); - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, propertyName, slot) ? slot.getValue(exec, base, propertyName) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - JSValue* n2 = jsNumber(v->toNumber(exec) + 1); - base->put(exec, propertyName, n2); - - return n2; -} - -JSValue* PreDecBracketNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* subscript = m_subscript->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSObject* base = baseValue->toObject(exec); - - uint32_t propertyIndex; - if (subscript->getUInt32(propertyIndex)) { - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, propertyIndex, slot) ? slot.getValue(exec, base, propertyIndex) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - JSValue* n2 = jsNumber(v->toNumber(exec) - 1); - base->put(exec, propertyIndex, n2); - - return n2; - } - - Identifier propertyName(subscript->toString(exec)); - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, propertyName, slot) ? slot.getValue(exec, base, propertyName) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - JSValue* n2 = jsNumber(v->toNumber(exec) - 1); - base->put(exec, propertyName, n2); - - return n2; -} - -// ------------------------------ PrefixDotNode ---------------------------------- - -void PrefixDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_base.get()); -} - -JSValue* PreIncDotNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSObject* base = baseValue->toObject(exec); - - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, base, m_ident) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - double n = v->toNumber(exec); - JSValue* n2 = jsNumber(n + 1); - base->put(exec, m_ident, n2); - - return n2; -} - -JSValue* PreDecDotNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSObject* base = baseValue->toObject(exec); - - PropertySlot slot; - JSValue* v = base->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, base, m_ident) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - - double n = v->toNumber(exec); - JSValue* n2 = jsNumber(n - 1); - base->put(exec, m_ident, n2); - - return n2; -} - -// ------------------------------ PrefixErrorNode ----------------------------------- - -JSValue* PrefixErrorNode::evaluate(ExecState* exec) -{ - throwError(exec, ReferenceError, "Prefix %s operator applied to value that is not a reference.", - m_operator == OpPlusPlus ? "++" : "--"); - handleException(exec); - return jsUndefined(); -} - -// ------------------------------ UnaryPlusNode -------------------------------- - -void UnaryPlusNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr.get()); -} - -// ECMA 11.4.6 -JSValue* UnaryPlusNode::evaluate(ExecState* exec) -{ - JSValue* v = m_expr->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - return v->toJSNumber(exec); -} - -bool UnaryPlusNode::evaluateToBoolean(ExecState* exec) -{ - return m_expr->evaluateToBoolean(exec); -} - -double UnaryPlusNode::evaluateToNumber(ExecState* exec) -{ - return m_expr->evaluateToNumber(exec); -} - -int32_t UnaryPlusNode::evaluateToInt32(ExecState* exec) -{ - return m_expr->evaluateToInt32(exec); -} - -uint32_t UnaryPlusNode::evaluateToUInt32(ExecState* exec) -{ - return m_expr->evaluateToInt32(exec); -} - -// ------------------------------ NegateNode ----------------------------------- - -void NegateNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr.get()); -} - -// ECMA 11.4.7 -JSValue* NegateNode::evaluate(ExecState* exec) -{ - // No need to check exception, caller will do so right after evaluate() - return jsNumber(-m_expr->evaluateToNumber(exec)); -} - -double NegateNode::evaluateToNumber(ExecState* exec) -{ - // No need to check exception, caller will do so right after evaluateToNumber() - return -m_expr->evaluateToNumber(exec); -} - -// ------------------------------ BitwiseNotNode ------------------------------- - -void BitwiseNotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr.get()); -} - -// ECMA 11.4.8 -int32_t BitwiseNotNode::inlineEvaluateToInt32(ExecState* exec) -{ - return ~m_expr->evaluateToInt32(exec); -} - -JSValue* BitwiseNotNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToInt32(exec)); -} - -double BitwiseNotNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -bool BitwiseNotNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -int32_t BitwiseNotNode::evaluateToInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -uint32_t BitwiseNotNode::evaluateToUInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -// ------------------------------ LogicalNotNode ------------------------------- - -void LogicalNotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr.get()); -} - -// ECMA 11.4.9 -JSValue* LogicalNotNode::evaluate(ExecState* exec) -{ - return jsBoolean(!m_expr->evaluateToBoolean(exec)); -} - -bool LogicalNotNode::evaluateToBoolean(ExecState* exec) -{ - return !m_expr->evaluateToBoolean(exec); -} - -// ------------------------------ Multiplicative Nodes ----------------------------------- - -void MultNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_term1.get()); - nodeStack.append(m_term2.get()); -} - -// ECMA 11.5.1 -double MultNode::inlineEvaluateToNumber(ExecState* exec) -{ - double n1 = m_term1->evaluateToNumber(exec); - KJS_CHECKEXCEPTIONNUMBER - double n2 = m_term2->evaluateToNumber(exec); - return n1 * n2; -} - -JSValue* MultNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToNumber(exec)); -} - -double MultNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToNumber(exec); -} - -bool MultNode::evaluateToBoolean(ExecState* exec) -{ - double result = inlineEvaluateToNumber(exec); - return result > 0.0 || 0.0 > result; // NaN produces false as well -} - -int32_t MultNode::evaluateToInt32(ExecState* exec) -{ - return JSValue::toInt32(inlineEvaluateToNumber(exec)); -} - -uint32_t MultNode::evaluateToUInt32(ExecState* exec) -{ - return JSValue::toUInt32(inlineEvaluateToNumber(exec)); -} - -void DivNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_term1.get()); - nodeStack.append(m_term2.get()); -} - -// ECMA 11.5.2 -double DivNode::inlineEvaluateToNumber(ExecState* exec) -{ - double n1 = m_term1->evaluateToNumber(exec); - KJS_CHECKEXCEPTIONNUMBER - double n2 = m_term2->evaluateToNumber(exec); - return n1 / n2; -} - -JSValue* DivNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToNumber(exec)); -} - -double DivNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToNumber(exec); -} - -int32_t DivNode::evaluateToInt32(ExecState* exec) -{ - return JSValue::toInt32(inlineEvaluateToNumber(exec)); -} - -uint32_t DivNode::evaluateToUInt32(ExecState* exec) -{ - return JSValue::toUInt32(inlineEvaluateToNumber(exec)); -} - -void ModNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_term1.get()); - nodeStack.append(m_term2.get()); -} - -// ECMA 11.5.3 -double ModNode::inlineEvaluateToNumber(ExecState* exec) -{ - double n1 = m_term1->evaluateToNumber(exec); - KJS_CHECKEXCEPTIONNUMBER - double n2 = m_term2->evaluateToNumber(exec); - return fmod(n1, n2); -} - -JSValue* ModNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToNumber(exec)); -} - -double ModNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToNumber(exec); -} - -bool ModNode::evaluateToBoolean(ExecState* exec) -{ - double result = inlineEvaluateToNumber(exec); - return result > 0.0 || 0.0 > result; // NaN produces false as well -} - -int32_t ModNode::evaluateToInt32(ExecState* exec) -{ - return JSValue::toInt32(inlineEvaluateToNumber(exec)); -} - -uint32_t ModNode::evaluateToUInt32(ExecState* exec) -{ - return JSValue::toUInt32(inlineEvaluateToNumber(exec)); -} - -// ------------------------------ Additive Nodes -------------------------------------- - -static JSValue* throwOutOfMemoryError(ExecState* exec) -{ - JSObject* error = Error::create(exec, GeneralError, "Out of memory"); - exec->setException(error); - return error; -} - -static double throwOutOfMemoryErrorToNumber(ExecState* exec) -{ - JSObject* error = Error::create(exec, GeneralError, "Out of memory"); - exec->setException(error); - return 0.0; -} - -// ECMA 11.6 -static JSValue* addSlowCase(ExecState* exec, JSValue* v1, JSValue* v2) -{ - // exception for the Date exception in defaultValue() - JSValue* p1 = v1->toPrimitive(exec, UnspecifiedType); - JSValue* p2 = v2->toPrimitive(exec, UnspecifiedType); - - if (p1->isString() || p2->isString()) { - UString value = p1->toString(exec) + p2->toString(exec); - if (value.isNull()) - return throwOutOfMemoryError(exec); - return jsString(value); - } - - return jsNumber(p1->toNumber(exec) + p2->toNumber(exec)); -} - -static double addSlowCaseToNumber(ExecState* exec, JSValue* v1, JSValue* v2) -{ - // exception for the Date exception in defaultValue() - JSValue* p1 = v1->toPrimitive(exec, UnspecifiedType); - JSValue* p2 = v2->toPrimitive(exec, UnspecifiedType); - - if (p1->isString() || p2->isString()) { - UString value = p1->toString(exec) + p2->toString(exec); - if (value.isNull()) - return throwOutOfMemoryErrorToNumber(exec); - return value.toDouble(); - } - - return p1->toNumber(exec) + p2->toNumber(exec); -} - -// Fast-path choices here are based on frequency data from SunSpider: -// Add case: -// --------------------------- -// 5627160 Add case: 1 1 -// 247427 Add case: 5 5 -// 20901 Add case: 5 6 -// 13978 Add case: 5 1 -// 4000 Add case: 1 5 -// 1 Add case: 3 5 - -static inline JSValue* add(ExecState* exec, JSValue* v1, JSValue* v2) -{ - JSType t1 = v1->type(); - JSType t2 = v2->type(); - const unsigned bothTypes = (t1 << 3) | t2; - - if (bothTypes == ((NumberType << 3) | NumberType)) - return jsNumber(v1->toNumber(exec) + v2->toNumber(exec)); - if (bothTypes == ((StringType << 3) | StringType)) { - UString value = static_cast(v1)->value() + static_cast(v2)->value(); - if (value.isNull()) - return throwOutOfMemoryError(exec); - return jsString(value); - } - - // All other cases are pretty uncommon - return addSlowCase(exec, v1, v2); -} - -static inline double addToNumber(ExecState* exec, JSValue* v1, JSValue* v2) -{ - JSType t1 = v1->type(); - JSType t2 = v2->type(); - const unsigned bothTypes = (t1 << 3) | t2; - - if (bothTypes == ((NumberType << 3) | NumberType)) - return v1->toNumber(exec) + v2->toNumber(exec); - if (bothTypes == ((StringType << 3) | StringType)) { - UString value = static_cast(v1)->value() + static_cast(v2)->value(); - if (value.isNull()) - return throwOutOfMemoryErrorToNumber(exec); - return value.toDouble(); - } - - // All other cases are pretty uncommon - return addSlowCaseToNumber(exec, v1, v2); -} - -void AddNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_term1.get()); - nodeStack.append(m_term2.get()); -} - -// ECMA 11.6.1 -JSValue* AddNode::evaluate(ExecState* exec) -{ - JSValue* v1 = m_term1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSValue* v2 = m_term2->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - return add(exec, v1, v2); -} - -double AddNode::inlineEvaluateToNumber(ExecState* exec) -{ - JSValue* v1 = m_term1->evaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - - JSValue* v2 = m_term2->evaluate(exec); - KJS_CHECKEXCEPTIONNUMBER - - return addToNumber(exec, v1, v2); -} - -double AddNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToNumber(exec); -} - -int32_t AddNode::evaluateToInt32(ExecState* exec) -{ - return JSValue::toInt32(inlineEvaluateToNumber(exec)); -} - -uint32_t AddNode::evaluateToUInt32(ExecState* exec) -{ - return JSValue::toUInt32(inlineEvaluateToNumber(exec)); -} - -double AddNumbersNode::inlineEvaluateToNumber(ExecState* exec) -{ - double n1 = m_term1->evaluateToNumber(exec); - KJS_CHECKEXCEPTIONNUMBER - double n2 = m_term2->evaluateToNumber(exec); - return n1 + n2; -} - -JSValue* AddNumbersNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToNumber(exec)); -} - -double AddNumbersNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToNumber(exec); -} - -int32_t AddNumbersNode::evaluateToInt32(ExecState* exec) -{ - return JSValue::toInt32(inlineEvaluateToNumber(exec)); -} - -uint32_t AddNumbersNode::evaluateToUInt32(ExecState* exec) -{ - return JSValue::toUInt32(inlineEvaluateToNumber(exec)); -} - -JSValue* AddStringsNode::evaluate(ExecState* exec) -{ - JSValue* v1 = m_term1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSValue* v2 = m_term2->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - return jsString(static_cast(v1)->value() + static_cast(v2)->value()); -} - -JSValue* AddStringLeftNode::evaluate(ExecState* exec) -{ - JSValue* v1 = m_term1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSValue* v2 = m_term2->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSValue* p2 = v2->toPrimitive(exec, UnspecifiedType); - return jsString(static_cast(v1)->value() + p2->toString(exec)); -} - -JSValue* AddStringRightNode::evaluate(ExecState* exec) -{ - JSValue* v1 = m_term1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSValue* v2 = m_term2->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSValue* p1 = v1->toPrimitive(exec, UnspecifiedType); - return jsString(p1->toString(exec) + static_cast(v2)->value()); -} - -void SubNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_term1.get()); - nodeStack.append(m_term2.get()); -} - -// ECMA 11.6.2 -double SubNode::inlineEvaluateToNumber(ExecState* exec) -{ - double n1 = m_term1->evaluateToNumber(exec); - KJS_CHECKEXCEPTIONNUMBER - double n2 = m_term2->evaluateToNumber(exec); - return n1 - n2; -} - -JSValue* SubNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToNumber(exec)); -} - -double SubNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToNumber(exec); -} - -int32_t SubNode::evaluateToInt32(ExecState* exec) -{ - return JSValue::toInt32(inlineEvaluateToNumber(exec)); -} - -uint32_t SubNode::evaluateToUInt32(ExecState* exec) -{ - return JSValue::toUInt32(inlineEvaluateToNumber(exec)); -} - -// ------------------------------ Shift Nodes ------------------------------------ - -void LeftShiftNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_term1.get()); - nodeStack.append(m_term2.get()); -} - -// ECMA 11.7.1 -int32_t LeftShiftNode::inlineEvaluateToInt32(ExecState* exec) -{ - int i1 = m_term1->evaluateToInt32(exec); - KJS_CHECKEXCEPTIONNUMBER - unsigned int i2 = m_term2->evaluateToUInt32(exec) & 0x1f; - return (i1 << i2); -} - -JSValue* LeftShiftNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToInt32(exec)); -} - -double LeftShiftNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -int32_t LeftShiftNode::evaluateToInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -uint32_t LeftShiftNode::evaluateToUInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -void RightShiftNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_term1.get()); - nodeStack.append(m_term2.get()); -} - -// ECMA 11.7.2 -int32_t RightShiftNode::inlineEvaluateToInt32(ExecState* exec) -{ - int i1 = m_term1->evaluateToInt32(exec); - KJS_CHECKEXCEPTIONNUMBER - unsigned int i2 = m_term2->evaluateToUInt32(exec) & 0x1f; - return (i1 >> i2); -} - -JSValue* RightShiftNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToInt32(exec)); -} - -double RightShiftNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -int32_t RightShiftNode::evaluateToInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -uint32_t RightShiftNode::evaluateToUInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -void UnsignedRightShiftNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_term1.get()); - nodeStack.append(m_term2.get()); -} - -// ECMA 11.7.3 -uint32_t UnsignedRightShiftNode::inlineEvaluateToUInt32(ExecState* exec) -{ - unsigned int i1 = m_term1->evaluateToUInt32(exec); - KJS_CHECKEXCEPTIONNUMBER - unsigned int i2 = m_term2->evaluateToUInt32(exec) & 0x1f; - return (i1 >> i2); -} - -JSValue* UnsignedRightShiftNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToUInt32(exec)); -} - -double UnsignedRightShiftNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToUInt32(exec); -} - -int32_t UnsignedRightShiftNode::evaluateToInt32(ExecState* exec) -{ - return inlineEvaluateToUInt32(exec); -} - -uint32_t UnsignedRightShiftNode::evaluateToUInt32(ExecState* exec) -{ - return inlineEvaluateToUInt32(exec); -} - -// ------------------------------ Relational Nodes ------------------------------- - -static inline bool lessThan(ExecState* exec, JSValue* v1, JSValue* v2) -{ - double n1; - double n2; - JSValue* p1; - JSValue* p2; - bool wasNotString1 = v1->getPrimitiveNumber(exec, n1, p1); - bool wasNotString2 = v2->getPrimitiveNumber(exec, n2, p2); - - if (wasNotString1 | wasNotString2) - return n1 < n2; - - return static_cast(p1)->value() < static_cast(p2)->value(); -} - -static inline bool lessThanEq(ExecState* exec, JSValue* v1, JSValue* v2) -{ - double n1; - double n2; - JSValue* p1; - JSValue* p2; - bool wasNotString1 = v1->getPrimitiveNumber(exec, n1, p1); - bool wasNotString2 = v2->getPrimitiveNumber(exec, n2, p2); - - if (wasNotString1 | wasNotString2) - return n1 <= n2; - - return !(static_cast(p2)->value() < static_cast(p1)->value()); -} - -void LessNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.8.1 -bool LessNode::inlineEvaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return lessThan(exec, v1, v2); -} - -JSValue* LessNode::evaluate(ExecState* exec) -{ - return jsBoolean(inlineEvaluateToBoolean(exec)); -} - -bool LessNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToBoolean(exec); -} - -bool LessNumbersNode::inlineEvaluateToBoolean(ExecState* exec) -{ - double n1 = m_expr1->evaluateToNumber(exec); - KJS_CHECKEXCEPTIONVALUE - double n2 = m_expr2->evaluateToNumber(exec); - return n1 < n2; -} - -JSValue* LessNumbersNode::evaluate(ExecState* exec) -{ - return jsBoolean(inlineEvaluateToBoolean(exec)); -} - -bool LessNumbersNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToBoolean(exec); -} - -bool LessStringsNode::inlineEvaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* v2 = m_expr2->evaluate(exec); - return static_cast(v1)->value() < static_cast(v2)->value(); -} - -JSValue* LessStringsNode::evaluate(ExecState* exec) -{ - return jsBoolean(inlineEvaluateToBoolean(exec)); -} - -bool LessStringsNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToBoolean(exec); -} - -void GreaterNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.8.2 -bool GreaterNode::inlineEvaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return lessThan(exec, v2, v1); -} - -JSValue* GreaterNode::evaluate(ExecState* exec) -{ - return jsBoolean(inlineEvaluateToBoolean(exec)); -} - -bool GreaterNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToBoolean(exec); -} - -void LessEqNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.8.3 -bool LessEqNode::inlineEvaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return lessThanEq(exec, v1, v2); -} - -JSValue* LessEqNode::evaluate(ExecState* exec) -{ - return jsBoolean(inlineEvaluateToBoolean(exec)); -} - -bool LessEqNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToBoolean(exec); -} - -void GreaterEqNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.8.4 -bool GreaterEqNode::inlineEvaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return lessThanEq(exec, v2, v1); -} - -JSValue* GreaterEqNode::evaluate(ExecState* exec) -{ - return jsBoolean(inlineEvaluateToBoolean(exec)); -} - -bool GreaterEqNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToBoolean(exec); -} - -void InstanceOfNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.8.6 -JSValue* InstanceOfNode::evaluate(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - if (!v2->isObject()) - return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with instanceof operator.", v2, m_expr2.get()); - - JSObject* o2 = static_cast(v2); - - // According to the spec, only some types of objects "implement" the [[HasInstance]] property. - // But we are supposed to throw an exception where the object does not "have" the [[HasInstance]] - // property. It seems that all objects have the property, but not all implement it, so in this - // case we return false (consistent with Mozilla). - if (!o2->implementsHasInstance()) - return jsBoolean(false); - - return jsBoolean(o2->hasInstance(exec, v1)); -} - -bool InstanceOfNode::evaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - - if (!v2->isObject()) { - throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with 'instanceof' operator.", v2, m_expr2.get()); - return false; - } - - JSObject* o2 = static_cast(v2); - - // According to the spec, only some types of objects "implement" the [[HasInstance]] property. - // But we are supposed to throw an exception where the object does not "have" the [[HasInstance]] - // property. It seems that all objects have the property, but not all implement it, so in this - // case we return false (consistent with Mozilla). - if (!o2->implementsHasInstance()) - return false; - - return o2->hasInstance(exec, v1); -} - -void InNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.8.7 -JSValue* InNode::evaluate(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - if (!v2->isObject()) - return throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with 'in' operator.", v2, m_expr2.get()); - - return jsBoolean(static_cast(v2)->hasProperty(exec, Identifier(v1->toString(exec)))); -} - -bool InNode::evaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - - if (!v2->isObject()) { - throwError(exec, TypeError, "Value %s (result of expression %s) is not an object. Cannot be used with 'in' operator.", v2, m_expr2.get()); - return false; - } - - return static_cast(v2)->hasProperty(exec, Identifier(v1->toString(exec))); -} - -// ------------------------------ Equality Nodes ------------------------------------ - -void EqualNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.9.1 -bool EqualNode::inlineEvaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - - return equal(exec, v1, v2); -} - -JSValue* EqualNode::evaluate(ExecState* exec) -{ - return jsBoolean(inlineEvaluateToBoolean(exec)); -} - -bool EqualNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToBoolean(exec); -} - -void NotEqualNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.9.2 -bool NotEqualNode::inlineEvaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - - return !equal(exec,v1, v2); -} - -JSValue* NotEqualNode::evaluate(ExecState* exec) -{ - return jsBoolean(inlineEvaluateToBoolean(exec)); -} - -bool NotEqualNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToBoolean(exec); -} - -void StrictEqualNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.9.4 -bool StrictEqualNode::inlineEvaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - - return strictEqual(exec,v1, v2); -} - -JSValue* StrictEqualNode::evaluate(ExecState* exec) -{ - return jsBoolean(inlineEvaluateToBoolean(exec)); -} - -bool StrictEqualNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToBoolean(exec); -} - -void NotStrictEqualNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.9.5 -bool NotStrictEqualNode::inlineEvaluateToBoolean(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONBOOLEAN - - return !strictEqual(exec,v1, v2); -} - -JSValue* NotStrictEqualNode::evaluate(ExecState* exec) -{ - return jsBoolean(inlineEvaluateToBoolean(exec)); -} - -bool NotStrictEqualNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToBoolean(exec); -} - -// ------------------------------ Bit Operation Nodes ---------------------------------- - -void BitAndNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.10 -JSValue* BitAndNode::evaluate(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - return jsNumberFromAnd(exec, v1, v2); -} - -int32_t BitAndNode::inlineEvaluateToInt32(ExecState* exec) -{ - int32_t i1 = m_expr1->evaluateToInt32(exec); - KJS_CHECKEXCEPTIONNUMBER - int32_t i2 = m_expr2->evaluateToInt32(exec); - return (i1 & i2); -} - -double BitAndNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -bool BitAndNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -int32_t BitAndNode::evaluateToInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -uint32_t BitAndNode::evaluateToUInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -void BitXOrNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -int32_t BitXOrNode::inlineEvaluateToInt32(ExecState* exec) -{ - int i1 = m_expr1->evaluateToInt32(exec); - KJS_CHECKEXCEPTIONNUMBER - int i2 = m_expr2->evaluateToInt32(exec); - return (i1 ^ i2); -} - -JSValue* BitXOrNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToInt32(exec)); -} - -double BitXOrNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -bool BitXOrNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -int32_t BitXOrNode::evaluateToInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -uint32_t BitXOrNode::evaluateToUInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -void BitOrNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -int32_t BitOrNode::inlineEvaluateToInt32(ExecState* exec) -{ - int i1 = m_expr1->evaluateToInt32(exec); - KJS_CHECKEXCEPTIONNUMBER - int i2 = m_expr2->evaluateToInt32(exec); - return (i1 | i2); -} - -JSValue* BitOrNode::evaluate(ExecState* exec) -{ - return jsNumber(inlineEvaluateToInt32(exec)); -} - -double BitOrNode::evaluateToNumber(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -bool BitOrNode::evaluateToBoolean(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -int32_t BitOrNode::evaluateToInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -uint32_t BitOrNode::evaluateToUInt32(ExecState* exec) -{ - return inlineEvaluateToInt32(exec); -} - -// ------------------------------ Binary Logical Nodes ---------------------------- - -void LogicalAndNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.11 -JSValue* LogicalAndNode::evaluate(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - bool b1 = v1->toBoolean(exec); - KJS_CHECKEXCEPTIONVALUE - if (!b1) - return v1; - JSValue* v2 = m_expr2->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - return v2; -} - -bool LogicalAndNode::evaluateToBoolean(ExecState* exec) -{ - bool b = m_expr1->evaluateToBoolean(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return b && m_expr2->evaluateToBoolean(exec); -} - -void LogicalOrNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -JSValue* LogicalOrNode::evaluate(ExecState* exec) -{ - JSValue* v1 = m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - if (v1->toBoolean(exec)) - return v1; - return m_expr2->evaluate(exec); -} - -bool LogicalOrNode::evaluateToBoolean(ExecState* exec) -{ - bool b = m_expr1->evaluateToBoolean(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return b || m_expr2->evaluateToBoolean(exec); -} - -// ------------------------------ ConditionalNode ------------------------------ - -void ConditionalNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); - nodeStack.append(m_logical.get()); -} - -// ECMA 11.12 -JSValue* ConditionalNode::evaluate(ExecState* exec) -{ - bool b = m_logical->evaluateToBoolean(exec); - KJS_CHECKEXCEPTIONVALUE - return b ? m_expr1->evaluate(exec) : m_expr2->evaluate(exec); -} - -bool ConditionalNode::evaluateToBoolean(ExecState* exec) -{ - bool b = m_logical->evaluateToBoolean(exec); - KJS_CHECKEXCEPTIONBOOLEAN - return b ? m_expr1->evaluateToBoolean(exec) : m_expr2->evaluateToBoolean(exec); -} - -double ConditionalNode::evaluateToNumber(ExecState* exec) -{ - bool b = m_logical->evaluateToBoolean(exec); - KJS_CHECKEXCEPTIONNUMBER - return b ? m_expr1->evaluateToNumber(exec) : m_expr2->evaluateToNumber(exec); -} - -int32_t ConditionalNode::evaluateToInt32(ExecState* exec) -{ - bool b = m_logical->evaluateToBoolean(exec); - KJS_CHECKEXCEPTIONNUMBER - return b ? m_expr1->evaluateToInt32(exec) : m_expr2->evaluateToInt32(exec); -} - -uint32_t ConditionalNode::evaluateToUInt32(ExecState* exec) -{ - bool b = m_logical->evaluateToBoolean(exec); - KJS_CHECKEXCEPTIONNUMBER - return b ? m_expr1->evaluateToUInt32(exec) : m_expr2->evaluateToUInt32(exec); -} - -// ECMA 11.13 - -static ALWAYS_INLINE JSValue* valueForReadModifyAssignment(ExecState* exec, JSValue* current, ExpressionNode* right, Operator oper) KJS_FAST_CALL; -static ALWAYS_INLINE JSValue* valueForReadModifyAssignment(ExecState* exec, JSValue* current, ExpressionNode* right, Operator oper) -{ - JSValue* v; - int i1; - int i2; - unsigned int ui; - switch (oper) { - case OpMultEq: - v = jsNumber(current->toNumber(exec) * right->evaluateToNumber(exec)); - break; - case OpDivEq: - v = jsNumber(current->toNumber(exec) / right->evaluateToNumber(exec)); - break; - case OpPlusEq: - v = add(exec, current, right->evaluate(exec)); - break; - case OpMinusEq: - v = jsNumber(current->toNumber(exec) - right->evaluateToNumber(exec)); - break; - case OpLShift: - i1 = current->toInt32(exec); - i2 = right->evaluateToInt32(exec); - v = jsNumber(i1 << i2); - break; - case OpRShift: - i1 = current->toInt32(exec); - i2 = right->evaluateToInt32(exec); - v = jsNumber(i1 >> i2); - break; - case OpURShift: - ui = current->toUInt32(exec); - i2 = right->evaluateToInt32(exec); - v = jsNumber(ui >> i2); - break; - case OpAndEq: - i1 = current->toInt32(exec); - i2 = right->evaluateToInt32(exec); - v = jsNumber(i1 & i2); - break; - case OpXOrEq: - i1 = current->toInt32(exec); - i2 = right->evaluateToInt32(exec); - v = jsNumber(i1 ^ i2); - break; - case OpOrEq: - i1 = current->toInt32(exec); - i2 = right->evaluateToInt32(exec); - v = jsNumber(i1 | i2); - break; - case OpModEq: { - double d1 = current->toNumber(exec); - double d2 = right->evaluateToNumber(exec); - v = jsNumber(fmod(d1, d2)); - } - break; - default: - ASSERT_NOT_REACHED(); - v = jsUndefined(); - } - - return v; -} - -// ------------------------------ ReadModifyResolveNode ----------------------------------- - -void ReadModifyResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack& nodeStack) -{ - nodeStack.append(m_right.get()); - size_t index = symbolTable.get(m_ident.ustring().rep()); - if (index != missingSymbolMarker()) { - if (isConstant(localStorage, index)) - new (this) ReadModifyConstNode(index); - else - new (this) ReadModifyLocalVarNode(index); - } -} - -// ------------------------------ AssignResolveNode ----------------------------------- - -void AssignResolveNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack& nodeStack) -{ - nodeStack.append(m_right.get()); - size_t index = symbolTable.get(m_ident.ustring().rep()); - if (index != missingSymbolMarker()) { - if (isConstant(localStorage, index)) - new (this) AssignConstNode; - else - new (this) AssignLocalVarNode(index); - } -} - -// ------------------------------ ReadModifyLocalVarNode ----------------------------------- - -JSValue* ReadModifyLocalVarNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - - ASSERT(m_operator != OpEqual); - JSValue* v = valueForReadModifyAssignment(exec, exec->localStorage()[m_index].value, m_right.get(), m_operator); - - KJS_CHECKEXCEPTIONVALUE - - // We can't store a pointer into localStorage() and use it throughout the function - // body, because valueForReadModifyAssignment() might cause an ActivationImp tear-off, - // changing the value of localStorage(). - - exec->localStorage()[m_index].value = v; - return v; -} - -// ------------------------------ AssignLocalVarNode ----------------------------------- - -JSValue* AssignLocalVarNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - JSValue* v = m_right->evaluate(exec); - - KJS_CHECKEXCEPTIONVALUE - - exec->localStorage()[m_index].value = v; - - return v; -} - -// ------------------------------ ReadModifyConstNode ----------------------------------- - -JSValue* ReadModifyConstNode::evaluate(ExecState* exec) -{ - ASSERT(exec->variableObject() == exec->scopeChain().top()); - JSValue* left = exec->localStorage()[m_index].value; - ASSERT(m_operator != OpEqual); - JSValue* result = valueForReadModifyAssignment(exec, left, m_right.get(), m_operator); - KJS_CHECKEXCEPTIONVALUE - return result; -} - -// ------------------------------ AssignConstNode ----------------------------------- - -JSValue* AssignConstNode::evaluate(ExecState* exec) -{ - return m_right->evaluate(exec); -} - -JSValue* ReadModifyResolveNode::evaluate(ExecState* exec) -{ - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // We must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - JSObject* base; - do { - base = *iter; - if (base->getPropertySlot(exec, m_ident, slot)) { - // See the comment in PostIncResolveNode::evaluate(). - - base = *iter; - goto found; - } - - ++iter; - } while (iter != end); - - ASSERT(m_operator != OpEqual); - return throwUndefinedVariableError(exec, m_ident); - -found: - JSValue* v; - - ASSERT(m_operator != OpEqual); - JSValue* v1 = slot.getValue(exec, base, m_ident); - KJS_CHECKEXCEPTIONVALUE - v = valueForReadModifyAssignment(exec, v1, m_right.get(), m_operator); - - KJS_CHECKEXCEPTIONVALUE - - // Since valueForReadModifyAssignment() might cause an ActivationImp tear-off, - // we need to get the base from the ScopeChainIterator again. - - (*iter)->put(exec, m_ident, v); - return v; -} - -JSValue* AssignResolveNode::evaluate(ExecState* exec) -{ - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // we must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - JSObject* base; - do { - base = *iter; - if (base->getPropertySlot(exec, m_ident, slot)) { - // See the comment in PostIncResolveNode::evaluate(). - - base = *iter; - goto found; - } - - ++iter; - } while (iter != end); - -found: - JSValue* v = m_right->evaluate(exec); - - KJS_CHECKEXCEPTIONVALUE - - base->put(exec, m_ident, v); - return v; -} - -// ------------------------------ ReadModifyDotNode ----------------------------------- - -void AssignDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_right.get()); - nodeStack.append(m_base.get()); -} - -JSValue* AssignDotNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSObject* base = baseValue->toObject(exec); - - JSValue* v = m_right->evaluate(exec); - - KJS_CHECKEXCEPTIONVALUE - - base->put(exec, m_ident, v); - return v; -} - -void ReadModifyDotNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_right.get()); - nodeStack.append(m_base.get()); -} - -JSValue* ReadModifyDotNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSObject* base = baseValue->toObject(exec); - - JSValue* v; - - ASSERT(m_operator != OpEqual); - PropertySlot slot; - JSValue* v1 = base->getPropertySlot(exec, m_ident, slot) ? slot.getValue(exec, base, m_ident) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - v = valueForReadModifyAssignment(exec, v1, m_right.get(), m_operator); - - KJS_CHECKEXCEPTIONVALUE - - base->put(exec, m_ident, v); - return v; -} - -// ------------------------------ AssignErrorNode ----------------------------------- - -JSValue* AssignErrorNode::evaluate(ExecState* exec) -{ - throwError(exec, ReferenceError, "Left side of assignment is not a reference."); - handleException(exec); - return jsUndefined(); -} - -// ------------------------------ AssignBracketNode ----------------------------------- - -void AssignBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_right.get()); - nodeStack.append(m_subscript.get()); - nodeStack.append(m_base.get()); -} - -JSValue* AssignBracketNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* subscript = m_subscript->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSObject* base = baseValue->toObject(exec); - - uint32_t propertyIndex; - if (subscript->getUInt32(propertyIndex)) { - JSValue* v = m_right->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - base->put(exec, propertyIndex, v); - return v; - } - - Identifier propertyName(subscript->toString(exec)); - JSValue* v = m_right->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - base->put(exec, propertyName, v); - return v; -} -void ReadModifyBracketNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_right.get()); - nodeStack.append(m_subscript.get()); - nodeStack.append(m_base.get()); -} - -JSValue* ReadModifyBracketNode::evaluate(ExecState* exec) -{ - JSValue* baseValue = m_base->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - JSValue* subscript = m_subscript->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - JSObject* base = baseValue->toObject(exec); - - uint32_t propertyIndex; - if (subscript->getUInt32(propertyIndex)) { - JSValue* v; - ASSERT(m_operator != OpEqual); - PropertySlot slot; - JSValue* v1 = base->getPropertySlot(exec, propertyIndex, slot) ? slot.getValue(exec, base, propertyIndex) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - v = valueForReadModifyAssignment(exec, v1, m_right.get(), m_operator); - - KJS_CHECKEXCEPTIONVALUE - - base->put(exec, propertyIndex, v); - return v; - } - - Identifier propertyName(subscript->toString(exec)); - JSValue* v; - - ASSERT(m_operator != OpEqual); - PropertySlot slot; - JSValue* v1 = base->getPropertySlot(exec, propertyName, slot) ? slot.getValue(exec, base, propertyName) : jsUndefined(); - KJS_CHECKEXCEPTIONVALUE - v = valueForReadModifyAssignment(exec, v1, m_right.get(), m_operator); - - KJS_CHECKEXCEPTIONVALUE - - base->put(exec, propertyName, v); - return v; -} - -// ------------------------------ CommaNode ------------------------------------ - -void CommaNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 11.14 -JSValue* CommaNode::evaluate(ExecState* exec) -{ - m_expr1->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - return m_expr2->evaluate(exec); -} - -// ------------------------------ ConstDeclNode ---------------------------------- - -ConstDeclNode::ConstDeclNode(const Identifier& ident, ExpressionNode* init) - : m_ident(ident) - , m_init(init) -{ -} - -void ConstDeclNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_next) - nodeStack.append(m_next.get()); - if (m_init) - nodeStack.append(m_init.get()); -} - -void ConstDeclNode::handleSlowCase(ExecState* exec, const ScopeChain& chain, JSValue* val) -{ - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // We must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - JSObject* base; - - do { - base = *iter; - if (base->getPropertySlot(exec, m_ident, slot)) - break; - - ++iter; - } while (iter != end); - - unsigned flags = 0; - base->getPropertyAttributes(m_ident, flags); - flags |= ReadOnly; - - base->put(exec, m_ident, val, flags); -} - -// ECMA 12.2 -inline void ConstDeclNode::evaluateSingle(ExecState* exec) -{ - ASSERT(exec->variableObject()->hasOwnProperty(exec, m_ident) || exec->codeType() == EvalCode); // Guaranteed by processDeclarations. - const ScopeChain& chain = exec->scopeChain(); - JSObject* variableObject = exec->variableObject(); - - ASSERT(!chain.isEmpty()); - - bool inGlobalScope = ++chain.begin() == chain.end(); - - if (m_init) { - if (inGlobalScope) { - JSValue* val = m_init->evaluate(exec); - int flags = Internal; - if (exec->codeType() != EvalCode) - flags |= DontDelete; - flags |= ReadOnly; - variableObject->put(exec, m_ident, val, flags); - } else { - JSValue* val = m_init->evaluate(exec); - KJS_CHECKEXCEPTIONVOID - - // if the variable object is the top of the scope chain, then that must - // be where this variable is declared, processVarDecls would have put - // it there. Don't search the scope chain, to optimize this very common case. - if (chain.top() != variableObject) - return handleSlowCase(exec, chain, val); - - unsigned flags = 0; - variableObject->getPropertyAttributes(m_ident, flags); - flags |= ReadOnly; - - variableObject->put(exec, m_ident, val, flags); - } - } -} - -JSValue* ConstDeclNode::evaluate(ExecState* exec) -{ - evaluateSingle(exec); - - if (ConstDeclNode* n = m_next.get()) { - do { - n->evaluateSingle(exec); - KJS_CHECKEXCEPTIONVALUE - n = n->m_next.get(); - } while (n); - } - return jsUndefined(); -} - -// ------------------------------ ConstStatementNode ----------------------------- - -void ConstStatementNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - ASSERT(m_next); - nodeStack.append(m_next.get()); -} - -// ECMA 12.2 -JSValue* ConstStatementNode::execute(ExecState* exec) -{ - m_next->evaluate(exec); - KJS_CHECKEXCEPTION - - return exec->setNormalCompletion(); -} - -// ------------------------------ Helper functions for handling Vectors of StatementNode ------------------------------- - -static inline void statementListPushFIFO(StatementVector& statements, DeclarationStacks::NodeStack& stack) -{ - StatementVector::iterator it = statements.end(); - StatementVector::iterator begin = statements.begin(); - while (it != begin) { - --it; - stack.append((*it).get()); - } -} - -static inline Node* statementListInitializeVariableAccessStack(StatementVector& statements, DeclarationStacks::NodeStack& stack) -{ - if (statements.isEmpty()) - return 0; - - StatementVector::iterator it = statements.end(); - StatementVector::iterator begin = statements.begin(); - StatementVector::iterator beginPlusOne = begin + 1; - - while (it != beginPlusOne) { - --it; - stack.append((*it).get()); - } - - return (*begin).get(); -} - -static inline JSValue* statementListExecute(StatementVector& statements, ExecState* exec) -{ - JSValue* value = 0; - size_t size = statements.size(); - for (size_t i = 0; i != size; ++i) { - JSValue* statementValue = statements[i]->execute(exec); - if (statementValue) - value = statementValue; - if (exec->completionType() != Normal) - return value; - } - return exec->setNormalCompletion(value); -} - -// ------------------------------ BlockNode ------------------------------------ - -BlockNode::BlockNode() -{ -} - -BlockNode::BlockNode(SourceElements* children) -{ - if (children) - children->releaseContentsIntoVector(m_children); -} - -void BlockNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - statementListPushFIFO(m_children, nodeStack); -} - -// ECMA 12.1 -JSValue* BlockNode::execute(ExecState* exec) -{ - return statementListExecute(m_children, exec); -} - -// ------------------------------ EmptyStatementNode --------------------------- - -// ECMA 12.3 -JSValue* EmptyStatementNode::execute(ExecState* exec) -{ - return exec->setNormalCompletion(); -} - -// ------------------------------ ExprStatementNode ---------------------------- - -void ExprStatementNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - ASSERT(m_expr); - nodeStack.append(m_expr.get()); -} - -// ECMA 12.4 -JSValue* ExprStatementNode::execute(ExecState* exec) -{ - JSValue* value = m_expr->evaluate(exec); - KJS_CHECKEXCEPTION - - return exec->setNormalCompletion(value); -} - -// ------------------------------ VarStatementNode ---------------------------- - -void VarStatementNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - ASSERT(m_expr); - nodeStack.append(m_expr.get()); -} - -JSValue* VarStatementNode::execute(ExecState* exec) -{ - m_expr->evaluate(exec); - KJS_CHECKEXCEPTION - - return exec->setNormalCompletion(); -} - -// ------------------------------ IfNode --------------------------------------- - -void IfNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_ifBlock.get()); - nodeStack.append(m_condition.get()); -} - -// ECMA 12.5 -JSValue* IfNode::execute(ExecState* exec) -{ - bool b = m_condition->evaluateToBoolean(exec); - KJS_CHECKEXCEPTION - - if (b) - return m_ifBlock->execute(exec); - return exec->setNormalCompletion(); -} - -void IfElseNode::optimizeVariableAccess(const SymbolTable& symbolTable, const LocalStorage& localStorage, NodeStack& nodeStack) -{ - nodeStack.append(m_elseBlock.get()); - IfNode::optimizeVariableAccess(symbolTable, localStorage, nodeStack); -} - -// ECMA 12.5 -JSValue* IfElseNode::execute(ExecState* exec) -{ - bool b = m_condition->evaluateToBoolean(exec); - KJS_CHECKEXCEPTION - - if (b) - return m_ifBlock->execute(exec); - return m_elseBlock->execute(exec); -} - -// ------------------------------ DoWhileNode ---------------------------------- - -void DoWhileNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_statement.get()); - nodeStack.append(m_expr.get()); -} - -// ECMA 12.6.1 -JSValue* DoWhileNode::execute(ExecState* exec) -{ - JSValue* value = 0; - - while (1) { - exec->pushIteration(); - JSValue* statementValue = m_statement->execute(exec); - exec->popIteration(); - - if (exec->dynamicGlobalObject()->timedOut()) - return setInterruptedCompletion(exec); - - if (statementValue) - value = statementValue; - - if (exec->completionType() != Normal) { - if (exec->completionType() == Continue && m_labelStack.contains(exec->breakOrContinueTarget())) - goto continueDoWhileLoop; - if (exec->completionType() == Break && m_labelStack.contains(exec->breakOrContinueTarget())) - break; - return statementValue; - } - - continueDoWhileLoop: - bool b = m_expr->evaluateToBoolean(exec); - KJS_CHECKEXCEPTION - if (!b) - break; - } - - return exec->setNormalCompletion(value); -} - -// ------------------------------ WhileNode ------------------------------------ - -void WhileNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_statement.get()); - nodeStack.append(m_expr.get()); -} - -// ECMA 12.6.2 -JSValue* WhileNode::execute(ExecState* exec) -{ - JSValue* value = 0; - - while (1) { - bool b = m_expr->evaluateToBoolean(exec); - KJS_CHECKEXCEPTION - if (!b) - break; - - exec->pushIteration(); - JSValue* statementValue = m_statement->execute(exec); - exec->popIteration(); - - if (exec->dynamicGlobalObject()->timedOut()) - return setInterruptedCompletion(exec); - - if (statementValue) - value = statementValue; - - if (exec->completionType() != Normal) { - if (exec->completionType() == Continue && m_labelStack.contains(exec->breakOrContinueTarget())) - continue; - if (exec->completionType() == Break && m_labelStack.contains(exec->breakOrContinueTarget())) - break; - return statementValue; - } - } - - return exec->setNormalCompletion(value); -} - -// ------------------------------ ForNode -------------------------------------- - -void ForNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_statement.get()); - nodeStack.append(m_expr3.get()); - nodeStack.append(m_expr2.get()); - nodeStack.append(m_expr1.get()); -} - -// ECMA 12.6.3 -JSValue* ForNode::execute(ExecState* exec) -{ - JSValue* value = 0; - - m_expr1->evaluate(exec); - KJS_CHECKEXCEPTION - - while (1) { - bool b = m_expr2->evaluateToBoolean(exec); - KJS_CHECKEXCEPTION - if (!b) - break; - - exec->pushIteration(); - JSValue* statementValue = m_statement->execute(exec); - exec->popIteration(); - if (statementValue) - value = statementValue; - - if (exec->dynamicGlobalObject()->timedOut()) - return setInterruptedCompletion(exec); - - if (exec->completionType() != Normal) { - if (exec->completionType() == Continue && m_labelStack.contains(exec->breakOrContinueTarget())) - goto continueForLoop; - if (exec->completionType() == Break && m_labelStack.contains(exec->breakOrContinueTarget())) - break; - return statementValue; - } - - continueForLoop: - m_expr3->evaluate(exec); - KJS_CHECKEXCEPTION - } - - return exec->setNormalCompletion(value); -} - -// ------------------------------ ForInNode ------------------------------------ - -ForInNode::ForInNode(ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) - : m_init(0L) - , m_lexpr(l) - , m_expr(expr) - , m_statement(statement) - , m_identIsVarDecl(false) -{ -} - -ForInNode::ForInNode(const Identifier& ident, ExpressionNode* in, ExpressionNode* expr, StatementNode* statement) - : m_ident(ident) - , m_lexpr(new ResolveNode(ident)) - , m_expr(expr) - , m_statement(statement) - , m_identIsVarDecl(true) -{ - if (in) - m_init = new AssignResolveNode(ident, in); - // for( var foo = bar in baz ) -} - -void ForInNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_statement.get()); - nodeStack.append(m_expr.get()); - nodeStack.append(m_lexpr.get()); - if (m_init) - nodeStack.append(m_init.get()); -} - -// ECMA 12.6.4 -JSValue* ForInNode::execute(ExecState* exec) -{ - JSValue* value = 0; - - if (m_init) { - m_init->evaluate(exec); - KJS_CHECKEXCEPTION - } - - JSValue* e = m_expr->evaluate(exec); - KJS_CHECKEXCEPTION - - // For Null and Undefined, we want to make sure not to go through - // the loop at all, because toObject will throw an exception. - if (e->isUndefinedOrNull()) - return exec->setNormalCompletion(); - - JSObject* v = e->toObject(exec); - PropertyNameArray propertyNames; - v->getPropertyNames(exec, propertyNames); - - PropertyNameArray::const_iterator end = propertyNames.end(); - for (PropertyNameArray::const_iterator it = propertyNames.begin(); it != end; ++it) { - const Identifier& name = *it; - if (!v->hasProperty(exec, name)) - continue; - - JSValue* str = jsOwnedString(name.ustring()); - - if (m_lexpr->isResolveNode()) { - const Identifier& ident = static_cast(m_lexpr.get())->identifier(); - - const ScopeChain& chain = exec->scopeChain(); - ScopeChainIterator iter = chain.begin(); - ScopeChainIterator end = chain.end(); - - // we must always have something in the scope chain - ASSERT(iter != end); - - PropertySlot slot; - JSObject* o; - do { - o = *iter; - if (o->getPropertySlot(exec, ident, slot)) { - o->put(exec, ident, str); - break; - } - ++iter; - } while (iter != end); - - if (iter == end) - o->put(exec, ident, str); - } else if (m_lexpr->isDotAccessorNode()) { - const Identifier& ident = static_cast(m_lexpr.get())->identifier(); - JSValue* v = static_cast(m_lexpr.get())->base()->evaluate(exec); - KJS_CHECKEXCEPTION - JSObject* o = v->toObject(exec); - - o->put(exec, ident, str); - } else { - ASSERT(m_lexpr->isBracketAccessorNode()); - JSValue* v = static_cast(m_lexpr.get())->base()->evaluate(exec); - KJS_CHECKEXCEPTION - JSValue* v2 = static_cast(m_lexpr.get())->subscript()->evaluate(exec); - KJS_CHECKEXCEPTION - JSObject* o = v->toObject(exec); - - uint32_t i; - if (v2->getUInt32(i)) - o->put(exec, i, str); - o->put(exec, Identifier(v2->toString(exec)), str); - } - - KJS_CHECKEXCEPTION - - exec->pushIteration(); - JSValue* statementValue = m_statement->execute(exec); - exec->popIteration(); - if (statementValue) - value = statementValue; - - if (exec->completionType() != Normal) { - if (exec->completionType() == Continue && m_labelStack.contains(exec->breakOrContinueTarget())) - continue; - if (exec->completionType() == Break && m_labelStack.contains(exec->breakOrContinueTarget())) - break; - return statementValue; - } - } - - return exec->setNormalCompletion(value); -} - -// ------------------------------ ContinueNode --------------------------------- - -// ECMA 12.7 -JSValue* ContinueNode::execute(ExecState* exec) -{ - if (m_ident.isEmpty() && !exec->inIteration()) - return setErrorCompletion(exec, SyntaxError, "Invalid continue statement."); - if (!m_ident.isEmpty() && !exec->seenLabels().contains(m_ident)) - return setErrorCompletion(exec, SyntaxError, "Label %s not found.", m_ident); - return exec->setContinueCompletion(&m_ident); -} - -// ------------------------------ BreakNode ------------------------------------ - -// ECMA 12.8 -JSValue* BreakNode::execute(ExecState* exec) -{ - if (m_ident.isEmpty() && !exec->inIteration() && !exec->inSwitch()) - return setErrorCompletion(exec, SyntaxError, "Invalid break statement."); - if (!m_ident.isEmpty() && !exec->seenLabels().contains(m_ident)) - return setErrorCompletion(exec, SyntaxError, "Label %s not found."); - return exec->setBreakCompletion(&m_ident); -} - -// ------------------------------ ReturnNode ----------------------------------- - -void ReturnNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_value) - nodeStack.append(m_value.get()); -} - -// ECMA 12.9 -JSValue* ReturnNode::execute(ExecState* exec) -{ - CodeType codeType = exec->codeType(); - if (codeType != FunctionCode) - return setErrorCompletion(exec, SyntaxError, "Invalid return statement."); - - if (!m_value) - return exec->setReturnValueCompletion(jsUndefined()); - - JSValue* v = m_value->evaluate(exec); - KJS_CHECKEXCEPTION - - return exec->setReturnValueCompletion(v); -} - -// ------------------------------ WithNode ------------------------------------- - -void WithNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - // Can't optimize within statement because "with" introduces a dynamic scope. - nodeStack.append(m_expr.get()); -} - -// ECMA 12.10 -JSValue* WithNode::execute(ExecState* exec) -{ - JSValue* v = m_expr->evaluate(exec); - KJS_CHECKEXCEPTION - JSObject* o = v->toObject(exec); - KJS_CHECKEXCEPTION - exec->dynamicGlobalObject()->tearOffActivation(exec); - exec->pushScope(o); - JSValue* value = m_statement->execute(exec); - exec->popScope(); - - return value; -} - -// ------------------------------ CaseClauseNode ------------------------------- - -void CaseClauseNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_expr) - nodeStack.append(m_expr.get()); - statementListPushFIFO(m_children, nodeStack); -} - -// ECMA 12.11 -JSValue* CaseClauseNode::evaluate(ExecState* exec) -{ - JSValue* v = m_expr->evaluate(exec); - KJS_CHECKEXCEPTIONVALUE - - return v; -} - -// ECMA 12.11 -JSValue* CaseClauseNode::executeStatements(ExecState* exec) -{ - return statementListExecute(m_children, exec); -} - -// ------------------------------ ClauseListNode ------------------------------- - -void ClauseListNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_next) - nodeStack.append(m_next.get()); - nodeStack.append(m_clause.get()); -} - -// ------------------------------ CaseBlockNode -------------------------------- - -CaseBlockNode::CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2) - : m_list1(list1) - , m_defaultClause(defaultClause) - , m_list2(list2) -{ -} - -void CaseBlockNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - if (m_list2) - nodeStack.append(m_list2.get()); - if (m_defaultClause) - nodeStack.append(m_defaultClause.get()); - if (m_list1) - nodeStack.append(m_list1.get()); -} - -// ECMA 12.11 -JSValue* CaseBlockNode::executeBlock(ExecState* exec, JSValue* input) -{ - ClauseListNode* a = m_list1.get(); - while (a) { - CaseClauseNode* clause = a->getClause(); - a = a->getNext(); - JSValue* v = clause->evaluate(exec); - KJS_CHECKEXCEPTION - if (strictEqual(exec, input, v)) { - JSValue* res = clause->executeStatements(exec); - if (exec->completionType() != Normal) - return res; - for (; a; a = a->getNext()) { - JSValue* res = a->getClause()->executeStatements(exec); - if (exec->completionType() != Normal) - return res; - } - break; - } - } - - ClauseListNode* b = m_list2.get(); - while (b) { - CaseClauseNode* clause = b->getClause(); - b = b->getNext(); - JSValue* v = clause->evaluate(exec); - KJS_CHECKEXCEPTION - if (strictEqual(exec, input, v)) { - JSValue* res = clause->executeStatements(exec); - if (exec->completionType() != Normal) - return res; - goto step18; - } - } - - // default clause - if (m_defaultClause) { - JSValue* res = m_defaultClause->executeStatements(exec); - if (exec->completionType() != Normal) - return res; - } - b = m_list2.get(); -step18: - while (b) { - CaseClauseNode* clause = b->getClause(); - JSValue* res = clause->executeStatements(exec); - if (exec->completionType() != Normal) - return res; - b = b->getNext(); - } - - // bail out on error - KJS_CHECKEXCEPTION - - return exec->setNormalCompletion(); -} - -// ------------------------------ SwitchNode ----------------------------------- - -void SwitchNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_block.get()); - nodeStack.append(m_expr.get()); -} - -// ECMA 12.11 -JSValue* SwitchNode::execute(ExecState* exec) -{ - JSValue* v = m_expr->evaluate(exec); - KJS_CHECKEXCEPTION - - exec->pushSwitch(); - JSValue* result = m_block->executeBlock(exec, v); - exec->popSwitch(); - - if (exec->completionType() == Break && m_labelStack.contains(exec->breakOrContinueTarget())) - exec->setCompletionType(Normal); - return result; -} - -// ------------------------------ LabelNode ------------------------------------ - -void LabelNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_statement.get()); -} - -// ECMA 12.12 -JSValue* LabelNode::execute(ExecState* exec) -{ - if (!exec->seenLabels().push(m_label)) - return setErrorCompletion(exec, SyntaxError, "Duplicated label %s found.", m_label); - JSValue* result = m_statement->execute(exec); - exec->seenLabels().pop(); - - if (exec->completionType() == Break && exec->breakOrContinueTarget() == m_label) - exec->setCompletionType(Normal); - return result; -} - -// ------------------------------ ThrowNode ------------------------------------ - -void ThrowNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - nodeStack.append(m_expr.get()); -} - -// ECMA 12.13 -JSValue* ThrowNode::execute(ExecState* exec) -{ - JSValue* v = m_expr->evaluate(exec); - KJS_CHECKEXCEPTION - - handleException(exec, v); - return exec->setThrowCompletion(v); -} - -// ------------------------------ TryNode -------------------------------------- - -void TryNode::optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack& nodeStack) -{ - // Can't optimize within catchBlock because "catch" introduces a dynamic scope. - if (m_finallyBlock) - nodeStack.append(m_finallyBlock.get()); - nodeStack.append(m_tryBlock.get()); -} - -// ECMA 12.14 -JSValue* TryNode::execute(ExecState* exec) -{ - JSValue* result = m_tryBlock->execute(exec); - - if (m_catchBlock && exec->completionType() == Throw) { - JSObject* obj = new JSObject; - obj->put(exec, m_exceptionIdent, result, DontDelete); - exec->dynamicGlobalObject()->tearOffActivation(exec); - exec->pushScope(obj); - result = m_catchBlock->execute(exec); - exec->popScope(); - } - - if (m_finallyBlock) { - ComplType savedCompletionType = exec->completionType(); - JSValue* finallyResult = m_finallyBlock->execute(exec); - if (exec->completionType() != Normal) - result = finallyResult; - else - exec->setCompletionType(savedCompletionType); - } - - return result; -} - -// ------------------------------ FunctionBodyNode ----------------------------- - -ScopeNode::ScopeNode() - : BlockNode() -{ -} - -ScopeNode::ScopeNode(const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack) - : BlockNode(children) - , m_source(source) -{ - if (varStack) - m_varStack = *varStack; - if (funcStack) - m_functionStack = *funcStack; -} - -void ScopeNode::setData(SourceElements* children, VarStack* varStack, FunctionStack* funcStack) -{ - if (children) - children->releaseContentsIntoVector(m_children); - if (varStack) - m_varStack = *varStack; - if (funcStack) - m_functionStack = *funcStack; -} - -// ------------------------------ ProgramNode ----------------------------- - -ProgramNode::ProgramNode(const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack) - : ScopeNode(source, children, varStack, funcStack) -{ -} - -ProgramNode* ProgramNode::create(const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack) -{ - return new ProgramNode(source, children, varStack, funcStack); -} - -// ------------------------------ EvalNode ----------------------------- - -EvalNode::EvalNode(const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack) - : ScopeNode(source, children, varStack, funcStack) -{ -} - -EvalNode* EvalNode::create(const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack) -{ - return new EvalNode(source, children, varStack, funcStack); -} - -// ------------------------------ FunctionBodyNode ----------------------------- - -FunctionBodyNode::FunctionBodyNode() - : ScopeNode() - , m_initialized(false) -{ -} - -FunctionBodyNode::FunctionBodyNode(const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack) - : ScopeNode(source, children, varStack, funcStack) - , m_initialized(false) -{ -} - -FunctionBodyNode* FunctionBodyNode::create() -{ - return new FunctionBodyNode(); -} - -FunctionBodyNode* FunctionBodyNode::create(SourceElements* children, VarStack* varStack, FunctionStack* funcStack) -{ - // debugger code removed - return new FunctionBodyNode(SourceCode(), children, varStack, funcStack); -} - -FunctionBodyNode* FunctionBodyNode::create(const SourceCode& source, SourceElements* children, VarStack* varStack, FunctionStack* funcStack) -{ - // debugger code removed - return new FunctionBodyNode(source, children, varStack, funcStack); -} - -void FunctionBodyNode::initializeSymbolTable(ExecState* exec) -{ - SymbolTable& symbolTable = exec->variableObject()->symbolTable(); - ASSERT(symbolTable.isEmpty()); - - size_t localStorageIndex = 0; - - // Order must match the order in processDeclarations. - - for (size_t i = 0, size = m_parameters.size(); i < size; ++i, ++localStorageIndex) { - UString::Rep* rep = m_parameters[i].ustring().rep(); - symbolTable.set(rep, localStorageIndex); - } - - for (size_t i = 0, size = m_functionStack.size(); i < size; ++i, ++localStorageIndex) { - UString::Rep* rep = m_functionStack[i]->m_ident.ustring().rep(); - symbolTable.set(rep, localStorageIndex); - } - - for (size_t i = 0, size = m_varStack.size(); i < size; ++i, ++localStorageIndex) { - Identifier& ident = m_varStack[i].first; - if (ident == exec->propertyNames().arguments) - continue; - symbolTable.add(ident.ustring().rep(), localStorageIndex); - } -} - -void ProgramNode::initializeSymbolTable(ExecState* exec) -{ - // If a previous script defined a symbol with the same name as one of our - // symbols, to avoid breaking previously optimized nodes, we need to reuse - // the symbol's existing storage index. So, we can't be as efficient as - // FunctionBodyNode::initializeSymbolTable, which knows that no bindings - // have yet been made. - - JSVariableObject* variableObject = exec->variableObject(); - SymbolTable& symbolTable = variableObject->symbolTable(); - - size_t localStorageIndex = symbolTable.size(); - size_t size; - - // Order must match the order in processDeclarations. - - size = m_functionStack.size(); - m_functionIndexes.resize(size); - for (size_t i = 0; i < size; ++i) { - UString::Rep* rep = m_functionStack[i]->m_ident.ustring().rep(); - pair result = symbolTable.add(rep, localStorageIndex); - m_functionIndexes[i] = result.first->second; - if (result.second) - ++localStorageIndex; - } - - size = m_varStack.size(); - m_varIndexes.resize(size); - for (size_t i = 0; i < size; ++i) { - const Identifier& ident = m_varStack[i].first; - if (variableObject->hasProperty(exec, ident)) { - m_varIndexes[i] = missingSymbolMarker(); // Signal not to initialize this declaration. - continue; - } - - UString::Rep* rep = ident.ustring().rep(); - pair result = symbolTable.add(rep, localStorageIndex); - if (!result.second) { - m_varIndexes[i] = missingSymbolMarker(); // Signal not to initialize this declaration. - continue; - } - - m_varIndexes[i] = result.first->second; - ++localStorageIndex; - } -} - -void ScopeNode::optimizeVariableAccess(ExecState* exec) -{ - NodeStack nodeStack; - Node* node = statementListInitializeVariableAccessStack(m_children, nodeStack); - if (!node) - return; - - const SymbolTable& symbolTable = exec->variableObject()->symbolTable(); - const LocalStorage& localStorage = exec->variableObject()->localStorage(); - while (true) { - node->optimizeVariableAccess(symbolTable, localStorage, nodeStack); - - size_t size = nodeStack.size(); - if (!size) - break; - --size; - node = nodeStack[size]; - nodeStack.shrink(size); - } -} - -void FunctionBodyNode::processDeclarations(ExecState* exec) -{ - if (!m_initialized) - initializeSymbolTable(exec); - - if (!m_functionStack.isEmpty()) - exec->dynamicGlobalObject()->tearOffActivation(exec); - - LocalStorage& localStorage = exec->variableObject()->localStorage(); - - // We can't just resize localStorage here because that would temporarily - // leave uninitialized entries, which would crash GC during the mark phase. - size_t totalSize = m_varStack.size() + m_parameters.size() + m_functionStack.size(); - if (totalSize > localStorage.capacity()) // Doing this check inline avoids function call overhead. - localStorage.reserveCapacity(totalSize); - - int minAttributes = Internal | DontDelete; - - // In order for our localStorage indexes to be correct, we must match the - // order of addition in initializeSymbolTable(). - - const List& args = *exec->arguments(); - for (size_t i = 0, size = m_parameters.size(); i < size; ++i) - localStorage.uncheckedAppend(LocalStorageEntry(args[i], DontDelete)); - - for (size_t i = 0, size = m_functionStack.size(); i < size; ++i) { - FuncDeclNode* node = m_functionStack[i]; - localStorage.uncheckedAppend(LocalStorageEntry(node->makeFunction(exec), minAttributes)); - } - - for (size_t i = 0, size = m_varStack.size(); i < size; ++i) { - int attributes = minAttributes; - if (m_varStack[i].second & DeclarationStacks::IsConstant) - attributes |= ReadOnly; - localStorage.uncheckedAppend(LocalStorageEntry(jsUndefined(), attributes)); - } - - if (!m_initialized) { - optimizeVariableAccess(exec); - m_initialized = true; - } -} - -static void gccIsCrazy() KJS_FAST_CALL; -static void gccIsCrazy() -{ -} - -void ProgramNode::processDeclarations(ExecState* exec) -{ - // If you remove this call, some SunSpider tests, including - // bitops-nsieve-bits.js, will regress substantially on Mac, due to a ~40% - // increase in L2 cache misses. FIXME: WTF? - gccIsCrazy(); - - initializeSymbolTable(exec); - - LocalStorage& localStorage = exec->variableObject()->localStorage(); - - // We can't just resize localStorage here because that would temporarily - // leave uninitialized entries, which would crash GC during the mark phase. - localStorage.reserveCapacity(localStorage.size() + m_varStack.size() + m_functionStack.size()); - - int minAttributes = Internal | DontDelete; - - // In order for our localStorage indexes to be correct, we must match the - // order of addition in initializeSymbolTable(). - - for (size_t i = 0, size = m_functionStack.size(); i < size; ++i) { - FuncDeclNode* node = m_functionStack[i]; - LocalStorageEntry entry = LocalStorageEntry(node->makeFunction(exec), minAttributes); - size_t index = m_functionIndexes[i]; - - if (index == localStorage.size()) - localStorage.uncheckedAppend(entry); - else { - ASSERT(index < localStorage.size()); - localStorage[index] = entry; - } - } - - for (size_t i = 0, size = m_varStack.size(); i < size; ++i) { - size_t index = m_varIndexes[i]; - if (index == missingSymbolMarker()) - continue; - - int attributes = minAttributes; - if (m_varStack[i].second & DeclarationStacks::IsConstant) - attributes |= ReadOnly; - LocalStorageEntry entry = LocalStorageEntry(jsUndefined(), attributes); - - ASSERT(index == localStorage.size()); - localStorage.uncheckedAppend(entry); - } - - optimizeVariableAccess(exec); -} - -void EvalNode::processDeclarations(ExecState* exec) -{ - // We could optimize access to pre-existing symbols here, but SunSpider - // reports that to be a net loss. - - size_t i; - size_t size; - - JSVariableObject* variableObject = exec->variableObject(); - - int minAttributes = Internal; - - for (i = 0, size = m_varStack.size(); i < size; ++i) { - Identifier& ident = m_varStack[i].first; - if (variableObject->hasProperty(exec, ident)) - continue; - int attributes = minAttributes; - if (m_varStack[i].second & DeclarationStacks::IsConstant) - attributes |= ReadOnly; - variableObject->put(exec, ident, jsUndefined(), attributes); - } - - for (i = 0, size = m_functionStack.size(); i < size; ++i) { - FuncDeclNode* node = m_functionStack[i]; - variableObject->put(exec, node->m_ident, node->makeFunction(exec), minAttributes); - } -} - -UString FunctionBodyNode::paramString() const -{ - UString s(""); - size_t count = m_parameters.size(); - for (size_t pos = 0; pos < count; ++pos) { - if (!s.isEmpty()) - s += ", "; - s += m_parameters[pos].ustring(); - } - - return s; -} - -JSValue* ProgramNode::execute(ExecState* exec) -{ - processDeclarations(exec); - return ScopeNode::execute(exec); -} - -JSValue* EvalNode::execute(ExecState* exec) -{ - processDeclarations(exec); - return ScopeNode::execute(exec); -} - -JSValue* FunctionBodyNode::execute(ExecState* exec) -{ - if (m_children.isEmpty()) - parser().reparse(this); - processDeclarations(exec); - return ScopeNode::execute(exec); -} - -// ------------------------------ FunctionBodyNodeWithDebuggerHooks --------------------------------- - -FunctionBodyNodeWithDebuggerHooks::FunctionBodyNodeWithDebuggerHooks(SourceElements* children, DeclarationStacks::VarStack* varStack, DeclarationStacks::FunctionStack* funcStack) - : FunctionBodyNode(SourceCode(), children, varStack, funcStack) -{ -} - -JSValue* FunctionBodyNodeWithDebuggerHooks::execute(ExecState* exec) -{ - if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) { - if (!dbg->callEvent(exec, sourceID(), lineNo(), exec->function(), *exec->arguments())) { - dbg->imp()->abort(); - return exec->setInterruptedCompletion(); - } - } - - JSValue* result = FunctionBodyNode::execute(exec); - - if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) { - if (exec->completionType() == Throw) - exec->setException(result); - if (!dbg->returnEvent(exec, sourceID(), lineNo(), exec->function())) { - dbg->imp()->abort(); - return exec->setInterruptedCompletion(); - } - } - - return result; -} - -// ------------------------------ FuncDeclNode --------------------------------- - -void FuncDeclNode::addParams() -{ - for (ParameterNode* p = m_parameter.get(); p; p = p->nextParam()) - m_body->parameters().append(p->ident()); -} - -FunctionImp* FuncDeclNode::makeFunction(ExecState* exec) -{ - FunctionImp* func = new FunctionImp(exec, m_ident, m_body.get(), exec->scopeChain()); - - JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList()); - proto->putDirect(exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum); - func->putDirect(exec->propertyNames().prototype, proto, Internal | DontDelete); - func->putDirect(exec->propertyNames().length, jsNumber(m_body->parameters().size()), ReadOnly | DontDelete | DontEnum); - return func; -} - -JSValue* FuncDeclNode::execute(ExecState* exec) -{ - return exec->setNormalCompletion(); -} - -// ------------------------------ FuncExprNode --------------------------------- - -// ECMA 13 -void FuncExprNode::addParams() -{ - for (ParameterNode* p = m_parameter.get(); p; p = p->nextParam()) - m_body->parameters().append(p->ident()); -} - -JSValue* FuncExprNode::evaluate(ExecState* exec) -{ - exec->dynamicGlobalObject()->tearOffActivation(exec); - - bool named = !m_ident.isNull(); - JSObject* functionScopeObject = 0; - - if (named) { - // named FunctionExpressions can recursively call themselves, - // but they won't register with the current scope chain and should - // be contained as single property in an anonymous object. - functionScopeObject = new JSObject; - exec->pushScope(functionScopeObject); - } - - FunctionImp* func = new FunctionImp(exec, m_ident, m_body.get(), exec->scopeChain()); - JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList()); - proto->putDirect(exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum); - func->putDirect(exec->propertyNames().prototype, proto, Internal | DontDelete); - - if (named) { - functionScopeObject->putDirect(m_ident, func, Internal | ReadOnly | (exec->codeType() == EvalCode ? 0 : DontDelete)); - exec->popScope(); - } - - return func; -} - -} // namespace KJS diff --git a/kjs/nodes.h b/kjs/nodes.h deleted file mode 100644 index 20a0a2c..0000000 --- a/kjs/nodes.h +++ /dev/null @@ -1,2919 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) - * Copyright (C) 2007 Maks Orlovich - * Copyright (C) 2007 Eric Seidel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef NODES_H_ -#define NODES_H_ - -#include "internal.h" -#include "regexp.h" -#include "SourceCode.h" -#include "SymbolTable.h" -#include -#include -#include -#include - -#if PLATFORM(X86) && COMPILER(GCC) -#define KJS_FAST_CALL __attribute__((regparm(3))) -#else -#define KJS_FAST_CALL -#endif - -namespace KJS { - - class ConstDeclNode; - class FuncDeclNode; - class Node; - class PropertyListNode; - class SourceStream; - - enum Operator { - OpEqual, - OpPlusEq, - OpMinusEq, - OpMultEq, - OpDivEq, - OpPlusPlus, - OpMinusMinus, - OpAndEq, - OpXOrEq, - OpOrEq, - OpModEq, - OpLShift, - OpRShift, - OpURShift, - }; - - enum Precedence { - PrecPrimary, - PrecMember, - PrecCall, - PrecLeftHandSide, - PrecPostfix, - PrecUnary, - PrecMultiplicitave, - PrecAdditive, - PrecShift, - PrecRelational, - PrecEquality, - PrecBitwiseAnd, - PrecBitwiseXor, - PrecBitwiseOr, - PrecLogicalAnd, - PrecLogicalOr, - PrecConditional, - PrecAssignment, - PrecExpression - }; - - struct DeclarationStacks { - typedef Vector NodeStack; - enum { IsConstant = 1, HasInitializer = 2 } VarAttrs; - typedef Vector, 16> VarStack; - typedef Vector FunctionStack; - - DeclarationStacks(ExecState* e, NodeStack& n, VarStack& v, FunctionStack& f) - : exec(e) - , nodeStack(n) - , varStack(v) - , functionStack(f) - { - } - - ExecState* exec; - NodeStack& nodeStack; - VarStack& varStack; - FunctionStack& functionStack; - }; - - class ParserRefCounted : Noncopyable { - protected: - ParserRefCounted() KJS_FAST_CALL; - ParserRefCounted(PlacementNewAdoptType) KJS_FAST_CALL - { - } - - public: - void ref() KJS_FAST_CALL; - void deref() KJS_FAST_CALL; - unsigned refcount() KJS_FAST_CALL; - - static void deleteNewObjects() KJS_FAST_CALL; - - virtual ~ParserRefCounted(); - }; - - class Node : public ParserRefCounted { - public: - typedef DeclarationStacks::NodeStack NodeStack; - typedef DeclarationStacks::VarStack VarStack; - typedef DeclarationStacks::FunctionStack FunctionStack; - - Node() KJS_FAST_CALL; - Node(PlacementNewAdoptType placementAdopt) KJS_FAST_CALL - : ParserRefCounted(placementAdopt) - { - } - - UString toString() KJS_FAST_CALL; - int lineNo() const KJS_FAST_CALL { return m_line; } - - // Serialization. - virtual void streamTo(SourceStream&) KJS_FAST_CALL = 0; - virtual Precedence precedence() const = 0; - virtual bool needsParensIfLeftmost() const { return false; } - - // Used for iterative, depth-first traversal of the node tree. Does not cross function call boundaries. - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL { } - - protected: - JSValue* setInterruptedCompletion(ExecState*); - Node(JSType) KJS_FAST_CALL; // used by ExpressionNode - - // for use in execute() - JSValue* setErrorCompletion(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL; - JSValue* setErrorCompletion(ExecState*, ErrorType, const char* msg, const Identifier&) KJS_FAST_CALL; - - // for use in evaluate() - JSValue* throwError(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL; - JSValue* throwError(ExecState*, ErrorType, const char* msg, const char*) KJS_FAST_CALL; - JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*) KJS_FAST_CALL; - JSValue* throwError(ExecState*, ErrorType, const char* msg, const Identifier&) KJS_FAST_CALL; - JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, const Identifier&) KJS_FAST_CALL; - JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*, Node*) KJS_FAST_CALL; - JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*, const Identifier&) KJS_FAST_CALL; - - JSValue* throwUndefinedVariableError(ExecState*, const Identifier&) KJS_FAST_CALL; - - void handleException(ExecState*) KJS_FAST_CALL; - void handleException(ExecState*, JSValue*) KJS_FAST_CALL; - - // for use in execute() - JSValue* rethrowException(ExecState*) KJS_FAST_CALL; - - int m_line : 28; - unsigned m_expectedReturnType : 3; // JSType - }; - - class ExpressionNode : public Node { - public: - ExpressionNode() KJS_FAST_CALL : Node() {} - ExpressionNode(JSType expectedReturn) KJS_FAST_CALL - : Node(expectedReturn) - { - } - - // Special constructor for cases where we overwrite an object in place. - ExpressionNode(PlacementNewAdoptType) KJS_FAST_CALL - : Node(PlacementNewAdopt) - { - } - - virtual bool isNumber() const KJS_FAST_CALL { return false; } - virtual bool isLocation() const KJS_FAST_CALL { return false; } - virtual bool isResolveNode() const KJS_FAST_CALL { return false; } - virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return false; } - virtual bool isDotAccessorNode() const KJS_FAST_CALL { return false; } - virtual bool isFuncExprNode() const KJS_FAST_CALL { return false; } - - JSType expectedReturnType() const KJS_FAST_CALL { return static_cast(m_expectedReturnType); } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL = 0; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - - // Used to optimize those nodes that do extra work when returning a result, even if the result has no semantic relevance - virtual void optimizeForUnnecessaryResult() { } - }; - - class StatementNode : public Node { - public: - StatementNode() KJS_FAST_CALL; - void setLoc(int line0, int line1) KJS_FAST_CALL; - int firstLine() const KJS_FAST_CALL { return lineNo(); } - int lastLine() const KJS_FAST_CALL { return m_lastLine; } - virtual JSValue* execute(ExecState *exec) KJS_FAST_CALL = 0; - void pushLabel(const Identifier& ident) KJS_FAST_CALL { m_labelStack.push(ident); } - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - virtual bool isEmptyStatement() const KJS_FAST_CALL { return false; } - virtual bool isExprStatement() const KJS_FAST_CALL { return false; } - - protected: - LabelStack m_labelStack; - - private: - int m_lastLine; - }; - - class NullNode : public ExpressionNode { - public: - NullNode() KJS_FAST_CALL : ExpressionNode(NullType) {} - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPrimary; } - }; - - class FalseNode : public ExpressionNode { - public: - FalseNode() KJS_FAST_CALL - : ExpressionNode(BooleanType) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL { return false; } - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPrimary; } - }; - - class TrueNode : public ExpressionNode { - public: - TrueNode() KJS_FAST_CALL - : ExpressionNode(BooleanType) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL { return true; } - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPrimary; } - }; - - class PlaceholderTrueNode : public TrueNode { - public: - // Like TrueNode, but does not serialize as "true". - PlaceholderTrueNode() KJS_FAST_CALL - : TrueNode() - { - } - - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - }; - - class NumberNode : public ExpressionNode { - public: - NumberNode(double v) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_double(v) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return signbit(m_double) ? PrecUnary : PrecPrimary; } - - virtual bool isNumber() const KJS_FAST_CALL { return true; } - double value() const KJS_FAST_CALL { return m_double; } - virtual void setValue(double d) KJS_FAST_CALL { m_double = d; } - - protected: - double m_double; - }; - - class ImmediateNumberNode : public NumberNode { - public: - ImmediateNumberNode(JSValue* v, double d) KJS_FAST_CALL - : NumberNode(d) - , m_value(v) - { - ASSERT(v == JSImmediate::from(d)); - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - - virtual void setValue(double d) KJS_FAST_CALL { m_double = d; m_value = JSImmediate::from(d); ASSERT(m_value); } - - private: - JSValue* m_value; // This is never a JSCell, only JSImmediate, thus no ProtectedPtr - }; - - class StringNode : public ExpressionNode { - public: - StringNode(const UString* v) KJS_FAST_CALL - : ExpressionNode(StringType) - , m_value(*v) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPrimary; } - - private: - UString m_value; - }; - - class RegExpNode : public ExpressionNode { - public: - RegExpNode(const UString& pattern, const UString& flags) KJS_FAST_CALL - : m_regExp(new RegExp(pattern, flags)) - { - } - - JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPrimary; } - - private: - RefPtr m_regExp; - }; - - class ThisNode : public ExpressionNode { - public: - ThisNode() KJS_FAST_CALL - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPrimary; } - }; - - class ResolveNode : public ExpressionNode { - public: - ResolveNode(const Identifier& ident) KJS_FAST_CALL - : m_ident(ident) - { - } - - // Special constructor for cases where we overwrite an object in place. - ResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : ExpressionNode(PlacementNewAdopt) - , m_ident(PlacementNewAdopt) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPrimary; } - - virtual bool isLocation() const KJS_FAST_CALL { return true; } - virtual bool isResolveNode() const KJS_FAST_CALL { return true; } - const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } - - protected: - ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); - Identifier m_ident; - size_t m_index; // Used by LocalVarAccessNode. - }; - - class LocalVarAccessNode : public ResolveNode { - public: - // Overwrites a ResolveNode in place. - LocalVarAccessNode(size_t i) KJS_FAST_CALL - : ResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - - private: - ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); - }; - - class ElementNode : public Node { - public: - ElementNode(int elision, ExpressionNode* node) KJS_FAST_CALL - : m_elision(elision) - , m_node(node) - { - } - - ElementNode(ElementNode* l, int elision, ExpressionNode* node) KJS_FAST_CALL - : m_elision(elision) - , m_node(node) - { - l->m_next = this; - } - - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - - PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } - - JSValue* evaluate(ExecState*) KJS_FAST_CALL; - - private: - friend class ArrayNode; - ListRefPtr m_next; - int m_elision; - RefPtr m_node; - }; - - class ArrayNode : public ExpressionNode { - public: - ArrayNode(int elision) KJS_FAST_CALL - : m_elision(elision) - , m_optional(true) - { - } - - ArrayNode(ElementNode* element) KJS_FAST_CALL - : m_element(element) - , m_elision(0) - , m_optional(false) - { - } - - ArrayNode(int elision, ElementNode* element) KJS_FAST_CALL - : m_element(element) - , m_elision(elision) - , m_optional(true) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPrimary; } - - private: - RefPtr m_element; - int m_elision; - bool m_optional; - }; - - class PropertyNode : public Node { - public: - enum Type { Constant, Getter, Setter }; - - PropertyNode(const Identifier& name, ExpressionNode* assign, Type type) KJS_FAST_CALL - : m_name(name) - , m_assign(assign) - , m_type(type) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - - JSValue* evaluate(ExecState*) KJS_FAST_CALL; - const Identifier& name() const { return m_name; } - - private: - friend class PropertyListNode; - Identifier m_name; - RefPtr m_assign; - Type m_type; - }; - - class PropertyListNode : public Node { - public: - PropertyListNode(PropertyNode* node) KJS_FAST_CALL - : m_node(node) - { - } - - PropertyListNode(PropertyNode* node, PropertyListNode* list) KJS_FAST_CALL - : m_node(node) - { - list->m_next = this; - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - - JSValue* evaluate(ExecState*) KJS_FAST_CALL; - PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } - - private: - friend class ObjectLiteralNode; - RefPtr m_node; - ListRefPtr m_next; - }; - - class ObjectLiteralNode : public ExpressionNode { - public: - ObjectLiteralNode() KJS_FAST_CALL - { - } - - ObjectLiteralNode(PropertyListNode* list) KJS_FAST_CALL - : m_list(list) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPrimary; } - virtual bool needsParensIfLeftmost() const { return true; } - - private: - RefPtr m_list; - }; - - class BracketAccessorNode : public ExpressionNode { - public: - BracketAccessorNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL - : m_base(base) - , m_subscript(subscript) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecMember; } - - virtual bool isLocation() const KJS_FAST_CALL { return true; } - virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return true; } - ExpressionNode* base() KJS_FAST_CALL { return m_base.get(); } - ExpressionNode* subscript() KJS_FAST_CALL { return m_subscript.get(); } - - private: - ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); - - RefPtr m_base; - RefPtr m_subscript; - }; - - class DotAccessorNode : public ExpressionNode { - public: - DotAccessorNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL - : m_base(base) - , m_ident(ident) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecMember; } - - virtual bool isLocation() const KJS_FAST_CALL { return true; } - virtual bool isDotAccessorNode() const KJS_FAST_CALL { return true; } - ExpressionNode* base() const KJS_FAST_CALL { return m_base.get(); } - const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } - - private: - ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); - - RefPtr m_base; - Identifier m_ident; - }; - - class ArgumentListNode : public Node { - public: - ArgumentListNode(ExpressionNode* expr) KJS_FAST_CALL - : m_expr(expr) - { - } - - ArgumentListNode(ArgumentListNode* listNode, ExpressionNode* expr) KJS_FAST_CALL - : m_expr(expr) - { - listNode->m_next = this; - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - - void evaluateList(ExecState*, List&) KJS_FAST_CALL; - PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } - - private: - friend class ArgumentsNode; - ListRefPtr m_next; - RefPtr m_expr; - }; - - class ArgumentsNode : public Node { - public: - ArgumentsNode() KJS_FAST_CALL - { - } - - ArgumentsNode(ArgumentListNode* listNode) KJS_FAST_CALL - : m_listNode(listNode) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - - void evaluateList(ExecState* exec, List& list) KJS_FAST_CALL { if (m_listNode) m_listNode->evaluateList(exec, list); } - - private: - RefPtr m_listNode; - }; - - class NewExprNode : public ExpressionNode { - public: - NewExprNode(ExpressionNode* expr) KJS_FAST_CALL - : m_expr(expr) - { - } - - NewExprNode(ExpressionNode* expr, ArgumentsNode* args) KJS_FAST_CALL - : m_expr(expr) - , m_args(args) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecLeftHandSide; } - - private: - ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); - - RefPtr m_expr; - RefPtr m_args; - }; - - class FunctionCallValueNode : public ExpressionNode { - public: - FunctionCallValueNode(ExpressionNode* expr, ArgumentsNode* args) KJS_FAST_CALL - : m_expr(expr) - , m_args(args) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecCall; } - - private: - RefPtr m_expr; - RefPtr m_args; - }; - - class FunctionCallResolveNode : public ExpressionNode { - public: - FunctionCallResolveNode(const Identifier& ident, ArgumentsNode* args) KJS_FAST_CALL - : m_ident(ident) - , m_args(args) - { - } - - FunctionCallResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : ExpressionNode(PlacementNewAdopt) - , m_ident(PlacementNewAdopt) - , m_args(PlacementNewAdopt) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecCall; } - - protected: - ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); - - Identifier m_ident; - RefPtr m_args; - size_t m_index; // Used by LocalVarFunctionCallNode. - }; - - class LocalVarFunctionCallNode : public FunctionCallResolveNode { - public: - LocalVarFunctionCallNode(size_t i) KJS_FAST_CALL - : FunctionCallResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - - private: - ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); - }; - - class FunctionCallBracketNode : public ExpressionNode { - public: - FunctionCallBracketNode(ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args) KJS_FAST_CALL - : m_base(base) - , m_subscript(subscript) - , m_args(args) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecCall; } - - protected: - RefPtr m_base; - RefPtr m_subscript; - RefPtr m_args; - }; - - class FunctionCallDotNode : public ExpressionNode { - public: - FunctionCallDotNode(ExpressionNode* base, const Identifier& ident, ArgumentsNode* args) KJS_FAST_CALL - : m_base(base) - , m_ident(ident) - , m_args(args) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecCall; } - - private: - ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); - - RefPtr m_base; - Identifier m_ident; - RefPtr m_args; - }; - - class PrePostResolveNode : public ExpressionNode { - public: - PrePostResolveNode(const Identifier& ident) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_ident(ident) - { - } - - PrePostResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : ExpressionNode(PlacementNewAdopt) - , m_ident(PlacementNewAdopt) - { - } - - protected: - Identifier m_ident; - size_t m_index; // Used by LocalVarPostfixNode. - }; - - class PostIncResolveNode : public PrePostResolveNode { - public: - PostIncResolveNode(const Identifier& ident) KJS_FAST_CALL - : PrePostResolveNode(ident) - { - } - - PostIncResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : PrePostResolveNode(PlacementNewAdopt) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPostfix; } - virtual void optimizeForUnnecessaryResult(); - }; - - class PostIncLocalVarNode : public PostIncResolveNode { - public: - PostIncLocalVarNode(size_t i) KJS_FAST_CALL - : PostIncResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void optimizeForUnnecessaryResult(); - }; - - class PostIncConstNode : public PostIncResolveNode { - public: - PostIncConstNode(size_t i) KJS_FAST_CALL - : PostIncResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class PostDecResolveNode : public PrePostResolveNode { - public: - PostDecResolveNode(const Identifier& ident) KJS_FAST_CALL - : PrePostResolveNode(ident) - { - } - - PostDecResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : PrePostResolveNode(PlacementNewAdopt) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPostfix; } - virtual void optimizeForUnnecessaryResult(); - }; - - class PostDecLocalVarNode : public PostDecResolveNode { - public: - PostDecLocalVarNode(size_t i) KJS_FAST_CALL - : PostDecResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void optimizeForUnnecessaryResult(); - - private: - ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); - }; - - class PostDecConstNode : public PostDecResolveNode { - public: - PostDecConstNode(size_t i) KJS_FAST_CALL - : PostDecResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class PostfixBracketNode : public ExpressionNode { - public: - PostfixBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL - : m_base(base) - , m_subscript(subscript) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPostfix; } - - protected: - RefPtr m_base; - RefPtr m_subscript; - }; - - class PostIncBracketNode : public PostfixBracketNode { - public: - PostIncBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL - : PostfixBracketNode(base, subscript) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - }; - - class PostDecBracketNode : public PostfixBracketNode { - public: - PostDecBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL - : PostfixBracketNode(base, subscript) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - }; - - class PostfixDotNode : public ExpressionNode { - public: - PostfixDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL - : m_base(base) - , m_ident(ident) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPostfix; } - - protected: - RefPtr m_base; - Identifier m_ident; - }; - - class PostIncDotNode : public PostfixDotNode { - public: - PostIncDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL - : PostfixDotNode(base, ident) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - }; - - class PostDecDotNode : public PostfixDotNode { - public: - PostDecDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL - : PostfixDotNode(base, ident) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - }; - - class PostfixErrorNode : public ExpressionNode { - public: - PostfixErrorNode(ExpressionNode* expr, Operator oper) KJS_FAST_CALL - : m_expr(expr) - , m_operator(oper) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPostfix; } - - private: - RefPtr m_expr; - Operator m_operator; - }; - - class DeleteResolveNode : public ExpressionNode { - public: - DeleteResolveNode(const Identifier& ident) KJS_FAST_CALL - : m_ident(ident) - { - } - - DeleteResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : ExpressionNode(PlacementNewAdopt) - , m_ident(PlacementNewAdopt) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - Identifier m_ident; - }; - - class LocalVarDeleteNode : public DeleteResolveNode { - public: - LocalVarDeleteNode() KJS_FAST_CALL - : DeleteResolveNode(PlacementNewAdopt) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class DeleteBracketNode : public ExpressionNode { - public: - DeleteBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL - : m_base(base) - , m_subscript(subscript) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - RefPtr m_base; - RefPtr m_subscript; - }; - - class DeleteDotNode : public ExpressionNode { - public: - DeleteDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL - : m_base(base) - , m_ident(ident) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - RefPtr m_base; - Identifier m_ident; - }; - - class DeleteValueNode : public ExpressionNode { - public: - DeleteValueNode(ExpressionNode* expr) KJS_FAST_CALL - : m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - RefPtr m_expr; - }; - - class VoidNode : public ExpressionNode { - public: - VoidNode(ExpressionNode* expr) KJS_FAST_CALL - : m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - RefPtr m_expr; - }; - - class TypeOfResolveNode : public ExpressionNode { - public: - TypeOfResolveNode(const Identifier& ident) KJS_FAST_CALL - : ExpressionNode(StringType) - , m_ident(ident) - { - } - - TypeOfResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : ExpressionNode(PlacementNewAdopt) - , m_ident(PlacementNewAdopt) - { - m_expectedReturnType = StringType; - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } - - protected: - Identifier m_ident; - size_t m_index; // Used by LocalTypeOfNode. - }; - - class LocalVarTypeOfNode : public TypeOfResolveNode { - public: - LocalVarTypeOfNode(size_t i) KJS_FAST_CALL - : TypeOfResolveNode(PlacementNewAdopt) - { - m_expectedReturnType = StringType; - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class TypeOfValueNode : public ExpressionNode { - public: - TypeOfValueNode(ExpressionNode* expr) KJS_FAST_CALL - : ExpressionNode(StringType) - , m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - RefPtr m_expr; - }; - - class PreIncResolveNode : public PrePostResolveNode { - public: - PreIncResolveNode(const Identifier& ident) KJS_FAST_CALL - : PrePostResolveNode(ident) - { - } - - PreIncResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : PrePostResolveNode(PlacementNewAdopt) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - }; - - class PreIncLocalVarNode : public PreIncResolveNode { - public: - PreIncLocalVarNode(size_t i) KJS_FAST_CALL - : PreIncResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class PreIncConstNode : public PreIncResolveNode { - public: - PreIncConstNode(size_t i) KJS_FAST_CALL - : PreIncResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class PreDecResolveNode : public PrePostResolveNode { - public: - PreDecResolveNode(const Identifier& ident) KJS_FAST_CALL - : PrePostResolveNode(ident) - { - } - - PreDecResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : PrePostResolveNode(PlacementNewAdopt) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - }; - - class PreDecLocalVarNode : public PreDecResolveNode { - public: - PreDecLocalVarNode(size_t i) KJS_FAST_CALL - : PreDecResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class PreDecConstNode : public PreDecResolveNode { - public: - PreDecConstNode(size_t i) KJS_FAST_CALL - : PreDecResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class PrefixBracketNode : public ExpressionNode { - public: - PrefixBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL - : m_base(base) - , m_subscript(subscript) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - protected: - RefPtr m_base; - RefPtr m_subscript; - }; - - class PreIncBracketNode : public PrefixBracketNode { - public: - PreIncBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL - : PrefixBracketNode(base, subscript) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - }; - - class PreDecBracketNode : public PrefixBracketNode { - public: - PreDecBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL - : PrefixBracketNode(base, subscript) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - }; - - class PrefixDotNode : public ExpressionNode { - public: - PrefixDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL - : m_base(base) - , m_ident(ident) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecPostfix; } - - protected: - RefPtr m_base; - Identifier m_ident; - }; - - class PreIncDotNode : public PrefixDotNode { - public: - PreIncDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL - : PrefixDotNode(base, ident) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - }; - - class PreDecDotNode : public PrefixDotNode { - public: - PreDecDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL - : PrefixDotNode(base, ident) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - }; - - class PrefixErrorNode : public ExpressionNode { - public: - PrefixErrorNode(ExpressionNode* expr, Operator oper) KJS_FAST_CALL - : m_expr(expr) - , m_operator(oper) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - RefPtr m_expr; - Operator m_operator; - }; - - class UnaryPlusNode : public ExpressionNode { - public: - UnaryPlusNode(ExpressionNode* expr) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - RefPtr m_expr; - }; - - class NegateNode : public ExpressionNode { - public: - NegateNode(ExpressionNode* expr) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - RefPtr m_expr; - }; - - class BitwiseNotNode : public ExpressionNode { - public: - BitwiseNotNode(ExpressionNode* expr) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); - - RefPtr m_expr; - }; - - class LogicalNotNode : public ExpressionNode { - public: - LogicalNotNode(ExpressionNode* expr) KJS_FAST_CALL - : ExpressionNode(BooleanType) - , m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecUnary; } - - private: - RefPtr m_expr; - }; - - class MultNode : public ExpressionNode { - public: - MultNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_term1(term1) - , m_term2(term2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecMultiplicitave; } - - private: - ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); - - RefPtr m_term1; - RefPtr m_term2; - }; - - class DivNode : public ExpressionNode { - public: - DivNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_term1(term1) - , m_term2(term2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecMultiplicitave; } - - private: - ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); - - RefPtr m_term1; - RefPtr m_term2; - }; - - class ModNode : public ExpressionNode { - public: - ModNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_term1(term1) - , m_term2(term2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecMultiplicitave; } - - private: - ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); - - RefPtr m_term1; - RefPtr m_term2; - }; - - class AddNode : public ExpressionNode { - public: - AddNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : m_term1(term1) - , m_term2(term2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecAdditive; } - - protected: - AddNode(ExpressionNode* term1, ExpressionNode* term2, JSType expectedReturn) KJS_FAST_CALL - : ExpressionNode(expectedReturn) - , m_term1(term1) - , m_term2(term2) - { - } - - RefPtr m_term1; - RefPtr m_term2; - - private: - ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); - }; - - class AddNumbersNode : public AddNode { - public: - AddNumbersNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : AddNode(term1, term2, NumberType) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - - private: - ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*) KJS_FAST_CALL; - }; - - class AddStringLeftNode : public AddNode { - public: - AddStringLeftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : AddNode(term1, term2, StringType) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class AddStringRightNode : public AddNode { - public: - AddStringRightNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : AddNode(term1, term2, StringType) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class AddStringsNode : public AddNode { - public: - AddStringsNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : AddNode(term1, term2, StringType) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class SubNode : public ExpressionNode { - public: - SubNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_term1(term1) - , m_term2(term2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecAdditive; } - - private: - ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); - - RefPtr m_term1; - RefPtr m_term2; - }; - - class LeftShiftNode : public ExpressionNode { - public: - LeftShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_term1(term1) - , m_term2(term2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecShift; } - - private: - ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); - - RefPtr m_term1; - RefPtr m_term2; - }; - - class RightShiftNode : public ExpressionNode { - public: - RightShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_term1(term1) - , m_term2(term2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecShift; } - - private: - ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); - - RefPtr m_term1; - RefPtr m_term2; - }; - - class UnsignedRightShiftNode : public ExpressionNode { - public: - UnsignedRightShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_term1(term1) - , m_term2(term2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecShift; } - private: - ALWAYS_INLINE uint32_t inlineEvaluateToUInt32(ExecState*); - - RefPtr m_term1; - RefPtr m_term2; - }; - - class LessNode : public ExpressionNode { - public: - LessNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(BooleanType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecRelational; } - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - - protected: - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class LessNumbersNode : public LessNode { - public: - LessNumbersNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : LessNode(expr1, expr2) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - }; - - class LessStringsNode : public LessNode { - public: - LessStringsNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : LessNode(expr1, expr2) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - }; - - class GreaterNode : public ExpressionNode { - public: - GreaterNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecRelational; } - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class LessEqNode : public ExpressionNode { - public: - LessEqNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecRelational; } - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class GreaterEqNode : public ExpressionNode { - public: - GreaterEqNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecRelational; } - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class InstanceOfNode : public ExpressionNode { - public: - InstanceOfNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(BooleanType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecRelational; } - - private: - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class InNode : public ExpressionNode { - public: - InNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecRelational; } - - private: - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class EqualNode : public ExpressionNode { - public: - EqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(BooleanType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecEquality; } - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class NotEqualNode : public ExpressionNode { - public: - NotEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(BooleanType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecEquality; } - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class StrictEqualNode : public ExpressionNode { - public: - StrictEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(BooleanType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecEquality; } - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class NotStrictEqualNode : public ExpressionNode { - public: - NotStrictEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(BooleanType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecEquality; } - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class BitAndNode : public ExpressionNode { - public: - BitAndNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecBitwiseAnd; } - - private: - ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class BitOrNode : public ExpressionNode { - public: - BitOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecBitwiseOr; } - - private: - ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class BitXOrNode : public ExpressionNode { - public: - BitXOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(NumberType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecBitwiseXor; } - - private: - ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - /** - * m_expr1 && m_expr2, m_expr1 || m_expr2 - */ - class LogicalAndNode : public ExpressionNode { - public: - LogicalAndNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(BooleanType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecLogicalAnd; } - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class LogicalOrNode : public ExpressionNode { - public: - LogicalOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : ExpressionNode(BooleanType) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecLogicalOr; } - - private: - ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); - - RefPtr m_expr1; - RefPtr m_expr2; - }; - - /** - * The ternary operator, "m_logical ? m_expr1 : m_expr2" - */ - class ConditionalNode : public ExpressionNode { - public: - ConditionalNode(ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : m_logical(logical) - , m_expr1(expr1) - , m_expr2(expr2) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; - virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; - virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; - virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecConditional; } - - private: - RefPtr m_logical; - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class ReadModifyResolveNode : public ExpressionNode { - public: - ReadModifyResolveNode(const Identifier& ident, Operator oper, ExpressionNode* right) KJS_FAST_CALL - : m_ident(ident) - , m_operator(oper) - , m_right(right) - { - } - - ReadModifyResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : ExpressionNode(PlacementNewAdopt) - , m_ident(PlacementNewAdopt) - , m_right(PlacementNewAdopt) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecAssignment; } - - protected: - Identifier m_ident; - Operator m_operator; - RefPtr m_right; - size_t m_index; // Used by ReadModifyLocalVarNode. - }; - - class ReadModifyLocalVarNode : public ReadModifyResolveNode { - public: - ReadModifyLocalVarNode(size_t i) KJS_FAST_CALL - : ReadModifyResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class ReadModifyConstNode : public ReadModifyResolveNode { - public: - ReadModifyConstNode(size_t i) KJS_FAST_CALL - : ReadModifyResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class AssignResolveNode : public ExpressionNode { - public: - AssignResolveNode(const Identifier& ident, ExpressionNode* right) KJS_FAST_CALL - : m_ident(ident) - , m_right(right) - { - } - - AssignResolveNode(PlacementNewAdoptType) KJS_FAST_CALL - : ExpressionNode(PlacementNewAdopt) - , m_ident(PlacementNewAdopt) - , m_right(PlacementNewAdopt) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecAssignment; } - - protected: - Identifier m_ident; - RefPtr m_right; - size_t m_index; // Used by ReadModifyLocalVarNode. - }; - - class AssignLocalVarNode : public AssignResolveNode { - public: - AssignLocalVarNode(size_t i) KJS_FAST_CALL - : AssignResolveNode(PlacementNewAdopt) - { - ASSERT(i != missingSymbolMarker()); - m_index = i; - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class AssignConstNode : public AssignResolveNode { - public: - AssignConstNode() KJS_FAST_CALL - : AssignResolveNode(PlacementNewAdopt) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - }; - - class ReadModifyBracketNode : public ExpressionNode { - public: - ReadModifyBracketNode(ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right) KJS_FAST_CALL - : m_base(base) - , m_subscript(subscript) - , m_operator(oper) - , m_right(right) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecAssignment; } - - protected: - RefPtr m_base; - RefPtr m_subscript; - Operator m_operator; - RefPtr m_right; - }; - - class AssignBracketNode : public ExpressionNode { - public: - AssignBracketNode(ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right) KJS_FAST_CALL - : m_base(base) - , m_subscript(subscript) - , m_right(right) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecAssignment; } - - protected: - RefPtr m_base; - RefPtr m_subscript; - RefPtr m_right; - }; - - class AssignDotNode : public ExpressionNode { - public: - AssignDotNode(ExpressionNode* base, const Identifier& ident, ExpressionNode* right) KJS_FAST_CALL - : m_base(base) - , m_ident(ident) - , m_right(right) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecAssignment; } - - protected: - RefPtr m_base; - Identifier m_ident; - RefPtr m_right; - }; - - class ReadModifyDotNode : public ExpressionNode { - public: - ReadModifyDotNode(ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right) KJS_FAST_CALL - : m_base(base) - , m_ident(ident) - , m_operator(oper) - , m_right(right) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecAssignment; } - - protected: - RefPtr m_base; - Identifier m_ident; - Operator m_operator; - RefPtr m_right; - }; - - class AssignErrorNode : public ExpressionNode { - public: - AssignErrorNode(ExpressionNode* left, Operator oper, ExpressionNode* right) KJS_FAST_CALL - : m_left(left) - , m_operator(oper) - , m_right(right) - { - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecAssignment; } - - protected: - RefPtr m_left; - Operator m_operator; - RefPtr m_right; - }; - - class CommaNode : public ExpressionNode { - public: - CommaNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : m_expr1(expr1) - , m_expr2(expr2) - { - m_expr1->optimizeForUnnecessaryResult(); - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecExpression; } - - private: - RefPtr m_expr1; - RefPtr m_expr2; - }; - - class VarDeclCommaNode : public CommaNode { - public: - VarDeclCommaNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL - : CommaNode(expr1, expr2) - { - } - virtual Precedence precedence() const { return PrecAssignment; } - }; - - class ConstDeclNode : public ExpressionNode { - public: - ConstDeclNode(const Identifier& ident, ExpressionNode* in) KJS_FAST_CALL; - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual KJS::JSValue* evaluate(ExecState*) KJS_FAST_CALL; - void evaluateSingle(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } - - Identifier m_ident; - ListRefPtr m_next; - RefPtr m_init; - - private: - void handleSlowCase(ExecState*, const ScopeChain&, JSValue*) KJS_FAST_CALL NEVER_INLINE; - }; - - class ConstStatementNode : public StatementNode { - public: - ConstStatementNode(ConstDeclNode* next) KJS_FAST_CALL - : m_next(next) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_next; - }; - - typedef Vector > StatementVector; - - class SourceElements : public ParserRefCounted { - public: - void append(PassRefPtr); - void releaseContentsIntoVector(StatementVector& destination) - { - ASSERT(destination.isEmpty()); - m_statements.swap(destination); - } - - private: - StatementVector m_statements; - }; - - class BlockNode : public StatementNode { - public: - BlockNode() KJS_FAST_CALL; - BlockNode(SourceElements* children) KJS_FAST_CALL; - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - protected: - StatementVector m_children; - }; - - class EmptyStatementNode : public StatementNode { - public: - EmptyStatementNode() KJS_FAST_CALL // debug - { - } - - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual bool isEmptyStatement() const KJS_FAST_CALL { return true; } - }; - - class ExprStatementNode : public StatementNode { - public: - ExprStatementNode(ExpressionNode* expr) KJS_FAST_CALL - : m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual bool isExprStatement() const KJS_FAST_CALL { return true; } - - ExpressionNode* expr() const { return m_expr.get(); } - - private: - RefPtr m_expr; - }; - - class VarStatementNode : public StatementNode { - public: - VarStatementNode(ExpressionNode* expr) KJS_FAST_CALL - : m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_expr; - }; - - class IfNode : public StatementNode { - public: - IfNode(ExpressionNode* condition, StatementNode* ifBlock) KJS_FAST_CALL - : m_condition(condition) - , m_ifBlock(ifBlock) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - protected: - RefPtr m_condition; - RefPtr m_ifBlock; - }; - - class IfElseNode : public IfNode { - public: - IfElseNode(ExpressionNode* condtion, StatementNode* ifBlock, StatementNode* elseBlock) KJS_FAST_CALL - : IfNode(condtion, ifBlock) - , m_elseBlock(elseBlock) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_elseBlock; - }; - - class DoWhileNode : public StatementNode { - public: - DoWhileNode(StatementNode* statement, ExpressionNode* expr) KJS_FAST_CALL - : m_statement(statement) - , m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_statement; - RefPtr m_expr; - }; - - class WhileNode : public StatementNode { - public: - WhileNode(ExpressionNode* expr, StatementNode* statement) KJS_FAST_CALL - : m_expr(expr) - , m_statement(statement) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_expr; - RefPtr m_statement; - }; - - class ForNode : public StatementNode { - public: - ForNode(ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, bool expr1WasVarDecl) KJS_FAST_CALL - : m_expr1(expr1 ? expr1 : new PlaceholderTrueNode) - , m_expr2(expr2 ? expr2 : new PlaceholderTrueNode) - , m_expr3(expr3 ? expr3 : new PlaceholderTrueNode) - , m_statement(statement) - , m_expr1WasVarDecl(expr1 && expr1WasVarDecl) - { - ASSERT(m_expr1); - ASSERT(m_expr2); - ASSERT(m_expr3); - ASSERT(statement); - - m_expr1->optimizeForUnnecessaryResult(); - m_expr3->optimizeForUnnecessaryResult(); - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_expr1; - RefPtr m_expr2; - RefPtr m_expr3; - RefPtr m_statement; - bool m_expr1WasVarDecl; - }; - - class ForInNode : public StatementNode { - public: - ForInNode(ExpressionNode*, ExpressionNode*, StatementNode*) KJS_FAST_CALL; - ForInNode(const Identifier&, ExpressionNode*, ExpressionNode*, StatementNode*) KJS_FAST_CALL; - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - Identifier m_ident; - RefPtr m_init; - RefPtr m_lexpr; - RefPtr m_expr; - RefPtr m_statement; - bool m_identIsVarDecl; - }; - - class ContinueNode : public StatementNode { - public: - ContinueNode() KJS_FAST_CALL - { - } - - ContinueNode(const Identifier& ident) KJS_FAST_CALL - : m_ident(ident) - { - } - - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - Identifier m_ident; - }; - - class BreakNode : public StatementNode { - public: - BreakNode() KJS_FAST_CALL - { - } - - BreakNode(const Identifier& ident) KJS_FAST_CALL - : m_ident(ident) - { - } - - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - Identifier m_ident; - }; - - class ReturnNode : public StatementNode { - public: - ReturnNode(ExpressionNode* value) KJS_FAST_CALL - : m_value(value) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_value; - }; - - class WithNode : public StatementNode { - public: - WithNode(ExpressionNode* expr, StatementNode* statement) KJS_FAST_CALL - : m_expr(expr) - , m_statement(statement) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_expr; - RefPtr m_statement; - }; - - class LabelNode : public StatementNode { - public: - LabelNode(const Identifier& label, StatementNode* statement) KJS_FAST_CALL - : m_label(label) - , m_statement(statement) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - Identifier m_label; - RefPtr m_statement; - }; - - class ThrowNode : public StatementNode { - public: - ThrowNode(ExpressionNode* expr) KJS_FAST_CALL - : m_expr(expr) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_expr; - }; - - class TryNode : public StatementNode { - public: - TryNode(StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, StatementNode* finallyBlock) KJS_FAST_CALL - : m_tryBlock(tryBlock) - , m_exceptionIdent(exceptionIdent) - , m_catchBlock(catchBlock) - , m_finallyBlock(finallyBlock) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_tryBlock; - Identifier m_exceptionIdent; - RefPtr m_catchBlock; - RefPtr m_finallyBlock; - }; - - class ParameterNode : public Node { - public: - ParameterNode(const Identifier& ident) KJS_FAST_CALL - : m_ident(ident) - { - } - - ParameterNode(ParameterNode* l, const Identifier& ident) KJS_FAST_CALL - : m_ident(ident) - { - l->m_next = this; - } - - Identifier ident() KJS_FAST_CALL { return m_ident; } - ParameterNode *nextParam() KJS_FAST_CALL { return m_next.get(); } - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - - private: - friend class FuncDeclNode; - friend class FuncExprNode; - Identifier m_ident; - ListRefPtr m_next; - }; - - class ScopeNode : public BlockNode { - public: - ScopeNode() KJS_FAST_CALL; - ScopeNode(const SourceCode&, SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; - - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - void setSource(const SourceCode& source) { m_source = source; } - const SourceCode& source() const { return m_source; } - const UString& sourceURL() const KJS_FAST_CALL { return m_source.provider()->url(); } - intptr_t sourceID() const { return m_source.provider()->asID(); } - - void setData(SourceElements*, VarStack*, FunctionStack*); - - protected: - void optimizeVariableAccess(ExecState*) KJS_FAST_CALL; - - VarStack m_varStack; - FunctionStack m_functionStack; - - private: - SourceCode m_source; - }; - - class ProgramNode : public ScopeNode { - public: - static ProgramNode* create(const SourceCode&, SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; - - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - - private: - ProgramNode(const SourceCode&, SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; - - void initializeSymbolTable(ExecState*) KJS_FAST_CALL; - ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; - - Vector m_varIndexes; // Storage indexes belonging to the nodes in m_varStack. (Recorded to avoid double lookup.) - Vector m_functionIndexes; // Storage indexes belonging to the nodes in m_functionStack. (Recorded to avoid double lookup.) - }; - - class EvalNode : public ScopeNode { - public: - static EvalNode* create(const SourceCode&, SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; - - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - - private: - EvalNode(const SourceCode&, SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; - - ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; - }; - - class FunctionBodyNode : public ScopeNode { - public: - static FunctionBodyNode* create() KJS_FAST_CALL; - static FunctionBodyNode* create(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; - static FunctionBodyNode* create(const SourceCode&, SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; - - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - SymbolTable& symbolTable() KJS_FAST_CALL { return m_symbolTable; } - - Vector& parameters() KJS_FAST_CALL { return m_parameters; } - UString paramString() const KJS_FAST_CALL; - - protected: - FunctionBodyNode() KJS_FAST_CALL; - FunctionBodyNode(const SourceCode&, SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; - - private: - void initializeSymbolTable(ExecState*) KJS_FAST_CALL; - ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; - - bool m_initialized; - Vector m_parameters; - SymbolTable m_symbolTable; - }; - - class FuncExprNode : public ExpressionNode { - public: - FuncExprNode(const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter = 0) KJS_FAST_CALL - : m_ident(ident) - , m_parameter(parameter) - , m_body(body) - { - addParams(); - m_body->setSource(source); - } - - virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { return PrecMember; } - virtual bool needsParensIfLeftmost() const { return true; } - virtual bool isFuncExprNode() const KJS_FAST_CALL { return true; } - - private: - void addParams() KJS_FAST_CALL; - - // Used for streamTo - friend class PropertyNode; - Identifier m_ident; - RefPtr m_parameter; - RefPtr m_body; - }; - - class FuncDeclNode : public StatementNode { - public: - FuncDeclNode(const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter = 0) KJS_FAST_CALL - : m_ident(ident) - , m_parameter(parameter) - , m_body(body) - { - addParams(); - m_body->setSource(source); - } - - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - ALWAYS_INLINE FunctionImp* makeFunction(ExecState*) KJS_FAST_CALL; - - Identifier m_ident; - - private: - void addParams() KJS_FAST_CALL; - - RefPtr m_parameter; - RefPtr m_body; - }; - - class CaseClauseNode : public Node { - public: - CaseClauseNode(ExpressionNode* expr) KJS_FAST_CALL - : m_expr(expr) - { - } - - CaseClauseNode(ExpressionNode* expr, SourceElements* children) KJS_FAST_CALL - : m_expr(expr) - { - if (children) - children->releaseContentsIntoVector(m_children); - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - - JSValue* evaluate(ExecState*) KJS_FAST_CALL; - JSValue* executeStatements(ExecState*) KJS_FAST_CALL; - - private: - RefPtr m_expr; - StatementVector m_children; - }; - - class ClauseListNode : public Node { - public: - ClauseListNode(CaseClauseNode* clause) KJS_FAST_CALL - : m_clause(clause) - { - } - - ClauseListNode(ClauseListNode* clauseList, CaseClauseNode* clause) KJS_FAST_CALL - : m_clause(clause) - { - clauseList->m_next = this; - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - CaseClauseNode* getClause() const KJS_FAST_CALL { return m_clause.get(); } - ClauseListNode* getNext() const KJS_FAST_CALL { return m_next.get(); } - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - PassRefPtr releaseNext() KJS_FAST_CALL { return m_next.release(); } - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - - private: - friend class CaseBlockNode; - RefPtr m_clause; - ListRefPtr m_next; - }; - - class CaseBlockNode : public Node { - public: - CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2) KJS_FAST_CALL; - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - JSValue* executeBlock(ExecState*, JSValue *input) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } - - private: - RefPtr m_list1; - RefPtr m_defaultClause; - RefPtr m_list2; - }; - - class SwitchNode : public StatementNode { - public: - SwitchNode(ExpressionNode* expr, CaseBlockNode* block) KJS_FAST_CALL - : m_expr(expr) - , m_block(block) - { - } - - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - - private: - RefPtr m_expr; - RefPtr m_block; - }; - - class BreakpointCheckStatement : public StatementNode { - public: - BreakpointCheckStatement(PassRefPtr) KJS_FAST_CALL; - - virtual JSValue* execute(ExecState*) KJS_FAST_CALL; - virtual void streamTo(SourceStream&) KJS_FAST_CALL; - virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; - - private: - RefPtr m_statement; - }; - - struct ElementList { - ElementNode* head; - ElementNode* tail; - }; - - struct PropertyList { - PropertyListNode* head; - PropertyListNode* tail; - }; - - struct ArgumentList { - ArgumentListNode* head; - ArgumentListNode* tail; - }; - - struct ConstDeclList { - ConstDeclNode* head; - ConstDeclNode* tail; - }; - - struct ParameterList { - ParameterNode* head; - ParameterNode* tail; - }; - - struct ClauseList { - ClauseListNode* head; - ClauseListNode* tail; - }; - -} // namespace KJS - -#endif // NODES_H_ diff --git a/kjs/nodes2string.cpp b/kjs/nodes2string.cpp deleted file mode 100644 index 24c2d9d..0000000 --- a/kjs/nodes2string.cpp +++ /dev/null @@ -1,980 +0,0 @@ -/* - * Copyright (C) 2002 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2007 Eric Seidel - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "nodes.h" - -#include -#include -#include - -using namespace WTF; -using namespace Unicode; - -namespace KJS { - -// A simple text streaming class that helps with code indentation. - -enum EndlType { Endl }; -enum IndentType { Indent }; -enum UnindentType { Unindent }; -enum DotExprType { DotExpr }; - -class SourceStream { -public: - SourceStream() - : m_numberNeedsParens(false) - , m_atStartOfStatement(true) - , m_precedence(PrecExpression) - { - } - - UString toString() const { return m_string; } - - SourceStream& operator<<(const Identifier&); - SourceStream& operator<<(const UString&); - SourceStream& operator<<(const char*); - SourceStream& operator<<(double); - SourceStream& operator<<(char); - SourceStream& operator<<(EndlType); - SourceStream& operator<<(IndentType); - SourceStream& operator<<(UnindentType); - SourceStream& operator<<(DotExprType); - SourceStream& operator<<(Precedence); - SourceStream& operator<<(Node*); - template SourceStream& operator<<(const RefPtr& n) { return *this << n.get(); } - -private: - UString m_string; - UString m_spacesForIndentation; - bool m_numberNeedsParens; - bool m_atStartOfStatement; - Precedence m_precedence; -}; - -// -------- - -static UString escapeStringForPrettyPrinting(const UString& s) -{ - UString escapedString; - - for (int i = 0; i < s.size(); i++) { - unsigned short c = s.data()[i].unicode(); - switch (c) { - case '\"': - escapedString += "\\\""; - break; - case '\n': - escapedString += "\\n"; - break; - case '\r': - escapedString += "\\r"; - break; - case '\t': - escapedString += "\\t"; - break; - case '\\': - escapedString += "\\\\"; - break; - default: - if (c < 128 && isPrintableChar(c)) - escapedString.append(c); - else { - char hexValue[7]; - snprintf(hexValue, 7, "\\u%04x", c); - escapedString += hexValue; - } - } - } - - return escapedString; -} - -static const char* operatorString(Operator oper) -{ - switch (oper) { - case OpEqual: - return "="; - case OpMultEq: - return "*="; - case OpDivEq: - return "/="; - case OpPlusEq: - return "+="; - case OpMinusEq: - return "-="; - case OpLShift: - return "<<="; - case OpRShift: - return ">>="; - case OpURShift: - return ">>>="; - case OpAndEq: - return "&="; - case OpXOrEq: - return "^="; - case OpOrEq: - return "|="; - case OpModEq: - return "%="; - case OpPlusPlus: - return "++"; - case OpMinusMinus: - return "--"; - } - ASSERT_NOT_REACHED(); - return "???"; -} - -static bool isParserRoundTripNumber(const UString& string) -{ - double number = string.toDouble(false, false); - if (isnan(number) || isinf(number)) - return false; - return string == UString::from(number); -} - -// -------- - -SourceStream& SourceStream::operator<<(char c) -{ - m_numberNeedsParens = false; - m_atStartOfStatement = false; - UChar ch(c); - m_string.append(ch); - return *this; -} - -SourceStream& SourceStream::operator<<(const char* s) -{ - m_numberNeedsParens = false; - m_atStartOfStatement = false; - m_string += s; - return *this; -} - -SourceStream& SourceStream::operator<<(double value) -{ - bool needParens = m_numberNeedsParens; - m_numberNeedsParens = false; - m_atStartOfStatement = false; - - if (needParens) - m_string.append('('); - m_string += UString::from(value); - if (needParens) - m_string.append(')'); - - return *this; -} - -SourceStream& SourceStream::operator<<(const UString& s) -{ - m_numberNeedsParens = false; - m_atStartOfStatement = false; - m_string += s; - return *this; -} - -SourceStream& SourceStream::operator<<(const Identifier& s) -{ - m_numberNeedsParens = false; - m_atStartOfStatement = false; - m_string += s.ustring(); - return *this; -} - -SourceStream& SourceStream::operator<<(Node* n) -{ - bool needParens = (m_precedence != PrecExpression && n->precedence() > m_precedence) || (m_atStartOfStatement && n->needsParensIfLeftmost()); - m_precedence = PrecExpression; - if (!n) - return *this; - if (needParens) { - m_numberNeedsParens = false; - m_string.append('('); - } - n->streamTo(*this); - if (needParens) - m_string.append(')'); - return *this; -} - -SourceStream& SourceStream::operator<<(EndlType) -{ - m_numberNeedsParens = false; - m_atStartOfStatement = true; - m_string.append('\n'); - m_string.append(m_spacesForIndentation); - return *this; -} - -SourceStream& SourceStream::operator<<(IndentType) -{ - m_numberNeedsParens = false; - m_atStartOfStatement = false; - m_spacesForIndentation += " "; - return *this; -} - -SourceStream& SourceStream::operator<<(UnindentType) -{ - m_numberNeedsParens = false; - m_atStartOfStatement = false; - m_spacesForIndentation = m_spacesForIndentation.substr(0, m_spacesForIndentation.size() - 2); - return *this; -} - -inline SourceStream& SourceStream::operator<<(DotExprType) -{ - m_numberNeedsParens = true; - return *this; -} - -inline SourceStream& SourceStream::operator<<(Precedence precedence) -{ - m_precedence = precedence; - return *this; -} - -static void streamLeftAssociativeBinaryOperator(SourceStream& s, Precedence precedence, - const char* operatorString, Node* left, Node* right) -{ - s << precedence << left - << ' ' << operatorString << ' ' - << static_cast(precedence - 1) << right; -} - -template static inline void streamLeftAssociativeBinaryOperator(SourceStream& s, - Precedence p, const char* o, const RefPtr& l, const RefPtr& r) -{ - streamLeftAssociativeBinaryOperator(s, p, o, l.get(), r.get()); -} - -static inline void bracketNodeStreamTo(SourceStream& s, const RefPtr& base, const RefPtr& subscript) -{ - s << PrecCall << base.get() << "[" << subscript.get() << "]"; -} - -static inline void dotNodeStreamTo(SourceStream& s, const RefPtr& base, const Identifier& ident) -{ - s << DotExpr << PrecCall << base.get() << "." << ident; -} - -// -------- - -UString Node::toString() -{ - SourceStream stream; - streamTo(stream); - return stream.toString(); -} - -// -------- - -void NullNode::streamTo(SourceStream& s) -{ - s << "null"; -} - -void FalseNode::streamTo(SourceStream& s) -{ - s << "false"; -} - -void TrueNode::streamTo(SourceStream& s) -{ - s << "true"; -} - -void PlaceholderTrueNode::streamTo(SourceStream&) -{ -} - -void NumberNode::streamTo(SourceStream& s) -{ - s << value(); -} - -void StringNode::streamTo(SourceStream& s) -{ - s << '"' << escapeStringForPrettyPrinting(m_value) << '"'; -} - -void RegExpNode::streamTo(SourceStream& s) -{ - s << '/' << m_regExp->pattern() << '/' << m_regExp->flags(); -} - -void ThisNode::streamTo(SourceStream& s) -{ - s << "this"; -} - -void ResolveNode::streamTo(SourceStream& s) -{ - s << m_ident; -} - -void ElementNode::streamTo(SourceStream& s) -{ - for (const ElementNode* n = this; n; n = n->m_next.get()) { - for (int i = 0; i < n->m_elision; i++) - s << ','; - s << PrecAssignment << n->m_node; - if (n->m_next) - s << ','; - } -} - -void ArrayNode::streamTo(SourceStream& s) -{ - s << '[' << m_element; - for (int i = 0; i < m_elision; i++) - s << ','; - // Parser consumes one elision comma if there's array elements - // present in the expression. - if (m_optional && m_element) - s << ','; - s << ']'; -} - -void ObjectLiteralNode::streamTo(SourceStream& s) -{ - if (m_list) - s << "{ " << m_list << " }"; - else - s << "{ }"; -} - -void PropertyListNode::streamTo(SourceStream& s) -{ - s << m_node; - for (const PropertyListNode* n = m_next.get(); n; n = n->m_next.get()) - s << ", " << n->m_node; -} - -void PropertyNode::streamTo(SourceStream& s) -{ - switch (m_type) { - case Constant: { - UString propertyName = name().ustring(); - if (isParserRoundTripNumber(propertyName)) - s << propertyName; - else - s << '"' << escapeStringForPrettyPrinting(propertyName) << '"'; - s << ": " << PrecAssignment << m_assign; - break; - } - case Getter: - case Setter: { - const FuncExprNode* func = static_cast(m_assign.get()); - if (m_type == Getter) - s << "get "; - else - s << "set "; - s << escapeStringForPrettyPrinting(name().ustring()) - << "(" << func->m_parameter << ')' << func->m_body; - break; - } - } -} - -void BracketAccessorNode::streamTo(SourceStream& s) -{ - bracketNodeStreamTo(s, m_base, m_subscript); -} - -void DotAccessorNode::streamTo(SourceStream& s) -{ - dotNodeStreamTo(s, m_base, m_ident); -} - -void ArgumentListNode::streamTo(SourceStream& s) -{ - s << PrecAssignment << m_expr; - for (ArgumentListNode* n = m_next.get(); n; n = n->m_next.get()) - s << ", " << PrecAssignment << n->m_expr; -} - -void ArgumentsNode::streamTo(SourceStream& s) -{ - s << '(' << m_listNode << ')'; -} - -void NewExprNode::streamTo(SourceStream& s) -{ - s << "new " << PrecMember << m_expr << m_args; -} - -void FunctionCallValueNode::streamTo(SourceStream& s) -{ - s << PrecCall << m_expr << m_args; -} - -void FunctionCallResolveNode::streamTo(SourceStream& s) -{ - s << m_ident << m_args; -} - -void FunctionCallBracketNode::streamTo(SourceStream& s) -{ - bracketNodeStreamTo(s, m_base, m_subscript); - s << m_args; -} - -void FunctionCallDotNode::streamTo(SourceStream& s) -{ - dotNodeStreamTo(s, m_base, m_ident); - s << m_args; -} - -void PostIncResolveNode::streamTo(SourceStream& s) -{ - s << m_ident << "++"; -} - -void PostDecResolveNode::streamTo(SourceStream& s) -{ - s << m_ident << "--"; -} - -void PostIncBracketNode::streamTo(SourceStream& s) -{ - bracketNodeStreamTo(s, m_base, m_subscript); - s << "++"; -} - -void PostDecBracketNode::streamTo(SourceStream& s) -{ - bracketNodeStreamTo(s, m_base, m_subscript); - s << "--"; -} - -void PostIncDotNode::streamTo(SourceStream& s) -{ - dotNodeStreamTo(s, m_base, m_ident); - s << "++"; -} - -void PostDecDotNode::streamTo(SourceStream& s) -{ - dotNodeStreamTo(s, m_base, m_ident); - s << "--"; -} - -void PostfixErrorNode::streamTo(SourceStream& s) -{ - s << PrecLeftHandSide << m_expr; - if (m_operator == OpPlusPlus) - s << "++"; - else - s << "--"; -} - -void DeleteResolveNode::streamTo(SourceStream& s) -{ - s << "delete " << m_ident; -} - -void DeleteBracketNode::streamTo(SourceStream& s) -{ - s << "delete "; - bracketNodeStreamTo(s, m_base, m_subscript); -} - -void DeleteDotNode::streamTo(SourceStream& s) -{ - s << "delete "; - dotNodeStreamTo(s, m_base, m_ident); -} - -void DeleteValueNode::streamTo(SourceStream& s) -{ - s << "delete " << PrecUnary << m_expr; -} - -void VoidNode::streamTo(SourceStream& s) -{ - s << "void " << PrecUnary << m_expr; -} - -void TypeOfValueNode::streamTo(SourceStream& s) -{ - s << "typeof " << PrecUnary << m_expr; -} - -void TypeOfResolveNode::streamTo(SourceStream& s) -{ - s << "typeof " << m_ident; -} - -void PreIncResolveNode::streamTo(SourceStream& s) -{ - s << "++" << m_ident; -} - -void PreDecResolveNode::streamTo(SourceStream& s) -{ - s << "--" << m_ident; -} - -void PreIncBracketNode::streamTo(SourceStream& s) -{ - s << "++"; - bracketNodeStreamTo(s, m_base, m_subscript); -} - -void PreDecBracketNode::streamTo(SourceStream& s) -{ - s << "--"; - bracketNodeStreamTo(s, m_base, m_subscript); -} - -void PreIncDotNode::streamTo(SourceStream& s) -{ - s << "++"; - dotNodeStreamTo(s, m_base, m_ident); -} - -void PreDecDotNode::streamTo(SourceStream& s) -{ - s << "--"; - dotNodeStreamTo(s, m_base, m_ident); -} - -void PrefixErrorNode::streamTo(SourceStream& s) -{ - if (m_operator == OpPlusPlus) - s << "++" << PrecUnary << m_expr; - else - s << "--" << PrecUnary << m_expr; -} - -void UnaryPlusNode::streamTo(SourceStream& s) -{ - s << "+ " << PrecUnary << m_expr; -} - -void NegateNode::streamTo(SourceStream& s) -{ - s << "- " << PrecUnary << m_expr; -} - -void BitwiseNotNode::streamTo(SourceStream& s) -{ - s << "~" << PrecUnary << m_expr; -} - -void LogicalNotNode::streamTo(SourceStream& s) -{ - s << "!" << PrecUnary << m_expr; -} - -void MultNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "*", m_term1, m_term2); -} - -void DivNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "/", m_term1, m_term2); -} - -void ModNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "%", m_term1, m_term2); -} - -void AddNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "+", m_term1, m_term2); -} - -void SubNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "-", m_term1, m_term2); -} - -void LeftShiftNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "<<", m_term1, m_term2); -} - -void RightShiftNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), ">>", m_term1, m_term2); -} - -void UnsignedRightShiftNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), ">>>", m_term1, m_term2); -} - -void LessNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "<", m_expr1, m_expr2); -} - -void GreaterNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), ">", m_expr1, m_expr2); -} - -void LessEqNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "<=", m_expr1, m_expr2); -} - -void GreaterEqNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), ">=", m_expr1, m_expr2); -} - -void InstanceOfNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "instanceof", m_expr1, m_expr2); -} - -void InNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "in", m_expr1, m_expr2); -} - -void EqualNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "==", m_expr1, m_expr2); -} - -void NotEqualNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "!=", m_expr1, m_expr2); -} - -void StrictEqualNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "===", m_expr1, m_expr2); -} - -void NotStrictEqualNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "!==", m_expr1, m_expr2); -} - -void BitAndNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "&", m_expr1, m_expr2); -} - -void BitXOrNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "^", m_expr1, m_expr2); -} - -void BitOrNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "|", m_expr1, m_expr2); -} - -void LogicalAndNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "&&", m_expr1, m_expr2); -} - -void LogicalOrNode::streamTo(SourceStream& s) -{ - streamLeftAssociativeBinaryOperator(s, precedence(), "||", m_expr1, m_expr2); -} - -void ConditionalNode::streamTo(SourceStream& s) -{ - s << PrecLogicalOr << m_logical - << " ? " << PrecAssignment << m_expr1 - << " : " << PrecAssignment << m_expr2; -} - -void ReadModifyResolveNode::streamTo(SourceStream& s) -{ - s << m_ident << ' ' << operatorString(m_operator) << ' ' << PrecAssignment << m_right; -} - -void AssignResolveNode::streamTo(SourceStream& s) -{ - s << m_ident << " = " << PrecAssignment << m_right; -} - -void ReadModifyBracketNode::streamTo(SourceStream& s) -{ - bracketNodeStreamTo(s, m_base, m_subscript); - s << ' ' << operatorString(m_operator) << ' ' << PrecAssignment << m_right; -} - -void AssignBracketNode::streamTo(SourceStream& s) -{ - bracketNodeStreamTo(s, m_base, m_subscript); - s << " = " << PrecAssignment << m_right; -} - -void ReadModifyDotNode::streamTo(SourceStream& s) -{ - dotNodeStreamTo(s, m_base, m_ident); - s << ' ' << operatorString(m_operator) << ' ' << PrecAssignment << m_right; -} - -void AssignDotNode::streamTo(SourceStream& s) -{ - dotNodeStreamTo(s, m_base, m_ident); - s << " = " << PrecAssignment << m_right; -} - -void AssignErrorNode::streamTo(SourceStream& s) -{ - s << PrecLeftHandSide << m_left << ' ' - << operatorString(m_operator) << ' ' << PrecAssignment << m_right; -} - -void CommaNode::streamTo(SourceStream& s) -{ - s << PrecAssignment << m_expr1 << ", " << PrecAssignment << m_expr2; -} - -void ConstDeclNode::streamTo(SourceStream& s) -{ - s << m_ident; - if (m_init) - s << " = " << m_init; - for (ConstDeclNode* n = m_next.get(); n; n = n->m_next.get()) { - s << ", " << m_ident; - if (m_init) - s << " = " << m_init; - } -} - -void ConstStatementNode::streamTo(SourceStream& s) -{ - s << Endl << "const " << m_next << ';'; -} - -static inline void statementListStreamTo(const Vector >& nodes, SourceStream& s) -{ - for (Vector >::const_iterator ptr = nodes.begin(); ptr != nodes.end(); ptr++) - s << *ptr; -} - -void BlockNode::streamTo(SourceStream& s) -{ - s << Endl << "{" << Indent; - statementListStreamTo(m_children, s); - s << Unindent << Endl << "}"; -} - -void ScopeNode::streamTo(SourceStream& s) -{ - s << Endl << "{" << Indent; - - bool printedVar = false; - for (size_t i = 0; i < m_varStack.size(); ++i) { - if (m_varStack[i].second == 0) { - if (!printedVar) { - s << Endl << "var "; - printedVar = true; - } else - s << ", "; - s << m_varStack[i].first; - } - } - if (printedVar) - s << ';'; - - statementListStreamTo(m_children, s); - s << Unindent << Endl << "}"; -} - -void FunctionBodyNode::streamTo(SourceStream& s) -{ - if (m_children.isEmpty()) - parser().reparse(this); - ScopeNode::streamTo(s); -} - -void EmptyStatementNode::streamTo(SourceStream& s) -{ - s << Endl << ';'; -} - -void ExprStatementNode::streamTo(SourceStream& s) -{ - s << Endl << m_expr << ';'; -} - -void VarStatementNode::streamTo(SourceStream& s) -{ - s << Endl << "var " << m_expr << ';'; -} - -void IfNode::streamTo(SourceStream& s) -{ - s << Endl << "if (" << m_condition << ')' << Indent << m_ifBlock << Unindent; -} - -void IfElseNode::streamTo(SourceStream& s) -{ - IfNode::streamTo(s); - s << Endl << "else" << Indent << m_elseBlock << Unindent; -} - -void DoWhileNode::streamTo(SourceStream& s) -{ - s << Endl << "do " << Indent << m_statement << Unindent << Endl - << "while (" << m_expr << ");"; -} - -void WhileNode::streamTo(SourceStream& s) -{ - s << Endl << "while (" << m_expr << ')' << Indent << m_statement << Unindent; -} - -void ForNode::streamTo(SourceStream& s) -{ - s << Endl << "for (" - << (m_expr1WasVarDecl ? "var " : "") - << m_expr1 - << "; " << m_expr2 - << "; " << m_expr3 - << ')' << Indent << m_statement << Unindent; -} - -void ForInNode::streamTo(SourceStream& s) -{ - s << Endl << "for ("; - if (m_identIsVarDecl) { - s << "var "; - if (m_init) - s << m_init; - else - s << PrecLeftHandSide << m_lexpr; - } else - s << PrecLeftHandSide << m_lexpr; - - s << " in " << m_expr << ')' << Indent << m_statement << Unindent; -} - -void ContinueNode::streamTo(SourceStream& s) -{ - s << Endl << "continue"; - if (!m_ident.isNull()) - s << ' ' << m_ident; - s << ';'; -} - -void BreakNode::streamTo(SourceStream& s) -{ - s << Endl << "break"; - if (!m_ident.isNull()) - s << ' ' << m_ident; - s << ';'; -} - -void ReturnNode::streamTo(SourceStream& s) -{ - s << Endl << "return"; - if (m_value) - s << ' ' << m_value; - s << ';'; -} - -void WithNode::streamTo(SourceStream& s) -{ - s << Endl << "with (" << m_expr << ") " << m_statement; -} - -void CaseClauseNode::streamTo(SourceStream& s) -{ - s << Endl; - if (m_expr) - s << "case " << m_expr; - else - s << "default"; - s << ":" << Indent; - statementListStreamTo(m_children, s); - s << Unindent; -} - -void ClauseListNode::streamTo(SourceStream& s) -{ - for (const ClauseListNode* n = this; n; n = n->getNext()) - s << n->getClause(); -} - -void CaseBlockNode::streamTo(SourceStream& s) -{ - for (const ClauseListNode* n = m_list1.get(); n; n = n->getNext()) - s << n->getClause(); - s << m_defaultClause; - for (const ClauseListNode* n = m_list2.get(); n; n = n->getNext()) - s << n->getClause(); -} - -void SwitchNode::streamTo(SourceStream& s) -{ - s << Endl << "switch (" << m_expr << ") {" - << Indent << m_block << Unindent - << Endl << "}"; -} - -void LabelNode::streamTo(SourceStream& s) -{ - s << Endl << m_label << ":" << Indent << m_statement << Unindent; -} - -void ThrowNode::streamTo(SourceStream& s) -{ - s << Endl << "throw " << m_expr << ';'; -} - -void TryNode::streamTo(SourceStream& s) -{ - s << Endl << "try " << m_tryBlock; - if (m_catchBlock) - s << Endl << "catch (" << m_exceptionIdent << ')' << m_catchBlock; - if (m_finallyBlock) - s << Endl << "finally " << m_finallyBlock; -} - -void ParameterNode::streamTo(SourceStream& s) -{ - s << m_ident; - for (ParameterNode* n = m_next.get(); n; n = n->m_next.get()) - s << ", " << n->m_ident; -} - -void FuncDeclNode::streamTo(SourceStream& s) -{ - s << Endl << "function " << m_ident << '(' << m_parameter << ')' << m_body; -} - -void FuncExprNode::streamTo(SourceStream& s) -{ - s << "function " << m_ident << '(' << m_parameter << ')' << m_body; -} - -} // namespace KJS diff --git a/kjs/number_object.h b/kjs/number_object.h deleted file mode 100644 index 36befed..0000000 --- a/kjs/number_object.h +++ /dev/null @@ -1,76 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef NUMBER_OBJECT_H_ -#define NUMBER_OBJECT_H_ - -#include "function_object.h" -#include "JSWrapperObject.h" - -namespace KJS { - - class NumberInstance : public JSWrapperObject { - public: - NumberInstance(JSObject* prototype); - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - }; - - /** - * @internal - * - * The initial value of Number.prototype (and thus all objects created - * with the Number constructor - */ - class NumberPrototype : public NumberInstance { - public: - NumberPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*); - }; - - /** - * @internal - * - * The initial value of the the global variable's "Number" property - */ - class NumberObjectImp : public InternalFunctionImp { - public: - NumberObjectImp(ExecState*, FunctionPrototype*, NumberPrototype*); - - virtual bool implementsConstruct() const; - virtual JSObject* construct(ExecState*, const List&); - - virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); - - bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - JSValue* getValueProperty(ExecState*, int token) const; - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - - enum { NaNValue, NegInfinity, PosInfinity, MaxValue, MinValue }; - - JSObject* construct(const List&); - }; - -} // namespace KJS - -#endif // NUMBER_OBJECT_H_ diff --git a/kjs/object.cpp b/kjs/object.cpp deleted file mode 100644 index d02af07..0000000 --- a/kjs/object.cpp +++ /dev/null @@ -1,681 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. - * Copyright (C) 2007 Eric Seidel (eric@webkit.org) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "object.h" - -#include "date_object.h" -#include "error_object.h" -#include "lookup.h" -#include "nodes.h" -#include "operations.h" -#include "PropertyNameArray.h" -#include -#include - -// maximum global call stack size. Protects against accidental or -// malicious infinite recursions. Define to -1 if you want no limit. -// In real-world testing it appears ok to bump the stack depth count to 500. -// This of course is dependent on stack frame size. -#define KJS_MAX_STACK 500 - -#define JAVASCRIPT_CALL_TRACING 0 -#define JAVASCRIPT_MARK_TRACING 0 - -#if JAVASCRIPT_CALL_TRACING -static bool _traceJavaScript = false; - -extern "C" { - void setTraceJavaScript(bool f) - { - _traceJavaScript = f; - } - - static bool traceJavaScript() - { - return _traceJavaScript; - } -} -#endif - -namespace KJS { - -// ------------------------------ Object --------------------------------------- - -JSValue *JSObject::call(ExecState *exec, JSObject *thisObj, const List &args) -{ - ASSERT(implementsCall()); - -#if KJS_MAX_STACK > 0 - static int depth = 0; // sum of all extant function calls - -#if JAVASCRIPT_CALL_TRACING - static bool tracing = false; - if (traceJavaScript() && !tracing) { - tracing = true; - for (int i = 0; i < depth; i++) - putchar (' '); - printf ("*** calling: %s\n", toString(exec).ascii()); - for (int j = 0; j < args.size(); j++) { - for (int i = 0; i < depth; i++) - putchar (' '); - printf ("*** arg[%d] = %s\n", j, args[j]->toString(exec).ascii()); - } - tracing = false; - } -#endif - - if (++depth > KJS_MAX_STACK) { - --depth; - return throwError(exec, RangeError, "Maximum call stack size exceeded."); - } -#endif - - JSValue *ret = callAsFunction(exec,thisObj,args); - -#if KJS_MAX_STACK > 0 - --depth; -#endif - -#if JAVASCRIPT_CALL_TRACING - if (traceJavaScript() && !tracing) { - tracing = true; - for (int i = 0; i < depth; i++) - putchar (' '); - printf ("*** returning: %s\n", ret->toString(exec).ascii()); - tracing = false; - } -#endif - - return ret; -} - -// ------------------------------ JSObject ------------------------------------ - -void JSObject::mark() -{ - JSCell::mark(); - -#if JAVASCRIPT_MARK_TRACING - static int markStackDepth = 0; - markStackDepth++; - for (int i = 0; i < markStackDepth; i++) - putchar('-'); - - printf("%s (%p)\n", className().UTF8String().c_str(), this); -#endif - - JSValue *proto = _proto; - if (!proto->marked()) - proto->mark(); - - _prop.mark(); - -#if JAVASCRIPT_MARK_TRACING - markStackDepth--; -#endif -} - -JSType JSObject::type() const -{ - return ObjectType; -} - -const ClassInfo *JSObject::classInfo() const -{ - return 0; -} - -UString JSObject::className() const -{ - const ClassInfo *ci = classInfo(); - if ( ci ) - return ci->className; - return "Object"; -} - -JSValue *JSObject::get(ExecState *exec, const Identifier &propertyName) const -{ - PropertySlot slot; - - if (const_cast(this)->getPropertySlot(exec, propertyName, slot)) - return slot.getValue(exec, const_cast(this), propertyName); - - return jsUndefined(); -} - -JSValue *JSObject::get(ExecState *exec, unsigned propertyName) const -{ - PropertySlot slot; - if (const_cast(this)->getPropertySlot(exec, propertyName, slot)) - return slot.getValue(exec, const_cast(this), propertyName); - - return jsUndefined(); -} - -bool JSObject::getPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot) -{ - JSObject *imp = this; - - while (true) { - if (imp->getOwnPropertySlot(exec, propertyName, slot)) - return true; - - JSValue *proto = imp->_proto; - if (!proto->isObject()) - break; - - imp = static_cast(proto); - } - - return false; -} - -bool JSObject::getOwnPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot) -{ - return getOwnPropertySlot(exec, Identifier::from(propertyName), slot); -} - -static void throwSetterError(ExecState *exec) -{ - throwError(exec, TypeError, "setting a property that has only a getter"); -} - -// ECMA 8.6.2.2 -void JSObject::put(ExecState* exec, const Identifier &propertyName, JSValue *value, int attr) -{ - ASSERT(value); - - if (propertyName == exec->propertyNames().underscoreProto) { - JSObject* proto = value->getObject(); - while (proto) { - if (proto == this) - throwError(exec, GeneralError, "cyclic __proto__ value"); - proto = proto->prototype() ? proto->prototype()->getObject() : 0; - } - - setPrototype(value); - return; - } - - // The put calls from JavaScript execution either have no attributes set, or in some cases - // have DontDelete set. For those calls, respect the ReadOnly flag. - bool checkReadOnly = !(attr & ~DontDelete); - - // Check if there are any setters or getters in the prototype chain - JSObject *obj = this; - bool hasGettersOrSetters = false; - while (true) { - if (obj->_prop.hasGetterSetterProperties()) { - hasGettersOrSetters = true; - break; - } - - if (!obj->_proto->isObject()) - break; - - obj = static_cast(obj->_proto); - } - - if (hasGettersOrSetters) { - if (checkReadOnly && !canPut(exec, propertyName)) - return; - - obj = this; - while (true) { - unsigned attributes; - if (JSValue *gs = obj->_prop.get(propertyName, attributes)) { - if (attributes & GetterSetter) { - JSObject *setterFunc = static_cast(gs)->getSetter(); - - if (!setterFunc) { - throwSetterError(exec); - return; - } - - List args; - args.append(value); - - setterFunc->call(exec, this, args); - return; - } else { - // If there's an existing property on the object or one of its - // prototype it should be replaced, so we just break here. - break; - } - } - - if (!obj->_proto->isObject()) - break; - - obj = static_cast(obj->_proto); - } - } - - _prop.put(propertyName, value, attr, checkReadOnly); -} - -void JSObject::put(ExecState *exec, unsigned propertyName, - JSValue *value, int attr) -{ - put(exec, Identifier::from(propertyName), value, attr); -} - -// ECMA 8.6.2.3 -bool JSObject::canPut(ExecState *, const Identifier &propertyName) const -{ - unsigned attributes; - - // Don't look in the prototype here. We can always put an override - // in the object, even if the prototype has a ReadOnly property. - // Also, there is no need to check the static property table, as this - // would have been done by the subclass already. - - if (!_prop.get(propertyName, attributes)) - return true; - - return !(attributes & ReadOnly); -} - -// ECMA 8.6.2.4 -bool JSObject::hasProperty(ExecState *exec, const Identifier &propertyName) const -{ - PropertySlot slot; - return const_cast(this)->getPropertySlot(exec, propertyName, slot); -} - -bool JSObject::hasProperty(ExecState *exec, unsigned propertyName) const -{ - PropertySlot slot; - return const_cast(this)->getPropertySlot(exec, propertyName, slot); -} - -// ECMA 8.6.2.5 -bool JSObject::deleteProperty(ExecState* /*exec*/, const Identifier &propertyName) -{ - unsigned attributes; - JSValue *v = _prop.get(propertyName, attributes); - if (v) { - if ((attributes & DontDelete)) - return false; - _prop.remove(propertyName); - if (attributes & GetterSetter) - _prop.setHasGetterSetterProperties(_prop.containsGettersOrSetters()); - return true; - } - - // Look in the static hashtable of properties - const HashEntry* entry = findPropertyHashEntry(propertyName); - if (entry && entry->attr & DontDelete) - return false; // this builtin property can't be deleted - return true; -} - -bool JSObject::hasOwnProperty(ExecState* exec, const Identifier& propertyName) const -{ - PropertySlot slot; - return const_cast(this)->getOwnPropertySlot(exec, propertyName, slot); -} - -bool JSObject::deleteProperty(ExecState *exec, unsigned propertyName) -{ - return deleteProperty(exec, Identifier::from(propertyName)); -} - -static ALWAYS_INLINE JSValue *tryGetAndCallProperty(ExecState *exec, const JSObject *object, const Identifier &propertyName) { - JSValue *v = object->get(exec, propertyName); - if (v->isObject()) { - JSObject *o = static_cast(v); - if (o->implementsCall()) { // spec says "not primitive type" but ... - JSObject *thisObj = const_cast(object); - JSValue* def = o->call(exec, thisObj, exec->emptyList()); - JSType defType = def->type(); - ASSERT(defType != GetterSetterType); - if (defType != ObjectType) - return def; - } - } - return NULL; -} - -bool JSObject::getPrimitiveNumber(ExecState* exec, double& number, JSValue*& result) -{ - result = defaultValue(exec, NumberType); - number = result->toNumber(exec); - return !result->isString(); -} - -// ECMA 8.6.2.6 -JSValue* JSObject::defaultValue(ExecState* exec, JSType hint) const -{ - /* Prefer String for Date objects */ - if ((hint == StringType) || (hint != NumberType && _proto == exec->lexicalGlobalObject()->datePrototype())) { - if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().toString)) - return v; - if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().valueOf)) - return v; - } else { - if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().valueOf)) - return v; - if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().toString)) - return v; - } - - if (exec->hadException()) - return exec->exception(); - - return throwError(exec, TypeError, "No default value"); -} - -const HashEntry* JSObject::findPropertyHashEntry(const Identifier& propertyName) const -{ - for (const ClassInfo *info = classInfo(); info; info = info->parentClass) { - if (const HashTable *propHashTable = info->propHashTable) { - if (const HashEntry *e = Lookup::findEntry(propHashTable, propertyName)) - return e; - } - } - return 0; -} - -void JSObject::defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunc) -{ - JSValue *o = getDirect(propertyName); - GetterSetterImp *gs; - - if (o && o->type() == GetterSetterType) { - gs = static_cast(o); - } else { - gs = new GetterSetterImp; - putDirect(propertyName, gs, GetterSetter); - } - - _prop.setHasGetterSetterProperties(true); - gs->setGetter(getterFunc); -} - -void JSObject::defineSetter(ExecState*, const Identifier& propertyName, JSObject* setterFunc) -{ - JSValue *o = getDirect(propertyName); - GetterSetterImp *gs; - - if (o && o->type() == GetterSetterType) { - gs = static_cast(o); - } else { - gs = new GetterSetterImp; - putDirect(propertyName, gs, GetterSetter); - } - - _prop.setHasGetterSetterProperties(true); - gs->setSetter(setterFunc); -} - -bool JSObject::implementsConstruct() const -{ - return false; -} - -JSObject* JSObject::construct(ExecState*, const List& /*args*/) -{ - ASSERT(false); - return NULL; -} - -JSObject* JSObject::construct(ExecState* exec, const List& args, const Identifier& /*functionName*/, const UString& /*sourceURL*/, int /*lineNumber*/) -{ - return construct(exec, args); -} - -bool JSObject::implementsCall() const -{ - return false; -} - -JSValue *JSObject::callAsFunction(ExecState* /*exec*/, JSObject* /*thisObj*/, const List &/*args*/) -{ - ASSERT(false); - return NULL; -} - -bool JSObject::implementsHasInstance() const -{ - return false; -} - -bool JSObject::hasInstance(ExecState* exec, JSValue* value) -{ - JSValue* proto = get(exec, exec->propertyNames().prototype); - if (!proto->isObject()) { - throwError(exec, TypeError, "intanceof called on an object with an invalid prototype property."); - return false; - } - - if (!value->isObject()) - return false; - - JSObject* o = static_cast(value); - while ((o = o->prototype()->getObject())) { - if (o == proto) - return true; - } - return false; -} - -bool JSObject::propertyIsEnumerable(ExecState*, const Identifier& propertyName) const -{ - unsigned attributes; - - if (!getPropertyAttributes(propertyName, attributes)) - return false; - else - return !(attributes & DontEnum); -} - -bool JSObject::getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const -{ - if (_prop.get(propertyName, attributes)) - return true; - - // Look in the static hashtable of properties - const HashEntry* e = findPropertyHashEntry(propertyName); - if (e) { - attributes = e->attr; - return true; - } - - return false; -} - -void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) -{ - _prop.getEnumerablePropertyNames(propertyNames); - - // Add properties from the static hashtable of properties - const ClassInfo *info = classInfo(); - while (info) { - if (info->propHashTable) { - int size = info->propHashTable->size; - const HashEntry *e = info->propHashTable->entries; - for (int i = 0; i < size; ++i, ++e) { - if (e->s && !(e->attr & DontEnum)) - propertyNames.add(e->s); - } - } - info = info->parentClass; - } - if (_proto->isObject()) - static_cast(_proto)->getPropertyNames(exec, propertyNames); -} - -bool JSObject::toBoolean(ExecState*) const -{ - return true; -} - -double JSObject::toNumber(ExecState *exec) const -{ - JSValue *prim = toPrimitive(exec,NumberType); - if (exec->hadException()) // should be picked up soon in nodes.cpp - return 0.0; - return prim->toNumber(exec); -} - -UString JSObject::toString(ExecState *exec) const -{ - JSValue *prim = toPrimitive(exec,StringType); - if (exec->hadException()) // should be picked up soon in nodes.cpp - return ""; - return prim->toString(exec); -} - -JSObject *JSObject::toObject(ExecState*) const -{ - return const_cast(this); -} - -void JSObject::putDirect(const Identifier &propertyName, JSValue *value, int attr) -{ - _prop.put(propertyName, value, attr); -} - -void JSObject::putDirect(const Identifier &propertyName, int value, int attr) -{ - _prop.put(propertyName, jsNumber(value), attr); -} - -void JSObject::removeDirect(const Identifier &propertyName) -{ - _prop.remove(propertyName); -} - -void JSObject::putDirectFunction(InternalFunctionImp* func, int attr) -{ - putDirect(func->functionName(), func, attr); -} - -void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue **location) -{ - GetterSetterImp *gs = static_cast(*location); - JSObject *getterFunc = gs->getGetter(); - if (getterFunc) - slot.setGetterSlot(this, getterFunc); - else - slot.setUndefined(this); -} - -// ------------------------------ Error ---------------------------------------- - -const char * const errorNamesArr[] = { - I18N_NOOP("Error"), // GeneralError - I18N_NOOP("Evaluation error"), // EvalError - I18N_NOOP("Range error"), // RangeError - I18N_NOOP("Reference error"), // ReferenceError - I18N_NOOP("Syntax error"), // SyntaxError - I18N_NOOP("Type error"), // TypeError - I18N_NOOP("URI error"), // URIError -}; - -const char * const * const Error::errorNames = errorNamesArr; - -JSObject *Error::create(ExecState *exec, ErrorType errtype, const UString &message, - int lineno, intptr_t sourceID, const UString &sourceURL) -{ - JSObject *cons; - switch (errtype) { - case EvalError: - cons = exec->lexicalGlobalObject()->evalErrorConstructor(); - break; - case RangeError: - cons = exec->lexicalGlobalObject()->rangeErrorConstructor(); - break; - case ReferenceError: - cons = exec->lexicalGlobalObject()->referenceErrorConstructor(); - break; - case SyntaxError: - cons = exec->lexicalGlobalObject()->syntaxErrorConstructor(); - break; - case TypeError: - cons = exec->lexicalGlobalObject()->typeErrorConstructor(); - break; - case URIError: - cons = exec->lexicalGlobalObject()->URIErrorConstructor(); - break; - default: - cons = exec->lexicalGlobalObject()->errorConstructor(); - break; - } - - List args; - if (message.isEmpty()) - args.append(jsString(errorNames[errtype])); - else - args.append(jsString(message)); - JSObject *err = static_cast(cons->construct(exec,args)); - - if (lineno != -1) - err->put(exec, "line", jsNumber(lineno)); - if (sourceID != -1) - err->put(exec, "sourceID", jsNumber(sourceID)); - - if(!sourceURL.isNull()) - err->put(exec, "sourceURL", jsString(sourceURL)); - - return err; -} - -JSObject *Error::create(ExecState *exec, ErrorType type, const char *message) -{ - return create(exec, type, message, -1, -1, NULL); -} - -JSObject *throwError(ExecState *exec, ErrorType type) -{ - JSObject *error = Error::create(exec, type, UString(), -1, -1, NULL); - exec->setException(error); - return error; -} - -JSObject *throwError(ExecState *exec, ErrorType type, const UString &message) -{ - JSObject *error = Error::create(exec, type, message, -1, -1, NULL); - exec->setException(error); - return error; -} - -JSObject *throwError(ExecState *exec, ErrorType type, const char *message) -{ - JSObject *error = Error::create(exec, type, message, -1, -1, NULL); - exec->setException(error); - return error; -} - -JSObject *throwError(ExecState *exec, ErrorType type, const UString &message, int line, intptr_t sourceID, const UString &sourceURL) -{ - JSObject *error = Error::create(exec, type, message, line, sourceID, sourceURL); - exec->setException(error); - return error; -} - -} // namespace KJS diff --git a/kjs/object.h b/kjs/object.h deleted file mode 100644 index 93cc0ac..0000000 --- a/kjs/object.h +++ /dev/null @@ -1,605 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_OBJECT_H -#define KJS_OBJECT_H - -#include "CommonIdentifiers.h" -#include "ExecState.h" -#include "JSType.h" -#include "list.h" -#include "property_map.h" -#include "property_slot.h" -#include "scope_chain.h" - -namespace KJS { - - class InternalFunctionImp; - class PropertyNameArray; - - struct HashEntry; - struct HashTable; - - // ECMA 262-3 8.6.1 - // Property attributes - enum Attribute { None = 0, - ReadOnly = 1 << 1, // property can be only read, not written - DontEnum = 1 << 2, // property doesn't appear in (for .. in ..) - DontDelete = 1 << 3, // property can't be deleted - Internal = 1 << 4, // an internal property, set to bypass checks - Function = 1 << 5, // property is a function - only used by static hashtables - GetterSetter = 1 << 6 }; // property is a getter or setter - - /** - * Class Information - */ - struct ClassInfo { - /** - * A string denoting the class name. Example: "Window". - */ - const char* className; - /** - * Pointer to the class information of the base class. - * 0L if there is none. - */ - const ClassInfo* parentClass; - /** - * Static hash-table of properties. - */ - const HashTable* propHashTable; - }; - - // This is an internal value object which stores getter and setter functions - // for a property. - class GetterSetterImp : public JSCell { - public: - JSType type() const { return GetterSetterType; } - - GetterSetterImp() : getter(0), setter(0) { } - - virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const; - virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); - virtual bool toBoolean(ExecState *exec) const; - virtual double toNumber(ExecState *exec) const; - virtual UString toString(ExecState *exec) const; - virtual JSObject *toObject(ExecState *exec) const; - - virtual void mark(); - - JSObject *getGetter() { return getter; } - void setGetter(JSObject *g) { getter = g; } - JSObject *getSetter() { return setter; } - void setSetter(JSObject *s) { setter = s; } - - private: - JSObject *getter; - JSObject *setter; - }; - - class JSObject : public JSCell { - public: - /** - * Creates a new JSObject with the specified prototype - * - * @param proto The prototype - */ - JSObject(JSValue* proto); - - /** - * Creates a new JSObject with a prototype of jsNull() - * (that is, the ECMAScript "null" value, not a null object pointer). - */ - JSObject(); - - virtual void mark(); - virtual JSType type() const; - - /** - * A pointer to a ClassInfo struct for this class. This provides a basic - * facility for run-time type information, and can be used to check an - * object's class an inheritance (see inherits()). This should - * always return a statically declared pointer, or 0 to indicate that - * there is no class information. - * - * This is primarily useful if you have application-defined classes that you - * wish to check against for casting purposes. - * - * For example, to specify the class info for classes FooImp and BarImp, - * where FooImp inherits from BarImp, you would add the following in your - * class declarations: - * - * \code - * class BarImp : public JSObject { - * virtual const ClassInfo *classInfo() const { return &info; } - * static const ClassInfo info; - * // ... - * }; - * - * class FooImp : public JSObject { - * virtual const ClassInfo *classInfo() const { return &info; } - * static const ClassInfo info; - * // ... - * }; - * \endcode - * - * And in your source file: - * - * \code - * const ClassInfo BarImp::info = { "Bar", 0, 0 }; // no parent class - * const ClassInfo FooImp::info = { "Foo", &BarImp::info, 0 }; - * \endcode - * - * @see inherits() - */ - virtual const ClassInfo *classInfo() const; - - /** - * Checks whether this object inherits from the class with the specified - * classInfo() pointer. This requires that both this class and the other - * class return a non-NULL pointer for their classInfo() methods (otherwise - * it will return false). - * - * For example, for two JSObject pointers obj1 and obj2, you can check - * if obj1's class inherits from obj2's class using the following: - * - * if (obj1->inherits(obj2->classInfo())) { - * // ... - * } - * - * If you have a handle to a statically declared ClassInfo, such as in the - * classInfo() example, you can check for inheritance without needing - * an instance of the other class: - * - * if (obj1->inherits(FooImp::info)) { - * // ... - * } - * - * @param cinfo The ClassInfo pointer for the class you want to check - * inheritance against. - * @return true if this object's class inherits from class with the - * ClassInfo pointer specified in cinfo - */ - bool inherits(const ClassInfo *cinfo) const; - - // internal properties (ECMA 262-3 8.6.2) - - /** - * Returns the prototype of this object. Note that this is not the same as - * the "prototype" property. - * - * See ECMA 8.6.2 - * - * @return The object's prototype - */ - JSValue *prototype() const; - void setPrototype(JSValue *proto); - - /** - * Returns the class name of the object - * - * See ECMA 8.6.2 - * - * @return The object's class name - */ - /** - * Implementation of the [[Class]] internal property (implemented by all - * Objects) - * - * The default implementation uses classInfo(). - * You should either implement classInfo(), or - * if you simply need a classname, you can reimplement className() - * instead. - */ - virtual UString className() const; - - /** - * Retrieves the specified property from the object. If neither the object - * or any other object in it's prototype chain have the property, this - * function will return Undefined. - * - * See ECMA 8.6.2.1 - * - * @param exec The current execution state - * @param propertyName The name of the property to retrieve - * - * @return The specified property, or Undefined - */ - JSValue *get(ExecState *exec, const Identifier &propertyName) const; - JSValue *get(ExecState *exec, unsigned propertyName) const; - - bool getPropertySlot(ExecState *, const Identifier&, PropertySlot&); - bool getPropertySlot(ExecState *, unsigned, PropertySlot&); - - virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); - virtual bool getOwnPropertySlot(ExecState *, unsigned index, PropertySlot&); - - /** - * Sets the specified property. - * - * See ECMA 8.6.2.2 - * - * @param exec The current execution state - * @param propertyName The name of the property to set - * @param propertyValue The value to set - */ - virtual void put(ExecState* exec, const Identifier &propertyName, JSValue* value, int attr = None); - virtual void put(ExecState* exec, unsigned propertyName, JSValue* value, int attr = None); - - /** - * Used to check whether or not a particular property is allowed to be set - * on an object - * - * See ECMA 8.6.2.3 - * - * @param exec The current execution state - * @param propertyName The name of the property - * @return true if the property can be set, otherwise false - */ - /** - * Implementation of the [[CanPut]] internal property (implemented by all - * Objects) - */ - virtual bool canPut(ExecState *exec, const Identifier &propertyName) const; - - /** - * Checks if a property is enumerable, that is if it doesn't have the DontEnum - * flag set - * - * See ECMA 15.2.4 - * @param exec The current execution state - * @param propertyName The name of the property - * @return true if the property is enumerable, otherwise false - */ - bool propertyIsEnumerable(ExecState *exec, const Identifier &propertyName) const; - - /** - * Checks to see whether the object (or any object in it's prototype chain) - * has a property with the specified name. - * - * See ECMA 8.6.2.4 - * - * @param exec The current execution state - * @param propertyName The name of the property to check for - * @return true if the object has the property, otherwise false - */ - bool hasProperty(ExecState*, const Identifier&) const; - bool hasProperty(ExecState*, unsigned) const; - bool hasOwnProperty(ExecState*, const Identifier&) const; - - /** - * Removes the specified property from the object. - * - * See ECMA 8.6.2.5 - * - * @param exec The current execution state - * @param propertyName The name of the property to delete - * @return true if the property was successfully deleted or did not - * exist on the object. false if deleting the specified property is not - * allowed. - */ - virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName); - virtual bool deleteProperty(ExecState *exec, unsigned propertyName); - - /** - * Converts the object into a primitive value. The value return may differ - * depending on the supplied hint - * - * See ECMA 8.6.2.6 - * - * @param exec The current execution state - * @param hint The desired primitive type to convert to - * @return A primitive value converted from the objetc. Note that the - * type of primitive value returned may not be the same as the requested - * hint. - */ - /** - * Implementation of the [[DefaultValue]] internal property (implemented by - * all Objects) - */ - virtual JSValue *defaultValue(ExecState *exec, JSType hint) const; - - /** - * Whether or not the object implements the construct() method. If this - * returns false you should not call the construct() method on this - * object (typically, an assertion will fail to indicate this). - * - * @return true if this object implements the construct() method, otherwise - * false - */ - virtual bool implementsConstruct() const; - - /** - * Creates a new object based on this object. Typically this means the - * following: - * 1. A new object is created - * 2. The prototype of the new object is set to the value of this object's - * "prototype" property - * 3. The call() method of this object is called, with the new object - * passed as the this value - * 4. The new object is returned - * - * In some cases, Host objects may differ from these semantics, although - * this is discouraged. - * - * If an error occurs during construction, the execution state's exception - * will be set. This can be tested for with ExecState::hadException(). - * Under some circumstances, the exception object may also be returned. - * - * Note: This function should not be called if implementsConstruct() returns - * false, in which case it will result in an assertion failure. - * - * @param exec The current execution state - * @param args The arguments to be passed to call() once the new object has - * been created - * @return The newly created & initialized object - */ - /** - * Implementation of the [[Construct]] internal property - */ - virtual JSObject* construct(ExecState* exec, const List& args); - virtual JSObject* construct(ExecState* exec, const List& args, const Identifier& functionName, const UString& sourceURL, int lineNumber); - - /** - * Whether or not the object implements the call() method. If this returns - * false you should not call the call() method on this object (typically, - * an assertion will fail to indicate this). - * - * @return true if this object implements the call() method, otherwise - * false - */ - virtual bool implementsCall() const; - - /** - * Calls this object as if it is a function. - * - * Note: This function should not be called if implementsCall() returns - * false, in which case it will result in an assertion failure. - * - * See ECMA 8.6.2.3 - * - * @param exec The current execution state - * @param thisObj The obj to be used as "this" within function execution. - * Note that in most cases this will be different from the C++ "this" - * object. For example, if the ECMAScript code "window.location->toString()" - * is executed, call() will be invoked on the C++ object which implements - * the toString method, with the thisObj being window.location - * @param args List of arguments to be passed to the function - * @return The return value from the function - */ - JSValue *call(ExecState *exec, JSObject *thisObj, const List &args); - virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); - - /** - * Whether or not the object implements the hasInstance() method. If this - * returns false you should not call the hasInstance() method on this - * object (typically, an assertion will fail to indicate this). - * - * @return true if this object implements the hasInstance() method, - * otherwise false - */ - virtual bool implementsHasInstance() const; - - /** - * Checks whether value delegates behavior to this object. Used by the - * instanceof operator. - * - * @param exec The current execution state - * @param value The value to check - * @return true if value delegates behavior to this object, otherwise - * false - */ - virtual bool hasInstance(ExecState *exec, JSValue *value); - - virtual void getPropertyNames(ExecState*, PropertyNameArray&); - - virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const; - virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); - virtual bool toBoolean(ExecState *exec) const; - virtual double toNumber(ExecState *exec) const; - virtual UString toString(ExecState *exec) const; - virtual JSObject *toObject(ExecState *exec) const; - - bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const; - - // WebCore uses this to make document.all and style.filter undetectable - virtual bool masqueradeAsUndefined() const { return false; } - - // This get function only looks at the property map. - // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want - // to look up in the prototype, it might already exist there) - JSValue *getDirect(const Identifier& propertyName) const - { return _prop.get(propertyName); } - JSValue **getDirectLocation(const Identifier& propertyName) - { return _prop.getLocation(propertyName); } - void putDirect(const Identifier &propertyName, JSValue *value, int attr = 0); - void putDirect(const Identifier &propertyName, int value, int attr = 0); - void removeDirect(const Identifier &propertyName); - - // convenience to add a function property under the function's own built-in name - void putDirectFunction(InternalFunctionImp*, int attr = 0); - - void fillGetterPropertySlot(PropertySlot& slot, JSValue **location); - - void defineGetter(ExecState *exec, const Identifier& propertyName, JSObject *getterFunc); - void defineSetter(ExecState *exec, const Identifier& propertyName, JSObject *setterFunc); - - void saveProperties(SavedProperties &p) const { _prop.save(p); } - void restoreProperties(const SavedProperties &p) { _prop.restore(p); } - - virtual bool isActivationObject() { return false; } - virtual bool isGlobalObject() const { return false; } - - protected: - PropertyMap _prop; - - private: - const HashEntry* findPropertyHashEntry( const Identifier& propertyName ) const; - JSValue *_proto; - }; - - /** - * Types of Native Errors available. For custom errors, GeneralError - * should be used. - */ - enum ErrorType { GeneralError = 0, - EvalError = 1, - RangeError = 2, - ReferenceError = 3, - SyntaxError = 4, - TypeError = 5, - URIError = 6, - TimeoutError = 7 - }; - - /** - * @short Factory methods for error objects. - */ - class Error { - public: - /** - * Factory method for error objects. - * - * @param exec The current execution state - * @param errtype Type of error. - * @param message Optional error message. - * @param lineNumber Optional line number. - * @param sourceId Optional source id. - * @param sourceURL Optional source URL. - */ - static JSObject *create(ExecState *, ErrorType, const UString &message, int lineNumber, intptr_t sourceID, const UString &sourceURL); - static JSObject *create(ExecState *, ErrorType, const char *message); - - /** - * Array of error names corresponding to ErrorType - */ - static const char * const * const errorNames; - }; - -JSObject *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, intptr_t sourceID, const UString &sourceURL); -JSObject *throwError(ExecState *, ErrorType, const UString &message); -JSObject *throwError(ExecState *, ErrorType, const char *message); -JSObject *throwError(ExecState *, ErrorType); - -inline JSObject::JSObject(JSValue* proto) - : _proto(proto) -{ - ASSERT(proto); -} - -inline JSObject::JSObject() - : _proto(jsNull()) -{ -} - -inline JSValue *JSObject::prototype() const -{ - return _proto; -} - -inline void JSObject::setPrototype(JSValue *proto) -{ - ASSERT(proto); - _proto = proto; -} - -inline bool JSObject::inherits(const ClassInfo *info) const -{ - for (const ClassInfo *ci = classInfo(); ci; ci = ci->parentClass) - if (ci == info) - return true; - return false; -} - -// this method is here to be after the inline declaration of JSObject::inherits -inline bool JSCell::isObject(const ClassInfo *info) const -{ - return isObject() && static_cast(this)->inherits(info); -} - -// this method is here to be after the inline declaration of JSCell::isObject -inline bool JSValue::isObject(const ClassInfo *c) const -{ - return !JSImmediate::isImmediate(this) && asCell()->isObject(c); -} - -// It may seem crazy to inline a function this large but it makes a big difference -// since this is function very hot in variable lookup -inline bool JSObject::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) -{ - JSObject *object = this; - while (true) { - if (object->getOwnPropertySlot(exec, propertyName, slot)) - return true; - - JSValue *proto = object->_proto; - if (!proto->isObject()) - return false; - - object = static_cast(proto); - } -} - -// It may seem crazy to inline a function this large, especially a virtual function, -// but it makes a big difference to property lookup that derived classes can inline their -// base class call to this. -ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - if (JSValue **location = getDirectLocation(propertyName)) { - if (_prop.hasGetterSetterProperties() && location[0]->type() == GetterSetterType) - fillGetterPropertySlot(slot, location); - else - slot.setValueSlot(this, location); - return true; - } - - // non-standard Netscape extension - if (propertyName == exec->propertyNames().underscoreProto) { - slot.setValueSlot(this, &_proto); - return true; - } - - return false; -} - -inline void ScopeChain::release() -{ - // This function is only called by deref(), - // Deref ensures these conditions are true. - ASSERT(_node && _node->refCount == 0); - ScopeChainNode *n = _node; - do { - ScopeChainNode *next = n->next; - delete n; - n = next; - } while (n && --n->refCount == 0); -} - -inline JSValue* JSObject::toPrimitive(ExecState* exec, JSType preferredType) const -{ - return defaultValue(exec, preferredType); -} - -} // namespace - -#endif // KJS_OBJECT_H diff --git a/kjs/object_object.cpp b/kjs/object_object.cpp deleted file mode 100644 index 90eaa93..0000000 --- a/kjs/object_object.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "object_object.h" - -#include "JSGlobalObject.h" -#include "operations.h" -#include "function_object.h" -#include - -namespace KJS { - -// ------------------------------ ObjectPrototype -------------------------------- - -static JSValue* objectProtoFuncValueOf(ExecState*, JSObject*, const List&); -static JSValue* objectProtoFuncHasOwnProperty(ExecState*, JSObject*, const List&); -static JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject*, const List&); -static JSValue* objectProtoFuncDefineGetter(ExecState*, JSObject*, const List&); -static JSValue* objectProtoFuncDefineSetter(ExecState*, JSObject*, const List&); -static JSValue* objectProtoFuncLookupGetter(ExecState*, JSObject*, const List&); -static JSValue* objectProtoFuncLookupSetter(ExecState*, JSObject*, const List&); -static JSValue* objectProtoFuncPropertyIsEnumerable(ExecState*, JSObject*, const List&); -static JSValue* objectProtoFuncToLocaleString(ExecState*, JSObject*, const List&); - -ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* functionPrototype) - : JSObject() // [[Prototype]] is null -{ - static const Identifier* hasOwnPropertyPropertyName = new Identifier("hasOwnProperty"); - static const Identifier* propertyIsEnumerablePropertyName = new Identifier("propertyIsEnumerable"); - static const Identifier* isPrototypeOfPropertyName = new Identifier("isPrototypeOf"); - static const Identifier* defineGetterPropertyName = new Identifier("__defineGetter__"); - static const Identifier* defineSetterPropertyName = new Identifier("__defineSetter__"); - static const Identifier* lookupGetterPropertyName = new Identifier("__lookupGetter__"); - static const Identifier* lookupSetterPropertyName = new Identifier("__lookupSetter__"); - - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *hasOwnPropertyPropertyName, objectProtoFuncHasOwnProperty), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *propertyIsEnumerablePropertyName, objectProtoFuncPropertyIsEnumerable), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *isPrototypeOfPropertyName, objectProtoFuncIsPrototypeOf), DontEnum); - - // Mozilla extensions - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, *defineGetterPropertyName, objectProtoFuncDefineGetter), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, *defineSetterPropertyName, objectProtoFuncDefineSetter), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *lookupGetterPropertyName, objectProtoFuncLookupGetter), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *lookupSetterPropertyName, objectProtoFuncLookupSetter), DontEnum); -} - - -// ------------------------------ Functions -------------------------------- - -// ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5, 15.2.4.7 - -JSValue* objectProtoFuncValueOf(ExecState*, JSObject* thisObj, const List&) -{ - return thisObj; -} - -JSValue* objectProtoFuncHasOwnProperty(ExecState* exec, JSObject* thisObj, const List& args) -{ - return jsBoolean(thisObj->hasOwnProperty(exec, Identifier(args[0]->toString(exec)))); -} - -JSValue* objectProtoFuncIsPrototypeOf(ExecState*, JSObject* thisObj, const List& args) -{ - if (!args[0]->isObject()) - return jsBoolean(false); - - JSValue* v = static_cast(args[0])->prototype(); - - while (true) { - if (!v->isObject()) - return jsBoolean(false); - if (thisObj == static_cast(v)) - return jsBoolean(true); - v = static_cast(v)->prototype(); - } -} - -JSValue* objectProtoFuncDefineGetter(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!args[1]->isObject() || !static_cast(args[1])->implementsCall()) - return throwError(exec, SyntaxError, "invalid getter usage"); - - thisObj->defineGetter(exec, Identifier(args[0]->toString(exec)), static_cast(args[1])); - return jsUndefined(); -} - -JSValue* objectProtoFuncDefineSetter(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!args[1]->isObject() || !static_cast(args[1])->implementsCall()) - return throwError(exec, SyntaxError, "invalid setter usage"); - - thisObj->defineSetter(exec, Identifier(args[0]->toString(exec)), static_cast(args[1])); - return jsUndefined(); -} - -JSValue* objectProtoFuncLookupGetter(ExecState* exec, JSObject* thisObj, const List& args) -{ - Identifier propertyName = Identifier(args[0]->toString(exec)); - JSObject* obj = thisObj; - while (true) { - JSValue* v = obj->getDirect(propertyName); - if (v) { - if (v->type() != GetterSetterType) - return jsUndefined(); - JSObject* funcObj = static_cast(v)->getGetter(); - if (!funcObj) - return jsUndefined(); - return funcObj; - } - - if (!obj->prototype() || !obj->prototype()->isObject()) - return jsUndefined(); - obj = static_cast(obj->prototype()); - } -} - -JSValue* objectProtoFuncLookupSetter(ExecState* exec, JSObject* thisObj, const List& args) -{ - Identifier propertyName = Identifier(args[0]->toString(exec)); - JSObject* obj = thisObj; - while (true) { - JSValue* v = obj->getDirect(propertyName); - if (v) { - if (v->type() != GetterSetterType) - return jsUndefined(); - JSObject* funcObj = static_cast(v)->getSetter(); - if (!funcObj) - return jsUndefined(); - return funcObj; - } - - if (!obj->prototype() || !obj->prototype()->isObject()) - return jsUndefined(); - obj = static_cast(obj->prototype()); - } -} - -JSValue* objectProtoFuncPropertyIsEnumerable(ExecState* exec, JSObject* thisObj, const List& args) -{ - return jsBoolean(thisObj->propertyIsEnumerable(exec, Identifier(args[0]->toString(exec)))); -} - -JSValue* objectProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const List&) -{ - return jsString(thisObj->toString(exec)); -} - -JSValue* objectProtoFuncToString(ExecState*, JSObject* thisObj, const List&) -{ - return jsString("[object " + thisObj->className() + "]"); -} - -// ------------------------------ ObjectObjectImp -------------------------------- - -ObjectObjectImp::ObjectObjectImp(ExecState* exec, ObjectPrototype* objProto, FunctionPrototype* funcProto) - : InternalFunctionImp(funcProto, "Object") -{ - // ECMA 15.2.3.1 - putDirect(exec->propertyNames().prototype, objProto, DontEnum|DontDelete|ReadOnly); - - // no. of arguments for constructor - putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); -} - - -bool ObjectObjectImp::implementsConstruct() const -{ - return true; -} - -// ECMA 15.2.2 -JSObject* ObjectObjectImp::construct(ExecState* exec, const List& args) -{ - JSValue* arg = args[0]; - switch (arg->type()) { - case StringType: - case BooleanType: - case NumberType: - case ObjectType: - return arg->toObject(exec); - case NullType: - case UndefinedType: - return new JSObject(exec->lexicalGlobalObject()->objectPrototype()); - default: - ASSERT_NOT_REACHED(); - return 0; - } -} - -JSValue* ObjectObjectImp::callAsFunction(ExecState* exec, JSObject* /*thisObj*/, const List &args) -{ - return construct(exec, args); -} - -} // namespace KJS diff --git a/kjs/operations.cpp b/kjs/operations.cpp deleted file mode 100644 index d2b3892..0000000 --- a/kjs/operations.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "operations.h" - -#include "internal.h" -#include "object.h" -#include -#include -#include - -#if HAVE(FLOAT_H) -#include -#endif - -namespace KJS { - -// ECMA 11.9.3 -bool equal(ExecState *exec, JSValue *v1, JSValue *v2) -{ - JSType t1 = v1->type(); - JSType t2 = v2->type(); - - if (t1 != t2) { - if (t1 == UndefinedType) - t1 = NullType; - if (t2 == UndefinedType) - t2 = NullType; - - if (t1 == BooleanType) - t1 = NumberType; - if (t2 == BooleanType) - t2 = NumberType; - - if (t1 == NumberType && t2 == StringType) { - // use toNumber - } else if (t1 == StringType && t2 == NumberType) - t1 = NumberType; - // use toNumber - else { - if ((t1 == StringType || t1 == NumberType) && t2 == ObjectType) { - v2 = v2->toPrimitive(exec); - if (exec->hadException()) - return false; - return equal(exec, v1, v2); - } - if (t1 == NullType && t2 == ObjectType) - return static_cast(v2)->masqueradeAsUndefined(); - if (t1 == ObjectType && (t2 == StringType || t2 == NumberType)) { - v1 = v1->toPrimitive(exec); - if (exec->hadException()) - return false; - return equal(exec, v1, v2); - } - if (t1 == ObjectType && t2 == NullType) - return static_cast(v1)->masqueradeAsUndefined(); - if (t1 != t2) - return false; - } - } - - if (t1 == UndefinedType || t1 == NullType) - return true; - - if (t1 == NumberType) { - double d1 = v1->toNumber(exec); - double d2 = v2->toNumber(exec); - return d1 == d2; - } - - if (t1 == StringType) - return static_cast(v1)->value() == static_cast(v2)->value(); - - if (t1 == BooleanType) - return v1->toBoolean(exec) == v2->toBoolean(exec); - - // types are Object - return v1 == v2; -} - -bool strictEqual(ExecState *exec, JSValue *v1, JSValue *v2) -{ - JSType t1 = v1->type(); - JSType t2 = v2->type(); - - if (t1 != t2) - return false; - if (t1 == UndefinedType || t1 == NullType) - return true; - if (t1 == NumberType) { - double n1 = v1->toNumber(exec); - double n2 = v2->toNumber(exec); - if (n1 == n2) - return true; - return false; - } else if (t1 == StringType) - return v1->toString(exec) == v2->toString(exec); - else if (t2 == BooleanType) - return v1->toBoolean(exec) == v2->toBoolean(exec); - - if (v1 == v2) - return true; - /* TODO: joined objects */ - - return false; -} - -} diff --git a/kjs/property_map.cpp b/kjs/property_map.cpp deleted file mode 100644 index 1da4917..0000000 --- a/kjs/property_map.cpp +++ /dev/null @@ -1,850 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "property_map.h" - -#include "object.h" -#include "protect.h" -#include "PropertyNameArray.h" -#include -#include -#include -#include -#include - -using std::max; -using WTF::doubleHash; - -#ifndef NDEBUG -#define DO_PROPERTYMAP_CONSTENCY_CHECK 0 -#define DUMP_PROPERTYMAP_STATS 0 -#else -#define DO_PROPERTYMAP_CONSTENCY_CHECK 0 -#define DUMP_PROPERTYMAP_STATS 0 -#endif - -#define USE_SINGLE_ENTRY 1 - -// 2/28/2006 ggaren: command-line JS iBench says that USE_SINGLE_ENTRY is a -// 3.2% performance boost. - -namespace KJS { - -// Choose a number for the following so that most property maps are smaller, -// but it's not going to blow out the stack to allocate this number of pointers. -static const int smallMapThreshold = 1024; - -// The point at which the function call overhead of the qsort implementation -// becomes small compared to the inefficiency of insertion sort. -static const unsigned tinyMapThreshold = 20; - -#if DUMP_PROPERTYMAP_STATS - -static int numProbes; -static int numCollisions; -static int numRehashes; -static int numRemoves; - -struct PropertyMapStatisticsExitLogger { ~PropertyMapStatisticsExitLogger(); }; - -static PropertyMapStatisticsExitLogger logger; - -PropertyMapStatisticsExitLogger::~PropertyMapStatisticsExitLogger() -{ - printf("\nKJS::PropertyMap statistics\n\n"); - printf("%d probes\n", numProbes); - printf("%d collisions (%.1f%%)\n", numCollisions, 100.0 * numCollisions / numProbes); - printf("%d rehashes\n", numRehashes); - printf("%d removes\n", numRemoves); -} - -#endif - -struct PropertyMapEntry { - UString::Rep* key; - JSValue* value; - unsigned attributes; - unsigned index; - - PropertyMapEntry(UString::Rep* k, JSValue* v, int a) - : key(k), value(v), attributes(a), index(0) - { - } -}; - -// lastIndexUsed is an ever-increasing index used to identify the order items -// were inserted into the property map. It's required that getEnumerablePropertyNames -// return the properties in the order they were added for compatibility with other -// browsers' JavaScript implementations. -struct PropertyMapHashTable { - unsigned sizeMask; - unsigned size; - unsigned keyCount; - unsigned deletedSentinelCount; - unsigned lastIndexUsed; - unsigned entryIndicies[1]; - - PropertyMapEntry* entries() - { - // The entries vector comes after the indices vector. - // The 0th item in the entries vector is not really used; it has to - // have a 0 in its key to allow the hash table lookup to handle deleted - // sentinels without any special-case code, but the other fields are unused. - return reinterpret_cast(&entryIndicies[size]); - } - - static size_t allocationSize(unsigned size) - { - // We never let a hash table get more than half full, - // So the number of indices we need is the size of the hash table. - // But the number of entries is half that (plus one for the deleted sentinel). - return sizeof(PropertyMapHashTable) - + (size - 1) * sizeof(unsigned) - + (1 + size / 2) * sizeof(PropertyMapEntry); - } -}; - -static const unsigned emptyEntryIndex = 0; -static const unsigned deletedSentinelIndex = 1; - -SavedProperties::SavedProperties() - : count(0) -{ -} - -SavedProperties::~SavedProperties() -{ -} - -#if !DO_PROPERTYMAP_CONSTENCY_CHECK - -inline void PropertyMap::checkConsistency() -{ -} - -#endif - -PropertyMap::~PropertyMap() -{ - if (!m_usingTable) { -#if USE_SINGLE_ENTRY - if (m_singleEntryKey) - m_singleEntryKey->deref(); -#endif - return; - } - - unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; - for (unsigned i = 1; i <= entryCount; i++) { - if (UString::Rep* key = m_u.table->entries()[i].key) - key->deref(); - } - fastFree(m_u.table); -} - -void PropertyMap::clear() -{ - if (!m_usingTable) { -#if USE_SINGLE_ENTRY - if (m_singleEntryKey) { - m_singleEntryKey->deref(); - m_singleEntryKey = 0; - } -#endif - return; - } - - unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; - for (unsigned i = 1; i <= entryCount; i++) { - if (UString::Rep* key = m_u.table->entries()[i].key) - key->deref(); - } - for (unsigned i = 0; i < m_u.table->size; i++) - m_u.table->entryIndicies[i] = emptyEntryIndex; - m_u.table->keyCount = 0; - m_u.table->deletedSentinelCount = 0; -} - -JSValue* PropertyMap::get(const Identifier& name, unsigned& attributes) const -{ - ASSERT(!name.isNull()); - - UString::Rep* rep = name._ustring.rep(); - - if (!m_usingTable) { -#if USE_SINGLE_ENTRY - if (rep == m_singleEntryKey) { - attributes = m_singleEntryAttributes; - return m_u.singleEntryValue; - } -#endif - return 0; - } - - unsigned i = rep->computedHash(); - -#if DUMP_PROPERTYMAP_STATS - ++numProbes; -#endif - - unsigned entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; - if (entryIndex == emptyEntryIndex) - return 0; - - if (rep == m_u.table->entries()[entryIndex - 1].key) { - attributes = m_u.table->entries()[entryIndex - 1].attributes; - return m_u.table->entries()[entryIndex - 1].value; - } - -#if DUMP_PROPERTYMAP_STATS - ++numCollisions; -#endif - - unsigned k = 1 | doubleHash(rep->computedHash()); - - while (1) { - i += k; - -#if DUMP_PROPERTYMAP_STATS - ++numRehashes; -#endif - - entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; - if (entryIndex == emptyEntryIndex) - return 0; - - if (rep == m_u.table->entries()[entryIndex - 1].key) { - attributes = m_u.table->entries()[entryIndex - 1].attributes; - return m_u.table->entries()[entryIndex - 1].value; - } - } -} - -JSValue* PropertyMap::get(const Identifier& name) const -{ - ASSERT(!name.isNull()); - - UString::Rep* rep = name._ustring.rep(); - - if (!m_usingTable) { -#if USE_SINGLE_ENTRY - if (rep == m_singleEntryKey) - return m_u.singleEntryValue; -#endif - return 0; - } - - unsigned i = rep->computedHash(); - -#if DUMP_PROPERTYMAP_STATS - ++numProbes; -#endif - - unsigned entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; - if (entryIndex == emptyEntryIndex) - return 0; - - if (rep == m_u.table->entries()[entryIndex - 1].key) - return m_u.table->entries()[entryIndex - 1].value; - -#if DUMP_PROPERTYMAP_STATS - ++numCollisions; -#endif - - unsigned k = 1 | doubleHash(rep->computedHash()); - - while (1) { - i += k; - -#if DUMP_PROPERTYMAP_STATS - ++numRehashes; -#endif - - entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; - if (entryIndex == emptyEntryIndex) - return 0; - - if (rep == m_u.table->entries()[entryIndex - 1].key) - return m_u.table->entries()[entryIndex - 1].value; - } -} - -JSValue** PropertyMap::getLocation(const Identifier& name) -{ - ASSERT(!name.isNull()); - - UString::Rep* rep = name._ustring.rep(); - - if (!m_usingTable) { -#if USE_SINGLE_ENTRY - if (rep == m_singleEntryKey) - return &m_u.singleEntryValue; -#endif - return 0; - } - - unsigned i = rep->computedHash(); - -#if DUMP_PROPERTYMAP_STATS - ++numProbes; -#endif - - unsigned entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; - if (entryIndex == emptyEntryIndex) - return 0; - - if (rep == m_u.table->entries()[entryIndex - 1].key) - return &m_u.table->entries()[entryIndex - 1].value; - -#if DUMP_PROPERTYMAP_STATS - ++numCollisions; -#endif - - unsigned k = 1 | doubleHash(rep->computedHash()); - - while (1) { - i += k; - -#if DUMP_PROPERTYMAP_STATS - ++numRehashes; -#endif - - entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; - if (entryIndex == emptyEntryIndex) - return 0; - - if (rep == m_u.table->entries()[entryIndex - 1].key) - return &m_u.table->entries()[entryIndex - 1].value; - } -} - -void PropertyMap::put(const Identifier& name, JSValue* value, unsigned attributes, bool checkReadOnly) -{ - ASSERT(!name.isNull()); - ASSERT(value); - - checkConsistency(); - - UString::Rep* rep = name._ustring.rep(); - -#if USE_SINGLE_ENTRY - if (!m_usingTable) { - if (!m_singleEntryKey) { - rep->ref(); - m_singleEntryKey = rep; - m_u.singleEntryValue = value; - m_singleEntryAttributes = static_cast(attributes); - checkConsistency(); - return; - } - if (rep == m_singleEntryKey && !(checkReadOnly && (m_singleEntryAttributes & ReadOnly))) { - m_u.singleEntryValue = value; - return; - } - } -#endif - - if (!m_usingTable || (m_u.table->keyCount + m_u.table->deletedSentinelCount) * 2 >= m_u.table->size) - expand(); - - // FIXME: Consider a fast case for tables with no deleted sentinels. - - unsigned i = rep->computedHash(); - unsigned k = 0; - bool foundDeletedElement = false; - unsigned deletedElementIndex = 0; // initialize to make the compiler happy - -#if DUMP_PROPERTYMAP_STATS - ++numProbes; -#endif - - while (1) { - unsigned entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; - if (entryIndex == emptyEntryIndex) - break; - - if (m_u.table->entries()[entryIndex - 1].key == rep) { - if (checkReadOnly && (m_u.table->entries()[entryIndex - 1].attributes & ReadOnly)) - return; - // Put a new value in an existing hash table entry. - m_u.table->entries()[entryIndex - 1].value = value; - // Attributes are intentionally not updated. - return; - } else if (entryIndex == deletedSentinelIndex) { - // If we find a deleted-element sentinel, remember it for use later. - if (!foundDeletedElement) { - foundDeletedElement = true; - deletedElementIndex = i; - } - } - - if (k == 0) { - k = 1 | doubleHash(rep->computedHash()); -#if DUMP_PROPERTYMAP_STATS - ++numCollisions; -#endif - } - - i += k; - -#if DUMP_PROPERTYMAP_STATS - ++numRehashes; -#endif - } - - // Figure out which entry to use. - unsigned entryIndex = m_u.table->keyCount + m_u.table->deletedSentinelCount + 2; - if (foundDeletedElement) { - i = deletedElementIndex; - --m_u.table->deletedSentinelCount; - - // Since we're not making the table bigger, we can't use the entry one past - // the end that we were planning on using, so search backwards for the empty - // slot that we can use. We know it will be there because we did at least one - // deletion in the past that left an entry empty. - while (m_u.table->entries()[--entryIndex - 1].key) - ; - } - - - // Create a new hash table entry. - m_u.table->entryIndicies[i & m_u.table->sizeMask] = entryIndex; - - // Create a new hash table entry. - rep->ref(); - m_u.table->entries()[entryIndex - 1].key = rep; - m_u.table->entries()[entryIndex - 1].value = value; - m_u.table->entries()[entryIndex - 1].attributes = attributes; - m_u.table->entries()[entryIndex - 1].index = ++m_u.table->lastIndexUsed; - ++m_u.table->keyCount; - - checkConsistency(); -} - -void PropertyMap::insert(const Entry& entry) -{ - ASSERT(m_u.table); - - unsigned i = entry.key->computedHash(); - unsigned k = 0; - -#if DUMP_PROPERTYMAP_STATS - ++numProbes; -#endif - - while (1) { - unsigned entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; - if (entryIndex == emptyEntryIndex) - break; - - if (k == 0) { - k = 1 | doubleHash(entry.key->computedHash()); -#if DUMP_PROPERTYMAP_STATS - ++numCollisions; -#endif - } - - i += k; - -#if DUMP_PROPERTYMAP_STATS - ++numRehashes; -#endif - } - - unsigned entryIndex = m_u.table->keyCount + 2; - m_u.table->entryIndicies[i & m_u.table->sizeMask] = entryIndex; - m_u.table->entries()[entryIndex - 1] = entry; - ++m_u.table->keyCount; -} - -void PropertyMap::expand() -{ - if (!m_usingTable) - createTable(); - else - rehash(m_u.table->size * 2); -} - -void PropertyMap::rehash() -{ - ASSERT(m_usingTable); - ASSERT(m_u.table); - ASSERT(m_u.table->size); - rehash(m_u.table->size); -} - -void PropertyMap::createTable() -{ - const unsigned newTableSize = 16; - - ASSERT(!m_usingTable); - - checkConsistency(); - -#if USE_SINGLE_ENTRY - JSValue* oldSingleEntryValue = m_u.singleEntryValue; -#endif - - m_u.table = static_cast(fastZeroedMalloc(Table::allocationSize(newTableSize))); - m_u.table->size = newTableSize; - m_u.table->sizeMask = newTableSize - 1; - m_usingTable = true; - -#if USE_SINGLE_ENTRY - if (m_singleEntryKey) { - insert(Entry(m_singleEntryKey, oldSingleEntryValue, m_singleEntryAttributes)); - m_singleEntryKey = 0; - } -#endif - - checkConsistency(); -} - -void PropertyMap::rehash(unsigned newTableSize) -{ - ASSERT(!m_singleEntryKey); - ASSERT(m_u.table); - ASSERT(m_usingTable); - - checkConsistency(); - - Table* oldTable = m_u.table; - - m_u.table = static_cast(fastZeroedMalloc(Table::allocationSize(newTableSize))); - m_u.table->size = newTableSize; - m_u.table->sizeMask = newTableSize - 1; - - unsigned lastIndexUsed = 0; - unsigned entryCount = oldTable->keyCount + oldTable->deletedSentinelCount; - for (unsigned i = 1; i <= entryCount; ++i) { - if (oldTable->entries()[i].key) { - lastIndexUsed = max(oldTable->entries()[i].index, lastIndexUsed); - insert(oldTable->entries()[i]); - } - } - m_u.table->lastIndexUsed = lastIndexUsed; - - fastFree(oldTable); - - checkConsistency(); -} - -void PropertyMap::remove(const Identifier& name) -{ - ASSERT(!name.isNull()); - - checkConsistency(); - - UString::Rep* rep = name._ustring.rep(); - - if (!m_usingTable) { -#if USE_SINGLE_ENTRY - if (rep == m_singleEntryKey) { - m_singleEntryKey->deref(); - m_singleEntryKey = 0; - checkConsistency(); - } -#endif - return; - } - -#if DUMP_PROPERTYMAP_STATS - ++numProbes; - ++numRemoves; -#endif - - // Find the thing to remove. - unsigned i = rep->computedHash(); - unsigned k = 0; - unsigned entryIndex; - UString::Rep* key = 0; - while (1) { - entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; - if (entryIndex == emptyEntryIndex) - return; - - key = m_u.table->entries()[entryIndex - 1].key; - if (rep == key) - break; - - if (k == 0) { - k = 1 | doubleHash(rep->computedHash()); -#if DUMP_PROPERTYMAP_STATS - ++numCollisions; -#endif - } - - i += k; - -#if DUMP_PROPERTYMAP_STATS - ++numRehashes; -#endif - } - - // Replace this one element with the deleted sentinel. Also clear out - // the entry so we can iterate all the entries as needed. - m_u.table->entryIndicies[i & m_u.table->sizeMask] = deletedSentinelIndex; - key->deref(); - m_u.table->entries()[entryIndex - 1].key = 0; - m_u.table->entries()[entryIndex - 1].value = jsUndefined(); - m_u.table->entries()[entryIndex - 1].attributes = 0; - ASSERT(m_u.table->keyCount >= 1); - --m_u.table->keyCount; - ++m_u.table->deletedSentinelCount; - - if (m_u.table->deletedSentinelCount * 4 >= m_u.table->size) - rehash(); - - checkConsistency(); -} - -void PropertyMap::mark() const -{ - if (!m_usingTable) { -#if USE_SINGLE_ENTRY - if (m_singleEntryKey) { - JSValue* v = m_u.singleEntryValue; - if (!v->marked()) - v->mark(); - } -#endif - return; - } - - unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; - for (unsigned i = 1; i <= entryCount; i++) { - JSValue* v = m_u.table->entries()[i].value; - if (!v->marked()) - v->mark(); - } -} - -static int comparePropertyMapEntryIndices(const void* a, const void* b) -{ - unsigned ia = static_cast(a)[0]->index; - unsigned ib = static_cast(b)[0]->index; - if (ia < ib) - return -1; - if (ia > ib) - return +1; - return 0; -} - -bool PropertyMap::containsGettersOrSetters() const -{ - if (!m_usingTable) { -#if USE_SINGLE_ENTRY - return !!(m_singleEntryAttributes & GetterSetter); -#else - return false; -#endif - } - - unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; - for (unsigned i = 1; i <= entryCount; i++) { - if (m_u.table->entries()[i].attributes & GetterSetter) - return true; - } - - return false; -} - -void PropertyMap::getEnumerablePropertyNames(PropertyNameArray& propertyNames) const -{ - if (!m_usingTable) { -#if USE_SINGLE_ENTRY - UString::Rep* key = m_singleEntryKey; - if (key && !(m_singleEntryAttributes & DontEnum)) - propertyNames.add(Identifier(key)); -#endif - return; - } - - if (m_u.table->keyCount < tinyMapThreshold) { - Entry* a[tinyMapThreshold]; - int i = 0; - unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; - for (unsigned k = 1; k <= entryCount; k++) { - if (m_u.table->entries()[k].key && !(m_u.table->entries()[k].attributes & DontEnum)) { - Entry* value = &m_u.table->entries()[k]; - int j; - for (j = i - 1; j >= 0 && a[j]->index > value->index; --j) - a[j + 1] = a[j]; - a[j + 1] = value; - ++i; - } - } - for (int k = 0; k < i; ++k) - propertyNames.add(Identifier(a[k]->key)); - return; - } - - // Allocate a buffer to use to sort the keys. - Vector sortedEnumerables(m_u.table->keyCount); - - // Get pointers to the enumerable entries in the buffer. - Entry** p = sortedEnumerables.data(); - unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; - for (unsigned i = 1; i <= entryCount; i++) { - if (m_u.table->entries()[i].key && !(m_u.table->entries()[i].attributes & DontEnum)) - *p++ = &m_u.table->entries()[i]; - } - - // Sort the entries by index. - qsort(sortedEnumerables.data(), p - sortedEnumerables.data(), sizeof(Entry*), comparePropertyMapEntryIndices); - - // Put the keys of the sorted entries into the list. - for (Entry** q = sortedEnumerables.data(); q != p; ++q) - propertyNames.add(Identifier(q[0]->key)); -} - -void PropertyMap::save(SavedProperties& s) const -{ - unsigned count = 0; - - if (!m_usingTable) { -#if USE_SINGLE_ENTRY - if (m_singleEntryKey && !(m_singleEntryAttributes & (ReadOnly | Function))) - ++count; -#endif - } else { - unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; - for (unsigned i = 1; i <= entryCount; ++i) - if (m_u.table->entries()[i].key && !(m_u.table->entries()[i].attributes & (ReadOnly | Function))) - ++count; - } - - s.properties.clear(); - s.count = count; - - if (count == 0) - return; - - s.properties.set(new SavedProperty[count]); - - SavedProperty* prop = s.properties.get(); - -#if USE_SINGLE_ENTRY - if (!m_usingTable) { - prop->init(m_singleEntryKey, m_u.singleEntryValue, m_singleEntryAttributes); - return; - } -#endif - - // Save in the right order so we don't lose the order. - // Another possibility would be to save the indices. - - // Allocate a buffer to use to sort the keys. - Vector sortedEntries(count); - - // Get pointers to the entries in the buffer. - Entry** p = sortedEntries.data(); - unsigned entryCount = m_u.table->keyCount + m_u.table->deletedSentinelCount; - for (unsigned i = 1; i <= entryCount; ++i) { - if (m_u.table->entries()[i].key && !(m_u.table->entries()[i].attributes & (ReadOnly | Function))) - *p++ = &m_u.table->entries()[i]; - } - ASSERT(p == sortedEntries.data() + count); - - // Sort the entries by index. - qsort(sortedEntries.data(), p - sortedEntries.data(), sizeof(Entry*), comparePropertyMapEntryIndices); - - // Put the sorted entries into the saved properties list. - for (Entry** q = sortedEntries.data(); q != p; ++q, ++prop) { - Entry* e = *q; - prop->init(e->key, e->value, e->attributes); - } -} - -void PropertyMap::restore(const SavedProperties& p) -{ - for (unsigned i = 0; i != p.count; ++i) - put(Identifier(p.properties[i].name()), p.properties[i].value(), p.properties[i].attributes()); -} - -#if DO_PROPERTYMAP_CONSTENCY_CHECK - -void PropertyMap::checkConsistency() -{ - if (!m_usingTable) - return; - - ASSERT(m_u.table->size >= 16); - ASSERT(m_u.table->sizeMask); - ASSERT(m_u.table->size == m_u.table->sizeMask + 1); - ASSERT(!(m_u.table->size & m_u.table->sizeMask)); - - ASSERT(m_u.table->keyCount <= m_u.table->size / 2); - ASSERT(m_u.table->deletedSentinelCount <= m_u.table->size / 4); - - ASSERT(m_u.table->keyCount + m_u.table->deletedSentinelCount <= m_u.table->size / 2); - - unsigned indexCount = 0; - unsigned deletedIndexCount = 0; - for (unsigned a = 0; a != m_u.table->size; ++a) { - unsigned entryIndex = m_u.table->entryIndicies[a]; - if (entryIndex == emptyEntryIndex) - continue; - if (entryIndex == deletedSentinelIndex) { - ++deletedIndexCount; - continue; - } - ASSERT(entryIndex > deletedSentinelIndex); - ASSERT(entryIndex - 1 <= m_u.table->keyCount + m_u.table->deletedSentinelCount); - ++indexCount; - - for (unsigned b = a + 1; b != m_u.table->size; ++b) - ASSERT(m_u.table->entryIndicies[b] != entryIndex); - } - ASSERT(indexCount == m_u.table->keyCount); - ASSERT(deletedIndexCount == m_u.table->deletedSentinelCount); - - ASSERT(m_u.table->entries()[0].key == 0); - - unsigned nonEmptyEntryCount = 0; - for (unsigned c = 1; c <= m_u.table->keyCount + m_u.table->deletedSentinelCount; ++c) { - UString::Rep* rep = m_u.table->entries()[c].key; - if (!rep) { - ASSERT(m_u.table->entries()[c].value->isUndefined()); - continue; - } - ++nonEmptyEntryCount; - unsigned i = rep->computedHash(); - unsigned k = 0; - unsigned entryIndex; - while (1) { - entryIndex = m_u.table->entryIndicies[i & m_u.table->sizeMask]; - ASSERT(entryIndex != emptyEntryIndex); - if (rep == m_u.table->entries()[entryIndex - 1].key) - break; - if (k == 0) - k = 1 | doubleHash(rep->computedHash()); - i += k; - } - ASSERT(entryIndex == c + 1); - } - - ASSERT(nonEmptyEntryCount == m_u.table->keyCount); -} - -#endif // DO_PROPERTYMAP_CONSTENCY_CHECK - -} // namespace KJS diff --git a/kjs/property_map.h b/kjs/property_map.h deleted file mode 100644 index 269e911..0000000 --- a/kjs/property_map.h +++ /dev/null @@ -1,184 +0,0 @@ -// -*- mode: c++; c-basic-offset: 4 -*- -/* - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_PROPERTY_MAP_H_ -#define KJS_PROPERTY_MAP_H_ - -#include "identifier.h" -#include "protect.h" -#include - -namespace KJS { - - class JSObject; - class JSValue; - class PropertyNameArray; - - struct PropertyMapEntry; - struct PropertyMapHashTable; - - class SavedProperty : Noncopyable { - public: - // Since we use this in arrays, we allocate it uninitialized - // and then explicitly initialize. This means we can allocate - // the array without initializing every saved property in the - // array twice. To accomplish this, the class uses data members - // with types that don't have constructors. - SavedProperty(); - void init(UString::Rep* name, JSValue*, unsigned attributes); - ~SavedProperty(); - - UString::Rep* name() const; - JSValue* value() const; - unsigned attributes() const; - - private: - UString::Rep* m_name; - JSValue* m_value; - unsigned m_attributes; - }; - - struct SavedProperties { - SavedProperties(); - ~SavedProperties(); - - unsigned count; - OwnArrayPtr properties; - }; - - class PropertyMap : Noncopyable { - public: - PropertyMap(); - ~PropertyMap(); - - void clear(); - - void put(const Identifier&, JSValue*, unsigned attributes, bool checkReadOnly = false); - void remove(const Identifier&); - JSValue* get(const Identifier&) const; - JSValue* get(const Identifier&, unsigned& attributes) const; - JSValue** getLocation(const Identifier& name); - - void mark() const; - void getEnumerablePropertyNames(PropertyNameArray&) const; - - void save(SavedProperties&) const; - void restore(const SavedProperties&); - - bool hasGetterSetterProperties() const { return m_getterSetterFlag; } - void setHasGetterSetterProperties(bool f) { m_getterSetterFlag = f; } - - bool containsGettersOrSetters() const; - - private: - typedef PropertyMapEntry Entry; - typedef PropertyMapHashTable Table; - - static bool keysMatch(const UString::Rep*, const UString::Rep*); - void expand(); - void rehash(); - void rehash(unsigned newTableSize); - void createTable(); - - void insert(const Entry&); - - void checkConsistency(); - - UString::Rep* m_singleEntryKey; - union { - JSValue* singleEntryValue; - Table* table; - } m_u; - - short m_singleEntryAttributes; - bool m_getterSetterFlag : 1; - bool m_usingTable : 1; - }; - - inline PropertyMap::PropertyMap() - : m_singleEntryKey(0) - , m_getterSetterFlag(false) - , m_usingTable(false) - - { - } - - inline SavedProperty::SavedProperty() -#ifndef NDEBUG - : m_name(0) - , m_value(0) - , m_attributes(0) -#endif - { - } - - inline void SavedProperty::init(UString::Rep* name, JSValue* value, unsigned attributes) - { - ASSERT(name); - ASSERT(value); - - ASSERT(!m_name); - ASSERT(!m_value); - ASSERT(!m_attributes); - - m_name = name; - m_value = value; - m_attributes = attributes; - name->ref(); - gcProtect(value); - } - - inline SavedProperty::~SavedProperty() - { - ASSERT(m_name); - ASSERT(m_value); - - m_name->deref(); - gcUnprotect(m_value); - } - - inline UString::Rep* SavedProperty::name() const - { - ASSERT(m_name); - ASSERT(m_value); - - return m_name; - } - - inline JSValue* SavedProperty::value() const - { - ASSERT(m_name); - ASSERT(m_value); - - return m_value; - } - - inline unsigned SavedProperty::attributes() const - { - ASSERT(m_name); - ASSERT(m_value); - - return m_attributes; - } - -} // namespace - -#endif // _KJS_PROPERTY_MAP_H_ diff --git a/kjs/property_slot.h b/kjs/property_slot.h deleted file mode 100644 index 4ec8b46..0000000 --- a/kjs/property_slot.h +++ /dev/null @@ -1,142 +0,0 @@ -// -*- c-basic-offset: 4 -*- -/* - * Copyright (C) 2005, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_PROPERTY_SLOT_H -#define KJS_PROPERTY_SLOT_H - -#include "identifier.h" -#include "value.h" -#include - -namespace KJS { - -class ExecState; -class JSObject; - -struct HashEntry; - -#define KJS_VALUE_SLOT_MARKER 0 -#define KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER reinterpret_cast(1) - -class PropertySlot { -public: - typedef JSValue* (*GetValueFunc)(ExecState*, JSObject* originalObject, const Identifier&, const PropertySlot&); - typedef JSValue* (*GetValueNumericFunc)(ExecState*, JSObject* originalObject, unsigned index, const PropertySlot&); - - JSValue* getValue(ExecState* exec, JSObject* originalObject, const Identifier& propertyName) const - { - if (m_getValue == KJS_VALUE_SLOT_MARKER) - return *m_data.valueSlot; - ASSERT(m_getValue != KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER); - return m_getValue(exec, originalObject, propertyName, *this); - } - - JSValue* getValue(ExecState* exec, JSObject* originalObject, unsigned propertyName) const - { - if (m_getValue == KJS_VALUE_SLOT_MARKER) - return *m_data.valueSlot; - if (m_getValue == KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER) - return m_data.numericFunc(exec, originalObject, propertyName, *this); - return m_getValue(exec, originalObject, Identifier::from(propertyName), *this); - } - - void setValueSlot(JSObject* slotBase, JSValue** valueSlot) - { - m_getValue = KJS_VALUE_SLOT_MARKER; - m_slotBase = slotBase; - m_data.valueSlot = valueSlot; - } - - void setStaticEntry(JSObject* slotBase, const HashEntry* staticEntry, GetValueFunc getValue) - { - ASSERT(getValue); - m_getValue = getValue; - m_slotBase = slotBase; - m_data.staticEntry = staticEntry; - } - - void setCustom(JSObject* slotBase, GetValueFunc getValue) - { - ASSERT(getValue); - m_getValue = getValue; - m_slotBase = slotBase; - } - - void setCustomIndex(JSObject* slotBase, unsigned index, GetValueFunc getValue) - { - ASSERT(getValue); - m_getValue = getValue; - m_slotBase = slotBase; - m_data.index = index; - } - - void setCustomNumeric(JSObject* slotBase, GetValueNumericFunc getValue) - { - ASSERT(getValue); - m_slotBase = slotBase; - m_getValue = KJS_NUMERIC_PROPERTY_NAME_SLOT_MARKER; - m_data.numericFunc = getValue; - } - - void setGetterSlot(JSObject* slotBase, JSObject* getterFunc) - { - m_getValue = functionGetter; - m_slotBase = slotBase; - m_data.getterFunc = getterFunc; - } - - void setUndefined(JSObject *slotBase) - { - m_slotBase = slotBase; - m_getValue = undefinedGetter; - } - - void setUngettable(JSObject* slotBase) // Used to signal that you have a property, but trying to get it at this time is an error. - { - m_slotBase = slotBase; - m_getValue = ungettableGetter; - } - - JSObject* slotBase() const { return m_slotBase; } - - const HashEntry* staticEntry() const { return m_data.staticEntry; } - unsigned index() const { return m_data.index; } - -private: - static JSValue* undefinedGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); - static JSValue* ungettableGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); - static JSValue* functionGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); - - GetValueFunc m_getValue; - - JSObject* m_slotBase; - union { - JSObject* getterFunc; - JSValue** valueSlot; - const HashEntry* staticEntry; - unsigned index; - GetValueNumericFunc numericFunc; - } m_data; -}; - -} - -#endif // KJS_PROPERTY_SLOT_H diff --git a/kjs/protect.h b/kjs/protect.h deleted file mode 100644 index 912e45c..0000000 --- a/kjs/protect.h +++ /dev/null @@ -1,143 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 2004 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - - -#ifndef _KJS_PROTECT_H_ -#define _KJS_PROTECT_H_ - -#include "value.h" -#include "collector.h" -#include "JSLock.h" - -namespace KJS { - - inline void gcProtect(JSValue *val) - { - Collector::protect(val); - } - - inline void gcUnprotect(JSValue *val) - { - Collector::unprotect(val); - } - - inline void gcProtectNullTolerant(JSValue *val) - { - if (val) - gcProtect(val); - } - - inline void gcUnprotectNullTolerant(JSValue *val) - { - if (val) - gcUnprotect(val); - } - - // FIXME: Share more code with RefPtr template? The only differences are the ref/deref operation - // and the implicit conversion to raw pointer - template class ProtectedPtr { - public: - ProtectedPtr() : m_ptr(NULL) { } - ProtectedPtr(T *ptr); - ProtectedPtr(const ProtectedPtr &); - ~ProtectedPtr(); - - template ProtectedPtr(const ProtectedPtr &); - - T *get() const { return m_ptr; } - operator T *() const { return m_ptr; } - T *operator->() const { return m_ptr; } - - bool operator!() const { return m_ptr == NULL; } - - ProtectedPtr &operator=(const ProtectedPtr &); - ProtectedPtr &operator=(T *); - - private: - T *m_ptr; - }; - - template ProtectedPtr::ProtectedPtr(T *ptr) - : m_ptr(ptr) - { - if (ptr) { - JSLock lock; - gcProtect(ptr); - } - } - - template ProtectedPtr::ProtectedPtr(const ProtectedPtr &o) - : m_ptr(o.get()) - { - if (T *ptr = m_ptr) { - JSLock lock; - gcProtect(ptr); - } - } - - template ProtectedPtr::~ProtectedPtr() - { - if (T *ptr = m_ptr) { - JSLock lock; - gcUnprotect(ptr); - } - } - - template template ProtectedPtr::ProtectedPtr(const ProtectedPtr &o) - : m_ptr(o.get()) - { - if (T *ptr = m_ptr) { - JSLock lock; - gcProtect(ptr); - } - } - - template ProtectedPtr &ProtectedPtr::operator=(const ProtectedPtr &o) - { - JSLock lock; - T *optr = o.m_ptr; - gcProtectNullTolerant(optr); - gcUnprotectNullTolerant(m_ptr); - m_ptr = optr; - return *this; - } - - template inline ProtectedPtr &ProtectedPtr::operator=(T *optr) - { - JSLock lock; - gcProtectNullTolerant(optr); - gcUnprotectNullTolerant(m_ptr); - m_ptr = optr; - return *this; - } - - template inline bool operator==(const ProtectedPtr &a, const ProtectedPtr &b) { return a.get() == b.get(); } - template inline bool operator==(const ProtectedPtr &a, const T *b) { return a.get() == b; } - template inline bool operator==(const T *a, const ProtectedPtr &b) { return a == b.get(); } - - template inline bool operator!=(const ProtectedPtr &a, const ProtectedPtr &b) { return a.get() != b.get(); } - template inline bool operator!=(const ProtectedPtr &a, const T *b) { return a.get() != b; } - template inline bool operator!=(const T *a, const ProtectedPtr &b) { return a != b.get(); } - -} // namespace - -#endif diff --git a/kjs/regexp.cpp b/kjs/regexp.cpp deleted file mode 100644 index 4839c86..0000000 --- a/kjs/regexp.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2001, 2004 Harri Porten (porten@kde.org) - * Copyright (c) 2007, Apple Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "regexp.h" - -#include "lexer.h" -#include -#include -#include -#include - -namespace KJS { - -RegExp::RegExp(const UString& pattern) - : m_pattern(pattern) - , m_flagBits(0) - , m_constructionError(0) - , m_numSubpatterns(0) -{ - m_regExp = jsRegExpCompile(reinterpret_cast(pattern.data()), pattern.size(), - JSRegExpDoNotIgnoreCase, JSRegExpSingleLine, &m_numSubpatterns, &m_constructionError); -} - -RegExp::RegExp(const UString& pattern, const UString& flags) - : m_pattern(pattern) - , m_flags(flags) - , m_flagBits(0) - , m_constructionError(0) - , m_numSubpatterns(0) -{ - // NOTE: The global flag is handled on a case-by-case basis by functions like - // String::match and RegExpImp::match. - if (flags.find('g') != -1) - m_flagBits |= Global; - - // FIXME: Eliminate duplication by adding a way ask a JSRegExp what its flags are? - JSRegExpIgnoreCaseOption ignoreCaseOption = JSRegExpDoNotIgnoreCase; - if (flags.find('i') != -1) { - m_flagBits |= IgnoreCase; - ignoreCaseOption = JSRegExpIgnoreCase; - } - - JSRegExpMultilineOption multilineOption = JSRegExpSingleLine; - if (flags.find('m') != -1) { - m_flagBits |= Multiline; - multilineOption = JSRegExpMultiline; - } - - m_regExp = jsRegExpCompile(reinterpret_cast(pattern.data()), pattern.size(), - ignoreCaseOption, multilineOption, &m_numSubpatterns, &m_constructionError); -} - -RegExp::~RegExp() -{ - jsRegExpFree(m_regExp); -} - -int RegExp::match(const UString& s, int i, OwnArrayPtr* ovector) -{ - if (i < 0) - i = 0; - if (ovector) - ovector->clear(); - - if (i > s.size() || s.isNull()) - return -1; - - if (!m_regExp) - return -1; - - // Set up the offset vector for the result. - // First 2/3 used for result, the last third used by PCRE. - int* offsetVector; - int offsetVectorSize; - int fixedSizeOffsetVector[3]; - if (!ovector) { - offsetVectorSize = 3; - offsetVector = fixedSizeOffsetVector; - } else { - offsetVectorSize = (m_numSubpatterns + 1) * 3; - offsetVector = new int [offsetVectorSize]; - ovector->set(offsetVector); - } - - int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast(s.data()), s.size(), i, offsetVector, offsetVectorSize); - - if (numMatches < 0) { -#ifndef NDEBUG - if (numMatches != JSRegExpErrorNoMatch) - fprintf(stderr, "jsRegExpExecute failed with result %d\n", numMatches); -#endif - if (ovector) - ovector->clear(); - return -1; - } - - return offsetVector[0]; -} - -} // namespace KJS diff --git a/kjs/regexp.h b/kjs/regexp.h deleted file mode 100644 index 2c62085..0000000 --- a/kjs/regexp.h +++ /dev/null @@ -1,75 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef KJS_REGEXP_H -#define KJS_REGEXP_H - -#include "ustring.h" -#include -#include -#include -#include - -namespace KJS { - - class RegExp : public RefCounted { - private: - enum { - Global = 1, - IgnoreCase = 2, - Multiline = 4 - }; - - public: - RegExp(const UString& pattern); - RegExp(const UString& pattern, const UString& flags); - ~RegExp(); - - bool global() const { return m_flagBits & Global; } - bool ignoreCase() const { return m_flagBits & IgnoreCase; } - bool multiline() const { return m_flagBits & Multiline; } - - const UString& pattern() const { return m_pattern; } - const UString& flags() const { return m_flags; } - - bool isValid() const { return !m_constructionError; } - const char* errorMessage() const { return m_constructionError; } - - int match(const UString&, int offset, OwnArrayPtr* ovector = 0); - unsigned numSubpatterns() const { return m_numSubpatterns; } - - private: - void compile(); - - // Data supplied by caller. - UString m_pattern; // FIXME: Just decompile m_regExp instead of storing this. - UString m_flags; // FIXME: Just decompile m_regExp instead of storing this. - int m_flagBits; - - // Data supplied by PCRE. - JSRegExp* m_regExp; - const char* m_constructionError; - unsigned m_numSubpatterns; - }; - -} // namespace - -#endif diff --git a/kjs/regexp_object.cpp b/kjs/regexp_object.cpp deleted file mode 100644 index 217c8db..0000000 --- a/kjs/regexp_object.cpp +++ /dev/null @@ -1,475 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2007, 2008 Apple Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "regexp_object.h" -#include "regexp_object.lut.h" - -#include "array_instance.h" -#include "array_object.h" -#include "error_object.h" -#include "internal.h" -#include "object.h" -#include "operations.h" -#include "regexp.h" -#include "types.h" -#include "value.h" -#include "UnusedParam.h" - -#include - -namespace KJS { - -// ------------------------------ RegExpPrototype --------------------------- - -static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, const List&); -static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, const List&); -static JSValue* regExpProtoFuncCompile(ExecState*, JSObject*, const List&); -static JSValue* regExpProtoFuncToString(ExecState*, JSObject*, const List&); - -// ECMA 15.10.5 - -const ClassInfo RegExpPrototype::info = { "RegExpPrototype", 0, 0 }; - -RegExpPrototype::RegExpPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype) - : JSObject(objectPrototype) -{ - static const Identifier* compilePropertyName = new Identifier("compile"); - static const Identifier* execPropertyName = new Identifier("exec"); - static const Identifier* testPropertyName = new Identifier("test"); - - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *compilePropertyName, regExpProtoFuncCompile), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *execPropertyName, regExpProtoFuncExec), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *testPropertyName, regExpProtoFuncTest), DontEnum); - putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum); -} - -// ------------------------------ Functions --------------------------- - -JSValue* regExpProtoFuncTest(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!thisObj->inherits(&RegExpImp::info)) - return throwError(exec, TypeError); - - return static_cast(thisObj)->test(exec, args); -} - -JSValue* regExpProtoFuncExec(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!thisObj->inherits(&RegExpImp::info)) - return throwError(exec, TypeError); - - return static_cast(thisObj)->exec(exec, args); -} - -JSValue* regExpProtoFuncCompile(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (!thisObj->inherits(&RegExpImp::info)) - return throwError(exec, TypeError); - - RefPtr regExp; - JSValue* arg0 = args[0]; - JSValue* arg1 = args[1]; - - if (arg0->isObject(&RegExpImp::info)) { - if (!arg1->isUndefined()) - return throwError(exec, TypeError, "Cannot supply flags when constructing one RegExp from another."); - regExp = static_cast(arg0)->regExp(); - } else { - UString pattern = args.isEmpty() ? UString("") : arg0->toString(exec); - UString flags = arg1->isUndefined() ? UString("") : arg1->toString(exec); - regExp = new RegExp(pattern, flags); - } - - if (!regExp->isValid()) - return throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage())); - - static_cast(thisObj)->setRegExp(regExp.release()); - static_cast(thisObj)->setLastIndex(0); - return jsUndefined(); -} - -JSValue* regExpProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&RegExpImp::info)) { - if (thisObj->inherits(&RegExpPrototype::info)) - return jsString("//"); - return throwError(exec, TypeError); - } - - UString result = "/" + thisObj->get(exec, exec->propertyNames().source)->toString(exec) + "/"; - if (thisObj->get(exec, exec->propertyNames().global)->toBoolean(exec)) - result += "g"; - if (thisObj->get(exec, exec->propertyNames().ignoreCase)->toBoolean(exec)) - result += "i"; - if (thisObj->get(exec, exec->propertyNames().multiline)->toBoolean(exec)) - result += "m"; - return jsString(result); -} - -// ------------------------------ RegExpImp ------------------------------------ - -const ClassInfo RegExpImp::info = { "RegExp", 0, &RegExpImpTable }; - -/* Source for regexp_object.lut.h -@begin RegExpImpTable 5 - global RegExpImp::Global DontDelete|ReadOnly|DontEnum - ignoreCase RegExpImp::IgnoreCase DontDelete|ReadOnly|DontEnum - multiline RegExpImp::Multiline DontDelete|ReadOnly|DontEnum - source RegExpImp::Source DontDelete|ReadOnly|DontEnum - lastIndex RegExpImp::LastIndex DontDelete|DontEnum -@end -*/ - -RegExpImp::RegExpImp(RegExpPrototype* regexpProto, PassRefPtr regExp) - : JSObject(regexpProto) - , m_regExp(regExp) - , m_lastIndex(0) -{ -} - -RegExpImp::~RegExpImp() -{ -} - -bool RegExpImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot(exec, &RegExpImpTable, this, propertyName, slot); -} - -JSValue* RegExpImp::getValueProperty(ExecState*, int token) const -{ - switch (token) { - case Global: - return jsBoolean(m_regExp->global()); - case IgnoreCase: - return jsBoolean(m_regExp->ignoreCase()); - case Multiline: - return jsBoolean(m_regExp->multiline()); - case Source: - return jsString(m_regExp->pattern()); - case LastIndex: - return jsNumber(m_lastIndex); - } - - ASSERT_NOT_REACHED(); - return 0; -} - -void RegExpImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attributes) -{ - lookupPut(exec, propertyName, value, attributes, &RegExpImpTable, this); -} - -void RegExpImp::putValueProperty(ExecState* exec, int token, JSValue* value, int) -{ - UNUSED_PARAM(token); - ASSERT(token == LastIndex); - m_lastIndex = value->toInteger(exec); -} - -bool RegExpImp::match(ExecState* exec, const List& args) -{ - RegExpObjectImp* regExpObj = exec->lexicalGlobalObject()->regExpConstructor(); - - UString input; - if (!args.isEmpty()) - input = args[0]->toString(exec); - else { - input = regExpObj->input(); - if (input.isNull()) { - throwError(exec, GeneralError, "No input."); - return false; - } - } - - bool global = get(exec, exec->propertyNames().global)->toBoolean(exec); - int lastIndex = 0; - if (global) { - if (m_lastIndex < 0 || m_lastIndex > input.size()) { - m_lastIndex = 0; - return false; - } - lastIndex = static_cast(m_lastIndex); - } - - int foundIndex; - int foundLength; - regExpObj->performMatch(m_regExp.get(), input, lastIndex, foundIndex, foundLength); - - if (global) { - lastIndex = foundIndex < 0 ? 0 : foundIndex + foundLength; - m_lastIndex = lastIndex; - } - - return foundIndex >= 0; -} - -JSValue* RegExpImp::test(ExecState* exec, const List& args) -{ - return jsBoolean(match(exec, args)); -} - -JSValue* RegExpImp::exec(ExecState* exec, const List& args) -{ - return match(exec, args) - ? exec->lexicalGlobalObject()->regExpConstructor()->arrayOfMatches(exec) - : jsNull(); -} - -bool RegExpImp::implementsCall() const -{ - return true; -} - -JSValue* RegExpImp::callAsFunction(ExecState* exec, JSObject*, const List& args) -{ - return RegExpImp::exec(exec, args); -} - -// ------------------------------ RegExpObjectImp ------------------------------ - -const ClassInfo RegExpObjectImp::info = { "Function", &InternalFunctionImp::info, &RegExpObjectImpTable }; - -/* Source for regexp_object.lut.h -@begin RegExpObjectImpTable 21 - input RegExpObjectImp::Input None - $_ RegExpObjectImp::Input DontEnum - multiline RegExpObjectImp::Multiline None - $* RegExpObjectImp::Multiline DontEnum - lastMatch RegExpObjectImp::LastMatch DontDelete|ReadOnly - $& RegExpObjectImp::LastMatch DontDelete|ReadOnly|DontEnum - lastParen RegExpObjectImp::LastParen DontDelete|ReadOnly - $+ RegExpObjectImp::LastParen DontDelete|ReadOnly|DontEnum - leftContext RegExpObjectImp::LeftContext DontDelete|ReadOnly - $` RegExpObjectImp::LeftContext DontDelete|ReadOnly|DontEnum - rightContext RegExpObjectImp::RightContext DontDelete|ReadOnly - $' RegExpObjectImp::RightContext DontDelete|ReadOnly|DontEnum - $1 RegExpObjectImp::Dollar1 DontDelete|ReadOnly - $2 RegExpObjectImp::Dollar2 DontDelete|ReadOnly - $3 RegExpObjectImp::Dollar3 DontDelete|ReadOnly - $4 RegExpObjectImp::Dollar4 DontDelete|ReadOnly - $5 RegExpObjectImp::Dollar5 DontDelete|ReadOnly - $6 RegExpObjectImp::Dollar6 DontDelete|ReadOnly - $7 RegExpObjectImp::Dollar7 DontDelete|ReadOnly - $8 RegExpObjectImp::Dollar8 DontDelete|ReadOnly - $9 RegExpObjectImp::Dollar9 DontDelete|ReadOnly -@end -*/ - -struct RegExpObjectImpPrivate { - // Global search cache / settings - RegExpObjectImpPrivate() : lastNumSubPatterns(0), multiline(false) { } - UString lastInput; - OwnArrayPtr lastOvector; - unsigned lastNumSubPatterns : 31; - bool multiline : 1; -}; - -RegExpObjectImp::RegExpObjectImp(ExecState* exec, FunctionPrototype* funcProto, RegExpPrototype* regProto) - : InternalFunctionImp(funcProto, "RegExp") - , d(new RegExpObjectImpPrivate) -{ - // ECMA 15.10.5.1 RegExp.prototype - putDirect(exec->propertyNames().prototype, regProto, DontEnum | DontDelete | ReadOnly); - - // no. of arguments for constructor - putDirect(exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum); -} - -/* - To facilitate result caching, exec(), test(), match(), search(), and replace() dipatch regular - expression matching through the performMatch function. We use cached results to calculate, - e.g., RegExp.lastMatch and RegExp.leftParen. -*/ -void RegExpObjectImp::performMatch(RegExp* r, const UString& s, int startOffset, int& position, int& length, int** ovector) -{ - OwnArrayPtr tmpOvector; - position = r->match(s, startOffset, &tmpOvector); - - if (ovector) - *ovector = tmpOvector.get(); - - if (position != -1) { - ASSERT(tmpOvector); - - length = tmpOvector[1] - tmpOvector[0]; - - d->lastInput = s; - d->lastOvector.set(tmpOvector.release()); - d->lastNumSubPatterns = r->numSubpatterns(); - } -} - -JSObject* RegExpObjectImp::arrayOfMatches(ExecState* exec) const -{ - unsigned lastNumSubpatterns = d->lastNumSubPatterns; - ArrayInstance* arr = new ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), lastNumSubpatterns + 1); - for (unsigned i = 0; i <= lastNumSubpatterns; ++i) { - int start = d->lastOvector[2 * i]; - if (start >= 0) - arr->put(exec, i, jsString(d->lastInput.substr(start, d->lastOvector[2 * i + 1] - start))); - } - arr->put(exec, exec->propertyNames().index, jsNumber(d->lastOvector[0])); - arr->put(exec, exec->propertyNames().input, jsString(d->lastInput)); - return arr; -} - -JSValue* RegExpObjectImp::getBackref(unsigned i) const -{ - if (d->lastOvector && i <= d->lastNumSubPatterns) - return jsString(d->lastInput.substr(d->lastOvector[2 * i], d->lastOvector[2 * i + 1] - d->lastOvector[2 * i])); - return jsString(""); -} - -JSValue* RegExpObjectImp::getLastParen() const -{ - unsigned i = d->lastNumSubPatterns; - if (i > 0) { - ASSERT(d->lastOvector); - return jsString(d->lastInput.substr(d->lastOvector[2 * i], d->lastOvector[2 * i + 1] - d->lastOvector[2 * i])); - } - return jsString(""); -} - -JSValue *RegExpObjectImp::getLeftContext() const -{ - if (d->lastOvector) - return jsString(d->lastInput.substr(0, d->lastOvector[0])); - return jsString(""); -} - -JSValue *RegExpObjectImp::getRightContext() const -{ - if (d->lastOvector) { - UString s = d->lastInput; - return jsString(s.substr(d->lastOvector[1], s.size() - d->lastOvector[1])); - } - return jsString(""); -} - -bool RegExpObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot(exec, &RegExpObjectImpTable, this, propertyName, slot); -} - -JSValue *RegExpObjectImp::getValueProperty(ExecState*, int token) const -{ - switch (token) { - case Dollar1: - return getBackref(1); - case Dollar2: - return getBackref(2); - case Dollar3: - return getBackref(3); - case Dollar4: - return getBackref(4); - case Dollar5: - return getBackref(5); - case Dollar6: - return getBackref(6); - case Dollar7: - return getBackref(7); - case Dollar8: - return getBackref(8); - case Dollar9: - return getBackref(9); - case Input: - return jsString(d->lastInput); - case Multiline: - return jsBoolean(d->multiline); - case LastMatch: - return getBackref(0); - case LastParen: - return getLastParen(); - case LeftContext: - return getLeftContext(); - case RightContext: - return getRightContext(); - default: - ASSERT(0); - } - - return jsString(""); -} - -void RegExpObjectImp::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr) -{ - lookupPut(exec, propertyName, value, attr, &RegExpObjectImpTable, this); -} - -void RegExpObjectImp::putValueProperty(ExecState *exec, int token, JSValue *value, int) -{ - switch (token) { - case Input: - d->lastInput = value->toString(exec); - break; - case Multiline: - d->multiline = value->toBoolean(exec); - break; - default: - ASSERT(0); - } -} - -bool RegExpObjectImp::implementsConstruct() const -{ - return true; -} - -// ECMA 15.10.4 -JSObject *RegExpObjectImp::construct(ExecState *exec, const List &args) -{ - JSValue* arg0 = args[0]; - JSValue* arg1 = args[1]; - - if (arg0->isObject(&RegExpImp::info)) { - if (!arg1->isUndefined()) - return throwError(exec, TypeError, "Cannot supply flags when constructing one RegExp from another."); - return static_cast(arg0); - } - - UString pattern = arg0->isUndefined() ? UString("") : arg0->toString(exec); - UString flags = arg1->isUndefined() ? UString("") : arg1->toString(exec); - - return createRegExpImp(exec, new RegExp(pattern, flags)); -} - -JSObject* RegExpObjectImp::createRegExpImp(ExecState* exec, PassRefPtr regExp) -{ - return regExp->isValid() - ? new RegExpImp(static_cast(exec->lexicalGlobalObject()->regExpPrototype()), regExp) - : throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage())); -} - -// ECMA 15.10.3 -JSValue *RegExpObjectImp::callAsFunction(ExecState *exec, JSObject * /*thisObj*/, const List &args) -{ - return construct(exec, args); -} - -const UString& RegExpObjectImp::input() const -{ - // Can detect a distinct initial state that is invisible to JavaScript, by checking for null - // state (since jsString turns null strings to empty strings). - return d->lastInput; -} - -} diff --git a/kjs/regexp_object.h b/kjs/regexp_object.h deleted file mode 100644 index 1ce2f16..0000000 --- a/kjs/regexp_object.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2007, 2008 Apple Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef REGEXP_OBJECT_H_ -#define REGEXP_OBJECT_H_ - -#include "function_object.h" -#include "regexp.h" - -namespace KJS { - - struct RegExpObjectImpPrivate; - - class RegExpPrototype : public JSObject { - public: - RegExpPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*); - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - }; - - class RegExpImp : public JSObject { - public: - enum { Global, IgnoreCase, Multiline, Source, LastIndex }; - - RegExpImp(RegExpPrototype*, PassRefPtr); - virtual ~RegExpImp(); - - void setRegExp(PassRefPtr r) { m_regExp = r; } - RegExp* regExp() const { return m_regExp.get(); } - - JSValue* test(ExecState*, const List& args); - JSValue* exec(ExecState*, const List& args); - - virtual bool implementsCall() const; - virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); - bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - JSValue* getValueProperty(ExecState*, int token) const; - void put(ExecState*, const Identifier&, JSValue*, int attributes = None); - void putValueProperty(ExecState*, int token, JSValue*, int attributes); - - virtual const ClassInfo* classInfo() const { return &info; } - static const ClassInfo info; - - void setLastIndex(double lastIndex) { m_lastIndex = lastIndex; } - - private: - bool match(ExecState*, const List& args); - - RefPtr m_regExp; - double m_lastIndex; - }; - - class RegExpObjectImp : public InternalFunctionImp { - public: - enum { Dollar1, Dollar2, Dollar3, Dollar4, Dollar5, Dollar6, Dollar7, Dollar8, Dollar9, - Input, Multiline, LastMatch, LastParen, LeftContext, RightContext }; - - RegExpObjectImp(ExecState*, FunctionPrototype*, RegExpPrototype*); - - virtual bool implementsConstruct() const; - virtual JSObject* construct(ExecState*, const List&); - JSObject* createRegExpImp(ExecState*, PassRefPtr); - virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&); - virtual void put(ExecState*, const Identifier&, JSValue*, int attributes = None); - void putValueProperty(ExecState*, int token, JSValue*, int attributes); - virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - JSValue* getValueProperty(ExecState*, int token) const; - virtual const ClassInfo* classInfo() const { return &info; } - - void performMatch(RegExp*, const UString&, int startOffset, int& position, int& length, int** ovector = 0); - JSObject* arrayOfMatches(ExecState*) const; - const UString& input() const; - - private: - JSValue* getBackref(unsigned) const; - JSValue* getLastParen() const; - JSValue* getLeftContext() const; - JSValue* getRightContext() const; - - OwnPtr d; - - static const ClassInfo info; - }; - -} // namespace - -#endif diff --git a/kjs/scope_chain.h b/kjs/scope_chain.h deleted file mode 100644 index 7441cb8..0000000 --- a/kjs/scope_chain.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003 Apple Computer, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_SCOPE_CHAIN_H -#define KJS_SCOPE_CHAIN_H - -#include - -namespace KJS { - - class JSObject; - class ExecState; - - class ScopeChainNode { - public: - ScopeChainNode(ScopeChainNode *n, JSObject *o) - : next(n), object(o), refCount(1) { } - - ScopeChainNode *next; - JSObject *object; - int refCount; - }; - - class ScopeChainIterator { - public: - ScopeChainIterator(ScopeChainNode *node) : m_node(node) {} - - JSObject * const & operator*() const { return m_node->object; } - JSObject * const * operator->() const { return &(operator*()); } - - ScopeChainIterator& operator++() { m_node = m_node->next; return *this; } - - // postfix ++ intentionally omitted - - bool operator==(const ScopeChainIterator& other) const { return m_node == other.m_node; } - bool operator!=(const ScopeChainIterator& other) const { return m_node != other.m_node; } - - private: - ScopeChainNode *m_node; - }; - - class ScopeChain { - public: - typedef ScopeChainIterator const_iterator; - typedef JSObject* ValueType; - - ScopeChain() : _node(0) { } - ~ScopeChain() { deref(); } - - ScopeChain(const ScopeChain &c) : _node(c._node) - { if (_node) ++_node->refCount; } - ScopeChain &operator=(const ScopeChain &); - - bool isEmpty() const { return !_node; } - JSObject *top() const { return _node->object; } - - JSObject *bottom() const; - - ScopeChainIterator begin() const { return ScopeChainIterator(_node); } - ScopeChainIterator end() const { return ScopeChainIterator(0); } - - void clear() { deref(); _node = 0; } - void push(JSObject *); - void push(const ScopeChain &); - void replaceTop(JSObject*); - void pop(); - - void mark(); - -#ifndef NDEBUG - void print(); -#endif - - private: - ScopeChainNode *_node; - - void deref() { if (_node && --_node->refCount == 0) release(); } - void ref() const; - - void release(); - }; - -inline void ScopeChain::ref() const -{ - for (ScopeChainNode *n = _node; n; n = n->next) { - if (n->refCount++ != 0) - break; - } -} - -inline ScopeChain &ScopeChain::operator=(const ScopeChain &c) -{ - c.ref(); - deref(); - _node = c._node; - return *this; -} - -inline JSObject *ScopeChain::bottom() const -{ - ScopeChainNode *last = 0; - for (ScopeChainNode *n = _node; n; n = n->next) - last = n; - if (!last) - return 0; - return last->object; -} - -inline void ScopeChain::push(JSObject *o) -{ - ASSERT(o); - _node = new ScopeChainNode(_node, o); -} - -inline void ScopeChain::replaceTop(JSObject* o) -{ - ASSERT(o); - _node->object = o; -} - -inline void ScopeChain::pop() -{ - ScopeChainNode *oldNode = _node; - ASSERT(oldNode); - ScopeChainNode *newNode = oldNode->next; - _node = newNode; - - if (--oldNode->refCount != 0) { - if (newNode) - ++newNode->refCount; - } else { - delete oldNode; - } -} - -} // namespace KJS - -#endif // KJS_SCOPE_CHAIN_H diff --git a/kjs/scope_chain_mark.h b/kjs/scope_chain_mark.h deleted file mode 100644 index bc4d5f8..0000000 --- a/kjs/scope_chain_mark.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef scope_chain_mark_h -#define scope_chain_mark_h - -#include "Activation.h" -#include "scope_chain.h" - -namespace KJS { - - inline void ScopeChain::mark() - { - for (ScopeChainNode* n = _node; n; n = n->next) { - JSObject* o = n->object; - - // An ActivationImp that is on the activation stack can't have the - // JSObject::marked() method called on it, because it doesn't have an - // entry in a GC mark bitmap, so we check here whether it is on the - // stack and directly call the portion of the marking code that is - // still relevant. - - if (o->isActivationObject() && static_cast(o)->isOnStack()) - static_cast(o)->markChildren(); - else if (!o->marked()) - o->mark(); - } - } - -} // namespace KJS - -#endif diff --git a/kjs/string_object.cpp b/kjs/string_object.cpp deleted file mode 100644 index 53b6ada..0000000 --- a/kjs/string_object.cpp +++ /dev/null @@ -1,1055 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "string_object.h" -#include "string_object.lut.h" - -#include "JSWrapperObject.h" -#include "PropertyNameArray.h" -#include "array_object.h" -#include "error_object.h" -#include "operations.h" -#include "regexp_object.h" -#include -#include - -#if PLATFORM(CF) -#include -#elif PLATFORM(WIN_OS) -#include -#endif - -using namespace WTF; - -namespace KJS { - -// ------------------------------ StringInstance ---------------------------- - -const ClassInfo StringInstance::info = { "String", 0, 0 }; - -StringInstance::StringInstance(JSObject *proto) - : JSWrapperObject(proto) -{ - setInternalValue(jsString("")); -} - -StringInstance::StringInstance(JSObject *proto, StringImp* string) - : JSWrapperObject(proto) -{ - setInternalValue(string); -} - -StringInstance::StringInstance(JSObject *proto, const UString &string) - : JSWrapperObject(proto) -{ - setInternalValue(jsString(string)); -} - -JSValue *StringInstance::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot &slot) -{ - return jsNumber(static_cast(slot.slotBase())->internalValue()->value().size()); -} - -JSValue* StringInstance::indexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) -{ - return jsString(static_cast(slot.slotBase())->internalValue()->value().substr(slot.index(), 1)); -} - -static JSValue* stringInstanceNumericPropertyGetter(ExecState*, JSObject*, unsigned index, const PropertySlot& slot) -{ - return jsString(static_cast(slot.slotBase())->internalValue()->value().substr(index, 1)); -} - -bool StringInstance::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - if (propertyName == exec->propertyNames().length) { - slot.setCustom(this, lengthGetter); - return true; - } - - bool isStrictUInt32; - unsigned i = propertyName.toStrictUInt32(&isStrictUInt32); - unsigned length = internalValue()->value().size(); - if (isStrictUInt32 && i < length) { - slot.setCustomIndex(this, i, indexGetter); - return true; - } - - return JSObject::getOwnPropertySlot(exec, propertyName, slot); -} - -bool StringInstance::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) -{ - unsigned length = internalValue()->value().size(); - if (propertyName < length) { - slot.setCustomNumeric(this, stringInstanceNumericPropertyGetter); - return true; - } - - return JSObject::getOwnPropertySlot(exec, Identifier::from(propertyName), slot); -} - -void StringInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr) -{ - if (propertyName == exec->propertyNames().length) - return; - JSObject::put(exec, propertyName, value, attr); -} - -bool StringInstance::deleteProperty(ExecState *exec, const Identifier &propertyName) -{ - if (propertyName == exec->propertyNames().length) - return false; - return JSObject::deleteProperty(exec, propertyName); -} - -void StringInstance::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) -{ - int size = internalValue()->getString().size(); - for (int i = 0; i < size; i++) - propertyNames.add(Identifier(UString::from(i))); - return JSObject::getPropertyNames(exec, propertyNames); -} - -// ------------------------------ StringPrototype --------------------------- -const ClassInfo StringPrototype::info = { "String", &StringInstance::info, &stringTable }; -/* Source for string_object.lut.h -@begin stringTable 26 - toString &stringProtoFuncToString DontEnum|Function 0 - valueOf &stringProtoFuncValueOf DontEnum|Function 0 - charAt &stringProtoFuncCharAt DontEnum|Function 1 - charCodeAt &stringProtoFuncCharCodeAt DontEnum|Function 1 - concat &stringProtoFuncConcat DontEnum|Function 1 - indexOf &stringProtoFuncIndexOf DontEnum|Function 1 - lastIndexOf &stringProtoFuncLastIndexOf DontEnum|Function 1 - match &stringProtoFuncMatch DontEnum|Function 1 - replace &stringProtoFuncReplace DontEnum|Function 2 - search &stringProtoFuncSearch DontEnum|Function 1 - slice &stringProtoFuncSlice DontEnum|Function 2 - split &stringProtoFuncSplit DontEnum|Function 2 - substr &stringProtoFuncSubstr DontEnum|Function 2 - substring &stringProtoFuncSubstring DontEnum|Function 2 - toLowerCase &stringProtoFuncToLowerCase DontEnum|Function 0 - toUpperCase &stringProtoFuncToUpperCase DontEnum|Function 0 - toLocaleLowerCase &stringProtoFuncToLocaleLowerCase DontEnum|Function 0 - toLocaleUpperCase &stringProtoFuncToLocaleUpperCase DontEnum|Function 0 - localeCompare &stringProtoFuncLocaleCompare DontEnum|Function 1 - - big &stringProtoFuncBig DontEnum|Function 0 - small &stringProtoFuncSmall DontEnum|Function 0 - blink &stringProtoFuncBlink DontEnum|Function 0 - bold &stringProtoFuncBold DontEnum|Function 0 - fixed &stringProtoFuncFixed DontEnum|Function 0 - italics &stringProtoFuncItalics DontEnum|Function 0 - strike &stringProtoFuncStrike DontEnum|Function 0 - sub &stringProtoFuncSub DontEnum|Function 0 - sup &stringProtoFuncSup DontEnum|Function 0 - fontcolor &stringProtoFuncFontcolor DontEnum|Function 1 - fontsize &stringProtoFuncFontsize DontEnum|Function 1 - anchor &stringProtoFuncAnchor DontEnum|Function 1 - link &stringProtoFuncLink DontEnum|Function 1 -@end -*/ -// ECMA 15.5.4 -StringPrototype::StringPrototype(ExecState* exec, ObjectPrototype* objProto) - : StringInstance(objProto) -{ - // The constructor will be added later, after StringObjectImp has been built - putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum); -} - -bool StringPrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot) -{ - return getStaticFunctionSlot(exec, &stringTable, this, propertyName, slot); -} - -// ------------------------------ Functions -------------------------- - -static inline void expandSourceRanges(UString::Range * & array, int& count, int& capacity) -{ - int newCapacity; - if (capacity == 0) { - newCapacity = 16; - } else { - newCapacity = capacity * 2; - } - - UString::Range *newArray = new UString::Range[newCapacity]; - for (int i = 0; i < count; i++) { - newArray[i] = array[i]; - } - - delete [] array; - - capacity = newCapacity; - array = newArray; -} - -static void pushSourceRange(UString::Range * & array, int& count, int& capacity, UString::Range range) -{ - if (count + 1 > capacity) - expandSourceRanges(array, count, capacity); - - array[count] = range; - count++; -} - -static inline void expandReplacements(UString * & array, int& count, int& capacity) -{ - int newCapacity; - if (capacity == 0) { - newCapacity = 16; - } else { - newCapacity = capacity * 2; - } - - UString *newArray = new UString[newCapacity]; - for (int i = 0; i < count; i++) { - newArray[i] = array[i]; - } - - delete [] array; - - capacity = newCapacity; - array = newArray; -} - -static void pushReplacement(UString * & array, int& count, int& capacity, UString replacement) -{ - if (count + 1 > capacity) - expandReplacements(array, count, capacity); - - array[count] = replacement; - count++; -} - -static inline UString substituteBackreferences(const UString &replacement, const UString &source, int *ovector, RegExp *reg) -{ - UString substitutedReplacement = replacement; - - int i = -1; - while ((i = substitutedReplacement.find(UString("$"), i + 1)) != -1) { - if (i+1 == substitutedReplacement.size()) - break; - - unsigned short ref = substitutedReplacement[i+1].unicode(); - int backrefStart = 0; - int backrefLength = 0; - int advance = 0; - - if (ref == '$') { // "$$" -> "$" - substitutedReplacement = substitutedReplacement.substr(0, i + 1) + substitutedReplacement.substr(i + 2); - continue; - } else if (ref == '&') { - backrefStart = ovector[0]; - backrefLength = ovector[1] - backrefStart; - } else if (ref == '`') { - backrefStart = 0; - backrefLength = ovector[0]; - } else if (ref == '\'') { - backrefStart = ovector[1]; - backrefLength = source.size() - backrefStart; - } else if (ref >= '0' && ref <= '9') { - // 1- and 2-digit back references are allowed - unsigned backrefIndex = ref - '0'; - if (backrefIndex > reg->numSubpatterns()) - continue; - if (substitutedReplacement.size() > i + 2) { - ref = substitutedReplacement[i+2].unicode(); - if (ref >= '0' && ref <= '9') { - backrefIndex = 10 * backrefIndex + ref - '0'; - if (backrefIndex > reg->numSubpatterns()) - backrefIndex = backrefIndex / 10; // Fall back to the 1-digit reference - else - advance = 1; - } - } - backrefStart = ovector[2 * backrefIndex]; - backrefLength = ovector[2 * backrefIndex + 1] - backrefStart; - } else - continue; - - substitutedReplacement = substitutedReplacement.substr(0, i) + source.substr(backrefStart, backrefLength) + substitutedReplacement.substr(i + 2 + advance); - i += backrefLength - 1; // - 1 offsets 'i + 1' - } - - return substitutedReplacement; -} -static inline int localeCompare(const UString& a, const UString& b) -{ -#if PLATFORM(WIN_OS) - int retval = CompareStringW(LOCALE_USER_DEFAULT, 0, - reinterpret_cast(a.data()), a.size(), - reinterpret_cast(b.data()), b.size()); - return !retval ? retval : retval - 2; -#elif PLATFORM(CF) - CFStringRef sa = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast(a.data()), a.size(), kCFAllocatorNull); - CFStringRef sb = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast(b.data()), b.size(), kCFAllocatorNull); - - int retval = CFStringCompare(sa, sb, kCFCompareLocalized); - - CFRelease(sa); - CFRelease(sb); - - return retval; -#else - return compare(a, b); -#endif -} - -static JSValue *replace(ExecState *exec, StringImp* sourceVal, JSValue *pattern, JSValue *replacement) -{ - UString source = sourceVal->value(); - JSObject *replacementFunction = 0; - UString replacementString; - - if (replacement->isObject() && replacement->toObject(exec)->implementsCall()) - replacementFunction = replacement->toObject(exec); - else - replacementString = replacement->toString(exec); - - if (pattern->isObject() && static_cast(pattern)->inherits(&RegExpImp::info)) { - RegExp *reg = static_cast(pattern)->regExp(); - bool global = reg->global(); - - RegExpObjectImp* regExpObj = static_cast(exec->lexicalGlobalObject()->regExpConstructor()); - - int lastIndex = 0; - int startPosition = 0; - - UString::Range *sourceRanges = 0; - int sourceRangeCount = 0; - int sourceRangeCapacity = 0; - UString *replacements = 0; - int replacementCount = 0; - int replacementCapacity = 0; - - // This is either a loop (if global is set) or a one-way (if not). - do { - int matchIndex; - int matchLen; - int* ovector; - regExpObj->performMatch(reg, source, startPosition, matchIndex, matchLen, &ovector); - if (matchIndex < 0) - break; - - pushSourceRange(sourceRanges, sourceRangeCount, sourceRangeCapacity, UString::Range(lastIndex, matchIndex - lastIndex)); - - UString substitutedReplacement; - if (replacementFunction) { - int completeMatchStart = ovector[0]; - List args; - - for (unsigned i = 0; i < reg->numSubpatterns() + 1; i++) { - int matchStart = ovector[i * 2]; - int matchLen = ovector[i * 2 + 1] - matchStart; - - if (matchStart < 0) - args.append(jsUndefined()); - else - args.append(jsString(source.substr(matchStart, matchLen))); - } - - args.append(jsNumber(completeMatchStart)); - args.append(sourceVal); - - substitutedReplacement = replacementFunction->call(exec, exec->dynamicGlobalObject(), - args)->toString(exec); - } else - substitutedReplacement = substituteBackreferences(replacementString, source, ovector, reg); - - pushReplacement(replacements, replacementCount, replacementCapacity, substitutedReplacement); - - lastIndex = matchIndex + matchLen; - startPosition = lastIndex; - - // special case of empty match - if (matchLen == 0) { - startPosition++; - if (startPosition > source.size()) - break; - } - } while (global); - - if (lastIndex < source.size()) - pushSourceRange(sourceRanges, sourceRangeCount, sourceRangeCapacity, UString::Range(lastIndex, source.size() - lastIndex)); - - UString result; - - if (sourceRanges) - result = source.spliceSubstringsWithSeparators(sourceRanges, sourceRangeCount, replacements, replacementCount); - - delete [] sourceRanges; - delete [] replacements; - - if (result == source) - return sourceVal; - - return jsString(result); - } - - // First arg is a string - UString patternString = pattern->toString(exec); - int matchPos = source.find(patternString); - int matchLen = patternString.size(); - // Do the replacement - if (matchPos == -1) - return sourceVal; - - if (replacementFunction) { - List args; - - args.append(jsString(source.substr(matchPos, matchLen))); - args.append(jsNumber(matchPos)); - args.append(sourceVal); - - replacementString = replacementFunction->call(exec, exec->dynamicGlobalObject(), - args)->toString(exec); - } - - return jsString(source.substr(0, matchPos) + replacementString + source.substr(matchPos + matchLen)); -} - -JSValue* stringProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&StringInstance::info)) - return throwError(exec, TypeError); - - return static_cast(thisObj)->internalValue(); -} - -JSValue* stringProtoFuncValueOf(ExecState* exec, JSObject* thisObj, const List&) -{ - if (!thisObj->inherits(&StringInstance::info)) - return throwError(exec, TypeError); - - return static_cast(thisObj)->internalValue(); -} - -JSValue* stringProtoFuncCharAt(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - int len = s.size(); - - UString u; - JSValue* a0 = args[0]; - double dpos = a0->toInteger(exec); - if (dpos >= 0 && dpos < len) - u = s.substr(static_cast(dpos), 1); - else - u = ""; - return jsString(u); -} - -JSValue* stringProtoFuncCharCodeAt(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - int len = s.size(); - - JSValue* result = 0; - - JSValue* a0 = args[0]; - double dpos = a0->toInteger(exec); - if (dpos >= 0 && dpos < len) - result = jsNumber(s[static_cast(dpos)].unicode()); - else - result = jsNaN(); - return result; -} - -JSValue* stringProtoFuncConcat(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - - List::const_iterator end = args.end(); - for (List::const_iterator it = args.begin(); it != end; ++it) { - s += (*it)->toString(exec); - } - return jsString(s); -} - -JSValue* stringProtoFuncIndexOf(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - int len = s.size(); - - JSValue* a0 = args[0]; - JSValue* a1 = args[1]; - UString u2 = a0->toString(exec); - double dpos = a1->toInteger(exec); - if (dpos < 0) - dpos = 0; - else if (dpos > len) - dpos = len; - return jsNumber(s.find(u2, static_cast(dpos))); -} - -JSValue* stringProtoFuncLastIndexOf(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - int len = s.size(); - - JSValue* a0 = args[0]; - JSValue* a1 = args[1]; - - UString u2 = a0->toString(exec); - double dpos = a1->toIntegerPreserveNaN(exec); - if (dpos < 0) - dpos = 0; - else if (!(dpos <= len)) // true for NaN - dpos = len; - return jsNumber(s.rfind(u2, static_cast(dpos))); -} - -JSValue* stringProtoFuncMatch(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - - JSValue* a0 = args[0]; - - UString u = s; - RegExp* reg; - RegExp* tmpReg = 0; - RegExpImp* imp = 0; - if (a0->isObject() && static_cast(a0)->inherits(&RegExpImp::info)) { - reg = static_cast(a0)->regExp(); - } else { - /* - * ECMA 15.5.4.12 String.prototype.search (regexp) - * If regexp is not an object whose [[Class]] property is "RegExp", it is - * replaced with the result of the expression new RegExp(regexp). - */ - reg = tmpReg = new RegExp(a0->toString(exec)); - } - RegExpObjectImp* regExpObj = static_cast(exec->lexicalGlobalObject()->regExpConstructor()); - int pos; - int matchLength; - regExpObj->performMatch(reg, u, 0, pos, matchLength); - JSValue* result; - if (!(reg->global())) { - // case without 'g' flag is handled like RegExp.prototype.exec - if (pos < 0) - result = jsNull(); - else - result = regExpObj->arrayOfMatches(exec); - } else { - // return array of matches - List list; - int lastIndex = 0; - while (pos >= 0) { - list.append(jsString(u.substr(pos, matchLength))); - lastIndex = pos; - pos += matchLength == 0 ? 1 : matchLength; - regExpObj->performMatch(reg, u, pos, pos, matchLength); - } - if (imp) - imp->setLastIndex(lastIndex); - if (list.isEmpty()) { - // if there are no matches at all, it's important to return - // Null instead of an empty array, because this matches - // other browsers and because Null is a false value. - result = jsNull(); - } else { - result = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, list); - } - } - delete tmpReg; - return result; -} - -JSValue* stringProtoFuncSearch(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - - JSValue* a0 = args[0]; - - UString u = s; - RegExp* reg; - RegExp* tmpReg = 0; - if (a0->isObject() && static_cast(a0)->inherits(&RegExpImp::info)) { - reg = static_cast(a0)->regExp(); - } else { - /* - * ECMA 15.5.4.12 String.prototype.search (regexp) - * If regexp is not an object whose [[Class]] property is "RegExp", it is - * replaced with the result of the expression new RegExp(regexp). - */ - reg = tmpReg = new RegExp(a0->toString(exec)); - } - RegExpObjectImp* regExpObj = static_cast(exec->lexicalGlobalObject()->regExpConstructor()); - int pos; - int matchLength; - regExpObj->performMatch(reg, u, 0, pos, matchLength); - delete tmpReg; - return jsNumber(pos); -} - -JSValue* stringProtoFuncReplace(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - - StringImp* sVal = thisObj->inherits(&StringInstance::info) ? - static_cast(thisObj)->internalValue() : - static_cast(jsString(s)); - - JSValue* a0 = args[0]; - JSValue* a1 = args[1]; - - return replace(exec, sVal, a0, a1); -} - -JSValue* stringProtoFuncSlice(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - int len = s.size(); - - JSValue* a0 = args[0]; - JSValue* a1 = args[1]; - - // The arg processing is very much like ArrayProtoFunc::Slice - double start = a0->toInteger(exec); - double end = a1->isUndefined() ? len : a1->toInteger(exec); - double from = start < 0 ? len + start : start; - double to = end < 0 ? len + end : end; - if (to > from && to > 0 && from < len) { - if (from < 0) - from = 0; - if (to > len) - to = len; - return jsString(s.substr(static_cast(from), static_cast(to - from))); - } - - return jsString(""); -} - -JSValue* stringProtoFuncSplit(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - - JSValue* a0 = args[0]; - JSValue* a1 = args[1]; - - JSObject *constructor = exec->lexicalGlobalObject()->arrayConstructor(); - JSObject* res = static_cast(constructor->construct(exec, exec->emptyList())); - JSValue* result = res; - UString u = s; - int pos; - int i = 0; - int p0 = 0; - uint32_t limit = a1->isUndefined() ? 0xFFFFFFFFU : a1->toUInt32(exec); - if (a0->isObject() && static_cast(a0)->inherits(&RegExpImp::info)) { - RegExp *reg = static_cast(a0)->regExp(); - if (u.isEmpty() && reg->match(u, 0) >= 0) { - // empty string matched by regexp -> empty array - res->put(exec, exec->propertyNames().length, jsNumber(0)); - return result; - } - pos = 0; - while (static_cast(i) != limit && pos < u.size()) { - OwnArrayPtr ovector; - int mpos = reg->match(u, pos, &ovector); - if (mpos < 0) - break; - int mlen = ovector[1] - ovector[0]; - pos = mpos + (mlen == 0 ? 1 : mlen); - if (mpos != p0 || mlen) { - res->put(exec,i, jsString(u.substr(p0, mpos-p0))); - p0 = mpos + mlen; - i++; - } - for (unsigned si = 1; si <= reg->numSubpatterns(); ++si) { - int spos = ovector[si * 2]; - if (spos < 0) - res->put(exec, i++, jsUndefined()); - else - res->put(exec, i++, jsString(u.substr(spos, ovector[si * 2 + 1] - spos))); - } - } - } else { - UString u2 = a0->toString(exec); - if (u2.isEmpty()) { - if (u.isEmpty()) { - // empty separator matches empty string -> empty array - res->put(exec, exec->propertyNames().length, jsNumber(0)); - return result; - } else { - while (static_cast(i) != limit && i < u.size()-1) - res->put(exec, i++, jsString(u.substr(p0++, 1))); - } - } else { - while (static_cast(i) != limit && (pos = u.find(u2, p0)) >= 0) { - res->put(exec, i, jsString(u.substr(p0, pos-p0))); - p0 = pos + u2.size(); - i++; - } - } - } - // add remaining string, if any - if (static_cast(i) != limit) - res->put(exec, i++, jsString(u.substr(p0))); - res->put(exec, exec->propertyNames().length, jsNumber(i)); - return result; -} - -JSValue* stringProtoFuncSubstr(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - int len = s.size(); - - JSValue* a0 = args[0]; - JSValue* a1 = args[1]; - - double start = a0->toInteger(exec); - double length = a1->isUndefined() ? len : a1->toInteger(exec); - if (start >= len) - return jsString(""); - if (length < 0) - return jsString(""); - if (start < 0) { - start += len; - if (start < 0) - start = 0; - } - if (length > len) - length = len; - return jsString(s.substr(static_cast(start), static_cast(length))); -} - -JSValue* stringProtoFuncSubstring(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - int len = s.size(); - - JSValue* a0 = args[0]; - JSValue* a1 = args[1]; - - double start = a0->toNumber(exec); - double end = a1->toNumber(exec); - if (isnan(start)) - start = 0; - if (isnan(end)) - end = 0; - if (start < 0) - start = 0; - if (end < 0) - end = 0; - if (start > len) - start = len; - if (end > len) - end = len; - if (a1->isUndefined()) - end = len; - if (start > end) { - double temp = end; - end = start; - start = temp; - } - return jsString(s.substr((int)start, (int)end-(int)start)); -} - -JSValue* stringProtoFuncToLowerCase(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - - StringImp* sVal = thisObj->inherits(&StringInstance::info) - ? static_cast(thisObj)->internalValue() - : static_cast(jsString(s)); - int ssize = s.size(); - if (!ssize) - return sVal; - Vector< ::UChar> buffer(ssize); - bool error; - int length = Unicode::toLower(buffer.data(), ssize, reinterpret_cast(s.data()), ssize, &error); - if (error) { - buffer.resize(length); - length = Unicode::toLower(buffer.data(), length, reinterpret_cast(s.data()), ssize, &error); - if (error) - return sVal; - } - if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) - return sVal; - return jsString(UString(reinterpret_cast(buffer.releaseBuffer()), length, false)); -} - -JSValue* stringProtoFuncToUpperCase(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - - StringImp* sVal = thisObj->inherits(&StringInstance::info) - ? static_cast(thisObj)->internalValue() - : static_cast(jsString(s)); - int ssize = s.size(); - if (!ssize) - return sVal; - Vector< ::UChar> buffer(ssize); - bool error; - int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast(s.data()), ssize, &error); - if (error) { - buffer.resize(length); - length = Unicode::toUpper(buffer.data(), length, reinterpret_cast(s.data()), ssize, &error); - if (error) - return sVal; - } - if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) - return sVal; - return jsString(UString(reinterpret_cast(buffer.releaseBuffer()), length, false)); -} - -JSValue* stringProtoFuncToLocaleLowerCase(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - - // FIXME: See http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt for locale-sensitive mappings that aren't implemented. - StringImp* sVal = thisObj->inherits(&StringInstance::info) - ? static_cast(thisObj)->internalValue() - : static_cast(jsString(s)); - int ssize = s.size(); - if (!ssize) - return sVal; - Vector< ::UChar> buffer(ssize); - bool error; - int length = Unicode::toLower(buffer.data(), ssize, reinterpret_cast(s.data()), ssize, &error); - if (error) { - buffer.resize(length); - length = Unicode::toLower(buffer.data(), length, reinterpret_cast(s.data()), ssize, &error); - if (error) - return sVal; - } - if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) - return sVal; - return jsString(UString(reinterpret_cast(buffer.releaseBuffer()), length, false)); -} - -JSValue* stringProtoFuncToLocaleUpperCase(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - - StringImp* sVal = thisObj->inherits(&StringInstance::info) - ? static_cast(thisObj)->internalValue() - : static_cast(jsString(s)); - int ssize = s.size(); - if (!ssize) - return sVal; - Vector< ::UChar> buffer(ssize); - bool error; - int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast(s.data()), ssize, &error); - if (error) { - buffer.resize(length); - length = Unicode::toUpper(buffer.data(), length, reinterpret_cast(s.data()), ssize, &error); - if (error) - return sVal; - } - if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) - return sVal; - return jsString(UString(reinterpret_cast(buffer.releaseBuffer()), length, false)); -} - -JSValue* stringProtoFuncLocaleCompare(ExecState* exec, JSObject* thisObj, const List& args) -{ - if (args.size() < 1) - return jsNumber(0); - - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - JSValue* a0 = args[0]; - return jsNumber(localeCompare(s, a0->toString(exec))); -} - -JSValue* stringProtoFuncBig(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - return jsString("" + s + ""); -} - -JSValue* stringProtoFuncSmall(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - return jsString("" + s + ""); -} - -JSValue* stringProtoFuncBlink(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - return jsString("" + s + ""); -} - -JSValue* stringProtoFuncBold(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - return jsString("" + s + ""); -} - -JSValue* stringProtoFuncFixed(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - return jsString("" + s + ""); -} - -JSValue* stringProtoFuncItalics(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - return jsString("" + s + ""); -} - -JSValue* stringProtoFuncStrike(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - return jsString("" + s + ""); -} - -JSValue* stringProtoFuncSub(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - return jsString("" + s + ""); -} - -JSValue* stringProtoFuncSup(ExecState* exec, JSObject* thisObj, const List&) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - return jsString("" + s + ""); -} - -JSValue* stringProtoFuncFontcolor(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - JSValue* a0 = args[0]; - return jsString("toString(exec) + "\">" + s + ""); -} - -JSValue* stringProtoFuncFontsize(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - JSValue* a0 = args[0]; - return jsString("toString(exec) + "\">" + s + ""); -} - -JSValue* stringProtoFuncAnchor(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - JSValue* a0 = args[0]; - return jsString("toString(exec) + "\">" + s + ""); -} - -JSValue* stringProtoFuncLink(ExecState* exec, JSObject* thisObj, const List& args) -{ - // This optimizes the common case that thisObj is a StringInstance - UString s = thisObj->inherits(&StringInstance::info) ? static_cast(thisObj)->internalValue()->value() : thisObj->toString(exec); - JSValue* a0 = args[0]; - return jsString("toString(exec) + "\">" + s + ""); -} - -// ------------------------------ StringObjectImp ------------------------------ - -StringObjectImp::StringObjectImp(ExecState* exec, FunctionPrototype* funcProto, StringPrototype* stringProto) - : InternalFunctionImp(funcProto, stringProto->classInfo()->className) -{ - // ECMA 15.5.3.1 String.prototype - putDirect(exec->propertyNames().prototype, stringProto, DontEnum|DontDelete|ReadOnly); - - putDirectFunction(new StringObjectFuncImp(exec, funcProto, exec->propertyNames().fromCharCode), DontEnum); - - // no. of arguments for constructor - putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); -} - - -bool StringObjectImp::implementsConstruct() const -{ - return true; -} - -// ECMA 15.5.2 -JSObject *StringObjectImp::construct(ExecState *exec, const List &args) -{ - JSObject *proto = exec->lexicalGlobalObject()->stringPrototype(); - if (args.size() == 0) - return new StringInstance(proto); - return new StringInstance(proto, args[0]->toString(exec)); -} - -// ECMA 15.5.1 -JSValue *StringObjectImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args) -{ - if (args.isEmpty()) - return jsString(""); - else { - JSValue *v = args[0]; - return jsString(v->toString(exec)); - } -} - -// ------------------------------ StringObjectFuncImp -------------------------- - -// ECMA 15.5.3.2 fromCharCode() -StringObjectFuncImp::StringObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name) - : InternalFunctionImp(funcProto, name) -{ - putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum); -} - -JSValue *StringObjectFuncImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args) -{ - UString s; - if (args.size()) { - UChar *buf = static_cast(fastMalloc(args.size() * sizeof(UChar))); - UChar *p = buf; - List::const_iterator end = args.end(); - for (List::const_iterator it = args.begin(); it != end; ++it) { - unsigned short u = static_cast((*it)->toUInt32(exec)); - *p++ = UChar(u); - } - s = UString(buf, args.size(), false); - } else - s = ""; - - return jsString(s); -} - -} // namespace KJS diff --git a/kjs/string_object.h b/kjs/string_object.h deleted file mode 100644 index 3bc9cb2..0000000 --- a/kjs/string_object.h +++ /dev/null @@ -1,153 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef STRING_OBJECT_H_ -#define STRING_OBJECT_H_ - -#include "function_object.h" -#include "JSWrapperObject.h" -#include "internal.h" -#include "lookup.h" - -namespace KJS { - - class StringInstance : public JSWrapperObject { - public: - StringInstance(JSObject *proto); - StringInstance(JSObject *proto, StringImp*); - StringInstance(JSObject *proto, const UString&); - - virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); - - virtual void put(ExecState* exec, const Identifier& propertyName, JSValue*, int attr = None); - virtual bool deleteProperty(ExecState* exec, const Identifier& propertyName); - virtual void getPropertyNames(ExecState*, PropertyNameArray&); - - virtual const ClassInfo *classInfo() const { return &info; } - static const ClassInfo info; - - StringImp* internalValue() const { return static_cast(JSWrapperObject::internalValue());} - - private: - bool inlineGetOwnPropertySlot(ExecState*, unsigned, PropertySlot&); - - static JSValue* lengthGetter(ExecState*, JSObject *, const Identifier&, const PropertySlot&); - static JSValue* indexGetter(ExecState*, JSObject *, const Identifier&, const PropertySlot&); - }; - - // WebCore uses this to make style.filter undetectable - class StringInstanceThatMasqueradesAsUndefined : public StringInstance { - public: - StringInstanceThatMasqueradesAsUndefined(JSObject* proto, const UString& string) - : StringInstance(proto, string) { } - virtual bool masqueradeAsUndefined() const { return true; } - virtual bool toBoolean(ExecState*) const { return false; } - }; - - /** - * @internal - * - * The initial value of String.prototype (and thus all objects created - * with the String constructor - */ - class StringPrototype : public StringInstance { - public: - StringPrototype(ExecState *exec, - ObjectPrototype *objProto); - virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&); - virtual const ClassInfo *classInfo() const { return &info; } - static const ClassInfo info; - }; - - /** - * @internal - * - * Functions to implement all methods that are properties of the - * String.prototype object - */ - - JSValue* stringProtoFuncToString(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncValueOf(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncCharAt(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncCharCodeAt(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncConcat(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncIndexOf(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncLastIndexOf(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncMatch(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncReplace(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncSearch(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncSlice(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncSplit(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncSubstr(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncSubstring(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncToLowerCase(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncToUpperCase(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncToLocaleLowerCase(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncToLocaleUpperCase(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncLocaleCompare(ExecState*, JSObject*, const List&); - - JSValue* stringProtoFuncBig(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncSmall(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncBlink(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncBold(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncFixed(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncItalics(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncStrike(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncSub(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncSup(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncFontcolor(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncFontsize(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncAnchor(ExecState*, JSObject*, const List&); - JSValue* stringProtoFuncLink(ExecState*, JSObject*, const List&); - - /** - * @internal - * - * The initial value of the the global variable's "String" property - */ - class StringObjectImp : public InternalFunctionImp { - public: - StringObjectImp(ExecState *exec, - FunctionPrototype *funcProto, - StringPrototype *stringProto); - - virtual bool implementsConstruct() const; - virtual JSObject *construct(ExecState *exec, const List &args); - virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); - }; - - /** - * @internal - * - * Class to implement all methods that are properties of the - * String object - */ - class StringObjectFuncImp : public InternalFunctionImp { - public: - StringObjectFuncImp(ExecState*, FunctionPrototype*, const Identifier&); - virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); - }; - -} // namespace - -#endif - diff --git a/kjs/testkjs.cpp b/kjs/testkjs.cpp deleted file mode 100644 index 6a7607c..0000000 --- a/kjs/testkjs.cpp +++ /dev/null @@ -1,346 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2004-2007 Apple Inc. - * Copyright (C) 2006 Bjoern Graf (bjoern.graf@gmail.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" - -#include "JSGlobalObject.h" -#include "JSLock.h" -#include "Parser.h" -#include "SourceCode.h" -#include "collector.h" -#include "interpreter.h" -#include "nodes.h" -#include "object.h" -#include "protect.h" -#include -#include -#include -#include -#include - -#if HAVE(SYS_TIME_H) -#include -#endif - -#if PLATFORM(WIN_OS) -#include -#include -#endif - -#if PLATFORM(QT) -#include -#endif - -using namespace KJS; -using namespace WTF; - -static bool fillBufferWithContentsOfFile(const UString& fileName, Vector& buffer); - -class StopWatch -{ -public: - void start(); - void stop(); - long getElapsedMS(); // call stop() first - -private: -#if PLATFORM(QT) - uint m_startTime; - uint m_stopTime; -#elif PLATFORM(WIN_OS) - DWORD m_startTime; - DWORD m_stopTime; -#else - // Windows does not have timeval, disabling this class for now (bug 7399) - timeval m_startTime; - timeval m_stopTime; -#endif -}; - -void StopWatch::start() -{ -#if PLATFORM(QT) - QDateTime t = QDateTime::currentDateTime(); - m_startTime = t.toTime_t() * 1000 + t.time().msec(); -#elif PLATFORM(WIN_OS) - m_startTime = timeGetTime(); -#else - gettimeofday(&m_startTime, 0); -#endif -} - -void StopWatch::stop() -{ -#if PLATFORM(QT) - QDateTime t = QDateTime::currentDateTime(); - m_stopTime = t.toTime_t() * 1000 + t.time().msec(); -#elif PLATFORM(WIN_OS) - m_stopTime = timeGetTime(); -#else - gettimeofday(&m_stopTime, 0); -#endif -} - -long StopWatch::getElapsedMS() -{ -#if PLATFORM(WIN_OS) || PLATFORM(QT) - return m_stopTime - m_startTime; -#else - timeval elapsedTime; - timersub(&m_stopTime, &m_startTime, &elapsedTime); - - return elapsedTime.tv_sec * 1000 + lroundf(elapsedTime.tv_usec / 1000.0f); -#endif -} - -class GlobalImp : public JSGlobalObject { -public: - virtual UString className() const { return "global"; } -}; -COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_GlobalImp_false); - -class TestFunctionImp : public JSObject { -public: - enum TestFunctionType { Print, Debug, Quit, GC, Version, Run, Load }; - - TestFunctionImp(TestFunctionType i, int length); - virtual bool implementsCall() const { return true; } - virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List &args); - -private: - TestFunctionType m_type; -}; - -TestFunctionImp::TestFunctionImp(TestFunctionType i, int length) - : JSObject() - , m_type(i) -{ - putDirect(Identifier("length"), length, DontDelete | ReadOnly | DontEnum); -} - -JSValue* TestFunctionImp::callAsFunction(ExecState* exec, JSObject*, const List &args) -{ - switch (m_type) { - case Print: - printf("%s\n", args[0]->toString(exec).UTF8String().c_str()); - return jsUndefined(); - case Debug: - fprintf(stderr, "--> %s\n", args[0]->toString(exec).UTF8String().c_str()); - return jsUndefined(); - case GC: - { - JSLock lock; - Collector::collect(); - return jsUndefined(); - } - case Version: - // We need this function for compatibility with the Mozilla JS tests but for now - // we don't actually do any version-specific handling - return jsUndefined(); - case Run: - { - StopWatch stopWatch; - UString fileName = args[0]->toString(exec); - Vector script; - if (!fillBufferWithContentsOfFile(fileName, script)) - return throwError(exec, GeneralError, "Could not open file."); - - stopWatch.start(); - - Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), makeSource(script.data(), fileName)); - stopWatch.stop(); - - return jsNumber(stopWatch.getElapsedMS()); - } - case Load: - { - UString fileName = args[0]->toString(exec); - Vector script; - if (!fillBufferWithContentsOfFile(fileName, script)) - return throwError(exec, GeneralError, "Could not open file."); - - Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), makeSource(script.data(), fileName)); - - return jsUndefined(); - } - case Quit: - exit(0); - default: - abort(); - } - return 0; -} - -// Use SEH for Release builds only to get rid of the crash report dialog -// (luckily the same tests fail in Release and Debug builds so far). Need to -// be in a separate main function because the kjsmain function requires object -// unwinding. - -#if PLATFORM(WIN_OS) && !defined(_DEBUG) -#define TRY __try { -#define EXCEPT(x) } __except (EXCEPTION_EXECUTE_HANDLER) { x; } -#else -#define TRY -#define EXCEPT(x) -#endif - -int kjsmain(int argc, char** argv); - -int main(int argc, char** argv) -{ -#if defined(_DEBUG) && PLATFORM(WIN_OS) - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); - _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); - _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); -#endif - - int res = 0; - TRY - res = kjsmain(argc, argv); - EXCEPT(res = 3) - return res; -} - -static GlobalImp* createGlobalObject() -{ - GlobalImp* global = new GlobalImp; - - // add debug() function - global->put(global->globalExec(), "debug", new TestFunctionImp(TestFunctionImp::Debug, 1)); - // add "print" for compatibility with the mozilla js shell - global->put(global->globalExec(), "print", new TestFunctionImp(TestFunctionImp::Print, 1)); - // add "quit" for compatibility with the mozilla js shell - global->put(global->globalExec(), "quit", new TestFunctionImp(TestFunctionImp::Quit, 0)); - // add "gc" for compatibility with the mozilla js shell - global->put(global->globalExec(), "gc", new TestFunctionImp(TestFunctionImp::GC, 0)); - // add "version" for compatibility with the mozilla js shell - global->put(global->globalExec(), "version", new TestFunctionImp(TestFunctionImp::Version, 1)); - global->put(global->globalExec(), "run", new TestFunctionImp(TestFunctionImp::Run, 1)); - global->put(global->globalExec(), "load", new TestFunctionImp(TestFunctionImp::Load, 1)); - - Interpreter::setShouldPrintExceptions(true); - return global; -} - -static bool prettyPrintScript(const UString& fileName, const Vector& script) -{ - int errLine = 0; - UString errMsg; - - RefPtr programNode = parser().parse(makeSource(script.data(), fileName), &errLine, &errMsg); - if (!programNode) { - fprintf(stderr, "%s:%d: %s.\n", fileName.UTF8String().c_str(), errLine, errMsg.UTF8String().c_str()); - return false; - } - - printf("%s\n", programNode->toString().UTF8String().c_str()); - return true; -} - -static bool runWithScripts(const Vector& fileNames, bool prettyPrint) -{ - GlobalImp* globalObject = createGlobalObject(); - Vector script; - - bool success = true; - - for (size_t i = 0; i < fileNames.size(); i++) { - UString fileName = fileNames[i]; - - if (!fillBufferWithContentsOfFile(fileName, script)) - return false; // fail early so we can catch missing files - - if (prettyPrint) - prettyPrintScript(fileName, script); - else { - Completion completion = Interpreter::evaluate(globalObject->globalExec(), makeSource(script.data(), fileName)); - success = success && completion.complType() != Throw; - } - } - return success; -} - -static void parseArguments(int argc, char** argv, Vector& fileNames, bool& prettyPrint) -{ - if (argc < 2) { - fprintf(stderr, "Usage: testkjs file1 [file2...]\n"); - exit(-1); - } - - for (int i = 1; i < argc; i++) { - const char* fileName = argv[i]; - if (strcmp(fileName, "-f") == 0) // mozilla test driver script uses "-f" prefix for files - continue; - if (strcmp(fileName, "-p") == 0) { - prettyPrint = true; - continue; - } - fileNames.append(fileName); - } -} - -int kjsmain(int argc, char** argv) -{ - JSLock lock; - - bool prettyPrint = false; - Vector fileNames; - parseArguments(argc, argv, fileNames, prettyPrint); - - bool success = runWithScripts(fileNames, prettyPrint); - -#ifndef NDEBUG - Collector::collect(); -#endif - - return success ? 0 : 3; -} - -static bool fillBufferWithContentsOfFile(const UString& fileName, Vector& buffer) -{ - FILE* f = fopen(fileName.UTF8String().c_str(), "r"); - if (!f) { - fprintf(stderr, "Could not open file: %s\n", fileName.UTF8String().c_str()); - return false; - } - - size_t buffer_size = 0; - size_t buffer_capacity = 1024; - - buffer.resize(buffer_capacity); - - while (!feof(f) && !ferror(f)) { - buffer_size += fread(buffer.data() + buffer_size, 1, buffer_capacity - buffer_size, f); - if (buffer_size == buffer_capacity) { // guarantees space for trailing '\0' - buffer_capacity *= 2; - buffer.resize(buffer_capacity); - } - } - fclose(f); - buffer[buffer_size] = '\0'; - - return true; -} diff --git a/kjs/testkjs.pro b/kjs/testkjs.pro deleted file mode 100644 index ab3016b..0000000 --- a/kjs/testkjs.pro +++ /dev/null @@ -1,34 +0,0 @@ -TEMPLATE = app -TARGET = testkjs -DESTDIR = .. -SOURCES = testkjs.cpp -QT -= gui -DEFINES -= KJS_IDENTIFIER_HIDE_GLOBALS -INCLUDEPATH += $$PWD/.. $$PWD $$PWD/../bindings $$PWD/../bindings/c $$PWD/../wtf -CONFIG -= app_bundle -qt-port:DEFINES += BUILDING_QT__ -#qt-port:LIBS += -L$$OUTPUT_DIR/lib -lQtWebKit -gtk-port { - QMAKE_CXXFLAGS += $$system(icu-config --cppflags) - LIBS += $$system(icu-config --ldflags) -} -QMAKE_RPATHDIR += $$OUTPUT_DIR/lib - -isEmpty(OUTPUT_DIR):OUTPUT_DIR=$$PWD/../.. -include($$OUTPUT_DIR/config.pri) -OBJECTS_DIR = tmp -OBJECTS_DIR_WTR = $$OBJECTS_DIR/ -win32-*: OBJECTS_DIR_WTR ~= s|/|\| -include($$PWD/../JavaScriptCore.pri) - -# Hack! Fix this. -SOURCES -= API/JSBase.cpp \ - API/JSCallbackConstructor.cpp \ - API/JSCallbackFunction.cpp \ - API/JSCallbackObject.cpp \ - API/JSClassRef.cpp \ - API/JSContextRef.cpp \ - API/JSObjectRef.cpp \ - API/JSStringRef.cpp \ - API/JSValueRef.cpp - diff --git a/kjs/types.h b/kjs/types.h deleted file mode 100644 index 603b2a2..0000000 --- a/kjs/types.h +++ /dev/null @@ -1,25 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * This file is part of the KDE libraries - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "completion.h" -#include "list.h" diff --git a/kjs/ustring.cpp b/kjs/ustring.cpp deleted file mode 100644 index 6f6add8..0000000 --- a/kjs/ustring.cpp +++ /dev/null @@ -1,1281 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" -#include "ustring.h" - -#include "JSLock.h" -#include "collector.h" -#include "dtoa.h" -#include "function.h" -#include "identifier.h" -#include "operations.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if HAVE(STRING_H) -#include -#endif -#if HAVE(STRINGS_H) -#include -#endif - -using namespace WTF; -using namespace WTF::Unicode; -using namespace std; - -namespace KJS { - -extern const double NaN; -extern const double Inf; - -static inline const size_t overflowIndicator() { return std::numeric_limits::max(); } -static inline const size_t maxUChars() { return std::numeric_limits::max() / sizeof(UChar); } - -static inline UChar* allocChars(size_t length) -{ - ASSERT(length); - if (length > maxUChars()) - return 0; - return static_cast(fastMalloc(sizeof(UChar) * length)); -} - -static inline UChar* reallocChars(UChar* buffer, size_t length) -{ - ASSERT(length); - if (length > maxUChars()) - return 0; - return static_cast(fastRealloc(buffer, sizeof(UChar) * length)); -} - -COMPILE_ASSERT(sizeof(UChar) == 2, uchar_is_2_bytes) - -CString::CString(const char *c) -{ - length = strlen(c); - data = new char[length+1]; - memcpy(data, c, length + 1); -} - -CString::CString(const char *c, size_t len) -{ - length = len; - data = new char[len+1]; - memcpy(data, c, len); - data[len] = 0; -} - -CString::CString(const CString &b) -{ - length = b.length; - if (b.data) { - data = new char[length+1]; - memcpy(data, b.data, length + 1); - } - else - data = 0; -} - -CString::~CString() -{ - delete [] data; -} - -CString &CString::append(const CString &t) -{ - char *n; - n = new char[length+t.length+1]; - if (length) - memcpy(n, data, length); - if (t.length) - memcpy(n+length, t.data, t.length); - length += t.length; - n[length] = 0; - - delete [] data; - data = n; - - return *this; -} - -CString &CString::operator=(const char *c) -{ - if (data) - delete [] data; - length = strlen(c); - data = new char[length+1]; - memcpy(data, c, length + 1); - - return *this; -} - -CString &CString::operator=(const CString &str) -{ - if (this == &str) - return *this; - - if (data) - delete [] data; - length = str.length; - if (str.data) { - data = new char[length + 1]; - memcpy(data, str.data, length + 1); - } - else - data = 0; - - return *this; -} - -bool operator==(const CString& c1, const CString& c2) -{ - size_t len = c1.size(); - return len == c2.size() && (len == 0 || memcmp(c1.c_str(), c2.c_str(), len) == 0); -} - -// Hack here to avoid a global with a constructor; point to an unsigned short instead of a UChar. -static unsigned short almostUChar; -UString::Rep UString::Rep::null = { 0, 0, 1, 0, 0, &UString::Rep::null, 0, 0, 0, 0, 0, 0 }; -UString::Rep UString::Rep::empty = { 0, 0, 1, 0, 0, &UString::Rep::empty, 0, reinterpret_cast(&almostUChar), 0, 0, 0, 0 }; -const int normalStatBufferSize = 4096; -static char *statBuffer = 0; // FIXME: This buffer is never deallocated. -static int statBufferSize = 0; - -PassRefPtr UString::Rep::createCopying(const UChar *d, int l) -{ - int sizeInBytes = l * sizeof(UChar); - UChar *copyD = static_cast(fastMalloc(sizeInBytes)); - memcpy(copyD, d, sizeInBytes); - - return create(copyD, l); -} - -PassRefPtr UString::Rep::create(UChar *d, int l) -{ - Rep* r = new Rep; - r->offset = 0; - r->len = l; - r->rc = 1; - r->_hash = 0; - r->isIdentifier = 0; - r->baseString = r; - r->reportedCost = 0; - r->buf = d; - r->usedCapacity = l; - r->capacity = l; - r->usedPreCapacity = 0; - r->preCapacity = 0; - - // steal the single reference this Rep was created with - return adoptRef(r); -} - -PassRefPtr UString::Rep::create(PassRefPtr base, int offset, int length) -{ - ASSERT(base); - - int baseOffset = base->offset; - - base = base->baseString; - - ASSERT(-(offset + baseOffset) <= base->usedPreCapacity); - ASSERT(offset + baseOffset + length <= base->usedCapacity); - - Rep *r = new Rep; - r->offset = baseOffset + offset; - r->len = length; - r->rc = 1; - r->_hash = 0; - r->isIdentifier = 0; - r->baseString = base.releaseRef(); - r->reportedCost = 0; - r->buf = 0; - r->usedCapacity = 0; - r->capacity = 0; - r->usedPreCapacity = 0; - r->preCapacity = 0; - - // steal the single reference this Rep was created with - return adoptRef(r); -} - -void UString::Rep::destroy() -{ - if (isIdentifier) - Identifier::remove(this); - if (baseString != this) { - baseString->deref(); - } else { - fastFree(buf); - } - delete this; -} - -// Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's -// or anything like that. -const unsigned PHI = 0x9e3779b9U; - -// Paul Hsieh's SuperFastHash -// http://www.azillionmonkeys.com/qed/hash.html -unsigned UString::Rep::computeHash(const UChar *s, int len) -{ - unsigned l = len; - uint32_t hash = PHI; - uint32_t tmp; - - int rem = l & 1; - l >>= 1; - - // Main loop - for (; l > 0; l--) { - hash += s[0].uc; - tmp = (s[1].uc << 11) ^ hash; - hash = (hash << 16) ^ tmp; - s += 2; - hash += hash >> 11; - } - - // Handle end case - if (rem) { - hash += s[0].uc; - hash ^= hash << 11; - hash += hash >> 17; - } - - // Force "avalanching" of final 127 bits - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 2; - hash += hash >> 15; - hash ^= hash << 10; - - // this avoids ever returning a hash code of 0, since that is used to - // signal "hash not computed yet", using a value that is likely to be - // effectively the same as 0 when the low bits are masked - if (hash == 0) - hash = 0x80000000; - - return hash; -} - -// Paul Hsieh's SuperFastHash -// http://www.azillionmonkeys.com/qed/hash.html -unsigned UString::Rep::computeHash(const char *s) -{ - // This hash is designed to work on 16-bit chunks at a time. But since the normal case - // (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they - // were 16-bit chunks, which should give matching results - - uint32_t hash = PHI; - uint32_t tmp; - size_t l = strlen(s); - - size_t rem = l & 1; - l >>= 1; - - // Main loop - for (; l > 0; l--) { - hash += (unsigned char)s[0]; - tmp = ((unsigned char)s[1] << 11) ^ hash; - hash = (hash << 16) ^ tmp; - s += 2; - hash += hash >> 11; - } - - // Handle end case - if (rem) { - hash += (unsigned char)s[0]; - hash ^= hash << 11; - hash += hash >> 17; - } - - // Force "avalanching" of final 127 bits - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 2; - hash += hash >> 15; - hash ^= hash << 10; - - // this avoids ever returning a hash code of 0, since that is used to - // signal "hash not computed yet", using a value that is likely to be - // effectively the same as 0 when the low bits are masked - if (hash == 0) - hash = 0x80000000; - - return hash; -} - -// put these early so they can be inlined -inline size_t UString::expandedSize(size_t size, size_t otherSize) const -{ - // Do the size calculation in two parts, returning overflowIndicator if - // we overflow the maximum value that we can handle. - - if (size > maxUChars()) - return overflowIndicator(); - - size_t expandedSize = ((size + 10) / 10 * 11) + 1; - if (maxUChars() - expandedSize < otherSize) - return overflowIndicator(); - - return expandedSize + otherSize; -} - -inline int UString::usedCapacity() const -{ - return m_rep->baseString->usedCapacity; -} - -inline int UString::usedPreCapacity() const -{ - return m_rep->baseString->usedPreCapacity; -} - -void UString::expandCapacity(int requiredLength) -{ - Rep* r = m_rep->baseString; - - if (requiredLength > r->capacity) { - size_t newCapacity = expandedSize(requiredLength, r->preCapacity); - UChar* oldBuf = r->buf; - r->buf = reallocChars(r->buf, newCapacity); - if (!r->buf) { - r->buf = oldBuf; - m_rep = &Rep::null; - return; - } - r->capacity = newCapacity - r->preCapacity; - } - if (requiredLength > r->usedCapacity) { - r->usedCapacity = requiredLength; - } -} - -void UString::expandPreCapacity(int requiredPreCap) -{ - Rep* r = m_rep->baseString; - - if (requiredPreCap > r->preCapacity) { - size_t newCapacity = expandedSize(requiredPreCap, r->capacity); - int delta = newCapacity - r->capacity - r->preCapacity; - - UChar* newBuf = allocChars(newCapacity); - if (!newBuf) { - m_rep = &Rep::null; - return; - } - memcpy(newBuf + delta, r->buf, (r->capacity + r->preCapacity) * sizeof(UChar)); - fastFree(r->buf); - r->buf = newBuf; - - r->preCapacity = newCapacity - r->capacity; - } - if (requiredPreCap > r->usedPreCapacity) { - r->usedPreCapacity = requiredPreCap; - } -} - -UString::UString(const char *c) -{ - if (!c) { - m_rep = &Rep::null; - return; - } - - if (!c[0]) { - m_rep = &Rep::empty; - return; - } - - size_t length = strlen(c); - UChar *d = allocChars(length); - if (!d) - m_rep = &Rep::null; - else { - for (size_t i = 0; i < length; i++) - d[i].uc = c[i]; - m_rep = Rep::create(d, static_cast(length)); - } -} - -UString::UString(const UChar *c, int length) -{ - if (length == 0) - m_rep = &Rep::empty; - else - m_rep = Rep::createCopying(c, length); -} - -UString::UString(UChar *c, int length, bool copy) -{ - if (length == 0) - m_rep = &Rep::empty; - else if (copy) - m_rep = Rep::createCopying(c, length); - else - m_rep = Rep::create(c, length); -} - -UString::UString(const Vector& buffer) -{ - if (!buffer.size()) - m_rep = &Rep::empty; - else - m_rep = Rep::createCopying(buffer.data(), buffer.size()); -} - - -UString::UString(const UString &a, const UString &b) -{ - int aSize = a.size(); - int aOffset = a.m_rep->offset; - int bSize = b.size(); - int bOffset = b.m_rep->offset; - int length = aSize + bSize; - - // possible cases: - - if (aSize == 0) { - // a is empty - m_rep = b.m_rep; - } else if (bSize == 0) { - // b is empty - m_rep = a.m_rep; - } else if (aOffset + aSize == a.usedCapacity() && aSize >= minShareSize && 4 * aSize >= bSize && - (-bOffset != b.usedPreCapacity() || aSize >= bSize)) { - // - a reaches the end of its buffer so it qualifies for shared append - // - also, it's at least a quarter the length of b - appending to a much shorter - // string does more harm than good - // - however, if b qualifies for prepend and is longer than a, we'd rather prepend - UString x(a); - x.expandCapacity(aOffset + length); - if (a.data() && x.data()) { - memcpy(const_cast(a.data() + aSize), b.data(), bSize * sizeof(UChar)); - m_rep = Rep::create(a.m_rep, 0, length); - } else - m_rep = &Rep::null; - } else if (-bOffset == b.usedPreCapacity() && bSize >= minShareSize && 4 * bSize >= aSize) { - // - b reaches the beginning of its buffer so it qualifies for shared prepend - // - also, it's at least a quarter the length of a - prepending to a much shorter - // string does more harm than good - UString y(b); - y.expandPreCapacity(-bOffset + aSize); - if (b.data() && y.data()) { - memcpy(const_cast(b.data() - aSize), a.data(), aSize * sizeof(UChar)); - m_rep = Rep::create(b.m_rep, -aSize, length); - } else - m_rep = &Rep::null; - } else { - // a does not qualify for append, and b does not qualify for prepend, gotta make a whole new string - size_t newCapacity = expandedSize(length, 0); - UChar* d = allocChars(newCapacity); - if (!d) - m_rep = &Rep::null; - else { - memcpy(d, a.data(), aSize * sizeof(UChar)); - memcpy(d + aSize, b.data(), bSize * sizeof(UChar)); - m_rep = Rep::create(d, length); - m_rep->capacity = newCapacity; - } - } -} - -const UString& UString::null() -{ - static UString* n = new UString; - return *n; -} - -UString UString::from(int i) -{ - UChar buf[1 + sizeof(i) * 3]; - UChar *end = buf + sizeof(buf) / sizeof(UChar); - UChar *p = end; - - if (i == 0) { - *--p = '0'; - } else if (i == INT_MIN) { - char minBuf[1 + sizeof(i) * 3]; - snprintf(minBuf, 1 + sizeof(i) * 3, "%d", INT_MIN); - return UString(minBuf); - } else { - bool negative = false; - if (i < 0) { - negative = true; - i = -i; - } - while (i) { - *--p = (unsigned short)((i % 10) + '0'); - i /= 10; - } - if (negative) { - *--p = '-'; - } - } - - return UString(p, static_cast(end - p)); -} - -UString UString::from(unsigned int u) -{ - UChar buf[sizeof(u) * 3]; - UChar *end = buf + sizeof(buf) / sizeof(UChar); - UChar *p = end; - - if (u == 0) { - *--p = '0'; - } else { - while (u) { - *--p = (unsigned short)((u % 10) + '0'); - u /= 10; - } - } - - return UString(p, static_cast(end - p)); -} - -UString UString::from(long l) -{ - UChar buf[1 + sizeof(l) * 3]; - UChar *end = buf + sizeof(buf) / sizeof(UChar); - UChar *p = end; - - if (l == 0) { - *--p = '0'; - } else if (l == LONG_MIN) { - char minBuf[1 + sizeof(l) * 3]; - snprintf(minBuf, 1 + sizeof(l) * 3, "%ld", LONG_MIN); - return UString(minBuf); - } else { - bool negative = false; - if (l < 0) { - negative = true; - l = -l; - } - while (l) { - *--p = (unsigned short)((l % 10) + '0'); - l /= 10; - } - if (negative) { - *--p = '-'; - } - } - - return UString(p, static_cast(end - p)); -} - -UString UString::from(double d) -{ - // avoid ever printing -NaN, in JS conceptually there is only one NaN value - if (isnan(d)) - return "NaN"; - - int buflength= 80; - char buf[buflength]; - int decimalPoint; - int sign; - - char *result = kjs_dtoa(d, 0, 0, &decimalPoint, &sign, NULL); - int length = static_cast(strlen(result)); - - int i = 0; - if (sign) { - buf[i++] = '-'; - } - - if (decimalPoint <= 0 && decimalPoint > -6) { - buf[i++] = '0'; - buf[i++] = '.'; - for (int j = decimalPoint; j < 0; j++) { - buf[i++] = '0'; - } - strlcpy(buf + i, result, buflength - i); - } else if (decimalPoint <= 21 && decimalPoint > 0) { - if (length <= decimalPoint) { - strlcpy(buf + i, result, buflength - i); - i += length; - for (int j = 0; j < decimalPoint - length; j++) { - buf[i++] = '0'; - } - buf[i] = '\0'; - } else { - int len = (decimalPoint <= buflength - i ? decimalPoint : buflength - i); - strncpy(buf + i, result, len); - i += len; - buf[i++] = '.'; - strlcpy(buf + i, result + decimalPoint, buflength - i); - } - } else if (result[0] < '0' || result[0] > '9') { - strlcpy(buf + i, result, buflength - i); - } else { - buf[i++] = result[0]; - if (length > 1) { - buf[i++] = '.'; - strlcpy(buf + i, result + 1, buflength - i); - i += length - 1; - } - - buf[i++] = 'e'; - buf[i++] = (decimalPoint >= 0) ? '+' : '-'; - // decimalPoint can't be more than 3 digits decimal given the - // nature of float representation - int exponential = decimalPoint - 1; - if (exponential < 0) - exponential = -exponential; - if (exponential >= 100) - buf[i++] = static_cast('0' + exponential / 100); - if (exponential >= 10) - buf[i++] = static_cast('0' + (exponential % 100) / 10); - buf[i++] = static_cast('0' + exponential % 10); - buf[i++] = '\0'; - assert(i <= buflength); - } - - kjs_freedtoa(result); - - return UString(buf); -} - -UString UString::spliceSubstringsWithSeparators(const Range* substringRanges, int rangeCount, const UString* separators, int separatorCount) const -{ - if (rangeCount == 1 && separatorCount == 0) { - int thisSize = size(); - int position = substringRanges[0].position; - int length = substringRanges[0].length; - if (position <= 0 && length >= thisSize) - return *this; - return UString::Rep::create(m_rep, max(0, position), min(thisSize, length)); - } - - int totalLength = 0; - for (int i = 0; i < rangeCount; i++) - totalLength += substringRanges[i].length; - for (int i = 0; i < separatorCount; i++) - totalLength += separators[i].size(); - - if (totalLength == 0) - return ""; - - UChar* buffer = allocChars(totalLength); - if (!buffer) - return null(); - - int maxCount = max(rangeCount, separatorCount); - int bufferPos = 0; - for (int i = 0; i < maxCount; i++) { - if (i < rangeCount) { - memcpy(buffer + bufferPos, data() + substringRanges[i].position, substringRanges[i].length * sizeof(UChar)); - bufferPos += substringRanges[i].length; - } - if (i < separatorCount) { - memcpy(buffer + bufferPos, separators[i].data(), separators[i].size() * sizeof(UChar)); - bufferPos += separators[i].size(); - } - } - - return UString::Rep::create(buffer, totalLength); -} - -UString &UString::append(const UString &t) -{ - int thisSize = size(); - int thisOffset = m_rep->offset; - int tSize = t.size(); - int length = thisSize + tSize; - - // possible cases: - if (thisSize == 0) { - // this is empty - *this = t; - } else if (tSize == 0) { - // t is empty - } else if (m_rep->baseIsSelf() && m_rep->rc == 1) { - // this is direct and has refcount of 1 (so we can just alter it directly) - expandCapacity(thisOffset + length); - if (data()) { - memcpy(const_cast(data() + thisSize), t.data(), tSize * sizeof(UChar)); - m_rep->len = length; - m_rep->_hash = 0; - } - } else if (thisOffset + thisSize == usedCapacity() && thisSize >= minShareSize) { - // this reaches the end of the buffer - extend it if it's long enough to append to - expandCapacity(thisOffset + length); - if (data()) { - memcpy(const_cast(data() + thisSize), t.data(), tSize * sizeof(UChar)); - m_rep = Rep::create(m_rep, 0, length); - } - } else { - // this is shared with someone using more capacity, gotta make a whole new string - size_t newCapacity = expandedSize(length, 0); - UChar* d = allocChars(newCapacity); - if (!d) - m_rep = &Rep::null; - else { - memcpy(d, data(), thisSize * sizeof(UChar)); - memcpy(const_cast(d + thisSize), t.data(), tSize * sizeof(UChar)); - m_rep = Rep::create(d, length); - m_rep->capacity = newCapacity; - } - } - - return *this; -} - -UString &UString::append(const char *t) -{ - int thisSize = size(); - int thisOffset = m_rep->offset; - int tSize = static_cast(strlen(t)); - int length = thisSize + tSize; - - // possible cases: - if (thisSize == 0) { - // this is empty - *this = t; - } else if (tSize == 0) { - // t is empty, we'll just return *this below. - } else if (m_rep->baseIsSelf() && m_rep->rc == 1) { - // this is direct and has refcount of 1 (so we can just alter it directly) - expandCapacity(thisOffset + length); - UChar *d = const_cast(data()); - if (d) { - for (int i = 0; i < tSize; ++i) - d[thisSize + i] = t[i]; - m_rep->len = length; - m_rep->_hash = 0; - } - } else if (thisOffset + thisSize == usedCapacity() && thisSize >= minShareSize) { - // this string reaches the end of the buffer - extend it - expandCapacity(thisOffset + length); - UChar *d = const_cast(data()); - if (d) { - for (int i = 0; i < tSize; ++i) - d[thisSize + i] = t[i]; - m_rep = Rep::create(m_rep, 0, length); - } - } else { - // this is shared with someone using more capacity, gotta make a whole new string - size_t newCapacity = expandedSize(length, 0); - UChar* d = allocChars(newCapacity); - if (!d) - m_rep = &Rep::null; - else { - memcpy(d, data(), thisSize * sizeof(UChar)); - for (int i = 0; i < tSize; ++i) - d[thisSize + i] = t[i]; - m_rep = Rep::create(d, length); - m_rep->capacity = newCapacity; - } - } - - return *this; -} - -UString &UString::append(unsigned short c) -{ - int thisOffset = m_rep->offset; - int length = size(); - - // possible cases: - if (length == 0) { - // this is empty - must make a new m_rep because we don't want to pollute the shared empty one - size_t newCapacity = expandedSize(1, 0); - UChar* d = allocChars(newCapacity); - if (!d) - m_rep = &Rep::null; - else { - d[0] = c; - m_rep = Rep::create(d, 1); - m_rep->capacity = newCapacity; - } - } else if (m_rep->baseIsSelf() && m_rep->rc == 1) { - // this is direct and has refcount of 1 (so we can just alter it directly) - expandCapacity(thisOffset + length + 1); - UChar *d = const_cast(data()); - if (d) { - d[length] = c; - m_rep->len = length + 1; - m_rep->_hash = 0; - } - } else if (thisOffset + length == usedCapacity() && length >= minShareSize) { - // this reaches the end of the string - extend it and share - expandCapacity(thisOffset + length + 1); - UChar *d = const_cast(data()); - if (d) { - d[length] = c; - m_rep = Rep::create(m_rep, 0, length + 1); - } - } else { - // this is shared with someone using more capacity, gotta make a whole new string - size_t newCapacity = expandedSize(length + 1, 0); - UChar* d = allocChars(newCapacity); - if (!d) - m_rep = &Rep::null; - else { - memcpy(d, data(), length * sizeof(UChar)); - d[length] = c; - m_rep = Rep::create(d, length + 1); - m_rep->capacity = newCapacity; - } - } - - return *this; -} - -CString UString::cstring() const -{ - return ascii(); -} - -char *UString::ascii() const -{ - // Never make the buffer smaller than normalStatBufferSize. - // Thus we almost never need to reallocate. - int length = size(); - int neededSize = length + 1; - if (neededSize < normalStatBufferSize) { - neededSize = normalStatBufferSize; - } - if (neededSize != statBufferSize) { - delete [] statBuffer; - statBuffer = new char [neededSize]; - statBufferSize = neededSize; - } - - const UChar *p = data(); - char *q = statBuffer; - const UChar *limit = p + length; - while (p != limit) { - *q = static_cast(p->uc); - ++p; - ++q; - } - *q = '\0'; - - return statBuffer; -} - -UString &UString::operator=(const char *c) -{ - if (!c) { - m_rep = &Rep::null; - return *this; - } - - if (!c[0]) { - m_rep = &Rep::empty; - return *this; - } - - int l = static_cast(strlen(c)); - UChar *d; - if (m_rep->rc == 1 && l <= m_rep->capacity && m_rep->baseIsSelf() && m_rep->offset == 0 && m_rep->preCapacity == 0) { - d = m_rep->buf; - m_rep->_hash = 0; - m_rep->len = l; - } else { - d = allocChars(l); - if (!d) { - m_rep = &Rep::null; - return *this; - } - m_rep = Rep::create(d, l); - } - for (int i = 0; i < l; i++) - d[i].uc = c[i]; - - return *this; -} - -bool UString::is8Bit() const -{ - const UChar *u = data(); - const UChar *limit = u + size(); - while (u < limit) { - if (u->uc > 0xFF) - return false; - ++u; - } - - return true; -} - -const UChar UString::operator[](int pos) const -{ - if (pos >= size()) - return '\0'; - return data()[pos]; -} - -double UString::toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const -{ - double d; - - // FIXME: If tolerateTrailingJunk is true, then we want to tolerate non-8-bit junk - // after the number, so is8Bit is too strict a check. - if (!is8Bit()) - return NaN; - - const char *c = ascii(); - - // skip leading white space - while (isASCIISpace(*c)) - c++; - - // empty string ? - if (*c == '\0') - return tolerateEmptyString ? 0.0 : NaN; - - // hex number ? - if (*c == '0' && (*(c+1) == 'x' || *(c+1) == 'X')) { - const char* firstDigitPosition = c + 2; - c++; - d = 0.0; - while (*(++c)) { - if (*c >= '0' && *c <= '9') - d = d * 16.0 + *c - '0'; - else if ((*c >= 'A' && *c <= 'F') || (*c >= 'a' && *c <= 'f')) - d = d * 16.0 + (*c & 0xdf) - 'A' + 10.0; - else - break; - } - - if (d >= mantissaOverflowLowerBound) - d = parseIntOverflow(firstDigitPosition, c - firstDigitPosition, 16); - } else { - // regular number ? - char *end; - d = kjs_strtod(c, &end); - if ((d != 0.0 || end != c) && d != Inf && d != -Inf) { - c = end; - } else { - double sign = 1.0; - - if (*c == '+') - c++; - else if (*c == '-') { - sign = -1.0; - c++; - } - - // We used strtod() to do the conversion. However, strtod() handles - // infinite values slightly differently than JavaScript in that it - // converts the string "inf" with any capitalization to infinity, - // whereas the ECMA spec requires that it be converted to NaN. - - if (c[0] == 'I' && c[1] == 'n' && c[2] == 'f' && c[3] == 'i' && c[4] == 'n' && c[5] == 'i' && c[6] == 't' && c[7] == 'y') { - d = sign * Inf; - c += 8; - } else if ((d == Inf || d == -Inf) && *c != 'I' && *c != 'i') - c = end; - else - return NaN; - } - } - - // allow trailing white space - while (isASCIISpace(*c)) - c++; - // don't allow anything after - unless tolerant=true - if (!tolerateTrailingJunk && *c != '\0') - d = NaN; - - return d; -} - -double UString::toDouble(bool tolerateTrailingJunk) const -{ - return toDouble(tolerateTrailingJunk, true); -} - -double UString::toDouble() const -{ - return toDouble(false, true); -} - -uint32_t UString::toUInt32(bool *ok) const -{ - double d = toDouble(); - bool b = true; - - if (d != static_cast(d)) { - b = false; - d = 0; - } - - if (ok) - *ok = b; - - return static_cast(d); -} - -uint32_t UString::toUInt32(bool *ok, bool tolerateEmptyString) const -{ - double d = toDouble(false, tolerateEmptyString); - bool b = true; - - if (d != static_cast(d)) { - b = false; - d = 0; - } - - if (ok) - *ok = b; - - return static_cast(d); -} - -uint32_t UString::toStrictUInt32(bool *ok) const -{ - if (ok) - *ok = false; - - // Empty string is not OK. - int len = m_rep->len; - if (len == 0) - return 0; - const UChar *p = m_rep->data(); - unsigned short c = p->unicode(); - - // If the first digit is 0, only 0 itself is OK. - if (c == '0') { - if (len == 1 && ok) - *ok = true; - return 0; - } - - // Convert to UInt32, checking for overflow. - uint32_t i = 0; - while (1) { - // Process character, turning it into a digit. - if (c < '0' || c > '9') - return 0; - const unsigned d = c - '0'; - - // Multiply by 10, checking for overflow out of 32 bits. - if (i > 0xFFFFFFFFU / 10) - return 0; - i *= 10; - - // Add in the digit, checking for overflow out of 32 bits. - const unsigned max = 0xFFFFFFFFU - d; - if (i > max) - return 0; - i += d; - - // Handle end of string. - if (--len == 0) { - if (ok) - *ok = true; - return i; - } - - // Get next character. - c = (++p)->unicode(); - } -} - -int UString::find(const UString &f, int pos) const -{ - int sz = size(); - int fsz = f.size(); - if (sz < fsz) - return -1; - if (pos < 0) - pos = 0; - if (fsz == 0) - return pos; - const UChar *end = data() + sz - fsz; - int fsizeminusone = (fsz - 1) * sizeof(UChar); - const UChar *fdata = f.data(); - unsigned short fchar = fdata->uc; - ++fdata; - for (const UChar *c = data() + pos; c <= end; c++) - if (c->uc == fchar && !memcmp(c + 1, fdata, fsizeminusone)) - return static_cast(c - data()); - - return -1; -} - -int UString::find(UChar ch, int pos) const -{ - if (pos < 0) - pos = 0; - const UChar *end = data() + size(); - for (const UChar *c = data() + pos; c < end; c++) - if (*c == ch) - return static_cast(c - data()); - - return -1; -} - -int UString::rfind(const UString &f, int pos) const -{ - int sz = size(); - int fsz = f.size(); - if (sz < fsz) - return -1; - if (pos < 0) - pos = 0; - if (pos > sz - fsz) - pos = sz - fsz; - if (fsz == 0) - return pos; - int fsizeminusone = (fsz - 1) * sizeof(UChar); - const UChar *fdata = f.data(); - for (const UChar *c = data() + pos; c >= data(); c--) { - if (*c == *fdata && !memcmp(c + 1, fdata + 1, fsizeminusone)) - return static_cast(c - data()); - } - - return -1; -} - -int UString::rfind(UChar ch, int pos) const -{ - if (isEmpty()) - return -1; - if (pos + 1 >= size()) - pos = size() - 1; - for (const UChar *c = data() + pos; c >= data(); c--) { - if (*c == ch) - return static_cast(c-data()); - } - - return -1; -} - -UString UString::substr(int pos, int len) const -{ - int s = size(); - - if (pos < 0) - pos = 0; - else if (pos >= s) - pos = s; - if (len < 0) - len = s; - if (pos + len >= s) - len = s - pos; - - if (pos == 0 && len == s) - return *this; - - return UString(Rep::create(m_rep, pos, len)); -} - -bool operator==(const UString& s1, const UString& s2) -{ - if (s1.m_rep->len != s2.m_rep->len) - return false; - - return (memcmp(s1.m_rep->data(), s2.m_rep->data(), - s1.m_rep->len * sizeof(UChar)) == 0); -} - -bool operator==(const UString& s1, const char *s2) -{ - if (s2 == 0) { - return s1.isEmpty(); - } - - const UChar *u = s1.data(); - const UChar *uend = u + s1.size(); - while (u != uend && *s2) { - if (u->uc != (unsigned char)*s2) - return false; - s2++; - u++; - } - - return u == uend && *s2 == 0; -} - -bool operator<(const UString& s1, const UString& s2) -{ - const int l1 = s1.size(); - const int l2 = s2.size(); - const int lmin = l1 < l2 ? l1 : l2; - const UChar *c1 = s1.data(); - const UChar *c2 = s2.data(); - int l = 0; - while (l < lmin && *c1 == *c2) { - c1++; - c2++; - l++; - } - if (l < lmin) - return (c1->uc < c2->uc); - - return (l1 < l2); -} - -int compare(const UString& s1, const UString& s2) -{ - const int l1 = s1.size(); - const int l2 = s2.size(); - const int lmin = l1 < l2 ? l1 : l2; - const UChar *c1 = s1.data(); - const UChar *c2 = s2.data(); - int l = 0; - while (l < lmin && *c1 == *c2) { - c1++; - c2++; - l++; - } - - if (l < lmin) - return (c1->uc > c2->uc) ? 1 : -1; - - if (l1 == l2) - return 0; - - return (l1 > l2) ? 1 : -1; -} - -CString UString::UTF8String(bool strict) const -{ - // Allocate a buffer big enough to hold all the characters. - const int length = size(); - Vector buffer(length * 3); - - // Convert to runs of 8-bit characters. - char* p = buffer.data(); - const ::UChar* d = reinterpret_cast(&data()->uc); - ConversionResult result = convertUTF16ToUTF8(&d, d + length, &p, p + buffer.size(), strict); - if (result != conversionOK) - return CString(); - - return CString(buffer.data(), p - buffer.data()); -} - -} // namespace KJS diff --git a/kjs/ustring.h b/kjs/ustring.h deleted file mode 100644 index dba58d7..0000000 --- a/kjs/ustring.h +++ /dev/null @@ -1,470 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef _KJS_USTRING_H_ -#define _KJS_USTRING_H_ - -#include "JSLock.h" -#include "collector.h" -#include -#include -#include -#include -#include -#include - -/* On some ARM platforms GCC won't pack structures by default so sizeof(UChar) - will end up being != 2 which causes crashes since the code depends on that. */ -#if COMPILER(GCC) && PLATFORM(FORCE_PACK) -#define PACK_STRUCT __attribute__((packed)) -#else -#define PACK_STRUCT -#endif - -/** - * @internal - */ -namespace DOM { - class DOMString; - class AtomicString; -} -class KJScript; - -namespace KJS { - - using WTF::PlacementNewAdoptType; - using WTF::PlacementNewAdopt; - - class UString; - - /** - * @short Unicode character. - * - * UChar represents a 16 bit Unicode character. It's internal data - * representation is compatible to XChar2b and QChar. It's therefore - * possible to exchange data with X and Qt with shallow copies. - */ - struct UChar { - /** - * Construct a character with uninitialized value. - */ - UChar(); - /** - * Construct a character with the value denoted by the arguments. - * @param h higher byte - * @param l lower byte - */ - UChar(unsigned char h , unsigned char l); - /** - * Construct a character with the given value. - * @param u 16 bit Unicode value - */ - UChar(char u); - UChar(unsigned char u); - UChar(unsigned short u); - /** - * @return The higher byte of the character. - */ - unsigned char high() const { return static_cast(uc >> 8); } - /** - * @return The lower byte of the character. - */ - unsigned char low() const { return static_cast(uc); } - /** - * @return the 16 bit Unicode value of the character - */ - unsigned short unicode() const { return uc; } - - unsigned short uc; - } PACK_STRUCT; - - inline UChar::UChar() { } - inline UChar::UChar(unsigned char h , unsigned char l) : uc(h << 8 | l) { } - inline UChar::UChar(char u) : uc((unsigned char)u) { } - inline UChar::UChar(unsigned char u) : uc(u) { } - inline UChar::UChar(unsigned short u) : uc(u) { } - - /** - * @short 8 bit char based string class - */ - class CString { - public: - CString() : data(0), length(0) { } - CString(const char *c); - CString(const char *c, size_t len); - CString(const CString &); - - ~CString(); - - CString &append(const CString &); - CString &operator=(const char *c); - CString &operator=(const CString &); - CString &operator+=(const CString &c) { return append(c); } - - size_t size() const { return length; } - const char *c_str() const { return data; } - private: - char *data; - size_t length; - }; - - /** - * @short Unicode string class - */ - class UString { - friend bool operator==(const UString&, const UString&); - - public: - /** - * @internal - */ - struct Rep { - - static PassRefPtr create(UChar *d, int l); - static PassRefPtr createCopying(const UChar *d, int l); - static PassRefPtr create(PassRefPtr base, int offset, int length); - - void destroy(); - - bool baseIsSelf() const { return baseString == this; } - UChar* data() const { return baseString->buf + baseString->preCapacity + offset; } - int size() const { return len; } - - unsigned hash() const { if (_hash == 0) _hash = computeHash(data(), len); return _hash; } - unsigned computedHash() const { ASSERT(_hash); return _hash; } // fast path for Identifiers - - static unsigned computeHash(const UChar *, int length); - static unsigned computeHash(const char *); - - Rep* ref() { ++rc; return this; } - ALWAYS_INLINE void deref() { if (--rc == 0) destroy(); } - - // unshared data - int offset; - int len; - int rc; - mutable unsigned _hash; - bool isIdentifier; - UString::Rep* baseString; - size_t reportedCost; - - // potentially shared data - UChar *buf; - int usedCapacity; - int capacity; - int usedPreCapacity; - int preCapacity; - - static Rep null; - static Rep empty; - }; - - public: - - /** - * Constructs a null string. - */ - UString(); - /** - * Constructs a string from a classical zero-terminated char string. - */ - UString(const char *c); - /** - * Constructs a string from an array of Unicode characters of the specified - * length. - */ - UString(const UChar *c, int length); - /** - * If copy is false the string data will be adopted. - * That means that the data will NOT be copied and the pointer will - * be deleted when the UString object is modified or destroyed. - * Behaviour defaults to a deep copy if copy is true. - */ - UString(UChar *c, int length, bool copy); - /** - * Copy constructor. Makes a shallow copy only. - */ - UString(const UString &s) : m_rep(s.m_rep) {} - - UString(const Vector& buffer); - - /** - * Convenience declaration only ! You'll be on your own to write the - * implementation for a construction from DOM::DOMString. - * - * Note: feel free to contact me if you want to see a dummy header for - * your favorite FooString class here ! - */ - UString(const DOM::DOMString&); - /** - * Convenience declaration only ! See UString(const DOM::DOMString&). - */ - UString(const DOM::AtomicString&); - - /** - * Concatenation constructor. Makes operator+ more efficient. - */ - UString(const UString &, const UString &); - /** - * Destructor. - */ - ~UString() {} - - // Special constructor for cases where we overwrite an object in place. - UString(PlacementNewAdoptType) : m_rep(PlacementNewAdopt) { } - - /** - * Constructs a string from an int. - */ - static UString from(int i); - /** - * Constructs a string from an unsigned int. - */ - static UString from(unsigned int u); - /** - * Constructs a string from a long int. - */ - static UString from(long u); - /** - * Constructs a string from a double. - */ - static UString from(double d); - - struct Range { - public: - Range(int pos, int len) : position(pos), length(len) {} - Range() {} - int position; - int length; - }; - - UString spliceSubstringsWithSeparators(const Range *substringRanges, int rangeCount, const UString *separators, int separatorCount) const; - - /** - * Append another string. - */ - UString &append(const UString &); - UString &append(const char *); - UString &append(unsigned short); - UString &append(char c) { return append(static_cast(static_cast(c))); } - UString &append(UChar c) { return append(c.uc); } - - /** - * @return The string converted to the 8-bit string type CString(). - * This method is not Unicode safe and shouldn't be used unless the string - * is known to be ASCII. - */ - CString cstring() const; - /** - * Convert the Unicode string to plain ASCII chars chopping of any higher - * bytes. This method should only be used for *debugging* purposes as it - * is neither Unicode safe nor free from side effects. In order not to - * waste any memory the char buffer is static and *shared* by all UString - * instances. - */ - char *ascii() const; - - /** - * Convert the string to UTF-8, assuming it is UTF-16 encoded. - * In non-strict mode, this function is tolerant of badly formed UTF-16, it - * can create UTF-8 strings that are invalid because they have characters in - * the range U+D800-U+DDFF, U+FFFE, or U+FFFF, but the UTF-8 string is - * guaranteed to be otherwise valid. - * In strict mode, error is returned as null CString. - */ - CString UTF8String(bool strict = false) const; - - /** - * @see UString(const DOM::DOMString&). - */ - DOM::DOMString domString() const; - - /** - * Assignment operator. - */ - UString &operator=(const char *c); - /** - * Appends the specified string. - */ - UString &operator+=(const UString &s) { return append(s); } - UString &operator+=(const char *s) { return append(s); } - - /** - * @return A pointer to the internal Unicode data. - */ - const UChar* data() const { return m_rep->data(); } - /** - * @return True if null. - */ - bool isNull() const { return (m_rep == &Rep::null); } - /** - * @return True if null or zero length. - */ - bool isEmpty() const { return (!m_rep->len); } - /** - * Use this if you want to make sure that this string is a plain ASCII - * string. For example, if you don't want to lose any information when - * using cstring() or ascii(). - * - * @return True if the string doesn't contain any non-ASCII characters. - */ - bool is8Bit() const; - /** - * @return The length of the string. - */ - int size() const { return m_rep->size(); } - /** - * Const character at specified position. - */ - const UChar operator[](int pos) const; - - /** - * Attempts an conversion to a number. Apart from floating point numbers, - * the algorithm will recognize hexadecimal representations (as - * indicated by a 0x or 0X prefix) and +/- Infinity. - * Returns NaN if the conversion failed. - * @param tolerateTrailingJunk if true, toDouble can tolerate garbage after the number. - * @param tolerateEmptyString if false, toDouble will turn an empty string into NaN rather than 0. - */ - double toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const; - double toDouble(bool tolerateTrailingJunk) const; - double toDouble() const; - - /** - * Attempts an conversion to a 32-bit integer. ok will be set - * according to the success. - * @param tolerateEmptyString if false, toUInt32 will return false for *ok for an empty string. - */ - uint32_t toUInt32(bool *ok = 0) const; - uint32_t toUInt32(bool *ok, bool tolerateEmptyString) const; - uint32_t toStrictUInt32(bool *ok = 0) const; - - /** - * Attempts an conversion to an array index. The "ok" boolean will be set - * to true if it is a valid array index according to the rule from - * ECMA 15.2 about what an array index is. It must exactly match the string - * form of an unsigned integer, and be less than 2^32 - 1. - */ - unsigned toArrayIndex(bool *ok = 0) const; - - /** - * @return Position of first occurrence of f starting at position pos. - * -1 if the search was not successful. - */ - int find(const UString &f, int pos = 0) const; - int find(UChar, int pos = 0) const; - /** - * @return Position of first occurrence of f searching backwards from - * position pos. - * -1 if the search was not successful. - */ - int rfind(const UString &f, int pos) const; - int rfind(UChar, int pos) const; - /** - * @return The sub string starting at position pos and length len. - */ - UString substr(int pos = 0, int len = -1) const; - /** - * Static instance of a null string. - */ - static const UString &null(); - - Rep* rep() const { return m_rep.get(); } - UString(PassRefPtr r) : m_rep(r) { ASSERT(m_rep); } - - size_t cost() const; - - private: - size_t expandedSize(size_t size, size_t otherSize) const; - int usedCapacity() const; - int usedPreCapacity() const; - void expandCapacity(int requiredLength); - void expandPreCapacity(int requiredPreCap); - - RefPtr m_rep; - }; - - inline bool operator==(const UChar &c1, const UChar &c2) { - return (c1.uc == c2.uc); - } - bool operator==(const UString& s1, const UString& s2); - inline bool operator!=(const UString& s1, const UString& s2) { - return !KJS::operator==(s1, s2); - } - bool operator<(const UString& s1, const UString& s2); - bool operator==(const UString& s1, const char *s2); - inline bool operator!=(const UString& s1, const char *s2) { - return !KJS::operator==(s1, s2); - } - inline bool operator==(const char *s1, const UString& s2) { - return operator==(s2, s1); - } - inline bool operator!=(const char *s1, const UString& s2) { - return !KJS::operator==(s1, s2); - } - bool operator==(const CString& s1, const CString& s2); - inline UString operator+(const UString& s1, const UString& s2) { - return UString(s1, s2); - } - - int compare(const UString &, const UString &); - -inline UString::UString() - : m_rep(&Rep::null) -{ -} - -// Rule from ECMA 15.2 about what an array index is. -// Must exactly match string form of an unsigned integer, and be less than 2^32 - 1. -inline unsigned UString::toArrayIndex(bool *ok) const -{ - unsigned i = toStrictUInt32(ok); - if (ok && i >= 0xFFFFFFFFU) - *ok = false; - return i; -} - -// We'd rather not do shared substring append for small strings, since -// this runs too much risk of a tiny initial string holding down a -// huge buffer. -// FIXME: this should be size_t but that would cause warnings until we -// fix UString sizes to be size_t instead of int -static const int minShareSize = Collector::minExtraCostSize / sizeof(UChar); - -inline size_t UString::cost() const -{ - size_t capacity = (m_rep->baseString->capacity + m_rep->baseString->preCapacity) * sizeof(UChar); - size_t reportedCost = m_rep->baseString->reportedCost; - ASSERT(capacity >= reportedCost); - - size_t capacityDelta = capacity - reportedCost; - - if (capacityDelta < static_cast(minShareSize)) - return 0; - - m_rep->baseString->reportedCost = capacity; - return capacityDelta; -} - -} // namespace - -#endif diff --git a/kjs/value.h b/kjs/value.h deleted file mode 100644 index 5ebb575..0000000 --- a/kjs/value.h +++ /dev/null @@ -1,523 +0,0 @@ -/* - * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2003, 2004, 2005, 2007 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef KJS_VALUE_H -#define KJS_VALUE_H - -#include "JSImmediate.h" -#include "collector.h" -#include "ustring.h" -#include // for size_t - -namespace KJS { - -class ExecState; -class JSObject; -class JSCell; - -struct ClassInfo; - -/** - * JSValue is the base type for all primitives (Undefined, Null, Boolean, - * String, Number) and objects in ECMAScript. - * - * Note: you should never inherit from JSValue as it is for primitive types - * only (all of which are provided internally by KJS). Instead, inherit from - * JSObject. - */ -class JSValue : Noncopyable { - friend class JSCell; // so it can derive from this class - friend class Collector; // so it can call asCell() - -private: - JSValue(); - virtual ~JSValue(); - -public: - // Querying the type. - JSType type() const; - bool isUndefined() const; - bool isNull() const; - bool isUndefinedOrNull() const; - bool isBoolean() const; - bool isNumber() const; - bool isString() const; - bool isObject() const; - bool isObject(const ClassInfo *) const; - - // Extracting the value. - bool getBoolean(bool&) const; - bool getBoolean() const; // false if not a boolean - bool getNumber(double&) const; - double getNumber() const; // NaN if not a number - bool getString(UString&) const; - UString getString() const; // null string if not a string - JSObject *getObject(); // NULL if not an object - const JSObject *getObject() const; // NULL if not an object - - // Extracting integer values. - bool getUInt32(uint32_t&) const; - bool getTruncatedInt32(int32_t&) const; - bool getTruncatedUInt32(uint32_t&) const; - - // Basic conversions. - JSValue* toPrimitive(ExecState* exec, JSType preferredType = UnspecifiedType) const; - bool getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value); - - bool toBoolean(ExecState *exec) const; - double toNumber(ExecState *exec) const; - JSValue* toJSNumber(ExecState*) const; // Fast path for when you expect that the value is an immediate number. - UString toString(ExecState *exec) const; - JSObject *toObject(ExecState *exec) const; - - // Integer conversions. - double toInteger(ExecState*) const; - double toIntegerPreserveNaN(ExecState*) const; - int32_t toInt32(ExecState*) const; - int32_t toInt32(ExecState*, bool& ok) const; - uint32_t toUInt32(ExecState*) const; - uint32_t toUInt32(ExecState*, bool& ok) const; - - // These are identical logic to above, and faster than jsNumber(number)->toInt32(exec) - static int32_t toInt32(double); - static int32_t toUInt32(double); - - // Floating point conversions. - float toFloat(ExecState*) const; - - // Garbage collection. - void mark(); - bool marked() const; - - static int32_t toInt32SlowCase(double, bool& ok); - static uint32_t toUInt32SlowCase(double, bool& ok); - -private: - int32_t toInt32SlowCase(ExecState*, bool& ok) const; - uint32_t toUInt32SlowCase(ExecState*, bool& ok) const; - - // Implementation details. - JSCell *asCell(); - const JSCell *asCell() const; - - // Give a compile time error if we try to copy one of these. - JSValue(const JSValue&); - JSValue& operator=(const JSValue&); -}; - -class JSCell : public JSValue { - friend class Collector; - friend class NumberImp; - friend class StringImp; - friend class JSObject; - friend class GetterSetterImp; -private: - JSCell(); - virtual ~JSCell(); -public: - // Querying the type. - virtual JSType type() const = 0; - bool isNumber() const; - bool isString() const; - bool isObject() const; - bool isObject(const ClassInfo *) const; - - // Extracting the value. - bool getNumber(double&) const; - double getNumber() const; // NaN if not a number - bool getString(UString&) const; - UString getString() const; // null string if not a string - JSObject *getObject(); // NULL if not an object - const JSObject *getObject() const; // NULL if not an object - - // Extracting integer values. - virtual bool getUInt32(uint32_t&) const; - virtual bool getTruncatedInt32(int32_t&) const; - virtual bool getTruncatedUInt32(uint32_t&) const; - - // Basic conversions. - virtual JSValue *toPrimitive(ExecState *exec, JSType preferredType = UnspecifiedType) const = 0; - virtual bool getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value) = 0; - virtual bool toBoolean(ExecState *exec) const = 0; - virtual double toNumber(ExecState *exec) const = 0; - virtual UString toString(ExecState *exec) const = 0; - virtual JSObject *toObject(ExecState *exec) const = 0; - - // Garbage collection. - void *operator new(size_t); - virtual void mark(); - bool marked() const; -}; - -JSValue *jsNumberCell(double); - -JSCell *jsString(const UString&); // returns empty string if passed null string -JSCell *jsString(const char* = ""); // returns empty string if passed 0 - -// should be used for strings that are owned by an object that will -// likely outlive the JSValue this makes, such as the parse tree or a -// DOM object that contains a UString -JSCell *jsOwnedString(const UString&); - -extern const double NaN; -extern const double Inf; - -inline JSValue *jsUndefined() -{ - return JSImmediate::undefinedImmediate(); -} - -inline JSValue *jsNull() -{ - return JSImmediate::nullImmediate(); -} - -inline JSValue *jsNaN() -{ - static const union { - uint64_t bits; - double d; - } nan = { 0x7ff80000ULL << 32 }; - return jsNumberCell(nan.d); -} - -inline JSValue *jsBoolean(bool b) -{ - return b ? JSImmediate::trueImmediate() : JSImmediate::falseImmediate(); -} - -ALWAYS_INLINE JSValue* jsNumber(double d) -{ - JSValue* v = JSImmediate::from(d); - return v ? v : jsNumberCell(d); -} - -ALWAYS_INLINE JSValue* jsNumber(int i) -{ - JSValue* v = JSImmediate::from(i); - return v ? v : jsNumberCell(i); -} - -ALWAYS_INLINE JSValue* jsNumber(unsigned i) -{ - JSValue* v = JSImmediate::from(i); - return v ? v : jsNumberCell(i); -} - -ALWAYS_INLINE JSValue* jsNumber(long i) -{ - JSValue* v = JSImmediate::from(i); - return v ? v : jsNumberCell(i); -} - -ALWAYS_INLINE JSValue* jsNumber(unsigned long i) -{ - JSValue* v = JSImmediate::from(i); - return v ? v : jsNumberCell(i); -} - -ALWAYS_INLINE JSValue* jsNumber(long long i) -{ - JSValue* v = JSImmediate::from(i); - return v ? v : jsNumberCell(static_cast(i)); -} - -ALWAYS_INLINE JSValue* jsNumber(unsigned long long i) -{ - JSValue* v = JSImmediate::from(i); - return v ? v : jsNumberCell(static_cast(i)); -} - -ALWAYS_INLINE JSValue* jsNumberFromAnd(ExecState *exec, JSValue* v1, JSValue* v2) -{ - if (JSImmediate::areBothImmediateNumbers(v1, v2)) - return JSImmediate::andImmediateNumbers(v1, v2); - return jsNumber(v1->toInt32(exec) & v2->toInt32(exec)); -} - -inline JSValue::JSValue() -{ -} - -inline JSValue::~JSValue() -{ -} - -inline JSCell::JSCell() -{ -} - -inline JSCell::~JSCell() -{ -} - -inline bool JSCell::isNumber() const -{ - return type() == NumberType; -} - -inline bool JSCell::isString() const -{ - return type() == StringType; -} - -inline bool JSCell::isObject() const -{ - return type() == ObjectType; -} - -inline bool JSCell::marked() const -{ - return Collector::isCellMarked(this); -} - -inline void JSCell::mark() -{ - return Collector::markCell(this); -} - -ALWAYS_INLINE JSCell* JSValue::asCell() -{ - ASSERT(!JSImmediate::isImmediate(this)); - return static_cast(this); -} - -ALWAYS_INLINE const JSCell* JSValue::asCell() const -{ - ASSERT(!JSImmediate::isImmediate(this)); - return static_cast(this); -} - -inline bool JSValue::isUndefined() const -{ - return this == jsUndefined(); -} - -inline bool JSValue::isNull() const -{ - return this == jsNull(); -} - -inline bool JSValue::isUndefinedOrNull() const -{ - return JSImmediate::isUndefinedOrNull(this); -} - -inline bool JSValue::isBoolean() const -{ - return JSImmediate::isBoolean(this); -} - -inline bool JSValue::isNumber() const -{ - return JSImmediate::isNumber(this) || (!JSImmediate::isImmediate(this) && asCell()->isNumber()); -} - -inline bool JSValue::isString() const -{ - return !JSImmediate::isImmediate(this) && asCell()->isString(); -} - -inline bool JSValue::isObject() const -{ - return !JSImmediate::isImmediate(this) && asCell()->isObject(); -} - -inline bool JSValue::getBoolean(bool& v) const -{ - if (JSImmediate::isBoolean(this)) { - v = JSImmediate::toBoolean(this); - return true; - } - - return false; -} - -inline bool JSValue::getBoolean() const -{ - return JSImmediate::isBoolean(this) ? JSImmediate::toBoolean(this) : false; -} - -inline bool JSValue::getNumber(double& v) const -{ - if (JSImmediate::isImmediate(this)) { - v = JSImmediate::toDouble(this); - return true; - } - return asCell()->getNumber(v); -} - -inline double JSValue::getNumber() const -{ - return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->getNumber(); -} - -inline bool JSValue::getString(UString& s) const -{ - return !JSImmediate::isImmediate(this) && asCell()->getString(s); -} - -inline UString JSValue::getString() const -{ - return JSImmediate::isImmediate(this) ? UString() : asCell()->getString(); -} - -inline JSObject *JSValue::getObject() -{ - return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject(); -} - -inline const JSObject *JSValue::getObject() const -{ - return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject(); -} - -ALWAYS_INLINE bool JSValue::getUInt32(uint32_t& v) const -{ - return JSImmediate::isImmediate(this) ? JSImmediate::getUInt32(this, v) : asCell()->getUInt32(v); -} - -ALWAYS_INLINE bool JSValue::getTruncatedInt32(int32_t& v) const -{ - return JSImmediate::isImmediate(this) ? JSImmediate::getTruncatedInt32(this, v) : asCell()->getTruncatedInt32(v); -} - -inline bool JSValue::getTruncatedUInt32(uint32_t& v) const -{ - return JSImmediate::isImmediate(this) ? JSImmediate::getTruncatedUInt32(this, v) : asCell()->getTruncatedUInt32(v); -} - -inline void JSValue::mark() -{ - ASSERT(!JSImmediate::isImmediate(this)); // callers should check !marked() before calling mark() - asCell()->mark(); -} - -inline bool JSValue::marked() const -{ - return JSImmediate::isImmediate(this) || asCell()->marked(); -} - -inline JSType JSValue::type() const -{ - return JSImmediate::isImmediate(this) ? JSImmediate::type(this) : asCell()->type(); -} - -inline JSValue* JSValue::toPrimitive(ExecState* exec, JSType preferredType) const -{ - return JSImmediate::isImmediate(this) ? const_cast(this) : asCell()->toPrimitive(exec, preferredType); -} - -inline bool JSValue::getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value) -{ - if (JSImmediate::isImmediate(this)) { - number = JSImmediate::toDouble(this); - value = this; - return true; - } - return asCell()->getPrimitiveNumber(exec, number, value); -} - -inline bool JSValue::toBoolean(ExecState *exec) const -{ - return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean(exec); -} - -ALWAYS_INLINE double JSValue::toNumber(ExecState *exec) const -{ - return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->toNumber(exec); -} - -ALWAYS_INLINE JSValue* JSValue::toJSNumber(ExecState* exec) const -{ - return JSImmediate::isNumber(this) ? const_cast(this) : jsNumber(this->toNumber(exec)); -} - -inline UString JSValue::toString(ExecState *exec) const -{ - return JSImmediate::isImmediate(this) ? JSImmediate::toString(this) : asCell()->toString(exec); -} - -inline JSObject* JSValue::toObject(ExecState* exec) const -{ - return JSImmediate::isImmediate(this) ? JSImmediate::toObject(this, exec) : asCell()->toObject(exec); -} - -ALWAYS_INLINE int32_t JSValue::toInt32(ExecState* exec) const -{ - int32_t i; - if (getTruncatedInt32(i)) - return i; - bool ok; - return toInt32SlowCase(exec, ok); -} - -inline uint32_t JSValue::toUInt32(ExecState* exec) const -{ - uint32_t i; - if (getTruncatedUInt32(i)) - return i; - bool ok; - return toUInt32SlowCase(exec, ok); -} - -inline int32_t JSValue::toInt32(double val) -{ - if (!(val >= -2147483648.0 && val < 2147483648.0)) { - bool ignored; - return toInt32SlowCase(val, ignored); - } - return static_cast(val); -} - -inline int32_t JSValue::toUInt32(double val) -{ - if (!(val >= 0.0 && val < 4294967296.0)) { - bool ignored; - return toUInt32SlowCase(val, ignored); - } - return static_cast(val); -} - -inline int32_t JSValue::toInt32(ExecState* exec, bool& ok) const -{ - int32_t i; - if (getTruncatedInt32(i)) { - ok = true; - return i; - } - return toInt32SlowCase(exec, ok); -} - -inline uint32_t JSValue::toUInt32(ExecState* exec, bool& ok) const -{ - uint32_t i; - if (getTruncatedUInt32(i)) { - ok = true; - return i; - } - return toUInt32SlowCase(exec, ok); -} - -} // namespace - -#endif // KJS_VALUE_H diff --git a/make-generated-sources.sh b/make-generated-sources.sh index e1e247b..943a7cc 100755 --- a/make-generated-sources.sh +++ b/make-generated-sources.sh @@ -2,7 +2,7 @@ export SRCROOT=$PWD export WebCore=$PWD -export CREATE_HASH_TABLE="$SRCROOT/kjs/create_hash_table" +export CREATE_HASH_TABLE="$SRCROOT/create_hash_table" mkdir -p DerivedSources/JavaScriptCore cd DerivedSources/JavaScriptCore diff --git a/os-win32/stdint.h b/os-win32/stdint.h index 48ae474..efab2ae 100644 --- a/os-win32/stdint.h +++ b/os-win32/stdint.h @@ -29,6 +29,8 @@ #error "This stdint.h file should only be compiled under Windows" #endif +#include + typedef unsigned char uint8_t; typedef signed char int8_t; typedef unsigned short uint16_t; @@ -38,6 +40,16 @@ typedef int int32_t; typedef __int64 int64_t; typedef unsigned __int64 uint64_t; +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) +#ifndef SIZE_MAX +#ifdef _WIN64 +#define SIZE_MAX _UI64_MAX +#else +#define SIZE_MAX _UI32_MAX +#endif +#endif +#endif + #ifndef CASSERT #define CASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1]; #endif diff --git a/parser/Grammar.y b/parser/Grammar.y new file mode 100644 index 0000000..ae787f6 --- /dev/null +++ b/parser/Grammar.y @@ -0,0 +1,2084 @@ +%pure_parser + +%{ + +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2007 Eric Seidel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "config.h" + +#include +#include +#include "JSValue.h" +#include "JSObject.h" +#include "Nodes.h" +#include "Lexer.h" +#include "JSString.h" +#include "JSGlobalData.h" +#include "CommonIdentifiers.h" +#include "NodeInfo.h" +#include "Parser.h" +#include + +#define YYMAXDEPTH 10000 +#define YYENABLE_NLS 0 + +/* default values for bison */ +#define YYDEBUG 0 // Set to 1 to debug a parse error. +#define jscyydebug 0 // Set to 1 to debug a parse error. +#if !PLATFORM(DARWIN) + // avoid triggering warnings in older bison +#define YYERROR_VERBOSE +#endif + +int jscyylex(void* lvalp, void* llocp, void* globalPtr); +int jscyyerror(const char*); +static inline bool allowAutomaticSemicolon(JSC::Lexer&, int); + +#define GLOBAL_DATA static_cast(globalPtr) +#define LEXER (GLOBAL_DATA->lexer) + +#define AUTO_SEMICOLON do { if (!allowAutomaticSemicolon(*LEXER, yychar)) YYABORT; } while (0) +#define SET_EXCEPTION_LOCATION(node, start, divot, end) node->setExceptionSourceCode((divot), (divot) - (start), (end) - (divot)) +#define DBG(l, s, e) (l)->setLoc((s).first_line, (e).last_line) + +using namespace JSC; +using namespace std; + +static ExpressionNode* makeAssignNode(void*, ExpressionNode* loc, Operator, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end); +static ExpressionNode* makePrefixNode(void*, ExpressionNode* expr, Operator, int start, int divot, int end); +static ExpressionNode* makePostfixNode(void*, ExpressionNode* expr, Operator, int start, int divot, int end); +static PropertyNode* makeGetterOrSetterPropertyNode(void*, const Identifier &getOrSet, const Identifier& name, ParameterNode*, FunctionBodyNode*, const SourceCode&); +static ExpressionNodeInfo makeFunctionCallNode(void*, ExpressionNodeInfo func, ArgumentsNodeInfo, int start, int divot, int end); +static ExpressionNode* makeTypeOfNode(void*, ExpressionNode*); +static ExpressionNode* makeDeleteNode(void*, ExpressionNode*, int start, int divot, int end); +static ExpressionNode* makeNegateNode(void*, ExpressionNode*); +static NumberNode* makeNumberNode(void*, double); +static ExpressionNode* makeBitwiseNotNode(void*, ExpressionNode*); +static ExpressionNode* makeMultNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); +static ExpressionNode* makeDivNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); +static ExpressionNode* makeAddNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); +static ExpressionNode* makeSubNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); +static ExpressionNode* makeLeftShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); +static ExpressionNode* makeRightShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments); +static StatementNode* makeVarStatementNode(void*, ExpressionNode*); +static ExpressionNode* combineVarInitializers(void*, ExpressionNode* list, AssignResolveNode* init); + +#if COMPILER(MSVC) + +#pragma warning(disable: 4065) +#pragma warning(disable: 4244) +#pragma warning(disable: 4702) + +// At least some of the time, the declarations of malloc and free that bison +// generates are causing warnings. A way to avoid this is to explicitly define +// the macros so that bison doesn't try to declare malloc and free. +#define YYMALLOC malloc +#define YYFREE free + +#endif + +#define YYPARSE_PARAM globalPtr +#define YYLEX_PARAM globalPtr + +template NodeDeclarationInfo createNodeDeclarationInfo(T node, ParserRefCountedData* varDecls, + ParserRefCountedData* funcDecls, + CodeFeatures info, + int numConstants) +{ + ASSERT((info & ~AllFeatures) == 0); + NodeDeclarationInfo result = {node, varDecls, funcDecls, info, numConstants}; + return result; +} + +template NodeInfo createNodeInfo(T node, CodeFeatures info, int numConstants) +{ + ASSERT((info & ~AllFeatures) == 0); + NodeInfo result = {node, info, numConstants}; + return result; +} + +template T mergeDeclarationLists(T decls1, T decls2) +{ + // decls1 or both are null + if (!decls1) + return decls2; + // only decls1 is non-null + if (!decls2) + return decls1; + + // Both are non-null + decls1->data.append(decls2->data); + + // We manually release the declaration lists to avoid accumulating many many + // unused heap allocated vectors + decls2->ref(); + decls2->deref(); + return decls1; +} + +static void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData*& varDecls, const Identifier& ident, unsigned attrs) +{ + if (!varDecls) + varDecls = new ParserRefCountedData(GLOBAL_DATA); + + varDecls->data.append(make_pair(ident, attrs)); + +} + +static inline void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData*& varDecls, ConstDeclNode* decl) +{ + unsigned attrs = DeclarationStacks::IsConstant; + if (decl->m_init) + attrs |= DeclarationStacks::HasInitializer; + appendToVarDeclarationList(globalPtr, varDecls, decl->m_ident, attrs); +} + +%} + +%union { + int intValue; + double doubleValue; + Identifier* ident; + + // expression subtrees + ExpressionNodeInfo expressionNode; + FuncDeclNodeInfo funcDeclNode; + PropertyNodeInfo propertyNode; + ArgumentsNodeInfo argumentsNode; + ConstDeclNodeInfo constDeclNode; + CaseBlockNodeInfo caseBlockNode; + CaseClauseNodeInfo caseClauseNode; + FuncExprNodeInfo funcExprNode; + + // statement nodes + StatementNodeInfo statementNode; + FunctionBodyNode* functionBodyNode; + ProgramNode* programNode; + + SourceElementsInfo sourceElements; + PropertyListInfo propertyList; + ArgumentListInfo argumentList; + VarDeclListInfo varDeclList; + ConstDeclListInfo constDeclList; + ClauseListInfo clauseList; + ElementListInfo elementList; + ParameterListInfo parameterList; + + Operator op; +} + +%start Program + +/* literals */ +%token NULLTOKEN TRUETOKEN FALSETOKEN + +/* keywords */ +%token BREAK CASE DEFAULT FOR NEW VAR CONSTTOKEN CONTINUE +%token FUNCTION RETURN VOIDTOKEN DELETETOKEN +%token IF THISTOKEN DO WHILE INTOKEN INSTANCEOF TYPEOF +%token SWITCH WITH RESERVED +%token THROW TRY CATCH FINALLY +%token DEBUGGER + +/* give an if without an else higher precedence than an else to resolve the ambiguity */ +%nonassoc IF_WITHOUT_ELSE +%nonassoc ELSE + +/* punctuators */ +%token EQEQ NE /* == and != */ +%token STREQ STRNEQ /* === and !== */ +%token LE GE /* < and > */ +%token OR AND /* || and && */ +%token PLUSPLUS MINUSMINUS /* ++ and -- */ +%token LSHIFT /* << */ +%token RSHIFT URSHIFT /* >> and >>> */ +%token PLUSEQUAL MINUSEQUAL /* += and -= */ +%token MULTEQUAL DIVEQUAL /* *= and /= */ +%token LSHIFTEQUAL /* <<= */ +%token RSHIFTEQUAL URSHIFTEQUAL /* >>= and >>>= */ +%token ANDEQUAL MODEQUAL /* &= and %= */ +%token XOREQUAL OREQUAL /* ^= and |= */ +%token OPENBRACE /* { (with char offset) */ +%token CLOSEBRACE /* { (with char offset) */ + +/* terminal types */ +%token NUMBER +%token IDENT STRING + +/* automatically inserted semicolon */ +%token AUTOPLUSPLUS AUTOMINUSMINUS + +/* non-terminal types */ +%type Literal ArrayLiteral + +%type PrimaryExpr PrimaryExprNoBrace +%type MemberExpr MemberExprNoBF /* BF => brace or function */ +%type NewExpr NewExprNoBF +%type CallExpr CallExprNoBF +%type LeftHandSideExpr LeftHandSideExprNoBF +%type PostfixExpr PostfixExprNoBF +%type UnaryExpr UnaryExprNoBF UnaryExprCommon +%type MultiplicativeExpr MultiplicativeExprNoBF +%type AdditiveExpr AdditiveExprNoBF +%type ShiftExpr ShiftExprNoBF +%type RelationalExpr RelationalExprNoIn RelationalExprNoBF +%type EqualityExpr EqualityExprNoIn EqualityExprNoBF +%type BitwiseANDExpr BitwiseANDExprNoIn BitwiseANDExprNoBF +%type BitwiseXORExpr BitwiseXORExprNoIn BitwiseXORExprNoBF +%type BitwiseORExpr BitwiseORExprNoIn BitwiseORExprNoBF +%type LogicalANDExpr LogicalANDExprNoIn LogicalANDExprNoBF +%type LogicalORExpr LogicalORExprNoIn LogicalORExprNoBF +%type ConditionalExpr ConditionalExprNoIn ConditionalExprNoBF +%type AssignmentExpr AssignmentExprNoIn AssignmentExprNoBF +%type Expr ExprNoIn ExprNoBF + +%type ExprOpt ExprNoInOpt + +%type Statement Block +%type VariableStatement ConstStatement EmptyStatement ExprStatement +%type IfStatement IterationStatement ContinueStatement +%type BreakStatement ReturnStatement WithStatement +%type SwitchStatement LabelledStatement +%type ThrowStatement TryStatement +%type DebuggerStatement + +%type Initializer InitializerNoIn +%type FunctionDeclaration +%type FunctionExpr +%type FunctionBody +%type SourceElements +%type FormalParameterList +%type AssignmentOperator +%type Arguments +%type ArgumentList +%type VariableDeclarationList VariableDeclarationListNoIn +%type ConstDeclarationList +%type ConstDeclaration +%type CaseBlock +%type CaseClause DefaultClause +%type CaseClauses CaseClausesOpt +%type Elision ElisionOpt +%type ElementList +%type Property +%type PropertyList +%% + +// FIXME: There are currently two versions of the grammar in this file, the normal one, and the NoNodes version used for +// lazy recompilation of FunctionBodyNodes. We should move to generating the two versions from a script to avoid bugs. +// In the mean time, make sure to make any changes to the grammar in both versions. + +Literal: + NULLTOKEN { $$ = createNodeInfo(new NullNode(GLOBAL_DATA), 0, 1); } + | TRUETOKEN { $$ = createNodeInfo(new BooleanNode(GLOBAL_DATA, true), 0, 1); } + | FALSETOKEN { $$ = createNodeInfo(new BooleanNode(GLOBAL_DATA, false), 0, 1); } + | NUMBER { $$ = createNodeInfo(makeNumberNode(GLOBAL_DATA, $1), 0, 1); } + | STRING { $$ = createNodeInfo(new StringNode(GLOBAL_DATA, *$1), 0, 1); } + | '/' /* regexp */ { + Lexer& l = *LEXER; + if (!l.scanRegExp()) + YYABORT; + RegExpNode* node = new RegExpNode(GLOBAL_DATA, l.pattern(), l.flags()); + int size = l.pattern().size() + 2; // + 2 for the two /'s + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size); + $$ = createNodeInfo(node, 0, 0); + } + | DIVEQUAL /* regexp with /= */ { + Lexer& l = *LEXER; + if (!l.scanRegExp()) + YYABORT; + RegExpNode* node = new RegExpNode(GLOBAL_DATA, "=" + l.pattern(), l.flags()); + int size = l.pattern().size() + 2; // + 2 for the two /'s + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size); + $$ = createNodeInfo(node, 0, 0); + } +; + +Property: + IDENT ':' AssignmentExpr { $$ = createNodeInfo(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); } + | STRING ':' AssignmentExpr { $$ = createNodeInfo(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); } + | NUMBER ':' AssignmentExpr { $$ = createNodeInfo(new PropertyNode(GLOBAL_DATA, Identifier(GLOBAL_DATA, UString::from($1)), $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); } + | IDENT IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, 0, $6, LEXER->sourceCode($5, $7, @5.first_line)), ClosureFeature, 0); DBG($6, @5, @7); if (!$$.m_node) YYABORT; } + | IDENT IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE + { + $$ = createNodeInfo(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, $4.m_node.head, $7, LEXER->sourceCode($6, $8, @6.first_line)), $4.m_features | ClosureFeature, 0); + if ($4.m_features & ArgumentsFeature) + $7->setUsesArguments(); + DBG($7, @6, @8); + if (!$$.m_node) + YYABORT; + } +; + +PropertyList: + Property { $$.m_node.head = new PropertyListNode(GLOBAL_DATA, $1.m_node); + $$.m_node.tail = $$.m_node.head; + $$.m_features = $1.m_features; + $$.m_numConstants = $1.m_numConstants; } + | PropertyList ',' Property { $$.m_node.head = $1.m_node.head; + $$.m_node.tail = new PropertyListNode(GLOBAL_DATA, $3.m_node, $1.m_node.tail); + $$.m_features = $1.m_features | $3.m_features; + $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; } +; + +PrimaryExpr: + PrimaryExprNoBrace + | OPENBRACE CLOSEBRACE { $$ = createNodeInfo(new ObjectLiteralNode(GLOBAL_DATA), 0, 0); } + | OPENBRACE PropertyList CLOSEBRACE { $$ = createNodeInfo(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); } + /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */ + | OPENBRACE PropertyList ',' CLOSEBRACE { $$ = createNodeInfo(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); } +; + +PrimaryExprNoBrace: + THISTOKEN { $$ = createNodeInfo(new ThisNode(GLOBAL_DATA), ThisFeature, 0); } + | Literal + | ArrayLiteral + | IDENT { $$ = createNodeInfo(new ResolveNode(GLOBAL_DATA, *$1, @1.first_column), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); } + | '(' Expr ')' { $$ = $2; } +; + +ArrayLiteral: + '[' ElisionOpt ']' { $$ = createNodeInfo(new ArrayNode(GLOBAL_DATA, $2), 0, $2 ? 1 : 0); } + | '[' ElementList ']' { $$ = createNodeInfo(new ArrayNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); } + | '[' ElementList ',' ElisionOpt ']' { $$ = createNodeInfo(new ArrayNode(GLOBAL_DATA, $4, $2.m_node.head), $2.m_features, $4 ? $2.m_numConstants + 1 : $2.m_numConstants); } +; + +ElementList: + ElisionOpt AssignmentExpr { $$.m_node.head = new ElementNode(GLOBAL_DATA, $1, $2.m_node); + $$.m_node.tail = $$.m_node.head; + $$.m_features = $2.m_features; + $$.m_numConstants = $2.m_numConstants; } + | ElementList ',' ElisionOpt AssignmentExpr + { $$.m_node.head = $1.m_node.head; + $$.m_node.tail = new ElementNode(GLOBAL_DATA, $1.m_node.tail, $3, $4.m_node); + $$.m_features = $1.m_features | $4.m_features; + $$.m_numConstants = $1.m_numConstants + $4.m_numConstants; } +; + +ElisionOpt: + /* nothing */ { $$ = 0; } + | Elision +; + +Elision: + ',' { $$ = 1; } + | Elision ',' { $$ = $1 + 1; } +; + +MemberExpr: + PrimaryExpr + | FunctionExpr { $$ = createNodeInfo($1.m_node, $1.m_features, $1.m_numConstants); } + | MemberExpr '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column); + $$ = createNodeInfo(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); + } + | MemberExpr '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column); + $$ = createNodeInfo(node, $1.m_features, $1.m_numConstants); + } + | NEW MemberExpr Arguments { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node, $3.m_node); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @3.last_column); + $$ = createNodeInfo(node, $2.m_features | $3.m_features, $2.m_numConstants + $3.m_numConstants); + } +; + +MemberExprNoBF: + PrimaryExprNoBrace + | MemberExprNoBF '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column); + $$ = createNodeInfo(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); + } + | MemberExprNoBF '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column); + $$ = createNodeInfo(node, $1.m_features, $1.m_numConstants); + } + | NEW MemberExpr Arguments { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node, $3.m_node); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @3.last_column); + $$ = createNodeInfo(node, $2.m_features | $3.m_features, $2.m_numConstants + $3.m_numConstants); + } +; + +NewExpr: + MemberExpr + | NEW NewExpr { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeInfo(node, $2.m_features, $2.m_numConstants); + } +; + +NewExprNoBF: + MemberExprNoBF + | NEW NewExpr { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeInfo(node, $2.m_features, $2.m_numConstants); + } +; + +CallExpr: + MemberExpr Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); } + | CallExpr Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); } + | CallExpr '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column); + $$ = createNodeInfo(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); + } + | CallExpr '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column); + $$ = createNodeInfo(node, $1.m_features, $1.m_numConstants); } +; + +CallExprNoBF: + MemberExprNoBF Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); } + | CallExprNoBF Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); } + | CallExprNoBF '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column); + $$ = createNodeInfo(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); + } + | CallExprNoBF '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column); + $$ = createNodeInfo(node, $1.m_features, $1.m_numConstants); + } +; + +Arguments: + '(' ')' { $$ = createNodeInfo(new ArgumentsNode(GLOBAL_DATA), 0, 0); } + | '(' ArgumentList ')' { $$ = createNodeInfo(new ArgumentsNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); } +; + +ArgumentList: + AssignmentExpr { $$.m_node.head = new ArgumentListNode(GLOBAL_DATA, $1.m_node); + $$.m_node.tail = $$.m_node.head; + $$.m_features = $1.m_features; + $$.m_numConstants = $1.m_numConstants; } + | ArgumentList ',' AssignmentExpr { $$.m_node.head = $1.m_node.head; + $$.m_node.tail = new ArgumentListNode(GLOBAL_DATA, $1.m_node.tail, $3.m_node); + $$.m_features = $1.m_features | $3.m_features; + $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; } +; + +LeftHandSideExpr: + NewExpr + | CallExpr +; + +LeftHandSideExprNoBF: + NewExprNoBF + | CallExprNoBF +; + +PostfixExpr: + LeftHandSideExpr + | LeftHandSideExpr PLUSPLUS { $$ = createNodeInfo(makePostfixNode(GLOBAL_DATA, $1.m_node, OpPlusPlus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); } + | LeftHandSideExpr MINUSMINUS { $$ = createNodeInfo(makePostfixNode(GLOBAL_DATA, $1.m_node, OpMinusMinus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); } +; + +PostfixExprNoBF: + LeftHandSideExprNoBF + | LeftHandSideExprNoBF PLUSPLUS { $$ = createNodeInfo(makePostfixNode(GLOBAL_DATA, $1.m_node, OpPlusPlus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); } + | LeftHandSideExprNoBF MINUSMINUS { $$ = createNodeInfo(makePostfixNode(GLOBAL_DATA, $1.m_node, OpMinusMinus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); } +; + +UnaryExprCommon: + DELETETOKEN UnaryExpr { $$ = createNodeInfo(makeDeleteNode(GLOBAL_DATA, $2.m_node, @1.first_column, @2.last_column, @2.last_column), $2.m_features, $2.m_numConstants); } + | VOIDTOKEN UnaryExpr { $$ = createNodeInfo(new VoidNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants + 1); } + | TYPEOF UnaryExpr { $$ = createNodeInfo(makeTypeOfNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); } + | PLUSPLUS UnaryExpr { $$ = createNodeInfo(makePrefixNode(GLOBAL_DATA, $2.m_node, OpPlusPlus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); } + | AUTOPLUSPLUS UnaryExpr { $$ = createNodeInfo(makePrefixNode(GLOBAL_DATA, $2.m_node, OpPlusPlus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); } + | MINUSMINUS UnaryExpr { $$ = createNodeInfo(makePrefixNode(GLOBAL_DATA, $2.m_node, OpMinusMinus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); } + | AUTOMINUSMINUS UnaryExpr { $$ = createNodeInfo(makePrefixNode(GLOBAL_DATA, $2.m_node, OpMinusMinus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); } + | '+' UnaryExpr { $$ = createNodeInfo(new UnaryPlusNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); } + | '-' UnaryExpr { $$ = createNodeInfo(makeNegateNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); } + | '~' UnaryExpr { $$ = createNodeInfo(makeBitwiseNotNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); } + | '!' UnaryExpr { $$ = createNodeInfo(new LogicalNotNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); } + +UnaryExpr: + PostfixExpr + | UnaryExprCommon +; + +UnaryExprNoBF: + PostfixExprNoBF + | UnaryExprCommon +; + +MultiplicativeExpr: + UnaryExpr + | MultiplicativeExpr '*' UnaryExpr { $$ = createNodeInfo(makeMultNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | MultiplicativeExpr '/' UnaryExpr { $$ = createNodeInfo(makeDivNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | MultiplicativeExpr '%' UnaryExpr { $$ = createNodeInfo(new ModNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +MultiplicativeExprNoBF: + UnaryExprNoBF + | MultiplicativeExprNoBF '*' UnaryExpr + { $$ = createNodeInfo(makeMultNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | MultiplicativeExprNoBF '/' UnaryExpr + { $$ = createNodeInfo(makeDivNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | MultiplicativeExprNoBF '%' UnaryExpr + { $$ = createNodeInfo(new ModNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +AdditiveExpr: + MultiplicativeExpr + | AdditiveExpr '+' MultiplicativeExpr { $$ = createNodeInfo(makeAddNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | AdditiveExpr '-' MultiplicativeExpr { $$ = createNodeInfo(makeSubNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +AdditiveExprNoBF: + MultiplicativeExprNoBF + | AdditiveExprNoBF '+' MultiplicativeExpr + { $$ = createNodeInfo(makeAddNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | AdditiveExprNoBF '-' MultiplicativeExpr + { $$ = createNodeInfo(makeSubNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +ShiftExpr: + AdditiveExpr + | ShiftExpr LSHIFT AdditiveExpr { $$ = createNodeInfo(makeLeftShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | ShiftExpr RSHIFT AdditiveExpr { $$ = createNodeInfo(makeRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | ShiftExpr URSHIFT AdditiveExpr { $$ = createNodeInfo(new UnsignedRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +ShiftExprNoBF: + AdditiveExprNoBF + | ShiftExprNoBF LSHIFT AdditiveExpr { $$ = createNodeInfo(makeLeftShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | ShiftExprNoBF RSHIFT AdditiveExpr { $$ = createNodeInfo(makeRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | ShiftExprNoBF URSHIFT AdditiveExpr { $$ = createNodeInfo(new UnsignedRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +RelationalExpr: + ShiftExpr + | RelationalExpr '<' ShiftExpr { $$ = createNodeInfo(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExpr '>' ShiftExpr { $$ = createNodeInfo(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExpr LE ShiftExpr { $$ = createNodeInfo(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExpr GE ShiftExpr { $$ = createNodeInfo(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExpr INSTANCEOF ShiftExpr { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column); + $$ = createNodeInfo(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExpr INTOKEN ShiftExpr { InNode* node = new InNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column); + $$ = createNodeInfo(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +RelationalExprNoIn: + ShiftExpr + | RelationalExprNoIn '<' ShiftExpr { $$ = createNodeInfo(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExprNoIn '>' ShiftExpr { $$ = createNodeInfo(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExprNoIn LE ShiftExpr { $$ = createNodeInfo(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExprNoIn GE ShiftExpr { $$ = createNodeInfo(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExprNoIn INSTANCEOF ShiftExpr + { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column); + $$ = createNodeInfo(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +RelationalExprNoBF: + ShiftExprNoBF + | RelationalExprNoBF '<' ShiftExpr { $$ = createNodeInfo(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExprNoBF '>' ShiftExpr { $$ = createNodeInfo(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExprNoBF LE ShiftExpr { $$ = createNodeInfo(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExprNoBF GE ShiftExpr { $$ = createNodeInfo(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExprNoBF INSTANCEOF ShiftExpr + { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column); + $$ = createNodeInfo(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | RelationalExprNoBF INTOKEN ShiftExpr + { InNode* node = new InNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column); + $$ = createNodeInfo(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +EqualityExpr: + RelationalExpr + | EqualityExpr EQEQ RelationalExpr { $$ = createNodeInfo(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | EqualityExpr NE RelationalExpr { $$ = createNodeInfo(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | EqualityExpr STREQ RelationalExpr { $$ = createNodeInfo(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | EqualityExpr STRNEQ RelationalExpr { $$ = createNodeInfo(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +EqualityExprNoIn: + RelationalExprNoIn + | EqualityExprNoIn EQEQ RelationalExprNoIn + { $$ = createNodeInfo(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | EqualityExprNoIn NE RelationalExprNoIn + { $$ = createNodeInfo(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | EqualityExprNoIn STREQ RelationalExprNoIn + { $$ = createNodeInfo(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | EqualityExprNoIn STRNEQ RelationalExprNoIn + { $$ = createNodeInfo(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +EqualityExprNoBF: + RelationalExprNoBF + | EqualityExprNoBF EQEQ RelationalExpr + { $$ = createNodeInfo(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | EqualityExprNoBF NE RelationalExpr { $$ = createNodeInfo(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | EqualityExprNoBF STREQ RelationalExpr + { $$ = createNodeInfo(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } + | EqualityExprNoBF STRNEQ RelationalExpr + { $$ = createNodeInfo(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +BitwiseANDExpr: + EqualityExpr + | BitwiseANDExpr '&' EqualityExpr { $$ = createNodeInfo(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +BitwiseANDExprNoIn: + EqualityExprNoIn + | BitwiseANDExprNoIn '&' EqualityExprNoIn + { $$ = createNodeInfo(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +BitwiseANDExprNoBF: + EqualityExprNoBF + | BitwiseANDExprNoBF '&' EqualityExpr { $$ = createNodeInfo(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +BitwiseXORExpr: + BitwiseANDExpr + | BitwiseXORExpr '^' BitwiseANDExpr { $$ = createNodeInfo(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +BitwiseXORExprNoIn: + BitwiseANDExprNoIn + | BitwiseXORExprNoIn '^' BitwiseANDExprNoIn + { $$ = createNodeInfo(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +BitwiseXORExprNoBF: + BitwiseANDExprNoBF + | BitwiseXORExprNoBF '^' BitwiseANDExpr + { $$ = createNodeInfo(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +BitwiseORExpr: + BitwiseXORExpr + | BitwiseORExpr '|' BitwiseXORExpr { $$ = createNodeInfo(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +BitwiseORExprNoIn: + BitwiseXORExprNoIn + | BitwiseORExprNoIn '|' BitwiseXORExprNoIn + { $$ = createNodeInfo(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +BitwiseORExprNoBF: + BitwiseXORExprNoBF + | BitwiseORExprNoBF '|' BitwiseXORExpr + { $$ = createNodeInfo(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +LogicalANDExpr: + BitwiseORExpr + | LogicalANDExpr AND BitwiseORExpr { $$ = createNodeInfo(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +LogicalANDExprNoIn: + BitwiseORExprNoIn + | LogicalANDExprNoIn AND BitwiseORExprNoIn + { $$ = createNodeInfo(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +LogicalANDExprNoBF: + BitwiseORExprNoBF + | LogicalANDExprNoBF AND BitwiseORExpr + { $$ = createNodeInfo(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +LogicalORExpr: + LogicalANDExpr + | LogicalORExpr OR LogicalANDExpr { $$ = createNodeInfo(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +LogicalORExprNoIn: + LogicalANDExprNoIn + | LogicalORExprNoIn OR LogicalANDExprNoIn + { $$ = createNodeInfo(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +LogicalORExprNoBF: + LogicalANDExprNoBF + | LogicalORExprNoBF OR LogicalANDExpr { $$ = createNodeInfo(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +ConditionalExpr: + LogicalORExpr + | LogicalORExpr '?' AssignmentExpr ':' AssignmentExpr + { $$ = createNodeInfo(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); } +; + +ConditionalExprNoIn: + LogicalORExprNoIn + | LogicalORExprNoIn '?' AssignmentExprNoIn ':' AssignmentExprNoIn + { $$ = createNodeInfo(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); } +; + +ConditionalExprNoBF: + LogicalORExprNoBF + | LogicalORExprNoBF '?' AssignmentExpr ':' AssignmentExpr + { $$ = createNodeInfo(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); } +; + +AssignmentExpr: + ConditionalExpr + | LeftHandSideExpr AssignmentOperator AssignmentExpr + { $$ = createNodeInfo(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature, + @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants); + } +; + +AssignmentExprNoIn: + ConditionalExprNoIn + | LeftHandSideExpr AssignmentOperator AssignmentExprNoIn + { $$ = createNodeInfo(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature, + @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants); + } +; + +AssignmentExprNoBF: + ConditionalExprNoBF + | LeftHandSideExprNoBF AssignmentOperator AssignmentExpr + { $$ = createNodeInfo(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature, + @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants); + } +; + +AssignmentOperator: + '=' { $$ = OpEqual; } + | PLUSEQUAL { $$ = OpPlusEq; } + | MINUSEQUAL { $$ = OpMinusEq; } + | MULTEQUAL { $$ = OpMultEq; } + | DIVEQUAL { $$ = OpDivEq; } + | LSHIFTEQUAL { $$ = OpLShift; } + | RSHIFTEQUAL { $$ = OpRShift; } + | URSHIFTEQUAL { $$ = OpURShift; } + | ANDEQUAL { $$ = OpAndEq; } + | XOREQUAL { $$ = OpXOrEq; } + | OREQUAL { $$ = OpOrEq; } + | MODEQUAL { $$ = OpModEq; } +; + +Expr: + AssignmentExpr + | Expr ',' AssignmentExpr { $$ = createNodeInfo(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +ExprNoIn: + AssignmentExprNoIn + | ExprNoIn ',' AssignmentExprNoIn { $$ = createNodeInfo(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +ExprNoBF: + AssignmentExprNoBF + | ExprNoBF ',' AssignmentExpr { $$ = createNodeInfo(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); } +; + +Statement: + Block + | VariableStatement + | ConstStatement + | FunctionDeclaration + | EmptyStatement + | ExprStatement + | IfStatement + | IterationStatement + | ContinueStatement + | BreakStatement + | ReturnStatement + | WithStatement + | SwitchStatement + | LabelledStatement + | ThrowStatement + | TryStatement + | DebuggerStatement +; + +Block: + OPENBRACE CLOSEBRACE { $$ = createNodeDeclarationInfo(new BlockNode(GLOBAL_DATA, 0), 0, 0, 0, 0); + DBG($$.m_node, @1, @2); } + | OPENBRACE SourceElements CLOSEBRACE { $$ = createNodeDeclarationInfo(new BlockNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants); + DBG($$.m_node, @1, @3); } +; + +VariableStatement: + VAR VariableDeclarationList ';' { $$ = createNodeDeclarationInfo(makeVarStatementNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants); + DBG($$.m_node, @1, @3); } + | VAR VariableDeclarationList error { $$ = createNodeDeclarationInfo(makeVarStatementNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants); + DBG($$.m_node, @1, @2); + AUTO_SEMICOLON; } +; + +VariableDeclarationList: + IDENT { $$.m_node = 0; + $$.m_varDeclarations = new ParserRefCountedData(GLOBAL_DATA); + appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, 0); + $$.m_funcDeclarations = 0; + $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0; + $$.m_numConstants = 0; + } + | IDENT Initializer { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$1, $2.m_node, $2.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.first_column + 1, @2.last_column); + $$.m_node = node; + $$.m_varDeclarations = new ParserRefCountedData(GLOBAL_DATA); + appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer); + $$.m_funcDeclarations = 0; + $$.m_features = ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features; + $$.m_numConstants = $2.m_numConstants; + } + | VariableDeclarationList ',' IDENT + { $$.m_node = $1.m_node; + $$.m_varDeclarations = $1.m_varDeclarations; + appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, 0); + $$.m_funcDeclarations = 0; + $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0); + $$.m_numConstants = $1.m_numConstants; + } + | VariableDeclarationList ',' IDENT Initializer + { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column); + $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node); + $$.m_varDeclarations = $1.m_varDeclarations; + appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer); + $$.m_funcDeclarations = 0; + $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features; + $$.m_numConstants = $1.m_numConstants + $4.m_numConstants; + } +; + +VariableDeclarationListNoIn: + IDENT { $$.m_node = 0; + $$.m_varDeclarations = new ParserRefCountedData(GLOBAL_DATA); + appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, 0); + $$.m_funcDeclarations = 0; + $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0; + $$.m_numConstants = 0; + } + | IDENT InitializerNoIn { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$1, $2.m_node, $2.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.first_column + 1, @2.last_column); + $$.m_node = node; + $$.m_varDeclarations = new ParserRefCountedData(GLOBAL_DATA); + appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer); + $$.m_funcDeclarations = 0; + $$.m_features = ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features; + $$.m_numConstants = $2.m_numConstants; + } + | VariableDeclarationListNoIn ',' IDENT + { $$.m_node = $1.m_node; + $$.m_varDeclarations = $1.m_varDeclarations; + appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, 0); + $$.m_funcDeclarations = 0; + $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0); + $$.m_numConstants = $1.m_numConstants; + } + | VariableDeclarationListNoIn ',' IDENT InitializerNoIn + { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature); + SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column); + $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node); + $$.m_varDeclarations = $1.m_varDeclarations; + appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer); + $$.m_funcDeclarations = 0; + $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features; + $$.m_numConstants = $1.m_numConstants + $4.m_numConstants; + } +; + +ConstStatement: + CONSTTOKEN ConstDeclarationList ';' { $$ = createNodeDeclarationInfo(new ConstStatementNode(GLOBAL_DATA, $2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants); + DBG($$.m_node, @1, @3); } + | CONSTTOKEN ConstDeclarationList error + { $$ = createNodeDeclarationInfo(new ConstStatementNode(GLOBAL_DATA, $2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants); + DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } +; + +ConstDeclarationList: + ConstDeclaration { $$.m_node.head = $1.m_node; + $$.m_node.tail = $$.m_node.head; + $$.m_varDeclarations = new ParserRefCountedData(GLOBAL_DATA); + appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, $1.m_node); + $$.m_funcDeclarations = 0; + $$.m_features = $1.m_features; + $$.m_numConstants = $1.m_numConstants; + } + | ConstDeclarationList ',' ConstDeclaration + { $$.m_node.head = $1.m_node.head; + $1.m_node.tail->m_next = $3.m_node; + $$.m_node.tail = $3.m_node; + $$.m_varDeclarations = $1.m_varDeclarations; + appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, $3.m_node); + $$.m_funcDeclarations = 0; + $$.m_features = $1.m_features | $3.m_features; + $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; } +; + +ConstDeclaration: + IDENT { $$ = createNodeInfo(new ConstDeclNode(GLOBAL_DATA, *$1, 0), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); } + | IDENT Initializer { $$ = createNodeInfo(new ConstDeclNode(GLOBAL_DATA, *$1, $2.m_node), ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features, $2.m_numConstants); } +; + +Initializer: + '=' AssignmentExpr { $$ = $2; } +; + +InitializerNoIn: + '=' AssignmentExprNoIn { $$ = $2; } +; + +EmptyStatement: + ';' { $$ = createNodeDeclarationInfo(new EmptyStatementNode(GLOBAL_DATA), 0, 0, 0, 0); } +; + +ExprStatement: + ExprNoBF ';' { $$ = createNodeDeclarationInfo(new ExprStatementNode(GLOBAL_DATA, $1.m_node), 0, 0, $1.m_features, $1.m_numConstants); + DBG($$.m_node, @1, @2); } + | ExprNoBF error { $$ = createNodeDeclarationInfo(new ExprStatementNode(GLOBAL_DATA, $1.m_node), 0, 0, $1.m_features, $1.m_numConstants); + DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } +; + +IfStatement: + IF '(' Expr ')' Statement %prec IF_WITHOUT_ELSE + { $$ = createNodeDeclarationInfo(new IfNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants); + DBG($$.m_node, @1, @4); } + | IF '(' Expr ')' Statement ELSE Statement + { $$ = createNodeDeclarationInfo(new IfElseNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node), + mergeDeclarationLists($5.m_varDeclarations, $7.m_varDeclarations), mergeDeclarationLists($5.m_funcDeclarations, $7.m_funcDeclarations), + $3.m_features | $5.m_features | $7.m_features, + $3.m_numConstants + $5.m_numConstants + $7.m_numConstants); + DBG($$.m_node, @1, @4); } +; + +IterationStatement: + DO Statement WHILE '(' Expr ')' ';' { $$ = createNodeDeclarationInfo(new DoWhileNode(GLOBAL_DATA, $2.m_node, $5.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features | $5.m_features, $2.m_numConstants + $5.m_numConstants); + DBG($$.m_node, @1, @3); } + | DO Statement WHILE '(' Expr ')' error { $$ = createNodeDeclarationInfo(new DoWhileNode(GLOBAL_DATA, $2.m_node, $5.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features | $5.m_features, $2.m_numConstants + $5.m_numConstants); + DBG($$.m_node, @1, @3); } // Always performs automatic semicolon insertion. + | WHILE '(' Expr ')' Statement { $$ = createNodeDeclarationInfo(new WhileNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants); + DBG($$.m_node, @1, @4); } + | FOR '(' ExprNoInOpt ';' ExprOpt ';' ExprOpt ')' Statement + { $$ = createNodeDeclarationInfo(new ForNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node, $9.m_node, false), $9.m_varDeclarations, $9.m_funcDeclarations, + $3.m_features | $5.m_features | $7.m_features | $9.m_features, + $3.m_numConstants + $5.m_numConstants + $7.m_numConstants + $9.m_numConstants); + DBG($$.m_node, @1, @8); + } + | FOR '(' VAR VariableDeclarationListNoIn ';' ExprOpt ';' ExprOpt ')' Statement + { $$ = createNodeDeclarationInfo(new ForNode(GLOBAL_DATA, $4.m_node, $6.m_node, $8.m_node, $10.m_node, true), + mergeDeclarationLists($4.m_varDeclarations, $10.m_varDeclarations), + mergeDeclarationLists($4.m_funcDeclarations, $10.m_funcDeclarations), + $4.m_features | $6.m_features | $8.m_features | $10.m_features, + $4.m_numConstants + $6.m_numConstants + $8.m_numConstants + $10.m_numConstants); + DBG($$.m_node, @1, @9); } + | FOR '(' LeftHandSideExpr INTOKEN Expr ')' Statement + { + ForInNode* node = new ForInNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node); + SET_EXCEPTION_LOCATION(node, @3.first_column, @3.last_column, @5.last_column); + $$ = createNodeDeclarationInfo(node, $7.m_varDeclarations, $7.m_funcDeclarations, + $3.m_features | $5.m_features | $7.m_features, + $3.m_numConstants + $5.m_numConstants + $7.m_numConstants); + DBG($$.m_node, @1, @6); + } + | FOR '(' VAR IDENT INTOKEN Expr ')' Statement + { ForInNode *forIn = new ForInNode(GLOBAL_DATA, *$4, 0, $6.m_node, $8.m_node, @5.first_column, @5.first_column - @4.first_column, @6.last_column - @5.first_column); + SET_EXCEPTION_LOCATION(forIn, @4.first_column, @5.first_column + 1, @6.last_column); + appendToVarDeclarationList(GLOBAL_DATA, $8.m_varDeclarations, *$4, DeclarationStacks::HasInitializer); + $$ = createNodeDeclarationInfo(forIn, $8.m_varDeclarations, $8.m_funcDeclarations, ((*$4 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $6.m_features | $8.m_features, $6.m_numConstants + $8.m_numConstants); + DBG($$.m_node, @1, @7); } + | FOR '(' VAR IDENT InitializerNoIn INTOKEN Expr ')' Statement + { ForInNode *forIn = new ForInNode(GLOBAL_DATA, *$4, $5.m_node, $7.m_node, $9.m_node, @5.first_column, @5.first_column - @4.first_column, @5.last_column - @5.first_column); + SET_EXCEPTION_LOCATION(forIn, @4.first_column, @6.first_column + 1, @7.last_column); + appendToVarDeclarationList(GLOBAL_DATA, $9.m_varDeclarations, *$4, DeclarationStacks::HasInitializer); + $$ = createNodeDeclarationInfo(forIn, $9.m_varDeclarations, $9.m_funcDeclarations, + ((*$4 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $5.m_features | $7.m_features | $9.m_features, + $5.m_numConstants + $7.m_numConstants + $9.m_numConstants); + DBG($$.m_node, @1, @8); } +; + +ExprOpt: + /* nothing */ { $$ = createNodeInfo(0, 0, 0); } + | Expr +; + +ExprNoInOpt: + /* nothing */ { $$ = createNodeInfo(0, 0, 0); } + | ExprNoIn +; + +ContinueStatement: + CONTINUE ';' { ContinueNode* node = new ContinueNode(GLOBAL_DATA); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, 0, 0); + DBG($$.m_node, @1, @2); } + | CONTINUE error { ContinueNode* node = new ContinueNode(GLOBAL_DATA); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, 0, 0); + DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } + | CONTINUE IDENT ';' { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *$2); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, 0, 0); + DBG($$.m_node, @1, @3); } + | CONTINUE IDENT error { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *$2); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, 0, 0); + DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } +; + +BreakStatement: + BREAK ';' { BreakNode* node = new BreakNode(GLOBAL_DATA); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, 0, 0); DBG($$.m_node, @1, @2); } + | BREAK error { BreakNode* node = new BreakNode(GLOBAL_DATA); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); + $$ = createNodeDeclarationInfo(new BreakNode(GLOBAL_DATA), 0, 0, 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } + | BREAK IDENT ';' { BreakNode* node = new BreakNode(GLOBAL_DATA, *$2); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, 0, 0); DBG($$.m_node, @1, @3); } + | BREAK IDENT error { BreakNode* node = new BreakNode(GLOBAL_DATA, *$2); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeDeclarationInfo(new BreakNode(GLOBAL_DATA, *$2), 0, 0, 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } +; + +ReturnStatement: + RETURN ';' { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, 0, 0); DBG($$.m_node, @1, @2); } + | RETURN error { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0); + SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } + | RETURN Expr ';' { ReturnNode* node = new ReturnNode(GLOBAL_DATA, $2.m_node); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @3); } + | RETURN Expr error { ReturnNode* node = new ReturnNode(GLOBAL_DATA, $2.m_node); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; } +; + +WithStatement: + WITH '(' Expr ')' Statement { $$ = createNodeDeclarationInfo(new WithNode(GLOBAL_DATA, $3.m_node, $5.m_node, @3.last_column, @3.last_column - @3.first_column), + $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features | WithFeature, $3.m_numConstants + $5.m_numConstants); + DBG($$.m_node, @1, @4); } +; + +SwitchStatement: + SWITCH '(' Expr ')' CaseBlock { $$ = createNodeDeclarationInfo(new SwitchNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations, + $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants); + DBG($$.m_node, @1, @4); } +; + +CaseBlock: + OPENBRACE CaseClausesOpt CLOSEBRACE { $$ = createNodeDeclarationInfo(new CaseBlockNode(GLOBAL_DATA, $2.m_node.head, 0, 0), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants); } + | OPENBRACE CaseClausesOpt DefaultClause CaseClausesOpt CLOSEBRACE + { $$ = createNodeDeclarationInfo(new CaseBlockNode(GLOBAL_DATA, $2.m_node.head, $3.m_node, $4.m_node.head), + mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $3.m_varDeclarations), $4.m_varDeclarations), + mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $3.m_funcDeclarations), $4.m_funcDeclarations), + $2.m_features | $3.m_features | $4.m_features, + $2.m_numConstants + $3.m_numConstants + $4.m_numConstants); } +; + +CaseClausesOpt: +/* nothing */ { $$.m_node.head = 0; $$.m_node.tail = 0; $$.m_varDeclarations = 0; $$.m_funcDeclarations = 0; $$.m_features = 0; $$.m_numConstants = 0; } + | CaseClauses +; + +CaseClauses: + CaseClause { $$.m_node.head = new ClauseListNode(GLOBAL_DATA, $1.m_node); + $$.m_node.tail = $$.m_node.head; + $$.m_varDeclarations = $1.m_varDeclarations; + $$.m_funcDeclarations = $1.m_funcDeclarations; + $$.m_features = $1.m_features; + $$.m_numConstants = $1.m_numConstants; } + | CaseClauses CaseClause { $$.m_node.head = $1.m_node.head; + $$.m_node.tail = new ClauseListNode(GLOBAL_DATA, $1.m_node.tail, $2.m_node); + $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations); + $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations); + $$.m_features = $1.m_features | $2.m_features; + $$.m_numConstants = $1.m_numConstants + $2.m_numConstants; + } +; + +CaseClause: + CASE Expr ':' { $$ = createNodeDeclarationInfo(new CaseClauseNode(GLOBAL_DATA, $2.m_node), 0, 0, $2.m_features, $2.m_numConstants); } + | CASE Expr ':' SourceElements { $$ = createNodeDeclarationInfo(new CaseClauseNode(GLOBAL_DATA, $2.m_node, $4.m_node), $4.m_varDeclarations, $4.m_funcDeclarations, $2.m_features | $4.m_features, $2.m_numConstants + $4.m_numConstants); } +; + +DefaultClause: + DEFAULT ':' { $$ = createNodeDeclarationInfo(new CaseClauseNode(GLOBAL_DATA, 0), 0, 0, 0, 0); } + | DEFAULT ':' SourceElements { $$ = createNodeDeclarationInfo(new CaseClauseNode(GLOBAL_DATA, 0, $3.m_node), $3.m_varDeclarations, $3.m_funcDeclarations, $3.m_features, $3.m_numConstants); } +; + +LabelledStatement: + IDENT ':' Statement { LabelNode* node = new LabelNode(GLOBAL_DATA, *$1, $3.m_node); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeDeclarationInfo(node, $3.m_varDeclarations, $3.m_funcDeclarations, $3.m_features, $3.m_numConstants); } +; + +ThrowStatement: + THROW Expr ';' { ThrowNode* node = new ThrowNode(GLOBAL_DATA, $2.m_node); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2); + } + | THROW Expr error { ThrowNode* node = new ThrowNode(GLOBAL_DATA, $2.m_node); + SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); + $$ = createNodeDeclarationInfo(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; + } +; + +TryStatement: + TRY Block FINALLY Block { $$ = createNodeDeclarationInfo(new TryNode(GLOBAL_DATA, $2.m_node, GLOBAL_DATA->propertyNames->nullIdentifier, false, 0, $4.m_node), + mergeDeclarationLists($2.m_varDeclarations, $4.m_varDeclarations), + mergeDeclarationLists($2.m_funcDeclarations, $4.m_funcDeclarations), + $2.m_features | $4.m_features, + $2.m_numConstants + $4.m_numConstants); + DBG($$.m_node, @1, @2); } + | TRY Block CATCH '(' IDENT ')' Block { $$ = createNodeDeclarationInfo(new TryNode(GLOBAL_DATA, $2.m_node, *$5, ($7.m_features & EvalFeature) != 0, $7.m_node, 0), + mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), + mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations), + $2.m_features | $7.m_features | CatchFeature, + $2.m_numConstants + $7.m_numConstants); + DBG($$.m_node, @1, @2); } + | TRY Block CATCH '(' IDENT ')' Block FINALLY Block + { $$ = createNodeDeclarationInfo(new TryNode(GLOBAL_DATA, $2.m_node, *$5, ($7.m_features & EvalFeature) != 0, $7.m_node, $9.m_node), + mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), $9.m_varDeclarations), + mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations), $9.m_funcDeclarations), + $2.m_features | $7.m_features | $9.m_features | CatchFeature, + $2.m_numConstants + $7.m_numConstants + $9.m_numConstants); + DBG($$.m_node, @1, @2); } +; + +DebuggerStatement: + DEBUGGER ';' { $$ = createNodeDeclarationInfo(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0); + DBG($$.m_node, @1, @2); } + | DEBUGGER error { $$ = createNodeDeclarationInfo(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0); + DBG($$.m_node, @1, @1); AUTO_SEMICOLON; } +; + +FunctionDeclaration: + FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeDeclarationInfo(new FuncDeclNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), 0, new ParserRefCountedData(GLOBAL_DATA), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | ClosureFeature, 0); DBG($6, @5, @7); $$.m_funcDeclarations->data.append(static_cast($$.m_node)); } + | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE + { + $$ = createNodeDeclarationInfo(new FuncDeclNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), 0, new ParserRefCountedData(GLOBAL_DATA), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features | ClosureFeature, 0); + if ($4.m_features & ArgumentsFeature) + $7->setUsesArguments(); + DBG($7, @6, @8); + $$.m_funcDeclarations->data.append(static_cast($$.m_node)); + } +; + +FunctionExpr: + FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, $5, LEXER->sourceCode($4, $6, @4.first_line)), ClosureFeature, 0); DBG($5, @4, @6); } + | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE + { + $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, $6, LEXER->sourceCode($5, $7, @5.first_line), $3.m_node.head), $3.m_features | ClosureFeature, 0); + if ($3.m_features & ArgumentsFeature) + $6->setUsesArguments(); + DBG($6, @5, @7); + } + | FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), ClosureFeature, 0); DBG($6, @5, @7); } + | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE + { + $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), $4.m_features | ClosureFeature, 0); + if ($4.m_features & ArgumentsFeature) + $7->setUsesArguments(); + DBG($7, @6, @8); + } +; + +FormalParameterList: + IDENT { $$.m_node.head = new ParameterNode(GLOBAL_DATA, *$1); + $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0; + $$.m_node.tail = $$.m_node.head; } + | FormalParameterList ',' IDENT { $$.m_node.head = $1.m_node.head; + $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0); + $$.m_node.tail = new ParameterNode(GLOBAL_DATA, $1.m_node.tail, *$3); } +; + +FunctionBody: + /* not in spec */ { $$ = FunctionBodyNode::create(GLOBAL_DATA); } + | SourceElements_NoNode { $$ = FunctionBodyNode::create(GLOBAL_DATA); } +; + +Program: + /* not in spec */ { GLOBAL_DATA->parser->didFinishParsing(new SourceElements(GLOBAL_DATA), 0, 0, NoFeatures, @0.last_line, 0); } + | SourceElements { GLOBAL_DATA->parser->didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations, $1.m_features, + @1.last_line, $1.m_numConstants); } +; + +SourceElements: + Statement { $$.m_node = new SourceElements(GLOBAL_DATA); + $$.m_node->append($1.m_node); + $$.m_varDeclarations = $1.m_varDeclarations; + $$.m_funcDeclarations = $1.m_funcDeclarations; + $$.m_features = $1.m_features; + $$.m_numConstants = $1.m_numConstants; + } + | SourceElements Statement { $$.m_node->append($2.m_node); + $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations); + $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations); + $$.m_features = $1.m_features | $2.m_features; + $$.m_numConstants = $1.m_numConstants + $2.m_numConstants; + } +; + +// Start NoNodes + +Literal_NoNode: + NULLTOKEN + | TRUETOKEN + | FALSETOKEN + | NUMBER { } + | STRING { } + | '/' /* regexp */ { Lexer& l = *LEXER; if (!l.scanRegExp()) YYABORT; } + | DIVEQUAL /* regexp with /= */ { Lexer& l = *LEXER; if (!l.scanRegExp()) YYABORT; } +; + +Property_NoNode: + IDENT ':' AssignmentExpr_NoNode { } + | STRING ':' AssignmentExpr_NoNode { } + | NUMBER ':' AssignmentExpr_NoNode { } + | IDENT IDENT '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE { if (*$1 != "get" && *$1 != "set") YYABORT; } + | IDENT IDENT '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE { if (*$1 != "get" && *$1 != "set") YYABORT; } +; + +PropertyList_NoNode: + Property_NoNode + | PropertyList_NoNode ',' Property_NoNode +; + +PrimaryExpr_NoNode: + PrimaryExprNoBrace_NoNode + | OPENBRACE CLOSEBRACE { } + | OPENBRACE PropertyList_NoNode CLOSEBRACE { } + /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */ + | OPENBRACE PropertyList_NoNode ',' CLOSEBRACE { } +; + +PrimaryExprNoBrace_NoNode: + THISTOKEN + | Literal_NoNode + | ArrayLiteral_NoNode + | IDENT { } + | '(' Expr_NoNode ')' +; + +ArrayLiteral_NoNode: + '[' ElisionOpt_NoNode ']' + | '[' ElementList_NoNode ']' + | '[' ElementList_NoNode ',' ElisionOpt_NoNode ']' +; + +ElementList_NoNode: + ElisionOpt_NoNode AssignmentExpr_NoNode + | ElementList_NoNode ',' ElisionOpt_NoNode AssignmentExpr_NoNode +; + +ElisionOpt_NoNode: + /* nothing */ + | Elision_NoNode +; + +Elision_NoNode: + ',' + | Elision_NoNode ',' +; + +MemberExpr_NoNode: + PrimaryExpr_NoNode + | FunctionExpr_NoNode + | MemberExpr_NoNode '[' Expr_NoNode ']' + | MemberExpr_NoNode '.' IDENT + | NEW MemberExpr_NoNode Arguments_NoNode +; + +MemberExprNoBF_NoNode: + PrimaryExprNoBrace_NoNode + | MemberExprNoBF_NoNode '[' Expr_NoNode ']' + | MemberExprNoBF_NoNode '.' IDENT + | NEW MemberExpr_NoNode Arguments_NoNode +; + +NewExpr_NoNode: + MemberExpr_NoNode + | NEW NewExpr_NoNode +; + +NewExprNoBF_NoNode: + MemberExprNoBF_NoNode + | NEW NewExpr_NoNode +; + +CallExpr_NoNode: + MemberExpr_NoNode Arguments_NoNode + | CallExpr_NoNode Arguments_NoNode + | CallExpr_NoNode '[' Expr_NoNode ']' + | CallExpr_NoNode '.' IDENT +; + +CallExprNoBF_NoNode: + MemberExprNoBF_NoNode Arguments_NoNode + | CallExprNoBF_NoNode Arguments_NoNode + | CallExprNoBF_NoNode '[' Expr_NoNode ']' + | CallExprNoBF_NoNode '.' IDENT +; + +Arguments_NoNode: + '(' ')' + | '(' ArgumentList_NoNode ')' +; + +ArgumentList_NoNode: + AssignmentExpr_NoNode + | ArgumentList_NoNode ',' AssignmentExpr_NoNode +; + +LeftHandSideExpr_NoNode: + NewExpr_NoNode + | CallExpr_NoNode +; + +LeftHandSideExprNoBF_NoNode: + NewExprNoBF_NoNode + | CallExprNoBF_NoNode +; + +PostfixExpr_NoNode: + LeftHandSideExpr_NoNode + | LeftHandSideExpr_NoNode PLUSPLUS + | LeftHandSideExpr_NoNode MINUSMINUS +; + +PostfixExprNoBF_NoNode: + LeftHandSideExprNoBF_NoNode + | LeftHandSideExprNoBF_NoNode PLUSPLUS + | LeftHandSideExprNoBF_NoNode MINUSMINUS +; + +UnaryExprCommon_NoNode: + DELETETOKEN UnaryExpr_NoNode + | VOIDTOKEN UnaryExpr_NoNode + | TYPEOF UnaryExpr_NoNode + | PLUSPLUS UnaryExpr_NoNode + | AUTOPLUSPLUS UnaryExpr_NoNode + | MINUSMINUS UnaryExpr_NoNode + | AUTOMINUSMINUS UnaryExpr_NoNode + | '+' UnaryExpr_NoNode + | '-' UnaryExpr_NoNode + | '~' UnaryExpr_NoNode + | '!' UnaryExpr_NoNode + +UnaryExpr_NoNode: + PostfixExpr_NoNode + | UnaryExprCommon_NoNode +; + +UnaryExprNoBF_NoNode: + PostfixExprNoBF_NoNode + | UnaryExprCommon_NoNode +; + +MultiplicativeExpr_NoNode: + UnaryExpr_NoNode + | MultiplicativeExpr_NoNode '*' UnaryExpr_NoNode + | MultiplicativeExpr_NoNode '/' UnaryExpr_NoNode + | MultiplicativeExpr_NoNode '%' UnaryExpr_NoNode +; + +MultiplicativeExprNoBF_NoNode: + UnaryExprNoBF_NoNode + | MultiplicativeExprNoBF_NoNode '*' UnaryExpr_NoNode + | MultiplicativeExprNoBF_NoNode '/' UnaryExpr_NoNode + | MultiplicativeExprNoBF_NoNode '%' UnaryExpr_NoNode +; + +AdditiveExpr_NoNode: + MultiplicativeExpr_NoNode + | AdditiveExpr_NoNode '+' MultiplicativeExpr_NoNode + | AdditiveExpr_NoNode '-' MultiplicativeExpr_NoNode +; + +AdditiveExprNoBF_NoNode: + MultiplicativeExprNoBF_NoNode + | AdditiveExprNoBF_NoNode '+' MultiplicativeExpr_NoNode + | AdditiveExprNoBF_NoNode '-' MultiplicativeExpr_NoNode +; + +ShiftExpr_NoNode: + AdditiveExpr_NoNode + | ShiftExpr_NoNode LSHIFT AdditiveExpr_NoNode + | ShiftExpr_NoNode RSHIFT AdditiveExpr_NoNode + | ShiftExpr_NoNode URSHIFT AdditiveExpr_NoNode +; + +ShiftExprNoBF_NoNode: + AdditiveExprNoBF_NoNode + | ShiftExprNoBF_NoNode LSHIFT AdditiveExpr_NoNode + | ShiftExprNoBF_NoNode RSHIFT AdditiveExpr_NoNode + | ShiftExprNoBF_NoNode URSHIFT AdditiveExpr_NoNode +; + +RelationalExpr_NoNode: + ShiftExpr_NoNode + | RelationalExpr_NoNode '<' ShiftExpr_NoNode + | RelationalExpr_NoNode '>' ShiftExpr_NoNode + | RelationalExpr_NoNode LE ShiftExpr_NoNode + | RelationalExpr_NoNode GE ShiftExpr_NoNode + | RelationalExpr_NoNode INSTANCEOF ShiftExpr_NoNode + | RelationalExpr_NoNode INTOKEN ShiftExpr_NoNode +; + +RelationalExprNoIn_NoNode: + ShiftExpr_NoNode + | RelationalExprNoIn_NoNode '<' ShiftExpr_NoNode + | RelationalExprNoIn_NoNode '>' ShiftExpr_NoNode + | RelationalExprNoIn_NoNode LE ShiftExpr_NoNode + | RelationalExprNoIn_NoNode GE ShiftExpr_NoNode + | RelationalExprNoIn_NoNode INSTANCEOF ShiftExpr_NoNode +; + +RelationalExprNoBF_NoNode: + ShiftExprNoBF_NoNode + | RelationalExprNoBF_NoNode '<' ShiftExpr_NoNode + | RelationalExprNoBF_NoNode '>' ShiftExpr_NoNode + | RelationalExprNoBF_NoNode LE ShiftExpr_NoNode + | RelationalExprNoBF_NoNode GE ShiftExpr_NoNode + | RelationalExprNoBF_NoNode INSTANCEOF ShiftExpr_NoNode + | RelationalExprNoBF_NoNode INTOKEN ShiftExpr_NoNode +; + +EqualityExpr_NoNode: + RelationalExpr_NoNode + | EqualityExpr_NoNode EQEQ RelationalExpr_NoNode + | EqualityExpr_NoNode NE RelationalExpr_NoNode + | EqualityExpr_NoNode STREQ RelationalExpr_NoNode + | EqualityExpr_NoNode STRNEQ RelationalExpr_NoNode +; + +EqualityExprNoIn_NoNode: + RelationalExprNoIn_NoNode + | EqualityExprNoIn_NoNode EQEQ RelationalExprNoIn_NoNode + | EqualityExprNoIn_NoNode NE RelationalExprNoIn_NoNode + | EqualityExprNoIn_NoNode STREQ RelationalExprNoIn_NoNode + | EqualityExprNoIn_NoNode STRNEQ RelationalExprNoIn_NoNode +; + +EqualityExprNoBF_NoNode: + RelationalExprNoBF_NoNode + | EqualityExprNoBF_NoNode EQEQ RelationalExpr_NoNode + | EqualityExprNoBF_NoNode NE RelationalExpr_NoNode + | EqualityExprNoBF_NoNode STREQ RelationalExpr_NoNode + | EqualityExprNoBF_NoNode STRNEQ RelationalExpr_NoNode +; + +BitwiseANDExpr_NoNode: + EqualityExpr_NoNode + | BitwiseANDExpr_NoNode '&' EqualityExpr_NoNode +; + +BitwiseANDExprNoIn_NoNode: + EqualityExprNoIn_NoNode + | BitwiseANDExprNoIn_NoNode '&' EqualityExprNoIn_NoNode +; + +BitwiseANDExprNoBF_NoNode: + EqualityExprNoBF_NoNode + | BitwiseANDExprNoBF_NoNode '&' EqualityExpr_NoNode +; + +BitwiseXORExpr_NoNode: + BitwiseANDExpr_NoNode + | BitwiseXORExpr_NoNode '^' BitwiseANDExpr_NoNode +; + +BitwiseXORExprNoIn_NoNode: + BitwiseANDExprNoIn_NoNode + | BitwiseXORExprNoIn_NoNode '^' BitwiseANDExprNoIn_NoNode +; + +BitwiseXORExprNoBF_NoNode: + BitwiseANDExprNoBF_NoNode + | BitwiseXORExprNoBF_NoNode '^' BitwiseANDExpr_NoNode +; + +BitwiseORExpr_NoNode: + BitwiseXORExpr_NoNode + | BitwiseORExpr_NoNode '|' BitwiseXORExpr_NoNode +; + +BitwiseORExprNoIn_NoNode: + BitwiseXORExprNoIn_NoNode + | BitwiseORExprNoIn_NoNode '|' BitwiseXORExprNoIn_NoNode +; + +BitwiseORExprNoBF_NoNode: + BitwiseXORExprNoBF_NoNode + | BitwiseORExprNoBF_NoNode '|' BitwiseXORExpr_NoNode +; + +LogicalANDExpr_NoNode: + BitwiseORExpr_NoNode + | LogicalANDExpr_NoNode AND BitwiseORExpr_NoNode +; + +LogicalANDExprNoIn_NoNode: + BitwiseORExprNoIn_NoNode + | LogicalANDExprNoIn_NoNode AND BitwiseORExprNoIn_NoNode +; + +LogicalANDExprNoBF_NoNode: + BitwiseORExprNoBF_NoNode + | LogicalANDExprNoBF_NoNode AND BitwiseORExpr_NoNode +; + +LogicalORExpr_NoNode: + LogicalANDExpr_NoNode + | LogicalORExpr_NoNode OR LogicalANDExpr_NoNode +; + +LogicalORExprNoIn_NoNode: + LogicalANDExprNoIn_NoNode + | LogicalORExprNoIn_NoNode OR LogicalANDExprNoIn_NoNode +; + +LogicalORExprNoBF_NoNode: + LogicalANDExprNoBF_NoNode + | LogicalORExprNoBF_NoNode OR LogicalANDExpr_NoNode +; + +ConditionalExpr_NoNode: + LogicalORExpr_NoNode + | LogicalORExpr_NoNode '?' AssignmentExpr_NoNode ':' AssignmentExpr_NoNode +; + +ConditionalExprNoIn_NoNode: + LogicalORExprNoIn_NoNode + | LogicalORExprNoIn_NoNode '?' AssignmentExprNoIn_NoNode ':' AssignmentExprNoIn_NoNode +; + +ConditionalExprNoBF_NoNode: + LogicalORExprNoBF_NoNode + | LogicalORExprNoBF_NoNode '?' AssignmentExpr_NoNode ':' AssignmentExpr_NoNode +; + +AssignmentExpr_NoNode: + ConditionalExpr_NoNode + | LeftHandSideExpr_NoNode AssignmentOperator_NoNode AssignmentExpr_NoNode +; + +AssignmentExprNoIn_NoNode: + ConditionalExprNoIn_NoNode + | LeftHandSideExpr_NoNode AssignmentOperator_NoNode AssignmentExprNoIn_NoNode +; + +AssignmentExprNoBF_NoNode: + ConditionalExprNoBF_NoNode + | LeftHandSideExprNoBF_NoNode AssignmentOperator_NoNode AssignmentExpr_NoNode +; + +AssignmentOperator_NoNode: + '=' + | PLUSEQUAL + | MINUSEQUAL + | MULTEQUAL + | DIVEQUAL + | LSHIFTEQUAL + | RSHIFTEQUAL + | URSHIFTEQUAL + | ANDEQUAL + | XOREQUAL + | OREQUAL + | MODEQUAL +; + +Expr_NoNode: + AssignmentExpr_NoNode + | Expr_NoNode ',' AssignmentExpr_NoNode +; + +ExprNoIn_NoNode: + AssignmentExprNoIn_NoNode + | ExprNoIn_NoNode ',' AssignmentExprNoIn_NoNode +; + +ExprNoBF_NoNode: + AssignmentExprNoBF_NoNode + | ExprNoBF_NoNode ',' AssignmentExpr_NoNode +; + +Statement_NoNode: + Block_NoNode + | VariableStatement_NoNode + | ConstStatement_NoNode + | FunctionDeclaration_NoNode + | EmptyStatement_NoNode + | ExprStatement_NoNode + | IfStatement_NoNode + | IterationStatement_NoNode + | ContinueStatement_NoNode + | BreakStatement_NoNode + | ReturnStatement_NoNode + | WithStatement_NoNode + | SwitchStatement_NoNode + | LabelledStatement_NoNode + | ThrowStatement_NoNode + | TryStatement_NoNode + | DebuggerStatement_NoNode +; + +Block_NoNode: + OPENBRACE CLOSEBRACE { } + | OPENBRACE SourceElements_NoNode CLOSEBRACE { } +; + +VariableStatement_NoNode: + VAR VariableDeclarationList_NoNode ';' + | VAR VariableDeclarationList_NoNode error { AUTO_SEMICOLON; } +; + +VariableDeclarationList_NoNode: + IDENT { } + | IDENT Initializer_NoNode { } + | VariableDeclarationList_NoNode ',' IDENT + | VariableDeclarationList_NoNode ',' IDENT Initializer_NoNode +; + +VariableDeclarationListNoIn_NoNode: + IDENT { } + | IDENT InitializerNoIn_NoNode { } + | VariableDeclarationListNoIn_NoNode ',' IDENT + | VariableDeclarationListNoIn_NoNode ',' IDENT InitializerNoIn_NoNode +; + +ConstStatement_NoNode: + CONSTTOKEN ConstDeclarationList_NoNode ';' + | CONSTTOKEN ConstDeclarationList_NoNode error { AUTO_SEMICOLON; } +; + +ConstDeclarationList_NoNode: + ConstDeclaration_NoNode + | ConstDeclarationList_NoNode ',' ConstDeclaration_NoNode +; + +ConstDeclaration_NoNode: + IDENT { } + | IDENT Initializer_NoNode { } +; + +Initializer_NoNode: + '=' AssignmentExpr_NoNode +; + +InitializerNoIn_NoNode: + '=' AssignmentExprNoIn_NoNode +; + +EmptyStatement_NoNode: + ';' +; + +ExprStatement_NoNode: + ExprNoBF_NoNode ';' + | ExprNoBF_NoNode error { AUTO_SEMICOLON; } +; + +IfStatement_NoNode: + IF '(' Expr_NoNode ')' Statement_NoNode %prec IF_WITHOUT_ELSE + | IF '(' Expr_NoNode ')' Statement_NoNode ELSE Statement_NoNode +; + +IterationStatement_NoNode: + DO Statement_NoNode WHILE '(' Expr_NoNode ')' ';' + | DO Statement_NoNode WHILE '(' Expr_NoNode ')' error // Always performs automatic semicolon insertion + | WHILE '(' Expr_NoNode ')' Statement_NoNode + | FOR '(' ExprNoInOpt_NoNode ';' ExprOpt_NoNode ';' ExprOpt_NoNode ')' Statement_NoNode + | FOR '(' VAR VariableDeclarationListNoIn_NoNode ';' ExprOpt_NoNode ';' ExprOpt_NoNode ')' Statement_NoNode + | FOR '(' LeftHandSideExpr_NoNode INTOKEN Expr_NoNode ')' Statement_NoNode + | FOR '(' VAR IDENT INTOKEN Expr_NoNode ')' Statement_NoNode + | FOR '(' VAR IDENT InitializerNoIn_NoNode INTOKEN Expr_NoNode ')' Statement_NoNode +; + +ExprOpt_NoNode: + /* nothing */ + | Expr_NoNode +; + +ExprNoInOpt_NoNode: + /* nothing */ + | ExprNoIn_NoNode +; + +ContinueStatement_NoNode: + CONTINUE ';' + | CONTINUE error { AUTO_SEMICOLON; } + | CONTINUE IDENT ';' + | CONTINUE IDENT error { AUTO_SEMICOLON; } +; + +BreakStatement_NoNode: + BREAK ';' + | BREAK error { AUTO_SEMICOLON; } + | BREAK IDENT ';' + | BREAK IDENT error { AUTO_SEMICOLON; } +; + +ReturnStatement_NoNode: + RETURN ';' + | RETURN error { AUTO_SEMICOLON; } + | RETURN Expr_NoNode ';' + | RETURN Expr_NoNode error { AUTO_SEMICOLON; } +; + +WithStatement_NoNode: + WITH '(' Expr_NoNode ')' Statement_NoNode +; + +SwitchStatement_NoNode: + SWITCH '(' Expr_NoNode ')' CaseBlock_NoNode +; + +CaseBlock_NoNode: + OPENBRACE CaseClausesOpt_NoNode CLOSEBRACE { } + | OPENBRACE CaseClausesOpt_NoNode DefaultClause_NoNode CaseClausesOpt_NoNode CLOSEBRACE { } +; + +CaseClausesOpt_NoNode: + /* nothing */ + | CaseClauses_NoNode +; + +CaseClauses_NoNode: + CaseClause_NoNode + | CaseClauses_NoNode CaseClause_NoNode +; + +CaseClause_NoNode: + CASE Expr_NoNode ':' + | CASE Expr_NoNode ':' SourceElements_NoNode +; + +DefaultClause_NoNode: + DEFAULT ':' + | DEFAULT ':' SourceElements_NoNode +; + +LabelledStatement_NoNode: + IDENT ':' Statement_NoNode { } +; + +ThrowStatement_NoNode: + THROW Expr_NoNode ';' + | THROW Expr_NoNode error { AUTO_SEMICOLON; } +; + +TryStatement_NoNode: + TRY Block_NoNode FINALLY Block_NoNode + | TRY Block_NoNode CATCH '(' IDENT ')' Block_NoNode + | TRY Block_NoNode CATCH '(' IDENT ')' Block_NoNode FINALLY Block_NoNode +; + +DebuggerStatement_NoNode: + DEBUGGER ';' + | DEBUGGER error { AUTO_SEMICOLON; } +; + +FunctionDeclaration_NoNode: + FUNCTION IDENT '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE + | FUNCTION IDENT '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE +; + +FunctionExpr_NoNode: + FUNCTION '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE + | FUNCTION '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE + | FUNCTION IDENT '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE + | FUNCTION IDENT '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE +; + +FormalParameterList_NoNode: + IDENT { } + | FormalParameterList_NoNode ',' IDENT +; + +FunctionBody_NoNode: + /* not in spec */ + | SourceElements_NoNode +; + +SourceElements_NoNode: + Statement_NoNode + | SourceElements_NoNode Statement_NoNode +; + +// End NoNodes + +%% + +static ExpressionNode* makeAssignNode(void* globalPtr, ExpressionNode* loc, Operator op, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end) +{ + if (!loc->isLocation()) + return new AssignErrorNode(GLOBAL_DATA, loc, op, expr, divot, divot - start, end - divot); + + if (loc->isResolveNode()) { + ResolveNode* resolve = static_cast(loc); + if (op == OpEqual) { + AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, resolve->identifier(), expr, exprHasAssignments); + SET_EXCEPTION_LOCATION(node, start, divot, end); + return node; + } else + return new ReadModifyResolveNode(GLOBAL_DATA, resolve->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot); + } + if (loc->isBracketAccessorNode()) { + BracketAccessorNode* bracket = static_cast(loc); + if (op == OpEqual) + return new AssignBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), expr, locHasAssignments, exprHasAssignments, bracket->divot(), bracket->divot() - start, end - bracket->divot()); + else { + ReadModifyBracketNode* node = new ReadModifyBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, expr, locHasAssignments, exprHasAssignments, divot, divot - start, end - divot); + node->setSubexpressionInfo(bracket->divot(), bracket->endOffset()); + return node; + } + } + ASSERT(loc->isDotAccessorNode()); + DotAccessorNode* dot = static_cast(loc); + if (op == OpEqual) + return new AssignDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), dot->divot() - start, end - dot->divot()); + + ReadModifyDotNode* node = new ReadModifyDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot); + node->setSubexpressionInfo(dot->divot(), dot->endOffset()); + return node; +} + +static ExpressionNode* makePrefixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end) +{ + if (!expr->isLocation()) + return new PrefixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot); + + if (expr->isResolveNode()) { + ResolveNode* resolve = static_cast(expr); + return new PrefixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot); + } + if (expr->isBracketAccessorNode()) { + BracketAccessorNode* bracket = static_cast(expr); + PrefixBracketNode* node = new PrefixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot); + node->setSubexpressionInfo(bracket->divot(), bracket->startOffset()); + return node; + } + ASSERT(expr->isDotAccessorNode()); + DotAccessorNode* dot = static_cast(expr); + PrefixDotNode* node = new PrefixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot); + node->setSubexpressionInfo(dot->divot(), dot->startOffset()); + return node; +} + +static ExpressionNode* makePostfixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end) +{ + if (!expr->isLocation()) + return new PostfixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot); + + if (expr->isResolveNode()) { + ResolveNode* resolve = static_cast(expr); + return new PostfixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot); + } + if (expr->isBracketAccessorNode()) { + BracketAccessorNode* bracket = static_cast(expr); + PostfixBracketNode* node = new PostfixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot); + node->setSubexpressionInfo(bracket->divot(), bracket->endOffset()); + return node; + + } + ASSERT(expr->isDotAccessorNode()); + DotAccessorNode* dot = static_cast(expr); + PostfixDotNode* node = new PostfixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot); + node->setSubexpressionInfo(dot->divot(), dot->endOffset()); + return node; +} + +static ExpressionNodeInfo makeFunctionCallNode(void* globalPtr, ExpressionNodeInfo func, ArgumentsNodeInfo args, int start, int divot, int end) +{ + CodeFeatures features = func.m_features | args.m_features; + int numConstants = func.m_numConstants + args.m_numConstants; + if (!func.m_node->isLocation()) + return createNodeInfo(new FunctionCallValueNode(GLOBAL_DATA, func.m_node, args.m_node, divot, divot - start, end - divot), features, numConstants); + if (func.m_node->isResolveNode()) { + ResolveNode* resolve = static_cast(func.m_node); + const Identifier& identifier = resolve->identifier(); + if (identifier == GLOBAL_DATA->propertyNames->eval) + return createNodeInfo(new EvalFunctionCallNode(GLOBAL_DATA, args.m_node, divot, divot - start, end - divot), EvalFeature | features, numConstants); + return createNodeInfo(new FunctionCallResolveNode(GLOBAL_DATA, identifier, args.m_node, divot, divot - start, end - divot), features, numConstants); + } + if (func.m_node->isBracketAccessorNode()) { + BracketAccessorNode* bracket = static_cast(func.m_node); + FunctionCallBracketNode* node = new FunctionCallBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), args.m_node, divot, divot - start, end - divot); + node->setSubexpressionInfo(bracket->divot(), bracket->endOffset()); + return createNodeInfo(node, features, numConstants); + } + ASSERT(func.m_node->isDotAccessorNode()); + DotAccessorNode* dot = static_cast(func.m_node); + FunctionCallDotNode* node = new FunctionCallDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), args.m_node, divot, divot - start, end - divot); + node->setSubexpressionInfo(dot->divot(), dot->endOffset()); + return createNodeInfo(node, features, numConstants); +} + +static ExpressionNode* makeTypeOfNode(void* globalPtr, ExpressionNode* expr) +{ + if (expr->isResolveNode()) { + ResolveNode* resolve = static_cast(expr); + return new TypeOfResolveNode(GLOBAL_DATA, resolve->identifier()); + } + return new TypeOfValueNode(GLOBAL_DATA, expr); +} + +static ExpressionNode* makeDeleteNode(void* globalPtr, ExpressionNode* expr, int start, int divot, int end) +{ + if (!expr->isLocation()) + return new DeleteValueNode(GLOBAL_DATA, expr); + if (expr->isResolveNode()) { + ResolveNode* resolve = static_cast(expr); + return new DeleteResolveNode(GLOBAL_DATA, resolve->identifier(), divot, divot - start, end - divot); + } + if (expr->isBracketAccessorNode()) { + BracketAccessorNode* bracket = static_cast(expr); + return new DeleteBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), divot, divot - start, end - divot); + } + ASSERT(expr->isDotAccessorNode()); + DotAccessorNode* dot = static_cast(expr); + return new DeleteDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), divot, divot - start, end - divot); +} + +static PropertyNode* makeGetterOrSetterPropertyNode(void* globalPtr, const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceCode& source) +{ + PropertyNode::Type type; + if (getOrSet == "get") + type = PropertyNode::Getter; + else if (getOrSet == "set") + type = PropertyNode::Setter; + else + return 0; + return new PropertyNode(GLOBAL_DATA, name, new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, body, source, params), type); +} + +static ExpressionNode* makeNegateNode(void* globalPtr, ExpressionNode* n) +{ + if (n->isNumber()) { + NumberNode* number = static_cast(n); + + if (number->value() > 0.0) { + number->setValue(-number->value()); + return number; + } + } + + return new NegateNode(GLOBAL_DATA, n); +} + +static NumberNode* makeNumberNode(void* globalPtr, double d) +{ + return new NumberNode(GLOBAL_DATA, d); +} + +static ExpressionNode* makeBitwiseNotNode(void* globalPtr, ExpressionNode* expr) +{ + if (expr->isNumber()) + return makeNumberNode(globalPtr, ~toInt32(static_cast(expr)->value())); + return new BitwiseNotNode(GLOBAL_DATA, expr); +} + +static ExpressionNode* makeMultNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) +{ + expr1 = expr1->stripUnaryPlus(); + expr2 = expr2->stripUnaryPlus(); + + if (expr1->isNumber() && expr2->isNumber()) + return makeNumberNode(globalPtr, static_cast(expr1)->value() * static_cast(expr2)->value()); + + if (expr1->isNumber() && static_cast(expr1)->value() == 1) + return new UnaryPlusNode(GLOBAL_DATA, expr2); + + if (expr2->isNumber() && static_cast(expr2)->value() == 1) + return new UnaryPlusNode(GLOBAL_DATA, expr1); + + return new MultNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); +} + +static ExpressionNode* makeDivNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) +{ + expr1 = expr1->stripUnaryPlus(); + expr2 = expr2->stripUnaryPlus(); + + if (expr1->isNumber() && expr2->isNumber()) + return makeNumberNode(globalPtr, static_cast(expr1)->value() / static_cast(expr2)->value()); + return new DivNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); +} + +static ExpressionNode* makeAddNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) +{ + if (expr1->isNumber() && expr2->isNumber()) + return makeNumberNode(globalPtr, static_cast(expr1)->value() + static_cast(expr2)->value()); + return new AddNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); +} + +static ExpressionNode* makeSubNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) +{ + expr1 = expr1->stripUnaryPlus(); + expr2 = expr2->stripUnaryPlus(); + + if (expr1->isNumber() && expr2->isNumber()) + return makeNumberNode(globalPtr, static_cast(expr1)->value() - static_cast(expr2)->value()); + return new SubNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); +} + +static ExpressionNode* makeLeftShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) +{ + if (expr1->isNumber() && expr2->isNumber()) + return makeNumberNode(globalPtr, toInt32(static_cast(expr1)->value()) << (toUInt32(static_cast(expr2)->value()) & 0x1f)); + return new LeftShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); +} + +static ExpressionNode* makeRightShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) +{ + if (expr1->isNumber() && expr2->isNumber()) + return makeNumberNode(globalPtr, toInt32(static_cast(expr1)->value()) >> (toUInt32(static_cast(expr2)->value()) & 0x1f)); + return new RightShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments); +} + +/* called by yyparse on error */ +int yyerror(const char *) +{ + return 1; +} + +/* may we automatically insert a semicolon ? */ +static bool allowAutomaticSemicolon(Lexer& lexer, int yychar) +{ + return yychar == CLOSEBRACE || yychar == 0 || lexer.prevTerminator(); +} + +static ExpressionNode* combineVarInitializers(void* globalPtr, ExpressionNode* list, AssignResolveNode* init) +{ + if (!list) + return init; + return new VarDeclCommaNode(GLOBAL_DATA, list, init); +} + +// We turn variable declarations into either assignments or empty +// statements (which later get stripped out), because the actual +// declaration work is hoisted up to the start of the function body +static StatementNode* makeVarStatementNode(void* globalPtr, ExpressionNode* expr) +{ + if (!expr) + return new EmptyStatementNode(GLOBAL_DATA); + return new VarStatementNode(GLOBAL_DATA, expr); +} + +#undef GLOBAL_DATA diff --git a/kjs/keywords.table b/parser/Keywords.table similarity index 100% rename from kjs/keywords.table rename to parser/Keywords.table diff --git a/parser/Lexer.cpp b/parser/Lexer.cpp new file mode 100644 index 0000000..c2880dc --- /dev/null +++ b/parser/Lexer.cpp @@ -0,0 +1,900 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All Rights Reserved. + * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "Lexer.h" + +#include "JSFunction.h" +#include "JSGlobalObjectFunctions.h" +#include "NodeInfo.h" +#include "Nodes.h" +#include "dtoa.h" +#include +#include +#include +#include +#include +#include + +using namespace WTF; +using namespace Unicode; + +// we can't specify the namespace in yacc's C output, so do it here +using namespace JSC; + +#ifndef KDE_USE_FINAL +#include "Grammar.h" +#endif + +#include "Lookup.h" +#include "Lexer.lut.h" + +// a bridge for yacc from the C world to C++ +int jscyylex(void* lvalp, void* llocp, void* globalData) +{ + return static_cast(globalData)->lexer->lex(lvalp, llocp); +} + +namespace JSC { + +static bool isDecimalDigit(int); + +Lexer::Lexer(JSGlobalData* globalData) + : yylineno(1) + , m_restrKeyword(false) + , m_eatNextIdentifier(false) + , m_stackToken(-1) + , m_lastToken(-1) + , m_position(0) + , m_code(0) + , m_length(0) + , m_isReparsing(false) + , m_atLineStart(true) + , m_current(0) + , m_next1(0) + , m_next2(0) + , m_next3(0) + , m_currentOffset(0) + , m_nextOffset1(0) + , m_nextOffset2(0) + , m_nextOffset3(0) + , m_globalData(globalData) + , m_mainTable(JSC::mainTable) +{ + m_buffer8.reserveInitialCapacity(initialReadBufferCapacity); + m_buffer16.reserveInitialCapacity(initialReadBufferCapacity); +} + +Lexer::~Lexer() +{ + m_mainTable.deleteTable(); +} + +void Lexer::setCode(const SourceCode& source) +{ + yylineno = source.firstLine(); + m_restrKeyword = false; + m_delimited = false; + m_eatNextIdentifier = false; + m_stackToken = -1; + m_lastToken = -1; + + m_position = source.startOffset(); + m_source = &source; + m_code = source.provider()->data(); + m_length = source.endOffset(); + m_skipLF = false; + m_skipCR = false; + m_error = false; + m_atLineStart = true; + + // read first characters + shift(4); +} + +void Lexer::shift(unsigned p) +{ + // ECMA-262 calls for stripping Cf characters here, but we only do this for BOM, + // see . + + while (p--) { + m_current = m_next1; + m_next1 = m_next2; + m_next2 = m_next3; + m_currentOffset = m_nextOffset1; + m_nextOffset1 = m_nextOffset2; + m_nextOffset2 = m_nextOffset3; + do { + if (m_position >= m_length) { + m_nextOffset3 = m_position; + m_position++; + m_next3 = -1; + break; + } + m_nextOffset3 = m_position; + m_next3 = m_code[m_position++]; + } while (m_next3 == 0xFEFF); + } +} + +// called on each new line +void Lexer::nextLine() +{ + yylineno++; + m_atLineStart = true; +} + +void Lexer::setDone(State s) +{ + m_state = s; + m_done = true; +} + +int Lexer::lex(void* p1, void* p2) +{ + YYSTYPE* lvalp = static_cast(p1); + YYLTYPE* llocp = static_cast(p2); + int token = 0; + m_state = Start; + unsigned short stringType = 0; // either single or double quotes + m_buffer8.clear(); + m_buffer16.clear(); + m_done = false; + m_terminator = false; + m_skipLF = false; + m_skipCR = false; + + // did we push a token on the stack previously ? + // (after an automatic semicolon insertion) + if (m_stackToken >= 0) { + setDone(Other); + token = m_stackToken; + m_stackToken = 0; + } + int startOffset = m_currentOffset; + while (!m_done) { + if (m_skipLF && m_current != '\n') // found \r but not \n afterwards + m_skipLF = false; + if (m_skipCR && m_current != '\r') // found \n but not \r afterwards + m_skipCR = false; + if (m_skipLF || m_skipCR) { // found \r\n or \n\r -> eat the second one + m_skipLF = false; + m_skipCR = false; + shift(1); + } + switch (m_state) { + case Start: + startOffset = m_currentOffset; + if (isWhiteSpace()) { + // do nothing + } else if (m_current == '/' && m_next1 == '/') { + shift(1); + m_state = InSingleLineComment; + } else if (m_current == '/' && m_next1 == '*') { + shift(1); + m_state = InMultiLineComment; + } else if (m_current == -1) { + if (!m_terminator && !m_delimited && !m_isReparsing) { + // automatic semicolon insertion if program incomplete + token = ';'; + m_stackToken = 0; + setDone(Other); + } else + setDone(Eof); + } else if (isLineTerminator()) { + nextLine(); + m_terminator = true; + if (m_restrKeyword) { + token = ';'; + setDone(Other); + } + } else if (m_current == '"' || m_current == '\'') { + m_state = InString; + stringType = static_cast(m_current); + } else if (isIdentStart(m_current)) { + record16(m_current); + m_state = InIdentifierOrKeyword; + } else if (m_current == '\\') + m_state = InIdentifierStartUnicodeEscapeStart; + else if (m_current == '0') { + record8(m_current); + m_state = InNum0; + } else if (isDecimalDigit(m_current)) { + record8(m_current); + m_state = InNum; + } else if (m_current == '.' && isDecimalDigit(m_next1)) { + record8(m_current); + m_state = InDecimal; + // + } else if (m_atLineStart && m_current == '-' && m_next1 == '-' && m_next2 == '>') { + shift(2); + m_state = InSingleLineComment; + } else { + token = matchPunctuator(lvalp->intValue, m_current, m_next1, m_next2, m_next3); + if (token != -1) + setDone(Other); + else + setDone(Bad); + } + break; + case InString: + if (m_current == stringType) { + shift(1); + setDone(String); + } else if (isLineTerminator() || m_current == -1) + setDone(Bad); + else if (m_current == '\\') + m_state = InEscapeSequence; + else + record16(m_current); + break; + // Escape Sequences inside of strings + case InEscapeSequence: + if (isOctalDigit(m_current)) { + if (m_current >= '0' && m_current <= '3' && + isOctalDigit(m_next1) && isOctalDigit(m_next2)) { + record16(convertOctal(m_current, m_next1, m_next2)); + shift(2); + m_state = InString; + } else if (isOctalDigit(m_current) && isOctalDigit(m_next1)) { + record16(convertOctal('0', m_current, m_next1)); + shift(1); + m_state = InString; + } else if (isOctalDigit(m_current)) { + record16(convertOctal('0', '0', m_current)); + m_state = InString; + } else + setDone(Bad); + } else if (m_current == 'x') + m_state = InHexEscape; + else if (m_current == 'u') + m_state = InUnicodeEscape; + else if (isLineTerminator()) { + nextLine(); + m_state = InString; + } else { + record16(singleEscape(static_cast(m_current))); + m_state = InString; + } + break; + case InHexEscape: + if (isHexDigit(m_current) && isHexDigit(m_next1)) { + m_state = InString; + record16(convertHex(m_current, m_next1)); + shift(1); + } else if (m_current == stringType) { + record16('x'); + shift(1); + setDone(String); + } else { + record16('x'); + record16(m_current); + m_state = InString; + } + break; + case InUnicodeEscape: + if (isHexDigit(m_current) && isHexDigit(m_next1) && isHexDigit(m_next2) && isHexDigit(m_next3)) { + record16(convertUnicode(m_current, m_next1, m_next2, m_next3)); + shift(3); + m_state = InString; + } else if (m_current == stringType) { + record16('u'); + shift(1); + setDone(String); + } else + setDone(Bad); + break; + case InSingleLineComment: + if (isLineTerminator()) { + nextLine(); + m_terminator = true; + if (m_restrKeyword) { + token = ';'; + setDone(Other); + } else + m_state = Start; + } else if (m_current == -1) + setDone(Eof); + break; + case InMultiLineComment: + if (m_current == -1) + setDone(Bad); + else if (isLineTerminator()) + nextLine(); + else if (m_current == '*' && m_next1 == '/') { + m_state = Start; + shift(1); + } + break; + case InIdentifierOrKeyword: + case InIdentifier: + if (isIdentPart(m_current)) + record16(m_current); + else if (m_current == '\\') + m_state = InIdentifierPartUnicodeEscapeStart; + else + setDone(m_state == InIdentifierOrKeyword ? IdentifierOrKeyword : Identifier); + break; + case InNum0: + if (m_current == 'x' || m_current == 'X') { + record8(m_current); + m_state = InHex; + } else if (m_current == '.') { + record8(m_current); + m_state = InDecimal; + } else if (m_current == 'e' || m_current == 'E') { + record8(m_current); + m_state = InExponentIndicator; + } else if (isOctalDigit(m_current)) { + record8(m_current); + m_state = InOctal; + } else if (isDecimalDigit(m_current)) { + record8(m_current); + m_state = InDecimal; + } else + setDone(Number); + break; + case InHex: + if (isHexDigit(m_current)) + record8(m_current); + else + setDone(Hex); + break; + case InOctal: + if (isOctalDigit(m_current)) + record8(m_current); + else if (isDecimalDigit(m_current)) { + record8(m_current); + m_state = InDecimal; + } else + setDone(Octal); + break; + case InNum: + if (isDecimalDigit(m_current)) + record8(m_current); + else if (m_current == '.') { + record8(m_current); + m_state = InDecimal; + } else if (m_current == 'e' || m_current == 'E') { + record8(m_current); + m_state = InExponentIndicator; + } else + setDone(Number); + break; + case InDecimal: + if (isDecimalDigit(m_current)) + record8(m_current); + else if (m_current == 'e' || m_current == 'E') { + record8(m_current); + m_state = InExponentIndicator; + } else + setDone(Number); + break; + case InExponentIndicator: + if (m_current == '+' || m_current == '-') + record8(m_current); + else if (isDecimalDigit(m_current)) { + record8(m_current); + m_state = InExponent; + } else + setDone(Bad); + break; + case InExponent: + if (isDecimalDigit(m_current)) + record8(m_current); + else + setDone(Number); + break; + case InIdentifierStartUnicodeEscapeStart: + if (m_current == 'u') + m_state = InIdentifierStartUnicodeEscape; + else + setDone(Bad); + break; + case InIdentifierPartUnicodeEscapeStart: + if (m_current == 'u') + m_state = InIdentifierPartUnicodeEscape; + else + setDone(Bad); + break; + case InIdentifierStartUnicodeEscape: + if (!isHexDigit(m_current) || !isHexDigit(m_next1) || !isHexDigit(m_next2) || !isHexDigit(m_next3)) { + setDone(Bad); + break; + } + token = convertUnicode(m_current, m_next1, m_next2, m_next3); + shift(3); + if (!isIdentStart(token)) { + setDone(Bad); + break; + } + record16(token); + m_state = InIdentifier; + break; + case InIdentifierPartUnicodeEscape: + if (!isHexDigit(m_current) || !isHexDigit(m_next1) || !isHexDigit(m_next2) || !isHexDigit(m_next3)) { + setDone(Bad); + break; + } + token = convertUnicode(m_current, m_next1, m_next2, m_next3); + shift(3); + if (!isIdentPart(token)) { + setDone(Bad); + break; + } + record16(token); + m_state = InIdentifier; + break; + default: + ASSERT(!"Unhandled state in switch statement"); + } + + // move on to the next character + if (!m_done) + shift(1); + if (m_state != Start && m_state != InSingleLineComment) + m_atLineStart = false; + } + + // no identifiers allowed directly after numeric literal, e.g. "3in" is bad + if ((m_state == Number || m_state == Octal || m_state == Hex) && isIdentStart(m_current)) + m_state = Bad; + + // terminate string + m_buffer8.append('\0'); + +#ifdef JSC_DEBUG_LEX + fprintf(stderr, "line: %d ", lineNo()); + fprintf(stderr, "yytext (%x): ", m_buffer8[0]); + fprintf(stderr, "%s ", m_buffer8.data()); +#endif + + double dval = 0; + if (m_state == Number) + dval = WTF::strtod(m_buffer8.data(), 0L); + else if (m_state == Hex) { // scan hex numbers + const char* p = m_buffer8.data() + 2; + while (char c = *p++) { + dval *= 16; + dval += convertHex(c); + } + + if (dval >= mantissaOverflowLowerBound) + dval = parseIntOverflow(m_buffer8.data() + 2, p - (m_buffer8.data() + 3), 16); + + m_state = Number; + } else if (m_state == Octal) { // scan octal number + const char* p = m_buffer8.data() + 1; + while (char c = *p++) { + dval *= 8; + dval += c - '0'; + } + + if (dval >= mantissaOverflowLowerBound) + dval = parseIntOverflow(m_buffer8.data() + 1, p - (m_buffer8.data() + 2), 8); + + m_state = Number; + } + +#ifdef JSC_DEBUG_LEX + switch (m_state) { + case Eof: + printf("(EOF)\n"); + break; + case Other: + printf("(Other)\n"); + break; + case Identifier: + printf("(Identifier)/(Keyword)\n"); + break; + case String: + printf("(String)\n"); + break; + case Number: + printf("(Number)\n"); + break; + default: + printf("(unknown)"); + } +#endif + + if (m_state != Identifier) + m_eatNextIdentifier = false; + + m_restrKeyword = false; + m_delimited = false; + llocp->first_line = yylineno; + llocp->last_line = yylineno; + llocp->first_column = startOffset; + llocp->last_column = m_currentOffset; + switch (m_state) { + case Eof: + token = 0; + break; + case Other: + if (token == '}' || token == ';') + m_delimited = true; + break; + case Identifier: + // Apply anonymous-function hack below (eat the identifier). + if (m_eatNextIdentifier) { + m_eatNextIdentifier = false; + token = lex(lvalp, llocp); + break; + } + lvalp->ident = makeIdentifier(m_buffer16); + token = IDENT; + break; + case IdentifierOrKeyword: { + lvalp->ident = makeIdentifier(m_buffer16); + const HashEntry* entry = m_mainTable.entry(m_globalData, *lvalp->ident); + if (!entry) { + // Lookup for keyword failed, means this is an identifier. + token = IDENT; + break; + } + token = entry->lexerValue(); + // Hack for "f = function somename() { ... }"; too hard to get into the grammar. + m_eatNextIdentifier = token == FUNCTION && m_lastToken == '='; + if (token == CONTINUE || token == BREAK || token == RETURN || token == THROW) + m_restrKeyword = true; + break; + } + case String: + // Atomize constant strings in case they're later used in property lookup. + lvalp->ident = makeIdentifier(m_buffer16); + token = STRING; + break; + case Number: + lvalp->doubleValue = dval; + token = NUMBER; + break; + case Bad: +#ifdef JSC_DEBUG_LEX + fprintf(stderr, "yylex: ERROR.\n"); +#endif + m_error = true; + return -1; + default: + ASSERT(!"unhandled numeration value in switch"); + m_error = true; + return -1; + } + m_lastToken = token; + return token; +} + +bool Lexer::isWhiteSpace() const +{ + return m_current == '\t' || m_current == 0x0b || m_current == 0x0c || isSeparatorSpace(m_current); +} + +bool Lexer::isLineTerminator() +{ + bool cr = (m_current == '\r'); + bool lf = (m_current == '\n'); + if (cr) + m_skipLF = true; + else if (lf) + m_skipCR = true; + return cr || lf || m_current == 0x2028 || m_current == 0x2029; +} + +bool Lexer::isIdentStart(int c) +{ + return isASCIIAlpha(c) || c == '$' || c == '_' || (!isASCII(c) && (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other))); +} + +bool Lexer::isIdentPart(int c) +{ + return isASCIIAlphanumeric(c) || c == '$' || c == '_' || (!isASCII(c) && (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other + | Mark_NonSpacing | Mark_SpacingCombining | Number_DecimalDigit | Punctuation_Connector))); +} + +static bool isDecimalDigit(int c) +{ + return isASCIIDigit(c); +} + +bool Lexer::isHexDigit(int c) +{ + return isASCIIHexDigit(c); +} + +bool Lexer::isOctalDigit(int c) +{ + return isASCIIOctalDigit(c); +} + +int Lexer::matchPunctuator(int& charPos, int c1, int c2, int c3, int c4) +{ + if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') { + shift(4); + return URSHIFTEQUAL; + } + if (c1 == '=' && c2 == '=' && c3 == '=') { + shift(3); + return STREQ; + } + if (c1 == '!' && c2 == '=' && c3 == '=') { + shift(3); + return STRNEQ; + } + if (c1 == '>' && c2 == '>' && c3 == '>') { + shift(3); + return URSHIFT; + } + if (c1 == '<' && c2 == '<' && c3 == '=') { + shift(3); + return LSHIFTEQUAL; + } + if (c1 == '>' && c2 == '>' && c3 == '=') { + shift(3); + return RSHIFTEQUAL; + } + if (c1 == '<' && c2 == '=') { + shift(2); + return LE; + } + if (c1 == '>' && c2 == '=') { + shift(2); + return GE; + } + if (c1 == '!' && c2 == '=') { + shift(2); + return NE; + } + if (c1 == '+' && c2 == '+') { + shift(2); + if (m_terminator) + return AUTOPLUSPLUS; + return PLUSPLUS; + } + if (c1 == '-' && c2 == '-') { + shift(2); + if (m_terminator) + return AUTOMINUSMINUS; + return MINUSMINUS; + } + if (c1 == '=' && c2 == '=') { + shift(2); + return EQEQ; + } + if (c1 == '+' && c2 == '=') { + shift(2); + return PLUSEQUAL; + } + if (c1 == '-' && c2 == '=') { + shift(2); + return MINUSEQUAL; + } + if (c1 == '*' && c2 == '=') { + shift(2); + return MULTEQUAL; + } + if (c1 == '/' && c2 == '=') { + shift(2); + return DIVEQUAL; + } + if (c1 == '&' && c2 == '=') { + shift(2); + return ANDEQUAL; + } + if (c1 == '^' && c2 == '=') { + shift(2); + return XOREQUAL; + } + if (c1 == '%' && c2 == '=') { + shift(2); + return MODEQUAL; + } + if (c1 == '|' && c2 == '=') { + shift(2); + return OREQUAL; + } + if (c1 == '<' && c2 == '<') { + shift(2); + return LSHIFT; + } + if (c1 == '>' && c2 == '>') { + shift(2); + return RSHIFT; + } + if (c1 == '&' && c2 == '&') { + shift(2); + return AND; + } + if (c1 == '|' && c2 == '|') { + shift(2); + return OR; + } + + switch (c1) { + case '=': + case '>': + case '<': + case ',': + case '!': + case '~': + case '?': + case ':': + case '.': + case '+': + case '-': + case '*': + case '/': + case '&': + case '|': + case '^': + case '%': + case '(': + case ')': + case '[': + case ']': + case ';': + shift(1); + return static_cast(c1); + case '{': + charPos = m_currentOffset; + shift(1); + return OPENBRACE; + case '}': + charPos = m_currentOffset; + shift(1); + return CLOSEBRACE; + default: + return -1; + } +} + +unsigned short Lexer::singleEscape(unsigned short c) +{ + switch (c) { + case 'b': + return 0x08; + case 't': + return 0x09; + case 'n': + return 0x0A; + case 'v': + return 0x0B; + case 'f': + return 0x0C; + case 'r': + return 0x0D; + case '"': + return 0x22; + case '\'': + return 0x27; + case '\\': + return 0x5C; + default: + return c; + } +} + +unsigned short Lexer::convertOctal(int c1, int c2, int c3) +{ + return static_cast((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0'); +} + +unsigned char Lexer::convertHex(int c) +{ + if (c >= '0' && c <= '9') + return static_cast(c - '0'); + if (c >= 'a' && c <= 'f') + return static_cast(c - 'a' + 10); + return static_cast(c - 'A' + 10); +} + +unsigned char Lexer::convertHex(int c1, int c2) +{ + return ((convertHex(c1) << 4) + convertHex(c2)); +} + +UChar Lexer::convertUnicode(int c1, int c2, int c3, int c4) +{ + unsigned char highByte = (convertHex(c1) << 4) + convertHex(c2); + unsigned char lowByte = (convertHex(c3) << 4) + convertHex(c4); + return (highByte << 8 | lowByte); +} + +void Lexer::record8(int c) +{ + ASSERT(c >= 0); + ASSERT(c <= 0xff); + m_buffer8.append(static_cast(c)); +} + +void Lexer::record16(int c) +{ + ASSERT(c >= 0); + ASSERT(c <= USHRT_MAX); + record16(UChar(static_cast(c))); +} + +void Lexer::record16(UChar c) +{ + m_buffer16.append(c); +} + +bool Lexer::scanRegExp() +{ + m_buffer16.clear(); + bool lastWasEscape = false; + bool inBrackets = false; + + while (1) { + if (isLineTerminator() || m_current == -1) + return false; + else if (m_current != '/' || lastWasEscape == true || inBrackets == true) { + // keep track of '[' and ']' + if (!lastWasEscape) { + if ( m_current == '[' && !inBrackets ) + inBrackets = true; + if ( m_current == ']' && inBrackets ) + inBrackets = false; + } + record16(m_current); + lastWasEscape = + !lastWasEscape && (m_current == '\\'); + } else { // end of regexp + m_pattern = UString(m_buffer16); + m_buffer16.clear(); + shift(1); + break; + } + shift(1); + } + + while (isIdentPart(m_current)) { + record16(m_current); + shift(1); + } + m_flags = UString(m_buffer16); + + return true; +} + +void Lexer::clear() +{ + m_identifiers.clear(); + + Vector newBuffer8; + newBuffer8.reserveInitialCapacity(initialReadBufferCapacity); + m_buffer8.swap(newBuffer8); + + Vector newBuffer16; + newBuffer16.reserveInitialCapacity(initialReadBufferCapacity); + m_buffer16.swap(newBuffer16); + + m_isReparsing = false; + + m_pattern = 0; + m_flags = 0; +} + +} // namespace JSC diff --git a/parser/Lexer.h b/parser/Lexer.h new file mode 100644 index 0000000..63d3892 --- /dev/null +++ b/parser/Lexer.h @@ -0,0 +1,171 @@ +/* + * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) + * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef Lexer_h +#define Lexer_h + +#include "Identifier.h" +#include "Lookup.h" +#include "SegmentedVector.h" +#include "SourceCode.h" +#include + +namespace JSC { + + class RegExp; + + class Lexer : Noncopyable { + public: + void setCode(const SourceCode&); + void setIsReparsing() { m_isReparsing = true; } + int lex(void* lvalp, void* llocp); + + int lineNo() const { return yylineno; } + + bool prevTerminator() const { return m_terminator; } + + enum State { + Start, + IdentifierOrKeyword, + Identifier, + InIdentifierOrKeyword, + InIdentifier, + InIdentifierStartUnicodeEscapeStart, + InIdentifierStartUnicodeEscape, + InIdentifierPartUnicodeEscapeStart, + InIdentifierPartUnicodeEscape, + InSingleLineComment, + InMultiLineComment, + InNum, + InNum0, + InHex, + InOctal, + InDecimal, + InExponentIndicator, + InExponent, + Hex, + Octal, + Number, + String, + Eof, + InString, + InEscapeSequence, + InHexEscape, + InUnicodeEscape, + Other, + Bad + }; + + bool scanRegExp(); + const UString& pattern() const { return m_pattern; } + const UString& flags() const { return m_flags; } + + static unsigned char convertHex(int); + static unsigned char convertHex(int c1, int c2); + static UChar convertUnicode(int c1, int c2, int c3, int c4); + static bool isIdentStart(int); + static bool isIdentPart(int); + static bool isHexDigit(int); + + bool sawError() const { return m_error; } + + void clear(); + SourceCode sourceCode(int openBrace, int closeBrace, int firstLine) { return SourceCode(m_source->provider(), openBrace, closeBrace + 1, firstLine); } + + private: + friend class JSGlobalData; + Lexer(JSGlobalData*); + ~Lexer(); + + void setDone(State); + void shift(unsigned int p); + void nextLine(); + int lookupKeyword(const char *); + + bool isWhiteSpace() const; + bool isLineTerminator(); + static bool isOctalDigit(int); + + ALWAYS_INLINE int matchPunctuator(int& charPos, int c1, int c2, int c3, int c4); + static unsigned short singleEscape(unsigned short); + static unsigned short convertOctal(int c1, int c2, int c3); + + void record8(int); + void record16(int); + void record16(UChar); + + JSC::Identifier* makeIdentifier(const Vector& buffer) + { + m_identifiers.append(JSC::Identifier(m_globalData, buffer.data(), buffer.size())); + return &m_identifiers.last(); + } + + static const size_t initialReadBufferCapacity = 32; + static const size_t initialIdentifierTableCapacity = 64; + + int yylineno; + int yycolumn; + + bool m_done; + Vector m_buffer8; + Vector m_buffer16; + bool m_terminator; + bool m_restrKeyword; + bool m_delimited; // encountered delimiter like "'" and "}" on last run + bool m_skipLF; + bool m_skipCR; + bool m_eatNextIdentifier; + int m_stackToken; + int m_lastToken; + + State m_state; + unsigned int m_position; + const SourceCode* m_source; + const UChar* m_code; + unsigned int m_length; + bool m_isReparsing; + int m_atLineStart; + bool m_error; + + // current and following unicode characters (int to allow for -1 for end-of-file marker) + int m_current; + int m_next1; + int m_next2; + int m_next3; + + int m_currentOffset; + int m_nextOffset1; + int m_nextOffset2; + int m_nextOffset3; + + SegmentedVector m_identifiers; + + JSGlobalData* m_globalData; + + UString m_pattern; + UString m_flags; + + const HashTable m_mainTable; + }; + +} // namespace JSC + +#endif // Lexer_h diff --git a/parser/NodeInfo.h b/parser/NodeInfo.h new file mode 100644 index 0000000..a518b23 --- /dev/null +++ b/parser/NodeInfo.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef NodeInfo_h +#define NodeInfo_h + +#include "Nodes.h" +#include "Parser.h" + +namespace JSC { + + template struct NodeInfo { + T m_node; + CodeFeatures m_features; + int m_numConstants; + }; + + typedef NodeInfo FuncDeclNodeInfo; + typedef NodeInfo FuncExprNodeInfo; + typedef NodeInfo ExpressionNodeInfo; + typedef NodeInfo ArgumentsNodeInfo; + typedef NodeInfo ConstDeclNodeInfo; + typedef NodeInfo PropertyNodeInfo; + typedef NodeInfo PropertyListInfo; + typedef NodeInfo ElementListInfo; + typedef NodeInfo ArgumentListInfo; + + template struct NodeDeclarationInfo { + T m_node; + ParserRefCountedData* m_varDeclarations; + ParserRefCountedData* m_funcDeclarations; + CodeFeatures m_features; + int m_numConstants; + }; + + typedef NodeDeclarationInfo StatementNodeInfo; + typedef NodeDeclarationInfo CaseBlockNodeInfo; + typedef NodeDeclarationInfo CaseClauseNodeInfo; + typedef NodeDeclarationInfo SourceElementsInfo; + typedef NodeDeclarationInfo ClauseListInfo; + typedef NodeDeclarationInfo VarDeclListInfo; + typedef NodeDeclarationInfo ConstDeclListInfo; + typedef NodeDeclarationInfo ParameterListInfo; + +} // namespace JSC + +#endif // NodeInfo_h diff --git a/parser/Nodes.cpp b/parser/Nodes.cpp new file mode 100644 index 0000000..8aa1788 --- /dev/null +++ b/parser/Nodes.cpp @@ -0,0 +1,2750 @@ +/* +* Copyright (C) 1999-2002 Harri Porten (porten@kde.org) +* Copyright (C) 2001 Peter Kelly (pmk@post.com) +* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +* Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) +* Copyright (C) 2007 Maks Orlovich +* Copyright (C) 2007 Eric Seidel +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Library General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Library General Public License for more details. +* +* You should have received a copy of the GNU Library General Public License +* along with this library; see the file COPYING.LIB. If not, write to +* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301, USA. +* +*/ + +#include "config.h" +#include "Nodes.h" + +#include "BytecodeGenerator.h" +#include "CallFrame.h" +#include "JSGlobalObject.h" +#include "JSStaticScopeObject.h" +#include "LabelScope.h" +#include "Parser.h" +#include "PropertyNameArray.h" +#include "RegExpObject.h" +#include "SamplingTool.h" +#include "Debugger.h" +#include "Lexer.h" +#include "Operations.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace WTF; + +namespace JSC { + +static void substitute(UString& string, const UString& substring) JSC_FAST_CALL; + +// ------------------------------ NodeReleaser -------------------------------- + +class NodeReleaser : Noncopyable { +public: + // Call this function inside the destructor of a class derived from Node. + // This will traverse the tree below this node, destroying all of those nodes, + // but without relying on recursion. + static void releaseAllNodes(ParserRefCounted* root); + + // Call this on each node in a the releaseNodes virtual function. + // It gives the node to the NodeReleaser, which will then release the + // node later at the end of the releaseAllNodes process. + template void release(RefPtr& node) { if (node) adopt(node.release()); } + void release(RefPtr& node) { if (node) adoptFunctionBodyNode(node); } + +private: + NodeReleaser() { } + ~NodeReleaser() { } + + void adopt(PassRefPtr); + void adoptFunctionBodyNode(RefPtr&); + + typedef Vector > NodeReleaseVector; + OwnPtr m_vector; +}; + +void NodeReleaser::releaseAllNodes(ParserRefCounted* root) +{ + ASSERT(root); + NodeReleaser releaser; + root->releaseNodes(releaser); + if (!releaser.m_vector) + return; + // Note: The call to release.m_vector->size() is intentionally inside + // the loop, since calls to releaseNodes are expected to increase the size. + for (size_t i = 0; i < releaser.m_vector->size(); ++i) { + ParserRefCounted* node = (*releaser.m_vector)[i].get(); + if (node->hasOneRef()) + node->releaseNodes(releaser); + } +} + +void NodeReleaser::adopt(PassRefPtr node) +{ + ASSERT(node); + if (!node->hasOneRef()) + return; + if (!m_vector) + m_vector.set(new NodeReleaseVector); + m_vector->append(node); +} + +void NodeReleaser::adoptFunctionBodyNode(RefPtr& functionBodyNode) +{ + // This sidesteps a problem where if you assign a PassRefPtr + // to a PassRefPtr we leave the two reference counts (FunctionBodyNode + // and ParserRefCounted) unbalanced. It would be nice to fix this problem in + // a cleaner way -- perhaps we could remove the FunctionBodyNode reference + // count at some point. + RefPtr node = functionBodyNode; + functionBodyNode = 0; + adopt(node.release()); +} + +// ------------------------------ ParserRefCounted ----------------------------------------- + +#ifndef NDEBUG +static RefCountedLeakCounter parserRefCountedCounter("JSC::Node"); +#endif + +ParserRefCounted::ParserRefCounted(JSGlobalData* globalData) + : m_globalData(globalData) +{ +#ifndef NDEBUG + parserRefCountedCounter.increment(); +#endif + if (!m_globalData->newParserObjects) + m_globalData->newParserObjects = new HashSet; + m_globalData->newParserObjects->add(this); + ASSERT(m_globalData->newParserObjects->contains(this)); +} + +ParserRefCounted::~ParserRefCounted() +{ +#ifndef NDEBUG + parserRefCountedCounter.decrement(); +#endif +} + +void ParserRefCounted::releaseNodes(NodeReleaser&) +{ +} + +void ParserRefCounted::ref() +{ + // bumping from 0 to 1 is just removing from the new nodes set + if (m_globalData->newParserObjects) { + HashSet::iterator it = m_globalData->newParserObjects->find(this); + if (it != m_globalData->newParserObjects->end()) { + m_globalData->newParserObjects->remove(it); + ASSERT(!m_globalData->parserObjectExtraRefCounts || !m_globalData->parserObjectExtraRefCounts->contains(this)); + return; + } + } + + ASSERT(!m_globalData->newParserObjects || !m_globalData->newParserObjects->contains(this)); + + if (!m_globalData->parserObjectExtraRefCounts) + m_globalData->parserObjectExtraRefCounts = new HashCountedSet; + m_globalData->parserObjectExtraRefCounts->add(this); +} + +void ParserRefCounted::deref() +{ + ASSERT(!m_globalData->newParserObjects || !m_globalData->newParserObjects->contains(this)); + + if (!m_globalData->parserObjectExtraRefCounts) { + delete this; + return; + } + + HashCountedSet::iterator it = m_globalData->parserObjectExtraRefCounts->find(this); + if (it == m_globalData->parserObjectExtraRefCounts->end()) + delete this; + else + m_globalData->parserObjectExtraRefCounts->remove(it); +} + +bool ParserRefCounted::hasOneRef() +{ + if (m_globalData->newParserObjects && m_globalData->newParserObjects->contains(this)) { + ASSERT(!m_globalData->parserObjectExtraRefCounts || !m_globalData->parserObjectExtraRefCounts->contains(this)); + return false; + } + + ASSERT(!m_globalData->newParserObjects || !m_globalData->newParserObjects->contains(this)); + + if (!m_globalData->parserObjectExtraRefCounts) + return true; + + return !m_globalData->parserObjectExtraRefCounts->contains(this); +} + +void ParserRefCounted::deleteNewObjects(JSGlobalData* globalData) +{ + if (!globalData->newParserObjects) + return; + +#ifndef NDEBUG + HashSet::iterator end = globalData->newParserObjects->end(); + for (HashSet::iterator it = globalData->newParserObjects->begin(); it != end; ++it) + ASSERT(!globalData->parserObjectExtraRefCounts || !globalData->parserObjectExtraRefCounts->contains(*it)); +#endif + deleteAllValues(*globalData->newParserObjects); + delete globalData->newParserObjects; + globalData->newParserObjects = 0; +} + +// ------------------------------ Node -------------------------------- + +Node::Node(JSGlobalData* globalData) + : ParserRefCounted(globalData) +{ + m_line = globalData->lexer->lineNo(); +} + +// ------------------------------ ThrowableExpressionData -------------------------------- + +static void substitute(UString& string, const UString& substring) +{ + int position = string.find("%s"); + ASSERT(position != -1); + UString newString = string.substr(0, position); + newString.append(substring); + newString.append(string.substr(position + 2)); + string = newString; +} + +RegisterID* ThrowableExpressionData::emitThrowError(BytecodeGenerator& generator, ErrorType e, const char* msg) +{ + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + RegisterID* exception = generator.emitNewError(generator.newTemporary(), e, jsString(generator.globalData(), msg)); + generator.emitThrow(exception); + return exception; +} + +RegisterID* ThrowableExpressionData::emitThrowError(BytecodeGenerator& generator, ErrorType e, const char* msg, const Identifier& label) +{ + UString message = msg; + substitute(message, label.ustring()); + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + RegisterID* exception = generator.emitNewError(generator.newTemporary(), e, jsString(generator.globalData(), message)); + generator.emitThrow(exception); + return exception; +} + +// ------------------------------ StatementNode -------------------------------- + +StatementNode::StatementNode(JSGlobalData* globalData) + : Node(globalData) + , m_lastLine(-1) +{ +} + +void StatementNode::setLoc(int firstLine, int lastLine) +{ + m_line = firstLine; + m_lastLine = lastLine; +} + +// ------------------------------ SourceElements -------------------------------- + +void SourceElements::append(PassRefPtr statement) +{ + if (statement->isEmptyStatement()) + return; + + m_statements.append(statement); +} + +// ------------------------------ NullNode ------------------------------------- + +RegisterID* NullNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (dst == generator.ignoredResult()) + return 0; + return generator.emitLoad(dst, jsNull()); +} + +// ------------------------------ BooleanNode ---------------------------------- + +RegisterID* BooleanNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (dst == generator.ignoredResult()) + return 0; + return generator.emitLoad(dst, m_value); +} + +// ------------------------------ NumberNode ----------------------------------- + +RegisterID* NumberNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (dst == generator.ignoredResult()) + return 0; + return generator.emitLoad(dst, m_double); +} + +// ------------------------------ StringNode ----------------------------------- + +RegisterID* StringNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (dst == generator.ignoredResult()) + return 0; + return generator.emitLoad(dst, m_value); +} + +// ------------------------------ RegExpNode ----------------------------------- + +RegisterID* RegExpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr regExp = RegExp::create(generator.globalData(), m_pattern, m_flags); + if (!regExp->isValid()) + return emitThrowError(generator, SyntaxError, ("Invalid regular expression: " + UString(regExp->errorMessage())).UTF8String().c_str()); + if (dst == generator.ignoredResult()) + return 0; + return generator.emitNewRegExp(generator.finalDestination(dst), regExp.get()); +} + +// ------------------------------ ThisNode ------------------------------------- + +RegisterID* ThisNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (dst == generator.ignoredResult()) + return 0; + return generator.moveToDestinationIfNeeded(dst, generator.thisRegister()); +} + +// ------------------------------ ResolveNode ---------------------------------- + +bool ResolveNode::isPure(BytecodeGenerator& generator) const +{ + return generator.isLocal(m_ident); +} + +RegisterID* ResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (RegisterID* local = generator.registerFor(m_ident)) { + if (dst == generator.ignoredResult()) + return 0; + return generator.moveToDestinationIfNeeded(dst, local); + } + + generator.emitExpressionInfo(m_startOffset + m_ident.size(), m_ident.size(), 0); + return generator.emitResolve(generator.finalDestination(dst), m_ident); +} + +// ------------------------------ ElementNode ------------------------------------ + +ElementNode::~ElementNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void ElementNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_next); + releaser.release(m_node); +} + +// ------------------------------ ArrayNode ------------------------------------ + +ArrayNode::~ArrayNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void ArrayNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_element); +} + +RegisterID* ArrayNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + // FIXME: Should we put all of this code into emitNewArray? + + unsigned length = 0; + ElementNode* firstPutElement; + for (firstPutElement = m_element.get(); firstPutElement; firstPutElement = firstPutElement->next()) { + if (firstPutElement->elision()) + break; + ++length; + } + + if (!firstPutElement && !m_elision) + return generator.emitNewArray(generator.finalDestination(dst), m_element.get()); + + RefPtr array = generator.emitNewArray(generator.tempDestination(dst), m_element.get()); + + for (ElementNode* n = firstPutElement; n; n = n->next()) { + RegisterID* value = generator.emitNode(n->value()); + length += n->elision(); + generator.emitPutByIndex(array.get(), length++, value); + } + + if (m_elision) { + RegisterID* value = generator.emitLoad(0, jsNumber(generator.globalData(), m_elision + length)); + generator.emitPutById(array.get(), generator.propertyNames().length, value); + } + + return generator.moveToDestinationIfNeeded(dst, array.get()); +} + +// ------------------------------ PropertyNode ---------------------------- + +PropertyNode::~PropertyNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void PropertyNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_assign); +} + +// ------------------------------ ObjectLiteralNode ---------------------------- + +ObjectLiteralNode::~ObjectLiteralNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void ObjectLiteralNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_list); +} + +RegisterID* ObjectLiteralNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (!m_list) { + if (dst == generator.ignoredResult()) + return 0; + return generator.emitNewObject(generator.finalDestination(dst)); + } + return generator.emitNode(dst, m_list.get()); +} + +// ------------------------------ PropertyListNode ----------------------------- + +PropertyListNode::~PropertyListNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void PropertyListNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_node); + releaser.release(m_next); +} + +RegisterID* PropertyListNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr newObj = generator.tempDestination(dst); + + generator.emitNewObject(newObj.get()); + + for (PropertyListNode* p = this; p; p = p->m_next.get()) { + RegisterID* value = generator.emitNode(p->m_node->m_assign.get()); + + switch (p->m_node->m_type) { + case PropertyNode::Constant: { + generator.emitPutById(newObj.get(), p->m_node->name(), value); + break; + } + case PropertyNode::Getter: { + generator.emitPutGetter(newObj.get(), p->m_node->name(), value); + break; + } + case PropertyNode::Setter: { + generator.emitPutSetter(newObj.get(), p->m_node->name(), value); + break; + } + default: + ASSERT_NOT_REACHED(); + } + } + + return generator.moveToDestinationIfNeeded(dst, newObj.get()); +} + +// ------------------------------ BracketAccessorNode -------------------------------- + +BracketAccessorNode::~BracketAccessorNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void BracketAccessorNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_base); + releaser.release(m_subscript); +} + +RegisterID* BracketAccessorNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr base = generator.emitNodeForLeftHandSide(m_base.get(), m_subscriptHasAssignments, m_subscript->isPure(generator)); + RegisterID* property = generator.emitNode(m_subscript.get()); + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + return generator.emitGetByVal(generator.finalDestination(dst), base.get(), property); +} + +// ------------------------------ DotAccessorNode -------------------------------- + +DotAccessorNode::~DotAccessorNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void DotAccessorNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_base); +} + +RegisterID* DotAccessorNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RegisterID* base = generator.emitNode(m_base.get()); + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + return generator.emitGetById(generator.finalDestination(dst), base, m_ident); +} + +// ------------------------------ ArgumentListNode ----------------------------- + +ArgumentListNode::~ArgumentListNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void ArgumentListNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_next); + releaser.release(m_expr); +} + +RegisterID* ArgumentListNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + ASSERT(m_expr); + return generator.emitNode(dst, m_expr.get()); +} + +// ------------------------------ ArgumentsNode ----------------------------- + +ArgumentsNode::~ArgumentsNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void ArgumentsNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_listNode); +} + +// ------------------------------ NewExprNode ---------------------------------- + +NewExprNode::~NewExprNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void NewExprNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_expr); + releaser.release(m_args); +} + +RegisterID* NewExprNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr func = generator.emitNode(m_expr.get()); + return generator.emitConstruct(generator.finalDestination(dst), func.get(), m_args.get(), divot(), startOffset(), endOffset()); +} + +// ------------------------------ EvalFunctionCallNode ---------------------------------- + +EvalFunctionCallNode::~EvalFunctionCallNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void EvalFunctionCallNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_args); +} + +RegisterID* EvalFunctionCallNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr func = generator.tempDestination(dst); + RefPtr thisRegister = generator.newTemporary(); + generator.emitExpressionInfo(divot() - startOffset() + 4, 4, 0); + generator.emitResolveWithBase(thisRegister.get(), func.get(), generator.propertyNames().eval); + return generator.emitCallEval(generator.finalDestination(dst, func.get()), func.get(), thisRegister.get(), m_args.get(), divot(), startOffset(), endOffset()); +} + +// ------------------------------ FunctionCallValueNode ---------------------------------- + +FunctionCallValueNode::~FunctionCallValueNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void FunctionCallValueNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_expr); + releaser.release(m_args); +} + +RegisterID* FunctionCallValueNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr func = generator.emitNode(m_expr.get()); + RefPtr thisRegister = generator.emitLoad(generator.newTemporary(), jsNull()); + return generator.emitCall(generator.finalDestination(dst, func.get()), func.get(), thisRegister.get(), m_args.get(), divot(), startOffset(), endOffset()); +} + +// ------------------------------ FunctionCallResolveNode ---------------------------------- + +FunctionCallResolveNode::~FunctionCallResolveNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void FunctionCallResolveNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_args); +} + +RegisterID* FunctionCallResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (RefPtr local = generator.registerFor(m_ident)) { + RefPtr thisRegister = generator.emitLoad(generator.newTemporary(), jsNull()); + return generator.emitCall(generator.finalDestination(dst, thisRegister.get()), local.get(), thisRegister.get(), m_args.get(), divot(), startOffset(), endOffset()); + } + + int index = 0; + size_t depth = 0; + JSObject* globalObject = 0; + if (generator.findScopedProperty(m_ident, index, depth, false, globalObject) && index != missingSymbolMarker()) { + RefPtr func = generator.emitGetScopedVar(generator.newTemporary(), depth, index, globalObject); + RefPtr thisRegister = generator.emitLoad(generator.newTemporary(), jsNull()); + return generator.emitCall(generator.finalDestination(dst, func.get()), func.get(), thisRegister.get(), m_args.get(), divot(), startOffset(), endOffset()); + } + + RefPtr func = generator.tempDestination(dst); + RefPtr thisRegister = generator.newTemporary(); + int identifierStart = divot() - startOffset(); + generator.emitExpressionInfo(identifierStart + m_ident.size(), m_ident.size(), 0); + generator.emitResolveFunction(thisRegister.get(), func.get(), m_ident); + return generator.emitCall(generator.finalDestination(dst, func.get()), func.get(), thisRegister.get(), m_args.get(), divot(), startOffset(), endOffset()); +} + +// ------------------------------ FunctionCallBracketNode ---------------------------------- + +FunctionCallBracketNode::~FunctionCallBracketNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void FunctionCallBracketNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_base); + releaser.release(m_subscript); + releaser.release(m_args); +} + +RegisterID* FunctionCallBracketNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr base = generator.emitNode(m_base.get()); + RegisterID* property = generator.emitNode(m_subscript.get()); + generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset); + RefPtr function = generator.emitGetByVal(generator.tempDestination(dst), base.get(), property); + RefPtr thisRegister = generator.emitMove(generator.newTemporary(), base.get()); + return generator.emitCall(generator.finalDestination(dst, function.get()), function.get(), thisRegister.get(), m_args.get(), divot(), startOffset(), endOffset()); +} + +// ------------------------------ FunctionCallDotNode ---------------------------------- + +FunctionCallDotNode::~FunctionCallDotNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void FunctionCallDotNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_base); + releaser.release(m_args); +} + +RegisterID* FunctionCallDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr base = generator.emitNode(m_base.get()); + generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset); + RefPtr function = generator.emitGetById(generator.tempDestination(dst), base.get(), m_ident); + RefPtr thisRegister = generator.emitMove(generator.newTemporary(), base.get()); + return generator.emitCall(generator.finalDestination(dst, function.get()), function.get(), thisRegister.get(), m_args.get(), divot(), startOffset(), endOffset()); +} + +// ------------------------------ PostfixResolveNode ---------------------------------- + +static RegisterID* emitPreIncOrDec(BytecodeGenerator& generator, RegisterID* srcDst, Operator oper) +{ + return (oper == OpPlusPlus) ? generator.emitPreInc(srcDst) : generator.emitPreDec(srcDst); +} + +static RegisterID* emitPostIncOrDec(BytecodeGenerator& generator, RegisterID* dst, RegisterID* srcDst, Operator oper) +{ + return (oper == OpPlusPlus) ? generator.emitPostInc(dst, srcDst) : generator.emitPostDec(dst, srcDst); +} + +RegisterID* PostfixResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (RegisterID* local = generator.registerFor(m_ident)) { + if (generator.isLocalConstant(m_ident)) { + if (dst == generator.ignoredResult()) + return 0; + return generator.emitToJSNumber(generator.finalDestination(dst), local); + } + + if (dst == generator.ignoredResult()) + return emitPreIncOrDec(generator, local, m_operator); + return emitPostIncOrDec(generator, generator.finalDestination(dst), local, m_operator); + } + + int index = 0; + size_t depth = 0; + JSObject* globalObject = 0; + if (generator.findScopedProperty(m_ident, index, depth, true, globalObject) && index != missingSymbolMarker()) { + RefPtr value = generator.emitGetScopedVar(generator.newTemporary(), depth, index, globalObject); + RegisterID* oldValue; + if (dst == generator.ignoredResult()) { + oldValue = 0; + emitPreIncOrDec(generator, value.get(), m_operator); + } else { + oldValue = emitPostIncOrDec(generator, generator.finalDestination(dst), value.get(), m_operator); + } + generator.emitPutScopedVar(depth, index, value.get(), globalObject); + return oldValue; + } + + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + RefPtr value = generator.newTemporary(); + RefPtr base = generator.emitResolveWithBase(generator.newTemporary(), value.get(), m_ident); + RegisterID* oldValue; + if (dst == generator.ignoredResult()) { + oldValue = 0; + emitPreIncOrDec(generator, value.get(), m_operator); + } else { + oldValue = emitPostIncOrDec(generator, generator.finalDestination(dst), value.get(), m_operator); + } + generator.emitPutById(base.get(), m_ident, value.get()); + return oldValue; +} + +// ------------------------------ PostfixBracketNode ---------------------------------- + +PostfixBracketNode::~PostfixBracketNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void PostfixBracketNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_base); + releaser.release(m_subscript); +} + +RegisterID* PostfixBracketNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr base = generator.emitNode(m_base.get()); + RefPtr property = generator.emitNode(m_subscript.get()); + + generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset); + RefPtr value = generator.emitGetByVal(generator.newTemporary(), base.get(), property.get()); + RegisterID* oldValue; + if (dst == generator.ignoredResult()) { + oldValue = 0; + if (m_operator == OpPlusPlus) + generator.emitPreInc(value.get()); + else + generator.emitPreDec(value.get()); + } else { + oldValue = (m_operator == OpPlusPlus) ? generator.emitPostInc(generator.finalDestination(dst), value.get()) : generator.emitPostDec(generator.finalDestination(dst), value.get()); + } + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + generator.emitPutByVal(base.get(), property.get(), value.get()); + return oldValue; +} + +// ------------------------------ PostfixDotNode ---------------------------------- + +PostfixDotNode::~PostfixDotNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void PostfixDotNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_base); +} + +RegisterID* PostfixDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr base = generator.emitNode(m_base.get()); + + generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset); + RefPtr value = generator.emitGetById(generator.newTemporary(), base.get(), m_ident); + RegisterID* oldValue; + if (dst == generator.ignoredResult()) { + oldValue = 0; + if (m_operator == OpPlusPlus) + generator.emitPreInc(value.get()); + else + generator.emitPreDec(value.get()); + } else { + oldValue = (m_operator == OpPlusPlus) ? generator.emitPostInc(generator.finalDestination(dst), value.get()) : generator.emitPostDec(generator.finalDestination(dst), value.get()); + } + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + generator.emitPutById(base.get(), m_ident, value.get()); + return oldValue; +} + +// ------------------------------ PostfixErrorNode ----------------------------------- + +PostfixErrorNode::~PostfixErrorNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void PostfixErrorNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_expr); +} + +RegisterID* PostfixErrorNode::emitBytecode(BytecodeGenerator& generator, RegisterID*) +{ + return emitThrowError(generator, ReferenceError, m_operator == OpPlusPlus ? "Postfix ++ operator applied to value that is not a reference." : "Postfix -- operator applied to value that is not a reference."); +} + +// ------------------------------ DeleteResolveNode ----------------------------------- + +RegisterID* DeleteResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (generator.registerFor(m_ident)) + return generator.emitUnexpectedLoad(generator.finalDestination(dst), false); + + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + RegisterID* base = generator.emitResolveBase(generator.tempDestination(dst), m_ident); + return generator.emitDeleteById(generator.finalDestination(dst, base), base, m_ident); +} + +// ------------------------------ DeleteBracketNode ----------------------------------- + +DeleteBracketNode::~DeleteBracketNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void DeleteBracketNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_base); + releaser.release(m_subscript); +} + +RegisterID* DeleteBracketNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr r0 = generator.emitNode(m_base.get()); + RegisterID* r1 = generator.emitNode(m_subscript.get()); + + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + return generator.emitDeleteByVal(generator.finalDestination(dst), r0.get(), r1); +} + +// ------------------------------ DeleteDotNode ----------------------------------- + +DeleteDotNode::~DeleteDotNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void DeleteDotNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_base); +} + +RegisterID* DeleteDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RegisterID* r0 = generator.emitNode(m_base.get()); + + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + return generator.emitDeleteById(generator.finalDestination(dst), r0, m_ident); +} + +// ------------------------------ DeleteValueNode ----------------------------------- + +DeleteValueNode::~DeleteValueNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void DeleteValueNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_expr); +} + +RegisterID* DeleteValueNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + generator.emitNode(generator.ignoredResult(), m_expr.get()); + + // delete on a non-location expression ignores the value and returns true + return generator.emitUnexpectedLoad(generator.finalDestination(dst), true); +} + +// ------------------------------ VoidNode ------------------------------------- + +VoidNode::~VoidNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void VoidNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_expr); +} + +RegisterID* VoidNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (dst == generator.ignoredResult()) { + generator.emitNode(generator.ignoredResult(), m_expr.get()); + return 0; + } + RefPtr r0 = generator.emitNode(m_expr.get()); + return generator.emitLoad(dst, jsUndefined()); +} + +// ------------------------------ TypeOfValueNode ----------------------------------- + +RegisterID* TypeOfResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (RegisterID* local = generator.registerFor(m_ident)) { + if (dst == generator.ignoredResult()) + return 0; + return generator.emitTypeOf(generator.finalDestination(dst), local); + } + + RefPtr scratch = generator.emitResolveBase(generator.tempDestination(dst), m_ident); + generator.emitGetById(scratch.get(), scratch.get(), m_ident); + if (dst == generator.ignoredResult()) + return 0; + return generator.emitTypeOf(generator.finalDestination(dst, scratch.get()), scratch.get()); +} + +// ------------------------------ TypeOfValueNode ----------------------------------- + +TypeOfValueNode::~TypeOfValueNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void TypeOfValueNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_expr); +} + +RegisterID* TypeOfValueNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (dst == generator.ignoredResult()) { + generator.emitNode(generator.ignoredResult(), m_expr.get()); + return 0; + } + RefPtr src = generator.emitNode(m_expr.get()); + return generator.emitTypeOf(generator.finalDestination(dst), src.get()); +} + +// ------------------------------ PrefixResolveNode ---------------------------------- + +RegisterID* PrefixResolveNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (RegisterID* local = generator.registerFor(m_ident)) { + if (generator.isLocalConstant(m_ident)) { + if (dst == generator.ignoredResult()) + return 0; + RefPtr r0 = generator.emitUnexpectedLoad(generator.finalDestination(dst), (m_operator == OpPlusPlus) ? 1.0 : -1.0); + return generator.emitBinaryOp(op_add, r0.get(), local, r0.get(), OperandTypes()); + } + + emitPreIncOrDec(generator, local, m_operator); + return generator.moveToDestinationIfNeeded(dst, local); + } + + int index = 0; + size_t depth = 0; + JSObject* globalObject = 0; + if (generator.findScopedProperty(m_ident, index, depth, false, globalObject) && index != missingSymbolMarker()) { + RefPtr propDst = generator.emitGetScopedVar(generator.tempDestination(dst), depth, index, globalObject); + emitPreIncOrDec(generator, propDst.get(), m_operator); + generator.emitPutScopedVar(depth, index, propDst.get(), globalObject); + return generator.moveToDestinationIfNeeded(dst, propDst.get()); + } + + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + RefPtr propDst = generator.tempDestination(dst); + RefPtr base = generator.emitResolveWithBase(generator.newTemporary(), propDst.get(), m_ident); + emitPreIncOrDec(generator, propDst.get(), m_operator); + generator.emitPutById(base.get(), m_ident, propDst.get()); + return generator.moveToDestinationIfNeeded(dst, propDst.get()); +} + +// ------------------------------ PrefixBracketNode ---------------------------------- + +PrefixBracketNode::~PrefixBracketNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void PrefixBracketNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_base); + releaser.release(m_subscript); +} + +RegisterID* PrefixBracketNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr base = generator.emitNode(m_base.get()); + RefPtr property = generator.emitNode(m_subscript.get()); + RefPtr propDst = generator.tempDestination(dst); + + generator.emitExpressionInfo(divot() + m_subexpressionDivotOffset, m_subexpressionStartOffset, endOffset() - m_subexpressionDivotOffset); + RegisterID* value = generator.emitGetByVal(propDst.get(), base.get(), property.get()); + if (m_operator == OpPlusPlus) + generator.emitPreInc(value); + else + generator.emitPreDec(value); + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + generator.emitPutByVal(base.get(), property.get(), value); + return generator.moveToDestinationIfNeeded(dst, propDst.get()); +} + +// ------------------------------ PrefixDotNode ---------------------------------- + +PrefixDotNode::~PrefixDotNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void PrefixDotNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_base); +} + +RegisterID* PrefixDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr base = generator.emitNode(m_base.get()); + RefPtr propDst = generator.tempDestination(dst); + + generator.emitExpressionInfo(divot() + m_subexpressionDivotOffset, m_subexpressionStartOffset, endOffset() - m_subexpressionDivotOffset); + RegisterID* value = generator.emitGetById(propDst.get(), base.get(), m_ident); + if (m_operator == OpPlusPlus) + generator.emitPreInc(value); + else + generator.emitPreDec(value); + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + generator.emitPutById(base.get(), m_ident, value); + return generator.moveToDestinationIfNeeded(dst, propDst.get()); +} + +// ------------------------------ PrefixErrorNode ----------------------------------- + +PrefixErrorNode::~PrefixErrorNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void PrefixErrorNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_expr); +} + +RegisterID* PrefixErrorNode::emitBytecode(BytecodeGenerator& generator, RegisterID*) +{ + return emitThrowError(generator, ReferenceError, m_operator == OpPlusPlus ? "Prefix ++ operator applied to value that is not a reference." : "Prefix -- operator applied to value that is not a reference."); +} + +// ------------------------------ Unary Operation Nodes ----------------------------------- + +UnaryOpNode::~UnaryOpNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void UnaryOpNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_expr); +} + +RegisterID* UnaryOpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RegisterID* src = generator.emitNode(m_expr.get()); + return generator.emitUnaryOp(opcodeID(), generator.finalDestination(dst), src); +} + +// ------------------------------ Binary Operation Nodes ----------------------------------- + +BinaryOpNode::~BinaryOpNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void BinaryOpNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_expr1); + releaser.release(m_expr2); +} + +RegisterID* BinaryOpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + OpcodeID opcodeID = this->opcodeID(); + if (opcodeID == op_neq) { + if (m_expr1->isNull() || m_expr2->isNull()) { + RefPtr src = generator.tempDestination(dst); + generator.emitNode(src.get(), m_expr1->isNull() ? m_expr2.get() : m_expr1.get()); + return generator.emitUnaryOp(op_neq_null, generator.finalDestination(dst, src.get()), src.get()); + } + } + + RefPtr src1 = generator.emitNodeForLeftHandSide(m_expr1.get(), m_rightHasAssignments, m_expr2->isPure(generator)); + RegisterID* src2 = generator.emitNode(m_expr2.get()); + return generator.emitBinaryOp(opcodeID, generator.finalDestination(dst, src1.get()), src1.get(), src2, OperandTypes(m_expr1->resultDescriptor(), m_expr2->resultDescriptor())); +} + +RegisterID* EqualNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + if (m_expr1->isNull() || m_expr2->isNull()) { + RefPtr src = generator.tempDestination(dst); + generator.emitNode(src.get(), m_expr1->isNull() ? m_expr2.get() : m_expr1.get()); + return generator.emitUnaryOp(op_eq_null, generator.finalDestination(dst, src.get()), src.get()); + } + + RefPtr src1 = generator.emitNodeForLeftHandSide(m_expr1.get(), m_rightHasAssignments, m_expr2->isPure(generator)); + RegisterID* src2 = generator.emitNode(m_expr2.get()); + return generator.emitEqualityOp(op_eq, generator.finalDestination(dst, src1.get()), src1.get(), src2); +} + +RegisterID* StrictEqualNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr src1 = generator.emitNodeForLeftHandSide(m_expr1.get(), m_rightHasAssignments, m_expr2->isPure(generator)); + RegisterID* src2 = generator.emitNode(m_expr2.get()); + return generator.emitEqualityOp(op_stricteq, generator.finalDestination(dst, src1.get()), src1.get(), src2); +} + +RegisterID* ReverseBinaryOpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr src1 = generator.emitNodeForLeftHandSide(m_expr1.get(), m_rightHasAssignments, m_expr2->isPure(generator)); + RegisterID* src2 = generator.emitNode(m_expr2.get()); + return generator.emitBinaryOp(opcodeID(), generator.finalDestination(dst, src1.get()), src2, src1.get(), OperandTypes(m_expr2->resultDescriptor(), m_expr1->resultDescriptor())); +} + +RegisterID* ThrowableBinaryOpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr src1 = generator.emitNodeForLeftHandSide(m_expr1.get(), m_rightHasAssignments, m_expr2->isPure(generator)); + RegisterID* src2 = generator.emitNode(m_expr2.get()); + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + return generator.emitBinaryOp(opcodeID(), generator.finalDestination(dst, src1.get()), src1.get(), src2, OperandTypes(m_expr1->resultDescriptor(), m_expr2->resultDescriptor())); +} + +RegisterID* InstanceOfNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr src1 = generator.emitNodeForLeftHandSide(m_expr1.get(), m_rightHasAssignments, m_expr2->isPure(generator)); + RefPtr src2 = generator.emitNode(m_expr2.get()); + + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + generator.emitGetByIdExceptionInfo(op_instanceof); + RegisterID* src2Prototype = generator.emitGetById(generator.newTemporary(), src2.get(), generator.globalData()->propertyNames->prototype); + + generator.emitExpressionInfo(divot(), startOffset(), endOffset()); + return generator.emitInstanceOf(generator.finalDestination(dst, src1.get()), src1.get(), src2.get(), src2Prototype); +} + +// ------------------------------ LogicalOpNode ---------------------------- + +LogicalOpNode::~LogicalOpNode() +{ + NodeReleaser::releaseAllNodes(this); +} + +void LogicalOpNode::releaseNodes(NodeReleaser& releaser) +{ + releaser.release(m_expr1); + releaser.release(m_expr2); +} + +RegisterID* LogicalOpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) +{ + RefPtr temp = generator.tempDestination(dst); + RefPtr