barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | #include "DFGOperations.h" |
| 28 | |
| 29 | #if ENABLE(DFG_JIT) |
| 30 | |
| 31 | #include "CodeBlock.h" |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 32 | #include "DFGRepatch.h" |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 33 | #include "Interpreter.h" |
| 34 | #include "JSByteArray.h" |
| 35 | #include "JSGlobalData.h" |
| 36 | #include "Operations.h" |
| 37 | |
barraclough@apple.com | 2decbec | 2011-09-28 01:09:33 +0000 | [diff] [blame] | 38 | |
| 39 | #if OS(DARWIN) || (OS(WINDOWS) && CPU(X86)) |
| 40 | #define SYMBOL_STRING(name) "_" #name |
| 41 | #else |
| 42 | #define SYMBOL_STRING(name) #name |
| 43 | #endif |
| 44 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 45 | #if CPU(X86_64) |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 46 | #define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, register) \ |
| 47 | asm( \ |
barraclough@apple.com | 2decbec | 2011-09-28 01:09:33 +0000 | [diff] [blame] | 48 | ".globl " SYMBOL_STRING(function) "\n" \ |
| 49 | SYMBOL_STRING(function) ":" "\n" \ |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 50 | "mov (%rsp), %" STRINGIZE(register) "\n" \ |
barraclough@apple.com | 2decbec | 2011-09-28 01:09:33 +0000 | [diff] [blame] | 51 | "jmp " SYMBOL_STRING(function) "WithReturnAddress" "\n" \ |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 52 | ); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 53 | #elif CPU(X86) |
| 54 | #define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, register) \ |
| 55 | asm( \ |
barraclough@apple.com | 2decbec | 2011-09-28 01:09:33 +0000 | [diff] [blame] | 56 | ".globl " SYMBOL_STRING(function) "\n" \ |
| 57 | SYMBOL_STRING(function) ":" "\n" \ |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 58 | "push (%esp)\n" \ |
barraclough@apple.com | 2decbec | 2011-09-28 01:09:33 +0000 | [diff] [blame] | 59 | "jmp " SYMBOL_STRING(function) "WithReturnAddress" "\n" \ |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 60 | ); |
| 61 | #endif |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 62 | #define FUNCTION_WRAPPER_WITH_ARG2_RETURN_ADDRESS(function) FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, rsi) |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 63 | #define FUNCTION_WRAPPER_WITH_ARG4_RETURN_ADDRESS(function) FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, rcx) |
commit-queue@webkit.org | 0df040e | 2011-06-27 21:38:09 +0000 | [diff] [blame] | 64 | #define FUNCTION_WRAPPER_WITH_ARG5_RETURN_ADDRESS(function) FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, r8) |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 65 | |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 66 | namespace JSC { namespace DFG { |
| 67 | |
weinig@apple.com | a96509f | 2011-06-15 21:57:17 +0000 | [diff] [blame] | 68 | static inline void putByVal(ExecState* exec, JSValue baseValue, uint32_t index, JSValue value) |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 69 | { |
| 70 | JSGlobalData* globalData = &exec->globalData(); |
| 71 | |
weinig@apple.com | a96509f | 2011-06-15 21:57:17 +0000 | [diff] [blame] | 72 | if (isJSArray(globalData, baseValue)) { |
| 73 | JSArray* array = asArray(baseValue); |
| 74 | if (array->canSetIndex(index)) { |
| 75 | array->setIndex(*globalData, index, value); |
| 76 | return; |
| 77 | } |
| 78 | |
| 79 | array->JSArray::put(exec, index, value); |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(index)) { |
| 84 | JSByteArray* byteArray = asByteArray(baseValue); |
| 85 | // FIXME: the JITstub used to relink this to an optimized form! |
| 86 | if (value.isInt32()) { |
| 87 | byteArray->setIndex(index, value.asInt32()); |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | double dValue = 0; |
| 92 | if (value.getNumber(dValue)) { |
| 93 | byteArray->setIndex(index, dValue); |
| 94 | return; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | baseValue.put(exec, index, value); |
| 99 | } |
| 100 | |
| 101 | template<bool strict> |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 102 | ALWAYS_INLINE static void DFG_OPERATION operationPutByValInternal(ExecState* exec, EncodedJSValue encodedBase, EncodedJSValue encodedProperty, EncodedJSValue encodedValue) |
weinig@apple.com | a96509f | 2011-06-15 21:57:17 +0000 | [diff] [blame] | 103 | { |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 104 | JSValue baseValue = JSValue::decode(encodedBase); |
| 105 | JSValue property = JSValue::decode(encodedProperty); |
| 106 | JSValue value = JSValue::decode(encodedValue); |
| 107 | |
| 108 | if (LIKELY(property.isUInt32())) { |
weinig@apple.com | a96509f | 2011-06-15 21:57:17 +0000 | [diff] [blame] | 109 | putByVal(exec, baseValue, property.asUInt32(), value); |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 110 | return; |
| 111 | } |
| 112 | |
weinig@apple.com | a96509f | 2011-06-15 21:57:17 +0000 | [diff] [blame] | 113 | if (property.isDouble()) { |
| 114 | double propertyAsDouble = property.asDouble(); |
| 115 | uint32_t propertyAsUInt32 = static_cast<uint32_t>(propertyAsDouble); |
| 116 | if (propertyAsDouble == propertyAsUInt32) { |
| 117 | putByVal(exec, baseValue, propertyAsUInt32, value); |
| 118 | return; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | JSGlobalData* globalData = &exec->globalData(); |
| 123 | |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 124 | // Don't put to an object if toString throws an exception. |
| 125 | Identifier ident(exec, property.toString(exec)); |
| 126 | if (!globalData->exception) { |
| 127 | PutPropertySlot slot(strict); |
| 128 | baseValue.put(exec, ident, value, slot); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | extern "C" { |
| 133 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 134 | EncodedJSValue DFG_OPERATION operationConvertThis(ExecState* exec, EncodedJSValue encodedOp) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 135 | { |
barraclough@apple.com | d997684 | 2011-03-17 23:11:47 +0000 | [diff] [blame] | 136 | return JSValue::encode(JSValue::decode(encodedOp).toThisObject(exec)); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 137 | } |
| 138 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 139 | EncodedJSValue DFG_OPERATION operationCreateThis(ExecState* exec, EncodedJSValue encodedOp) |
fpizlo@apple.com | bb159ec | 2011-09-21 22:17:06 +0000 | [diff] [blame] | 140 | { |
| 141 | JSFunction* constructor = asFunction(exec->callee()); |
| 142 | |
| 143 | #if !ASSERT_DISABLED |
| 144 | ConstructData constructData; |
| 145 | ASSERT(constructor->getConstructData(constructData) == ConstructTypeJS); |
| 146 | #endif |
| 147 | |
| 148 | JSGlobalData& globalData = exec->globalData(); |
| 149 | |
| 150 | Structure* structure; |
| 151 | JSValue proto = JSValue::decode(encodedOp); |
| 152 | if (proto.isObject()) |
| 153 | structure = asObject(proto)->inheritorID(globalData); |
| 154 | else |
| 155 | structure = constructor->scope()->globalObject->emptyObjectStructure(); |
| 156 | |
| 157 | return JSValue::encode(constructEmptyObject(exec, structure)); |
| 158 | } |
| 159 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 160 | EncodedJSValue DFG_OPERATION operationNewObject(ExecState* exec) |
fpizlo@apple.com | 98a693c | 2011-09-28 05:33:21 +0000 | [diff] [blame] | 161 | { |
| 162 | return JSValue::encode(constructEmptyObject(exec)); |
| 163 | } |
| 164 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 165 | EncodedJSValue DFG_OPERATION operationValueAdd(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 166 | { |
| 167 | JSValue op1 = JSValue::decode(encodedOp1); |
| 168 | JSValue op2 = JSValue::decode(encodedOp2); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 169 | |
fpizlo@apple.com | 5c90704 | 2011-09-15 01:24:39 +0000 | [diff] [blame] | 170 | return JSValue::encode(jsAdd(exec, op1, op2)); |
| 171 | } |
| 172 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 173 | EncodedJSValue DFG_OPERATION operationValueAddNotNumber(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
fpizlo@apple.com | 5c90704 | 2011-09-15 01:24:39 +0000 | [diff] [blame] | 174 | { |
| 175 | JSValue op1 = JSValue::decode(encodedOp1); |
| 176 | JSValue op2 = JSValue::decode(encodedOp2); |
| 177 | |
fpizlo@apple.com | 5df0cd8 | 2011-08-19 00:18:49 +0000 | [diff] [blame] | 178 | ASSERT(!op1.isNumber() || !op2.isNumber()); |
fpizlo@apple.com | 5c90704 | 2011-09-15 01:24:39 +0000 | [diff] [blame] | 179 | |
| 180 | if (op1.isString()) { |
| 181 | if (op2.isString()) |
| 182 | return JSValue::encode(jsString(exec, asString(op1), asString(op2))); |
| 183 | return JSValue::encode(jsString(exec, asString(op1), op2.toPrimitiveString(exec))); |
| 184 | } |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 185 | |
| 186 | return JSValue::encode(jsAddSlowCase(exec, op1, op2)); |
| 187 | } |
| 188 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 189 | EncodedJSValue DFG_OPERATION operationArithAdd(EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
commit-queue@webkit.org | b873a81 | 2011-06-26 19:30:56 +0000 | [diff] [blame] | 190 | { |
| 191 | double num1 = JSValue::decode(encodedOp1).uncheckedGetNumber(); |
| 192 | double num2 = JSValue::decode(encodedOp2).uncheckedGetNumber(); |
| 193 | return JSValue::encode(jsNumber(num1 + num2)); |
| 194 | } |
| 195 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 196 | EncodedJSValue DFG_OPERATION operationArithSub(EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
commit-queue@webkit.org | b873a81 | 2011-06-26 19:30:56 +0000 | [diff] [blame] | 197 | { |
| 198 | double num1 = JSValue::decode(encodedOp1).uncheckedGetNumber(); |
| 199 | double num2 = JSValue::decode(encodedOp2).uncheckedGetNumber(); |
| 200 | return JSValue::encode(jsNumber(num1 - num2)); |
| 201 | } |
| 202 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 203 | EncodedJSValue DFG_OPERATION operationArithMul(EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
commit-queue@webkit.org | b873a81 | 2011-06-26 19:30:56 +0000 | [diff] [blame] | 204 | { |
| 205 | double num1 = JSValue::decode(encodedOp1).uncheckedGetNumber(); |
| 206 | double num2 = JSValue::decode(encodedOp2).uncheckedGetNumber(); |
| 207 | return JSValue::encode(jsNumber(num1 * num2)); |
| 208 | } |
| 209 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 210 | EncodedJSValue DFG_OPERATION operationArithDiv(EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
commit-queue@webkit.org | b873a81 | 2011-06-26 19:30:56 +0000 | [diff] [blame] | 211 | { |
| 212 | double num1 = JSValue::decode(encodedOp1).uncheckedGetNumber(); |
| 213 | double num2 = JSValue::decode(encodedOp2).uncheckedGetNumber(); |
| 214 | return JSValue::encode(jsNumber(num1 / num2)); |
| 215 | } |
| 216 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 217 | EncodedJSValue DFG_OPERATION operationArithMod(EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
commit-queue@webkit.org | b873a81 | 2011-06-26 19:30:56 +0000 | [diff] [blame] | 218 | { |
| 219 | double num1 = JSValue::decode(encodedOp1).uncheckedGetNumber(); |
| 220 | double num2 = JSValue::decode(encodedOp2).uncheckedGetNumber(); |
| 221 | return JSValue::encode(jsNumber(fmod(num1, num2))); |
| 222 | } |
| 223 | |
weinig@apple.com | a96509f | 2011-06-15 21:57:17 +0000 | [diff] [blame] | 224 | static inline EncodedJSValue getByVal(ExecState* exec, JSCell* base, uint32_t index) |
| 225 | { |
| 226 | JSGlobalData* globalData = &exec->globalData(); |
| 227 | |
| 228 | // FIXME: the JIT used to handle these in compiled code! |
| 229 | if (isJSArray(globalData, base) && asArray(base)->canGetIndex(index)) |
| 230 | return JSValue::encode(asArray(base)->getIndex(index)); |
| 231 | |
| 232 | // FIXME: the JITstub used to relink this to an optimized form! |
| 233 | if (isJSString(globalData, base) && asString(base)->canGetIndex(index)) |
| 234 | return JSValue::encode(asString(base)->getIndex(exec, index)); |
| 235 | |
| 236 | // FIXME: the JITstub used to relink this to an optimized form! |
| 237 | if (isJSByteArray(globalData, base) && asByteArray(base)->canAccessIndex(index)) |
| 238 | return JSValue::encode(asByteArray(base)->getIndex(exec, index)); |
| 239 | |
| 240 | return JSValue::encode(JSValue(base).get(exec, index)); |
| 241 | } |
| 242 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 243 | EncodedJSValue DFG_OPERATION operationGetByVal(ExecState* exec, EncodedJSValue encodedBase, EncodedJSValue encodedProperty) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 244 | { |
| 245 | JSValue baseValue = JSValue::decode(encodedBase); |
| 246 | JSValue property = JSValue::decode(encodedProperty); |
| 247 | |
| 248 | if (LIKELY(baseValue.isCell())) { |
| 249 | JSCell* base = baseValue.asCell(); |
| 250 | |
| 251 | if (property.isUInt32()) { |
weinig@apple.com | a96509f | 2011-06-15 21:57:17 +0000 | [diff] [blame] | 252 | return getByVal(exec, base, property.asUInt32()); |
| 253 | } else if (property.isDouble()) { |
| 254 | double propertyAsDouble = property.asDouble(); |
| 255 | uint32_t propertyAsUInt32 = static_cast<uint32_t>(propertyAsDouble); |
| 256 | if (propertyAsUInt32 == propertyAsDouble) |
| 257 | return getByVal(exec, base, propertyAsUInt32); |
| 258 | } else if (property.isString()) { |
barraclough@apple.com | 5d959c7 | 2011-08-07 03:44:45 +0000 | [diff] [blame] | 259 | if (JSValue result = base->fastGetOwnProperty(exec, asString(property)->value(exec))) |
| 260 | return JSValue::encode(result); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 261 | } |
| 262 | } |
| 263 | |
| 264 | Identifier ident(exec, property.toString(exec)); |
| 265 | return JSValue::encode(baseValue.get(exec, ident)); |
| 266 | } |
| 267 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 268 | EncodedJSValue DFG_OPERATION operationGetById(ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 269 | { |
| 270 | JSValue baseValue = JSValue::decode(encodedBase); |
| 271 | PropertySlot slot(baseValue); |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 272 | return JSValue::encode(baseValue.get(exec, *propertyName, slot)); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 273 | } |
| 274 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 275 | #if CPU(X86_64) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 276 | EncodedJSValue DFG_OPERATION operationGetMethodOptimizeWithReturnAddress(ExecState*, EncodedJSValue, Identifier*, ReturnAddressPtr); |
commit-queue@webkit.org | c0f5cb0 | 2011-07-07 03:42:02 +0000 | [diff] [blame] | 277 | FUNCTION_WRAPPER_WITH_ARG4_RETURN_ADDRESS(operationGetMethodOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 278 | EncodedJSValue DFG_OPERATION operationGetMethodOptimizeWithReturnAddress(ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName, ReturnAddressPtr returnAddress) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 279 | #elif CPU(X86) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 280 | EncodedJSValue DFG_OPERATION operationGetMethodOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 281 | FUNCTION_WRAPPER_WITH_ARG4_RETURN_ADDRESS(operationGetMethodOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 282 | EncodedJSValue DFG_OPERATION operationGetMethodOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 283 | #endif |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 284 | { |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 285 | JSValue baseValue = JSValue::decode(encodedBase); |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 286 | PropertySlot slot(baseValue); |
| 287 | JSValue result = baseValue.get(exec, *propertyName, slot); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 288 | |
commit-queue@webkit.org | c0f5cb0 | 2011-07-07 03:42:02 +0000 | [diff] [blame] | 289 | MethodCallLinkInfo& methodInfo = exec->codeBlock()->getMethodCallLinkInfo(returnAddress); |
| 290 | if (methodInfo.seenOnce()) |
| 291 | dfgRepatchGetMethod(exec, baseValue, *propertyName, slot, methodInfo); |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 292 | else |
commit-queue@webkit.org | c0f5cb0 | 2011-07-07 03:42:02 +0000 | [diff] [blame] | 293 | methodInfo.setSeen(); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 294 | |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 295 | return JSValue::encode(result); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 296 | } |
| 297 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 298 | #if CPU(X86_64) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 299 | EncodedJSValue DFG_OPERATION operationGetByIdBuildListWithReturnAddress(ExecState*, EncodedJSValue, Identifier*, ReturnAddressPtr); |
commit-queue@webkit.org | e3cb779 | 2011-06-29 19:46:28 +0000 | [diff] [blame] | 300 | FUNCTION_WRAPPER_WITH_ARG4_RETURN_ADDRESS(operationGetByIdBuildList); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 301 | EncodedJSValue DFG_OPERATION operationGetByIdBuildListWithReturnAddress(ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName, ReturnAddressPtr returnAddress) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 302 | #elif CPU(X86) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 303 | EncodedJSValue DFG_OPERATION operationGetByIdBuildListWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 304 | FUNCTION_WRAPPER_WITH_ARG4_RETURN_ADDRESS(operationGetByIdBuildList); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 305 | EncodedJSValue DFG_OPERATION operationGetByIdBuildListWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 306 | #endif |
commit-queue@webkit.org | e3cb779 | 2011-06-29 19:46:28 +0000 | [diff] [blame] | 307 | { |
| 308 | JSValue baseValue = JSValue::decode(encodedBase); |
| 309 | PropertySlot slot(baseValue); |
| 310 | JSValue result = baseValue.get(exec, *propertyName, slot); |
| 311 | |
| 312 | StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress); |
| 313 | dfgBuildGetByIDList(exec, baseValue, *propertyName, slot, stubInfo); |
| 314 | |
| 315 | return JSValue::encode(result); |
| 316 | } |
| 317 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 318 | #if CPU(X86_64) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 319 | EncodedJSValue DFG_OPERATION operationGetByIdProtoBuildListWithReturnAddress(ExecState*, EncodedJSValue, Identifier*, ReturnAddressPtr); |
commit-queue@webkit.org | 5f59575 | 2011-07-13 21:44:42 +0000 | [diff] [blame] | 320 | FUNCTION_WRAPPER_WITH_ARG4_RETURN_ADDRESS(operationGetByIdProtoBuildList); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 321 | EncodedJSValue DFG_OPERATION operationGetByIdProtoBuildListWithReturnAddress(ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName, ReturnAddressPtr returnAddress) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 322 | #elif CPU(X86) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 323 | EncodedJSValue DFG_OPERATION operationGetByIdProtoBuildListWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 324 | FUNCTION_WRAPPER_WITH_ARG4_RETURN_ADDRESS(operationGetByIdProtoBuildList); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 325 | EncodedJSValue DFG_OPERATION operationGetByIdProtoBuildListWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 326 | #endif |
commit-queue@webkit.org | 5f59575 | 2011-07-13 21:44:42 +0000 | [diff] [blame] | 327 | { |
| 328 | JSValue baseValue = JSValue::decode(encodedBase); |
| 329 | PropertySlot slot(baseValue); |
| 330 | JSValue result = baseValue.get(exec, *propertyName, slot); |
| 331 | |
| 332 | StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress); |
| 333 | dfgBuildGetByIDProtoList(exec, baseValue, *propertyName, slot, stubInfo); |
| 334 | |
| 335 | return JSValue::encode(result); |
| 336 | } |
| 337 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 338 | #if CPU(X86_64) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 339 | EncodedJSValue DFG_OPERATION operationGetByIdOptimizeWithReturnAddress(ExecState*, EncodedJSValue, Identifier*, ReturnAddressPtr); |
commit-queue@webkit.org | c0f5cb0 | 2011-07-07 03:42:02 +0000 | [diff] [blame] | 340 | FUNCTION_WRAPPER_WITH_ARG4_RETURN_ADDRESS(operationGetByIdOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 341 | EncodedJSValue DFG_OPERATION operationGetByIdOptimizeWithReturnAddress(ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName, ReturnAddressPtr returnAddress) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 342 | #elif CPU(X86) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 343 | EncodedJSValue DFG_OPERATION operationGetByIdOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 344 | FUNCTION_WRAPPER_WITH_ARG4_RETURN_ADDRESS(operationGetByIdOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 345 | EncodedJSValue DFG_OPERATION operationGetByIdOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 346 | #endif |
commit-queue@webkit.org | c0f5cb0 | 2011-07-07 03:42:02 +0000 | [diff] [blame] | 347 | { |
| 348 | JSValue baseValue = JSValue::decode(encodedBase); |
| 349 | PropertySlot slot(baseValue); |
| 350 | JSValue result = baseValue.get(exec, *propertyName, slot); |
| 351 | |
| 352 | StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress); |
| 353 | if (stubInfo.seen) |
| 354 | dfgRepatchGetByID(exec, baseValue, *propertyName, slot, stubInfo); |
| 355 | else |
| 356 | stubInfo.seen = true; |
| 357 | |
| 358 | return JSValue::encode(result); |
| 359 | } |
| 360 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 361 | void DFG_OPERATION operationPutByValStrict(ExecState* exec, EncodedJSValue encodedBase, EncodedJSValue encodedProperty, EncodedJSValue encodedValue) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 362 | { |
| 363 | operationPutByValInternal<true>(exec, encodedBase, encodedProperty, encodedValue); |
| 364 | } |
| 365 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 366 | void DFG_OPERATION operationPutByValNonStrict(ExecState* exec, EncodedJSValue encodedBase, EncodedJSValue encodedProperty, EncodedJSValue encodedValue) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 367 | { |
| 368 | operationPutByValInternal<false>(exec, encodedBase, encodedProperty, encodedValue); |
| 369 | } |
| 370 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 371 | void DFG_OPERATION operationPutByValBeyondArrayBounds(ExecState* exec, JSArray* array, int32_t index, EncodedJSValue encodedValue) |
barraclough@apple.com | e2130ff | 2011-06-07 23:03:32 +0000 | [diff] [blame] | 372 | { |
| 373 | // We should only get here if index is outside the existing vector. |
| 374 | ASSERT(!array->canSetIndex(index)); |
| 375 | array->JSArray::put(exec, index, JSValue::decode(encodedValue)); |
| 376 | } |
| 377 | |
fpizlo@apple.com | 24d24e5 | 2011-10-04 02:55:54 +0000 | [diff] [blame^] | 378 | EncodedJSValue DFG_OPERATION operationArrayPush(ExecState* exec, JSArray* array, EncodedJSValue encodedValue) |
| 379 | { |
| 380 | array->push(exec, JSValue::decode(encodedValue)); |
| 381 | return JSValue::encode(jsNumber(array->length())); |
| 382 | } |
| 383 | |
| 384 | EncodedJSValue DFG_OPERATION operationArrayPop(ExecState*, JSArray* array) |
| 385 | { |
| 386 | return JSValue::encode(array->pop()); |
| 387 | } |
| 388 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 389 | void DFG_OPERATION operationPutByIdStrict(ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 390 | { |
| 391 | PutPropertySlot slot(true); |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 392 | JSValue::decode(encodedBase).put(exec, *propertyName, JSValue::decode(encodedValue), slot); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 393 | } |
| 394 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 395 | void DFG_OPERATION operationPutByIdNonStrict(ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 396 | { |
| 397 | PutPropertySlot slot(false); |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 398 | JSValue::decode(encodedBase).put(exec, *propertyName, JSValue::decode(encodedValue), slot); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 399 | } |
| 400 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 401 | void DFG_OPERATION operationPutByIdDirectStrict(ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 402 | { |
| 403 | PutPropertySlot slot(true); |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 404 | JSValue::decode(encodedBase).putDirect(exec, *propertyName, JSValue::decode(encodedValue), slot); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 405 | } |
| 406 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 407 | void DFG_OPERATION operationPutByIdDirectNonStrict(ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 408 | { |
| 409 | PutPropertySlot slot(false); |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 410 | JSValue::decode(encodedBase).putDirect(exec, *propertyName, JSValue::decode(encodedValue), slot); |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 411 | } |
| 412 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 413 | #if CPU(X86_64) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 414 | void DFG_OPERATION operationPutByIdStrictOptimizeWithReturnAddress(ExecState*, EncodedJSValue, EncodedJSValue, Identifier*, ReturnAddressPtr); |
commit-queue@webkit.org | 0df040e | 2011-06-27 21:38:09 +0000 | [diff] [blame] | 415 | FUNCTION_WRAPPER_WITH_ARG5_RETURN_ADDRESS(operationPutByIdStrictOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 416 | void DFG_OPERATION operationPutByIdStrictOptimizeWithReturnAddress(ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName, ReturnAddressPtr returnAddress) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 417 | #elif CPU(X86) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 418 | void DFG_OPERATION operationPutByIdStrictOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 419 | FUNCTION_WRAPPER_WITH_ARG5_RETURN_ADDRESS(operationPutByIdStrictOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 420 | void DFG_OPERATION operationPutByIdStrictOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 421 | #endif |
commit-queue@webkit.org | 0df040e | 2011-06-27 21:38:09 +0000 | [diff] [blame] | 422 | { |
| 423 | JSValue value = JSValue::decode(encodedValue); |
| 424 | JSValue base = JSValue::decode(encodedBase); |
| 425 | PutPropertySlot slot(true); |
| 426 | |
| 427 | base.put(exec, *propertyName, value, slot); |
| 428 | |
| 429 | StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress); |
| 430 | if (stubInfo.seen) |
| 431 | dfgRepatchPutByID(exec, base, *propertyName, slot, stubInfo, NotDirect); |
| 432 | else |
| 433 | stubInfo.seen = true; |
| 434 | } |
| 435 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 436 | #if CPU(X86_64) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 437 | void DFG_OPERATION operationPutByIdNonStrictOptimizeWithReturnAddress(ExecState*, EncodedJSValue, EncodedJSValue, Identifier*, ReturnAddressPtr); |
commit-queue@webkit.org | 0df040e | 2011-06-27 21:38:09 +0000 | [diff] [blame] | 438 | FUNCTION_WRAPPER_WITH_ARG5_RETURN_ADDRESS(operationPutByIdNonStrictOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 439 | void DFG_OPERATION operationPutByIdNonStrictOptimizeWithReturnAddress(ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName, ReturnAddressPtr returnAddress) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 440 | #elif CPU(X86) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 441 | void DFG_OPERATION operationPutByIdNonStrictOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 442 | FUNCTION_WRAPPER_WITH_ARG5_RETURN_ADDRESS(operationPutByIdNonStrictOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 443 | void DFG_OPERATION operationPutByIdNonStrictOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 444 | #endif |
commit-queue@webkit.org | 0df040e | 2011-06-27 21:38:09 +0000 | [diff] [blame] | 445 | { |
| 446 | JSValue value = JSValue::decode(encodedValue); |
| 447 | JSValue base = JSValue::decode(encodedBase); |
| 448 | PutPropertySlot slot(false); |
| 449 | |
| 450 | base.put(exec, *propertyName, value, slot); |
| 451 | |
| 452 | StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress); |
| 453 | if (stubInfo.seen) |
| 454 | dfgRepatchPutByID(exec, base, *propertyName, slot, stubInfo, NotDirect); |
| 455 | else |
| 456 | stubInfo.seen = true; |
| 457 | } |
| 458 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 459 | #if CPU(X86_64) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 460 | void DFG_OPERATION operationPutByIdDirectStrictOptimizeWithReturnAddress(ExecState*, EncodedJSValue, EncodedJSValue, Identifier*, ReturnAddressPtr); |
commit-queue@webkit.org | 0df040e | 2011-06-27 21:38:09 +0000 | [diff] [blame] | 461 | FUNCTION_WRAPPER_WITH_ARG5_RETURN_ADDRESS(operationPutByIdDirectStrictOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 462 | void DFG_OPERATION operationPutByIdDirectStrictOptimizeWithReturnAddress(ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName, ReturnAddressPtr returnAddress) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 463 | #elif CPU(X86) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 464 | void DFG_OPERATION operationPutByIdDirectStrictOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 465 | FUNCTION_WRAPPER_WITH_ARG5_RETURN_ADDRESS(operationPutByIdDirectStrictOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 466 | void DFG_OPERATION operationPutByIdDirectStrictOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 467 | #endif |
commit-queue@webkit.org | 0df040e | 2011-06-27 21:38:09 +0000 | [diff] [blame] | 468 | { |
| 469 | JSValue value = JSValue::decode(encodedValue); |
| 470 | JSValue base = JSValue::decode(encodedBase); |
| 471 | PutPropertySlot slot(true); |
| 472 | |
| 473 | base.putDirect(exec, *propertyName, value, slot); |
| 474 | |
| 475 | StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress); |
| 476 | if (stubInfo.seen) |
| 477 | dfgRepatchPutByID(exec, base, *propertyName, slot, stubInfo, Direct); |
| 478 | else |
| 479 | stubInfo.seen = true; |
| 480 | } |
| 481 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 482 | #if CPU(X86_64) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 483 | void DFG_OPERATION operationPutByIdDirectNonStrictOptimizeWithReturnAddress(ExecState*, EncodedJSValue, EncodedJSValue, Identifier*, ReturnAddressPtr); |
commit-queue@webkit.org | 0df040e | 2011-06-27 21:38:09 +0000 | [diff] [blame] | 484 | FUNCTION_WRAPPER_WITH_ARG5_RETURN_ADDRESS(operationPutByIdDirectNonStrictOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 485 | void DFG_OPERATION operationPutByIdDirectNonStrictOptimizeWithReturnAddress(ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName, ReturnAddressPtr returnAddress) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 486 | #elif CPU(X86) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 487 | void DFG_OPERATION operationPutByIdDirectNonStrictOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 488 | FUNCTION_WRAPPER_WITH_ARG5_RETURN_ADDRESS(operationPutByIdDirectNonStrictOptimize); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 489 | void DFG_OPERATION operationPutByIdDirectNonStrictOptimizeWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, Identifier* propertyName) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 490 | #endif |
commit-queue@webkit.org | 0df040e | 2011-06-27 21:38:09 +0000 | [diff] [blame] | 491 | { |
| 492 | JSValue value = JSValue::decode(encodedValue); |
| 493 | JSValue base = JSValue::decode(encodedBase); |
| 494 | PutPropertySlot slot(false); |
| 495 | |
| 496 | base.putDirect(exec, *propertyName, value, slot); |
| 497 | |
| 498 | StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress); |
| 499 | if (stubInfo.seen) |
| 500 | dfgRepatchPutByID(exec, base, *propertyName, slot, stubInfo, Direct); |
| 501 | else |
| 502 | stubInfo.seen = true; |
| 503 | } |
| 504 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 505 | RegisterSizedBoolean DFG_OPERATION operationCompareLess(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
barraclough@apple.com | 848a0cc | 2011-04-08 20:33:24 +0000 | [diff] [blame] | 506 | { |
barraclough@apple.com | 8a8aab6 | 2011-07-05 19:01:41 +0000 | [diff] [blame] | 507 | return jsLess<true>(exec, JSValue::decode(encodedOp1), JSValue::decode(encodedOp2)); |
barraclough@apple.com | 848a0cc | 2011-04-08 20:33:24 +0000 | [diff] [blame] | 508 | } |
| 509 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 510 | RegisterSizedBoolean DFG_OPERATION operationCompareLessEq(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
barraclough@apple.com | 848a0cc | 2011-04-08 20:33:24 +0000 | [diff] [blame] | 511 | { |
barraclough@apple.com | 8a8aab6 | 2011-07-05 19:01:41 +0000 | [diff] [blame] | 512 | return jsLessEq<true>(exec, JSValue::decode(encodedOp1), JSValue::decode(encodedOp2)); |
barraclough@apple.com | 848a0cc | 2011-04-08 20:33:24 +0000 | [diff] [blame] | 513 | } |
| 514 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 515 | RegisterSizedBoolean DFG_OPERATION operationCompareGreater(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 516 | { |
barraclough@apple.com | 8a8aab6 | 2011-07-05 19:01:41 +0000 | [diff] [blame] | 517 | return jsLess<false>(exec, JSValue::decode(encodedOp2), JSValue::decode(encodedOp1)); |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 518 | } |
| 519 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 520 | RegisterSizedBoolean DFG_OPERATION operationCompareGreaterEq(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 521 | { |
barraclough@apple.com | 8a8aab6 | 2011-07-05 19:01:41 +0000 | [diff] [blame] | 522 | return jsLessEq<false>(exec, JSValue::decode(encodedOp2), JSValue::decode(encodedOp1)); |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 523 | } |
| 524 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 525 | RegisterSizedBoolean DFG_OPERATION operationCompareEq(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
barraclough@apple.com | 848a0cc | 2011-04-08 20:33:24 +0000 | [diff] [blame] | 526 | { |
commit-queue@webkit.org | 10d804a | 2011-07-17 09:02:26 +0000 | [diff] [blame] | 527 | return JSValue::equalSlowCaseInline(exec, JSValue::decode(encodedOp1), JSValue::decode(encodedOp2)); |
barraclough@apple.com | 848a0cc | 2011-04-08 20:33:24 +0000 | [diff] [blame] | 528 | } |
| 529 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 530 | RegisterSizedBoolean DFG_OPERATION operationCompareStrictEqCell(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
commit-queue@webkit.org | 6efa2ca | 2011-07-19 00:36:37 +0000 | [diff] [blame] | 531 | { |
| 532 | JSValue op1 = JSValue::decode(encodedOp1); |
| 533 | JSValue op2 = JSValue::decode(encodedOp2); |
| 534 | |
| 535 | ASSERT(op1.isCell()); |
| 536 | ASSERT(op2.isCell()); |
| 537 | |
| 538 | return JSValue::strictEqualSlowCaseInline(exec, op1, op2); |
| 539 | } |
| 540 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 541 | RegisterSizedBoolean DFG_OPERATION operationCompareStrictEq(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) |
barraclough@apple.com | 848a0cc | 2011-04-08 20:33:24 +0000 | [diff] [blame] | 542 | { |
| 543 | return JSValue::strictEqual(exec, JSValue::decode(encodedOp1), JSValue::decode(encodedOp2)); |
| 544 | } |
| 545 | |
commit-queue@webkit.org | ecf81e6 | 2011-09-30 20:36:08 +0000 | [diff] [blame] | 546 | EncodedJSValue DFG_OPERATION getHostCallReturnValue(); |
| 547 | EncodedJSValue DFG_OPERATION getHostCallReturnValueWithExecState(ExecState*); |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 548 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 549 | #if CPU(X86_64) |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 550 | asm ( |
barraclough@apple.com | 2decbec | 2011-09-28 01:09:33 +0000 | [diff] [blame] | 551 | ".globl " SYMBOL_STRING(getHostCallReturnValue) "\n" |
| 552 | SYMBOL_STRING(getHostCallReturnValue) ":" "\n" |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 553 | "mov -40(%r13), %r13\n" |
| 554 | "mov %r13, %rdi\n" |
barraclough@apple.com | 2decbec | 2011-09-28 01:09:33 +0000 | [diff] [blame] | 555 | "jmp " SYMBOL_STRING(getHostCallReturnValueWithExecState) "\n" |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 556 | ); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 557 | #elif CPU(X86) |
| 558 | asm ( |
barraclough@apple.com | 2decbec | 2011-09-28 01:09:33 +0000 | [diff] [blame] | 559 | ".globl " SYMBOL_STRING(getHostCallReturnValue) "\n" |
| 560 | SYMBOL_STRING(getHostCallReturnValue) ":" "\n" |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 561 | "mov -40(%edi), %edi\n" |
commit-queue@webkit.org | ecf81e6 | 2011-09-30 20:36:08 +0000 | [diff] [blame] | 562 | "mov (%esp), %ecx\n" |
| 563 | "mov %edi, (%esp)\n" |
| 564 | "lea -4(%esp), %esp\n" |
| 565 | "mov %ecx, (%esp)\n" |
barraclough@apple.com | 2decbec | 2011-09-28 01:09:33 +0000 | [diff] [blame] | 566 | "jmp " SYMBOL_STRING(getHostCallReturnValueWithExecState) "\n" |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 567 | ); |
| 568 | #endif |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 569 | |
commit-queue@webkit.org | ecf81e6 | 2011-09-30 20:36:08 +0000 | [diff] [blame] | 570 | EncodedJSValue DFG_OPERATION getHostCallReturnValueWithExecState(ExecState* exec) |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 571 | { |
| 572 | return JSValue::encode(exec->globalData().hostCallReturnValue); |
| 573 | } |
| 574 | |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 575 | static void* handleHostCall(ExecState* execCallee, JSValue callee, CodeSpecializationKind kind) |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 576 | { |
| 577 | ExecState* exec = execCallee->callerFrame(); |
| 578 | JSGlobalData* globalData = &exec->globalData(); |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 579 | if (kind == CodeForCall) { |
| 580 | CallData callData; |
| 581 | CallType callType = getCallData(callee, callData); |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 582 | |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 583 | ASSERT(callType != CallTypeJS); |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 584 | |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 585 | if (callType == CallTypeHost) { |
| 586 | if (!globalData->interpreter->registerFile().grow(execCallee->registers())) { |
| 587 | globalData->exception = createStackOverflowError(exec); |
| 588 | return 0; |
| 589 | } |
| 590 | |
| 591 | execCallee->setScopeChain(exec->scopeChain()); |
| 592 | |
| 593 | globalData->hostCallReturnValue = JSValue::decode(callData.native.function(execCallee)); |
| 594 | |
| 595 | if (globalData->exception) |
| 596 | return 0; |
| 597 | return reinterpret_cast<void*>(getHostCallReturnValue); |
| 598 | } |
| 599 | |
| 600 | ASSERT(callType == CallTypeNone); |
barraclough@apple.com | 085e4ef | 2011-07-21 18:57:57 +0000 | [diff] [blame] | 601 | exec->globalData().exception = createNotAFunctionError(exec, callee); |
| 602 | return 0; |
| 603 | } |
| 604 | |
| 605 | ASSERT(kind == CodeForConstruct); |
| 606 | |
| 607 | ConstructData constructData; |
| 608 | ConstructType constructType = getConstructData(callee, constructData); |
| 609 | |
| 610 | ASSERT(constructType != ConstructTypeJS); |
| 611 | |
| 612 | if (constructType == ConstructTypeHost) { |
| 613 | if (!globalData->interpreter->registerFile().grow(execCallee->registers())) { |
| 614 | globalData->exception = createStackOverflowError(exec); |
| 615 | return 0; |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 616 | } |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 617 | |
barraclough@apple.com | 085e4ef | 2011-07-21 18:57:57 +0000 | [diff] [blame] | 618 | execCallee->setScopeChain(exec->scopeChain()); |
| 619 | |
| 620 | globalData->hostCallReturnValue = JSValue::decode(constructData.native.function(execCallee)); |
| 621 | |
| 622 | if (globalData->exception) |
| 623 | return 0; |
| 624 | return reinterpret_cast<void*>(getHostCallReturnValue); |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 625 | } |
barraclough@apple.com | 085e4ef | 2011-07-21 18:57:57 +0000 | [diff] [blame] | 626 | |
| 627 | ASSERT(constructType == ConstructTypeNone); |
| 628 | exec->globalData().exception = createNotAConstructorError(exec, callee); |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 629 | return 0; |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 630 | } |
| 631 | |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 632 | inline void* linkFor(ExecState* execCallee, ReturnAddressPtr returnAddress, CodeSpecializationKind kind) |
commit-queue@webkit.org | d4e53d6 | 2011-07-07 23:54:57 +0000 | [diff] [blame] | 633 | { |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 634 | ExecState* exec = execCallee->callerFrame(); |
| 635 | JSGlobalData* globalData = &exec->globalData(); |
| 636 | JSValue calleeAsValue = execCallee->calleeAsValue(); |
barraclough@apple.com | b38285c | 2011-09-21 19:59:39 +0000 | [diff] [blame] | 637 | JSCell* calleeAsFunctionCell = getJSFunction(calleeAsValue); |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 638 | if (!calleeAsFunctionCell) |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 639 | return handleHostCall(execCallee, calleeAsValue, kind); |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 640 | JSFunction* callee = asFunction(calleeAsFunctionCell); |
| 641 | ExecutableBase* executable = callee->executable(); |
| 642 | |
| 643 | MacroAssemblerCodePtr codePtr; |
| 644 | CodeBlock* codeBlock = 0; |
| 645 | if (executable->isHostFunction()) |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 646 | codePtr = executable->generatedJITCodeFor(kind).addressForCall(); |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 647 | else { |
barraclough@apple.com | 79fe398 | 2011-07-27 23:48:56 +0000 | [diff] [blame] | 648 | execCallee->setScopeChain(callee->scope()); |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 649 | FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable); |
barraclough@apple.com | 79fe398 | 2011-07-27 23:48:56 +0000 | [diff] [blame] | 650 | JSObject* error = functionExecutable->compileFor(execCallee, callee->scope(), kind); |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 651 | if (error) { |
| 652 | globalData->exception = createStackOverflowError(exec); |
| 653 | return 0; |
| 654 | } |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 655 | codeBlock = &functionExecutable->generatedBytecodeFor(kind); |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 656 | if (execCallee->argumentCountIncludingThis() == static_cast<size_t>(codeBlock->m_numParameters)) |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 657 | codePtr = functionExecutable->generatedJITCodeFor(kind).addressForCall(); |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 658 | else |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 659 | codePtr = functionExecutable->generatedJITCodeWithArityCheckFor(kind); |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 660 | } |
| 661 | CallLinkInfo& callLinkInfo = exec->codeBlock()->getCallLinkInfo(returnAddress); |
| 662 | if (!callLinkInfo.seenOnce()) |
| 663 | callLinkInfo.setSeen(); |
| 664 | else |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 665 | dfgLinkFor(execCallee, callLinkInfo, codeBlock, callee, codePtr, kind); |
barraclough@apple.com | 86d1dfa | 2011-07-08 23:40:39 +0000 | [diff] [blame] | 666 | return codePtr.executableAddress(); |
commit-queue@webkit.org | d4e53d6 | 2011-07-07 23:54:57 +0000 | [diff] [blame] | 667 | } |
| 668 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 669 | #if CPU(X86_64) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 670 | void* DFG_OPERATION operationLinkCallWithReturnAddress(ExecState*, ReturnAddressPtr); |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 671 | FUNCTION_WRAPPER_WITH_ARG2_RETURN_ADDRESS(operationLinkCall); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 672 | void* DFG_OPERATION operationLinkCallWithReturnAddress(ExecState* execCallee, ReturnAddressPtr returnAddress) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 673 | #elif CPU(X86) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 674 | void* DFG_OPERATION operationLinkCallWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* execCallee); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 675 | FUNCTION_WRAPPER_WITH_ARG2_RETURN_ADDRESS(operationLinkCall); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 676 | void* DFG_OPERATION operationLinkCallWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* execCallee) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 677 | #endif |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 678 | { |
| 679 | return linkFor(execCallee, returnAddress, CodeForCall); |
| 680 | } |
| 681 | |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 682 | #if CPU(X86_64) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 683 | void* DFG_OPERATION operationLinkConstructWithReturnAddress(ExecState*, ReturnAddressPtr); |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 684 | FUNCTION_WRAPPER_WITH_ARG2_RETURN_ADDRESS(operationLinkConstruct); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 685 | void* DFG_OPERATION operationLinkConstructWithReturnAddress(ExecState* execCallee, ReturnAddressPtr returnAddress) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 686 | #elif CPU(X86) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 687 | void* DFG_OPERATION operationLinkConstructWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* execCallee); |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 688 | FUNCTION_WRAPPER_WITH_ARG2_RETURN_ADDRESS(operationLinkConstruct); |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 689 | void* DFG_OPERATION operationLinkConstructWithReturnAddress(ReturnAddressPtr returnAddress, ExecState* execCallee) |
barraclough@apple.com | d910c0d | 2011-09-24 05:04:08 +0000 | [diff] [blame] | 690 | #endif |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 691 | { |
| 692 | return linkFor(execCallee, returnAddress, CodeForConstruct); |
| 693 | } |
| 694 | |
| 695 | inline void* virtualFor(ExecState* execCallee, CodeSpecializationKind kind) |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 696 | { |
| 697 | ExecState* exec = execCallee->callerFrame(); |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 698 | JSValue calleeAsValue = execCallee->calleeAsValue(); |
barraclough@apple.com | b38285c | 2011-09-21 19:59:39 +0000 | [diff] [blame] | 699 | JSCell* calleeAsFunctionCell = getJSFunction(calleeAsValue); |
commit-queue@webkit.org | acf52bf | 2011-07-06 06:35:44 +0000 | [diff] [blame] | 700 | if (UNLIKELY(!calleeAsFunctionCell)) |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 701 | return handleHostCall(execCallee, calleeAsValue, kind); |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 702 | |
| 703 | JSFunction* function = asFunction(calleeAsFunctionCell); |
barraclough@apple.com | 79fe398 | 2011-07-27 23:48:56 +0000 | [diff] [blame] | 704 | execCallee->setScopeChain(function->scopeUnchecked()); |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 705 | ExecutableBase* executable = function->executable(); |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 706 | if (UNLIKELY(!executable->hasJITCodeFor(kind))) { |
commit-queue@webkit.org | acf52bf | 2011-07-06 06:35:44 +0000 | [diff] [blame] | 707 | FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable); |
barraclough@apple.com | 79fe398 | 2011-07-27 23:48:56 +0000 | [diff] [blame] | 708 | JSObject* error = functionExecutable->compileFor(execCallee, function->scope(), kind); |
commit-queue@webkit.org | acf52bf | 2011-07-06 06:35:44 +0000 | [diff] [blame] | 709 | if (error) { |
| 710 | exec->globalData().exception = error; |
| 711 | return 0; |
| 712 | } |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 713 | } |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 714 | return executable->generatedJITCodeWithArityCheckFor(kind).executableAddress(); |
| 715 | } |
| 716 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 717 | void* DFG_OPERATION operationVirtualCall(ExecState* execCallee) |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 718 | { |
| 719 | return virtualFor(execCallee, CodeForCall); |
| 720 | } |
| 721 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 722 | void* DFG_OPERATION operationVirtualConstruct(ExecState* execCallee) |
commit-queue@webkit.org | 63ac900 | 2011-07-13 01:46:09 +0000 | [diff] [blame] | 723 | { |
| 724 | return virtualFor(execCallee, CodeForConstruct); |
commit-queue@webkit.org | 4ea4892 | 2011-07-06 00:56:49 +0000 | [diff] [blame] | 725 | } |
| 726 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 727 | EncodedJSValue DFG_OPERATION operationInstanceOf(ExecState* exec, EncodedJSValue encodedValue, EncodedJSValue encodedBase, EncodedJSValue encodedPrototype) |
barraclough@apple.com | 691cb22 | 2011-07-02 23:08:23 +0000 | [diff] [blame] | 728 | { |
| 729 | JSValue value = JSValue::decode(encodedValue); |
| 730 | JSValue base = JSValue::decode(encodedBase); |
| 731 | JSValue prototype = JSValue::decode(encodedPrototype); |
| 732 | |
| 733 | // Otherwise CheckHasInstance should have failed. |
| 734 | ASSERT(base.isCell()); |
| 735 | // At least one of these checks must have failed to get to the slow case. |
| 736 | ASSERT(!value.isCell() |
| 737 | || !prototype.isCell() |
weinig@apple.com | 00c765a | 2011-09-17 00:22:50 +0000 | [diff] [blame] | 738 | || !prototype.isObject() |
| 739 | || !base.asCell()->structure()->typeInfo().implementsDefaultHasInstance()); |
barraclough@apple.com | 691cb22 | 2011-07-02 23:08:23 +0000 | [diff] [blame] | 740 | |
| 741 | |
| 742 | // ECMA-262 15.3.5.3: |
| 743 | // Throw an exception either if base is not an object, or if it does not implement 'HasInstance' (i.e. is a function). |
| 744 | TypeInfo typeInfo(UnspecifiedType); |
| 745 | if (!base.isObject() || !(typeInfo = asObject(base)->structure()->typeInfo()).implementsHasInstance()) { |
| 746 | throwError(exec, createInvalidParamError(exec, "instanceof", base)); |
| 747 | return JSValue::encode(jsUndefined()); |
| 748 | } |
| 749 | |
| 750 | return JSValue::encode(jsBoolean(asObject(base)->hasInstance(exec, value, prototype))); |
| 751 | } |
| 752 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 753 | EncodedJSValue DFG_OPERATION operationResolve(ExecState* exec, Identifier* propertyName) |
barraclough@apple.com | e076443 | 2011-07-22 22:08:52 +0000 | [diff] [blame] | 754 | { |
| 755 | ScopeChainNode* scopeChain = exec->scopeChain(); |
| 756 | ScopeChainIterator iter = scopeChain->begin(); |
| 757 | ScopeChainIterator end = scopeChain->end(); |
| 758 | ASSERT(iter != end); |
| 759 | |
| 760 | do { |
| 761 | JSObject* record = iter->get(); |
| 762 | PropertySlot slot(record); |
| 763 | if (record->getPropertySlot(exec, *propertyName, slot)) |
| 764 | return JSValue::encode(slot.getValue(exec, *propertyName)); |
| 765 | } while (++iter != end); |
| 766 | |
| 767 | return throwVMError(exec, createUndefinedVariableError(exec, *propertyName)); |
| 768 | } |
| 769 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 770 | EncodedJSValue DFG_OPERATION operationResolveBase(ExecState* exec, Identifier* propertyName) |
barraclough@apple.com | e076443 | 2011-07-22 22:08:52 +0000 | [diff] [blame] | 771 | { |
| 772 | return JSValue::encode(resolveBase(exec, *propertyName, exec->scopeChain(), false)); |
| 773 | } |
| 774 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 775 | EncodedJSValue DFG_OPERATION operationResolveBaseStrictPut(ExecState* exec, Identifier* propertyName) |
barraclough@apple.com | e076443 | 2011-07-22 22:08:52 +0000 | [diff] [blame] | 776 | { |
| 777 | JSValue base = resolveBase(exec, *propertyName, exec->scopeChain(), true); |
| 778 | if (!base) |
| 779 | throwError(exec, createErrorForInvalidGlobalAssignment(exec, propertyName->ustring())); |
| 780 | return JSValue::encode(base); |
| 781 | } |
| 782 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 783 | EncodedJSValue DFG_OPERATION operationResolveGlobal(ExecState* exec, GlobalResolveInfo* resolveInfo, Identifier* propertyName) |
barraclough@apple.com | 014d4be | 2011-09-23 18:52:19 +0000 | [diff] [blame] | 784 | { |
| 785 | JSGlobalObject* globalObject = exec->lexicalGlobalObject(); |
| 786 | |
| 787 | PropertySlot slot(globalObject); |
| 788 | if (globalObject->getPropertySlot(exec, *propertyName, slot)) { |
| 789 | JSValue result = slot.getValue(exec, *propertyName); |
| 790 | |
| 791 | if (slot.isCacheableValue() && !globalObject->structure()->isUncacheableDictionary() && slot.slotBase() == globalObject) { |
| 792 | resolveInfo->structure.set(exec->globalData(), exec->codeBlock()->ownerExecutable(), globalObject->structure()); |
| 793 | resolveInfo->offset = slot.cachedOffset(); |
| 794 | } |
| 795 | |
| 796 | return JSValue::encode(result); |
| 797 | } |
| 798 | |
| 799 | return throwVMError(exec, createUndefinedVariableError(exec, *propertyName)); |
| 800 | } |
| 801 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 802 | EncodedJSValue DFG_OPERATION operationToPrimitive(ExecState* exec, EncodedJSValue value) |
fpizlo@apple.com | 90e5f0e | 2011-09-22 22:42:54 +0000 | [diff] [blame] | 803 | { |
| 804 | return JSValue::encode(JSValue::decode(value).toPrimitive(exec)); |
| 805 | } |
| 806 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 807 | EncodedJSValue DFG_OPERATION operationStrCat(ExecState* exec, void* start, size_t size) |
fpizlo@apple.com | 90e5f0e | 2011-09-22 22:42:54 +0000 | [diff] [blame] | 808 | { |
| 809 | return JSValue::encode(jsString(exec, static_cast<Register*>(start), size)); |
| 810 | } |
| 811 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 812 | EncodedJSValue DFG_OPERATION operationNewArray(ExecState* exec, void* start, size_t size) |
fpizlo@apple.com | 98a693c | 2011-09-28 05:33:21 +0000 | [diff] [blame] | 813 | { |
| 814 | ArgList argList(static_cast<Register*>(start), size); |
| 815 | return JSValue::encode(constructArray(exec, argList)); |
| 816 | } |
| 817 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 818 | EncodedJSValue DFG_OPERATION operationNewArrayBuffer(ExecState* exec, size_t start, size_t size) |
fpizlo@apple.com | 98a693c | 2011-09-28 05:33:21 +0000 | [diff] [blame] | 819 | { |
| 820 | ArgList argList(exec->codeBlock()->constantBuffer(start), size); |
| 821 | return JSValue::encode(constructArray(exec, argList)); |
| 822 | } |
| 823 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 824 | EncodedJSValue DFG_OPERATION operationNewRegexp(ExecState* exec, void* regexpPtr) |
fpizlo@apple.com | 98a693c | 2011-09-28 05:33:21 +0000 | [diff] [blame] | 825 | { |
| 826 | RegExp* regexp = static_cast<RegExp*>(regexpPtr); |
| 827 | if (!regexp->isValid()) { |
| 828 | throwError(exec, createSyntaxError(exec, "Invalid flags supplied to RegExp constructor.")); |
| 829 | return JSValue::encode(jsUndefined()); |
| 830 | } |
| 831 | |
barraclough@apple.com | 5922d25 | 2011-09-28 19:53:09 +0000 | [diff] [blame] | 832 | return JSValue::encode(RegExpObject::create(exec->globalData(), exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regexp)); |
fpizlo@apple.com | 98a693c | 2011-09-28 05:33:21 +0000 | [diff] [blame] | 833 | } |
| 834 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 835 | void DFG_OPERATION operationThrowHasInstanceError(ExecState* exec, EncodedJSValue encodedBase) |
barraclough@apple.com | 691cb22 | 2011-07-02 23:08:23 +0000 | [diff] [blame] | 836 | { |
| 837 | JSValue base = JSValue::decode(encodedBase); |
| 838 | |
barraclough@apple.com | 691cb22 | 2011-07-02 23:08:23 +0000 | [diff] [blame] | 839 | // We should only call this function if base is not an object, or if it does not implement 'HasInstance'. |
barraclough@apple.com | e076443 | 2011-07-22 22:08:52 +0000 | [diff] [blame] | 840 | ASSERT(!base.isObject() || !asObject(base)->structure()->typeInfo().implementsHasInstance()); |
barraclough@apple.com | 691cb22 | 2011-07-02 23:08:23 +0000 | [diff] [blame] | 841 | |
| 842 | throwError(exec, createInvalidParamError(exec, "instanceof", base)); |
| 843 | } |
| 844 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 845 | DFGHandler DFG_OPERATION lookupExceptionHandler(ExecState* exec, ReturnAddressPtr faultLocation) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 846 | { |
| 847 | JSValue exceptionValue = exec->exception(); |
| 848 | ASSERT(exceptionValue); |
| 849 | |
| 850 | unsigned vPCIndex = exec->codeBlock()->bytecodeOffset(faultLocation); |
| 851 | HandlerInfo* handler = exec->globalData().interpreter->throwException(exec, exceptionValue, vPCIndex); |
| 852 | |
| 853 | void* catchRoutine = handler ? handler->nativeCode.executableAddress() : (void*)ctiOpThrowNotCaught; |
| 854 | ASSERT(catchRoutine); |
| 855 | return DFGHandler(exec, catchRoutine); |
| 856 | } |
| 857 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 858 | double DFG_OPERATION dfgConvertJSValueToNumber(ExecState* exec, EncodedJSValue value) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 859 | { |
| 860 | return JSValue::decode(value).toNumber(exec); |
| 861 | } |
| 862 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 863 | int32_t DFG_OPERATION dfgConvertJSValueToInt32(ExecState* exec, EncodedJSValue value) |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 864 | { |
| 865 | return JSValue::decode(value).toInt32(exec); |
| 866 | } |
| 867 | |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 868 | RegisterSizedBoolean DFG_OPERATION dfgConvertJSValueToBoolean(ExecState* exec, EncodedJSValue encodedOp) |
barraclough@apple.com | 848a0cc | 2011-04-08 20:33:24 +0000 | [diff] [blame] | 869 | { |
| 870 | return JSValue::decode(encodedOp).toBoolean(exec); |
| 871 | } |
| 872 | |
fpizlo@apple.com | 6d31486 | 2011-09-12 03:42:39 +0000 | [diff] [blame] | 873 | #if ENABLE(DFG_VERBOSE_SPECULATION_FAILURE) |
barraclough@apple.com | 52e88de | 2011-09-29 01:36:00 +0000 | [diff] [blame] | 874 | void DFG_OPERATION debugOperationPrintSpeculationFailure(ExecState*, void* debugInfoRaw) |
fpizlo@apple.com | 746c6d07 | 2011-09-07 02:47:51 +0000 | [diff] [blame] | 875 | { |
| 876 | SpeculationFailureDebugInfo* debugInfo = static_cast<SpeculationFailureDebugInfo*>(debugInfoRaw); |
fpizlo@apple.com | f2bf0dd | 2011-09-26 04:05:28 +0000 | [diff] [blame] | 877 | CodeBlock* codeBlock = debugInfo->codeBlock; |
| 878 | printf("Speculation failure in %p at 0x%x with executeCounter = %d, reoptimizationRetryCounter = %u, optimizationDelayCounter = %u, success/fail %u/%u\n", codeBlock, debugInfo->debugOffset, codeBlock->alternative()->executeCounter(), codeBlock->alternative()->reoptimizationRetryCounter(), codeBlock->alternative()->optimizationDelayCounter(), codeBlock->speculativeSuccessCounter(), codeBlock->speculativeFailCounter()); |
fpizlo@apple.com | 746c6d07 | 2011-09-07 02:47:51 +0000 | [diff] [blame] | 879 | } |
| 880 | #endif |
| 881 | |
barraclough@apple.com | c7af2d3 | 2011-05-26 21:37:05 +0000 | [diff] [blame] | 882 | } // extern "C" |
barraclough@apple.com | 2302c04 | 2011-03-14 23:31:00 +0000 | [diff] [blame] | 883 | } } // namespace JSC::DFG |
| 884 | |
| 885 | #endif |