Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * vim: set ts=8 sts=4 et sw=4 tw=99: |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "jit/BaselineInspector.h" |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/DebugOnly.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "jit/BaselineIC.h" |
michael@0 | 12 | |
michael@0 | 13 | using namespace js; |
michael@0 | 14 | using namespace js::jit; |
michael@0 | 15 | |
michael@0 | 16 | using mozilla::DebugOnly; |
michael@0 | 17 | |
michael@0 | 18 | bool |
michael@0 | 19 | SetElemICInspector::sawOOBDenseWrite() const |
michael@0 | 20 | { |
michael@0 | 21 | if (!icEntry_) |
michael@0 | 22 | return false; |
michael@0 | 23 | |
michael@0 | 24 | // Check for a SetElem_DenseAdd stub. |
michael@0 | 25 | for (ICStub *stub = icEntry_->firstStub(); stub; stub = stub->next()) { |
michael@0 | 26 | if (stub->isSetElem_DenseAdd()) |
michael@0 | 27 | return true; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | // Check for a write hole bit on the SetElem_Fallback stub. |
michael@0 | 31 | ICStub *stub = icEntry_->fallbackStub(); |
michael@0 | 32 | if (stub->isSetElem_Fallback()) |
michael@0 | 33 | return stub->toSetElem_Fallback()->hasArrayWriteHole(); |
michael@0 | 34 | |
michael@0 | 35 | return false; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | bool |
michael@0 | 39 | SetElemICInspector::sawOOBTypedArrayWrite() const |
michael@0 | 40 | { |
michael@0 | 41 | if (!icEntry_) |
michael@0 | 42 | return false; |
michael@0 | 43 | |
michael@0 | 44 | // Check for SetElem_TypedArray stubs with expectOutOfBounds set. |
michael@0 | 45 | for (ICStub *stub = icEntry_->firstStub(); stub; stub = stub->next()) { |
michael@0 | 46 | if (!stub->isSetElem_TypedArray()) |
michael@0 | 47 | continue; |
michael@0 | 48 | if (stub->toSetElem_TypedArray()->expectOutOfBounds()) |
michael@0 | 49 | return true; |
michael@0 | 50 | } |
michael@0 | 51 | return false; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | bool |
michael@0 | 55 | SetElemICInspector::sawDenseWrite() const |
michael@0 | 56 | { |
michael@0 | 57 | if (!icEntry_) |
michael@0 | 58 | return false; |
michael@0 | 59 | |
michael@0 | 60 | // Check for a SetElem_DenseAdd or SetElem_Dense stub. |
michael@0 | 61 | for (ICStub *stub = icEntry_->firstStub(); stub; stub = stub->next()) { |
michael@0 | 62 | if (stub->isSetElem_DenseAdd() || stub->isSetElem_Dense()) |
michael@0 | 63 | return true; |
michael@0 | 64 | } |
michael@0 | 65 | return false; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | bool |
michael@0 | 69 | SetElemICInspector::sawTypedArrayWrite() const |
michael@0 | 70 | { |
michael@0 | 71 | if (!icEntry_) |
michael@0 | 72 | return false; |
michael@0 | 73 | |
michael@0 | 74 | // Check for a SetElem_TypedArray stub. |
michael@0 | 75 | for (ICStub *stub = icEntry_->firstStub(); stub; stub = stub->next()) { |
michael@0 | 76 | if (stub->isSetElem_TypedArray()) |
michael@0 | 77 | return true; |
michael@0 | 78 | } |
michael@0 | 79 | return false; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | bool |
michael@0 | 83 | BaselineInspector::maybeShapesForPropertyOp(jsbytecode *pc, ShapeVector &shapes) |
michael@0 | 84 | { |
michael@0 | 85 | // Return a list of shapes seen by the baseline IC for the current op. |
michael@0 | 86 | // An empty list indicates no shapes are known, or there was an uncacheable |
michael@0 | 87 | // access. |
michael@0 | 88 | JS_ASSERT(shapes.empty()); |
michael@0 | 89 | |
michael@0 | 90 | if (!hasBaselineScript()) |
michael@0 | 91 | return true; |
michael@0 | 92 | |
michael@0 | 93 | JS_ASSERT(isValidPC(pc)); |
michael@0 | 94 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 95 | |
michael@0 | 96 | ICStub *stub = entry.firstStub(); |
michael@0 | 97 | while (stub->next()) { |
michael@0 | 98 | Shape *shape; |
michael@0 | 99 | if (stub->isGetProp_Native()) { |
michael@0 | 100 | shape = stub->toGetProp_Native()->shape(); |
michael@0 | 101 | } else if (stub->isSetProp_Native()) { |
michael@0 | 102 | shape = stub->toSetProp_Native()->shape(); |
michael@0 | 103 | } else { |
michael@0 | 104 | shapes.clear(); |
michael@0 | 105 | return true; |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | // Don't add the same shape twice (this can happen if there are multiple |
michael@0 | 109 | // SetProp_Native stubs with different TypeObject's). |
michael@0 | 110 | bool found = false; |
michael@0 | 111 | for (size_t i = 0; i < shapes.length(); i++) { |
michael@0 | 112 | if (shapes[i] == shape) { |
michael@0 | 113 | found = true; |
michael@0 | 114 | break; |
michael@0 | 115 | } |
michael@0 | 116 | } |
michael@0 | 117 | |
michael@0 | 118 | if (!found && !shapes.append(shape)) |
michael@0 | 119 | return false; |
michael@0 | 120 | |
michael@0 | 121 | stub = stub->next(); |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | if (stub->isGetProp_Fallback()) { |
michael@0 | 125 | if (stub->toGetProp_Fallback()->hadUnoptimizableAccess()) |
michael@0 | 126 | shapes.clear(); |
michael@0 | 127 | } else { |
michael@0 | 128 | if (stub->toSetProp_Fallback()->hadUnoptimizableAccess()) |
michael@0 | 129 | shapes.clear(); |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | // Don't inline if there are more than 5 shapes. |
michael@0 | 133 | if (shapes.length() > 5) |
michael@0 | 134 | shapes.clear(); |
michael@0 | 135 | |
michael@0 | 136 | return true; |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | ICStub * |
michael@0 | 140 | BaselineInspector::monomorphicStub(jsbytecode *pc) |
michael@0 | 141 | { |
michael@0 | 142 | if (!hasBaselineScript()) |
michael@0 | 143 | return nullptr; |
michael@0 | 144 | |
michael@0 | 145 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 146 | |
michael@0 | 147 | ICStub *stub = entry.firstStub(); |
michael@0 | 148 | ICStub *next = stub->next(); |
michael@0 | 149 | |
michael@0 | 150 | if (!next || !next->isFallback()) |
michael@0 | 151 | return nullptr; |
michael@0 | 152 | |
michael@0 | 153 | return stub; |
michael@0 | 154 | } |
michael@0 | 155 | |
michael@0 | 156 | bool |
michael@0 | 157 | BaselineInspector::dimorphicStub(jsbytecode *pc, ICStub **pfirst, ICStub **psecond) |
michael@0 | 158 | { |
michael@0 | 159 | if (!hasBaselineScript()) |
michael@0 | 160 | return false; |
michael@0 | 161 | |
michael@0 | 162 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 163 | |
michael@0 | 164 | ICStub *stub = entry.firstStub(); |
michael@0 | 165 | ICStub *next = stub->next(); |
michael@0 | 166 | ICStub *after = next ? next->next() : nullptr; |
michael@0 | 167 | |
michael@0 | 168 | if (!after || !after->isFallback()) |
michael@0 | 169 | return false; |
michael@0 | 170 | |
michael@0 | 171 | *pfirst = stub; |
michael@0 | 172 | *psecond = next; |
michael@0 | 173 | return true; |
michael@0 | 174 | } |
michael@0 | 175 | |
michael@0 | 176 | MIRType |
michael@0 | 177 | BaselineInspector::expectedResultType(jsbytecode *pc) |
michael@0 | 178 | { |
michael@0 | 179 | // Look at the IC entries for this op to guess what type it will produce, |
michael@0 | 180 | // returning MIRType_None otherwise. |
michael@0 | 181 | |
michael@0 | 182 | ICStub *stub = monomorphicStub(pc); |
michael@0 | 183 | if (!stub) |
michael@0 | 184 | return MIRType_None; |
michael@0 | 185 | |
michael@0 | 186 | switch (stub->kind()) { |
michael@0 | 187 | case ICStub::BinaryArith_Int32: |
michael@0 | 188 | if (stub->toBinaryArith_Int32()->allowDouble()) |
michael@0 | 189 | return MIRType_Double; |
michael@0 | 190 | return MIRType_Int32; |
michael@0 | 191 | case ICStub::BinaryArith_BooleanWithInt32: |
michael@0 | 192 | case ICStub::UnaryArith_Int32: |
michael@0 | 193 | case ICStub::BinaryArith_DoubleWithInt32: |
michael@0 | 194 | return MIRType_Int32; |
michael@0 | 195 | case ICStub::BinaryArith_Double: |
michael@0 | 196 | case ICStub::UnaryArith_Double: |
michael@0 | 197 | return MIRType_Double; |
michael@0 | 198 | case ICStub::BinaryArith_StringConcat: |
michael@0 | 199 | case ICStub::BinaryArith_StringObjectConcat: |
michael@0 | 200 | return MIRType_String; |
michael@0 | 201 | default: |
michael@0 | 202 | return MIRType_None; |
michael@0 | 203 | } |
michael@0 | 204 | } |
michael@0 | 205 | |
michael@0 | 206 | // Whether a baseline stub kind is suitable for a double comparison that |
michael@0 | 207 | // converts its operands to doubles. |
michael@0 | 208 | static bool |
michael@0 | 209 | CanUseDoubleCompare(ICStub::Kind kind) |
michael@0 | 210 | { |
michael@0 | 211 | return kind == ICStub::Compare_Double || kind == ICStub::Compare_NumberWithUndefined; |
michael@0 | 212 | } |
michael@0 | 213 | |
michael@0 | 214 | // Whether a baseline stub kind is suitable for an int32 comparison that |
michael@0 | 215 | // converts its operands to int32. |
michael@0 | 216 | static bool |
michael@0 | 217 | CanUseInt32Compare(ICStub::Kind kind) |
michael@0 | 218 | { |
michael@0 | 219 | return kind == ICStub::Compare_Int32 || kind == ICStub::Compare_Int32WithBoolean; |
michael@0 | 220 | } |
michael@0 | 221 | |
michael@0 | 222 | MCompare::CompareType |
michael@0 | 223 | BaselineInspector::expectedCompareType(jsbytecode *pc) |
michael@0 | 224 | { |
michael@0 | 225 | ICStub *first = monomorphicStub(pc), *second = nullptr; |
michael@0 | 226 | if (!first && !dimorphicStub(pc, &first, &second)) |
michael@0 | 227 | return MCompare::Compare_Unknown; |
michael@0 | 228 | |
michael@0 | 229 | if (CanUseInt32Compare(first->kind()) && (!second || CanUseInt32Compare(second->kind()))) { |
michael@0 | 230 | ICCompare_Int32WithBoolean *coerce = |
michael@0 | 231 | first->isCompare_Int32WithBoolean() |
michael@0 | 232 | ? first->toCompare_Int32WithBoolean() |
michael@0 | 233 | : ((second && second->isCompare_Int32WithBoolean()) |
michael@0 | 234 | ? second->toCompare_Int32WithBoolean() |
michael@0 | 235 | : nullptr); |
michael@0 | 236 | if (coerce) { |
michael@0 | 237 | return coerce->lhsIsInt32() |
michael@0 | 238 | ? MCompare::Compare_Int32MaybeCoerceRHS |
michael@0 | 239 | : MCompare::Compare_Int32MaybeCoerceLHS; |
michael@0 | 240 | } |
michael@0 | 241 | return MCompare::Compare_Int32; |
michael@0 | 242 | } |
michael@0 | 243 | |
michael@0 | 244 | if (CanUseDoubleCompare(first->kind()) && (!second || CanUseDoubleCompare(second->kind()))) { |
michael@0 | 245 | ICCompare_NumberWithUndefined *coerce = |
michael@0 | 246 | first->isCompare_NumberWithUndefined() |
michael@0 | 247 | ? first->toCompare_NumberWithUndefined() |
michael@0 | 248 | : (second && second->isCompare_NumberWithUndefined()) |
michael@0 | 249 | ? second->toCompare_NumberWithUndefined() |
michael@0 | 250 | : nullptr; |
michael@0 | 251 | if (coerce) { |
michael@0 | 252 | return coerce->lhsIsUndefined() |
michael@0 | 253 | ? MCompare::Compare_DoubleMaybeCoerceLHS |
michael@0 | 254 | : MCompare::Compare_DoubleMaybeCoerceRHS; |
michael@0 | 255 | } |
michael@0 | 256 | return MCompare::Compare_Double; |
michael@0 | 257 | } |
michael@0 | 258 | |
michael@0 | 259 | return MCompare::Compare_Unknown; |
michael@0 | 260 | } |
michael@0 | 261 | |
michael@0 | 262 | static bool |
michael@0 | 263 | TryToSpecializeBinaryArithOp(ICStub **stubs, |
michael@0 | 264 | uint32_t nstubs, |
michael@0 | 265 | MIRType *result) |
michael@0 | 266 | { |
michael@0 | 267 | DebugOnly<bool> sawInt32 = false; |
michael@0 | 268 | bool sawDouble = false; |
michael@0 | 269 | bool sawOther = false; |
michael@0 | 270 | |
michael@0 | 271 | for (uint32_t i = 0; i < nstubs; i++) { |
michael@0 | 272 | switch (stubs[i]->kind()) { |
michael@0 | 273 | case ICStub::BinaryArith_Int32: |
michael@0 | 274 | sawInt32 = true; |
michael@0 | 275 | break; |
michael@0 | 276 | case ICStub::BinaryArith_BooleanWithInt32: |
michael@0 | 277 | sawInt32 = true; |
michael@0 | 278 | break; |
michael@0 | 279 | case ICStub::BinaryArith_Double: |
michael@0 | 280 | sawDouble = true; |
michael@0 | 281 | break; |
michael@0 | 282 | case ICStub::BinaryArith_DoubleWithInt32: |
michael@0 | 283 | sawDouble = true; |
michael@0 | 284 | break; |
michael@0 | 285 | default: |
michael@0 | 286 | sawOther = true; |
michael@0 | 287 | break; |
michael@0 | 288 | } |
michael@0 | 289 | } |
michael@0 | 290 | |
michael@0 | 291 | if (sawOther) |
michael@0 | 292 | return false; |
michael@0 | 293 | |
michael@0 | 294 | if (sawDouble) { |
michael@0 | 295 | *result = MIRType_Double; |
michael@0 | 296 | return true; |
michael@0 | 297 | } |
michael@0 | 298 | |
michael@0 | 299 | JS_ASSERT(sawInt32); |
michael@0 | 300 | *result = MIRType_Int32; |
michael@0 | 301 | return true; |
michael@0 | 302 | } |
michael@0 | 303 | |
michael@0 | 304 | MIRType |
michael@0 | 305 | BaselineInspector::expectedBinaryArithSpecialization(jsbytecode *pc) |
michael@0 | 306 | { |
michael@0 | 307 | if (!hasBaselineScript()) |
michael@0 | 308 | return MIRType_None; |
michael@0 | 309 | |
michael@0 | 310 | MIRType result; |
michael@0 | 311 | ICStub *stubs[2]; |
michael@0 | 312 | |
michael@0 | 313 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 314 | ICStub *stub = entry.fallbackStub(); |
michael@0 | 315 | if (stub->isBinaryArith_Fallback() && |
michael@0 | 316 | stub->toBinaryArith_Fallback()->hadUnoptimizableOperands()) |
michael@0 | 317 | { |
michael@0 | 318 | return MIRType_None; |
michael@0 | 319 | } |
michael@0 | 320 | |
michael@0 | 321 | stubs[0] = monomorphicStub(pc); |
michael@0 | 322 | if (stubs[0]) { |
michael@0 | 323 | if (TryToSpecializeBinaryArithOp(stubs, 1, &result)) |
michael@0 | 324 | return result; |
michael@0 | 325 | } |
michael@0 | 326 | |
michael@0 | 327 | if (dimorphicStub(pc, &stubs[0], &stubs[1])) { |
michael@0 | 328 | if (TryToSpecializeBinaryArithOp(stubs, 2, &result)) |
michael@0 | 329 | return result; |
michael@0 | 330 | } |
michael@0 | 331 | |
michael@0 | 332 | return MIRType_None; |
michael@0 | 333 | } |
michael@0 | 334 | |
michael@0 | 335 | bool |
michael@0 | 336 | BaselineInspector::hasSeenNonNativeGetElement(jsbytecode *pc) |
michael@0 | 337 | { |
michael@0 | 338 | if (!hasBaselineScript()) |
michael@0 | 339 | return false; |
michael@0 | 340 | |
michael@0 | 341 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 342 | ICStub *stub = entry.fallbackStub(); |
michael@0 | 343 | |
michael@0 | 344 | if (stub->isGetElem_Fallback()) |
michael@0 | 345 | return stub->toGetElem_Fallback()->hasNonNativeAccess(); |
michael@0 | 346 | return false; |
michael@0 | 347 | } |
michael@0 | 348 | |
michael@0 | 349 | bool |
michael@0 | 350 | BaselineInspector::hasSeenNegativeIndexGetElement(jsbytecode *pc) |
michael@0 | 351 | { |
michael@0 | 352 | if (!hasBaselineScript()) |
michael@0 | 353 | return false; |
michael@0 | 354 | |
michael@0 | 355 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 356 | ICStub *stub = entry.fallbackStub(); |
michael@0 | 357 | |
michael@0 | 358 | if (stub->isGetElem_Fallback()) |
michael@0 | 359 | return stub->toGetElem_Fallback()->hasNegativeIndex(); |
michael@0 | 360 | return false; |
michael@0 | 361 | } |
michael@0 | 362 | |
michael@0 | 363 | bool |
michael@0 | 364 | BaselineInspector::hasSeenAccessedGetter(jsbytecode *pc) |
michael@0 | 365 | { |
michael@0 | 366 | if (!hasBaselineScript()) |
michael@0 | 367 | return false; |
michael@0 | 368 | |
michael@0 | 369 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 370 | ICStub *stub = entry.fallbackStub(); |
michael@0 | 371 | |
michael@0 | 372 | if (stub->isGetProp_Fallback()) |
michael@0 | 373 | return stub->toGetProp_Fallback()->hasAccessedGetter(); |
michael@0 | 374 | return false; |
michael@0 | 375 | } |
michael@0 | 376 | |
michael@0 | 377 | bool |
michael@0 | 378 | BaselineInspector::hasSeenNonStringIterNext(jsbytecode *pc) |
michael@0 | 379 | { |
michael@0 | 380 | JS_ASSERT(JSOp(*pc) == JSOP_ITERNEXT); |
michael@0 | 381 | |
michael@0 | 382 | if (!hasBaselineScript()) |
michael@0 | 383 | return false; |
michael@0 | 384 | |
michael@0 | 385 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 386 | ICStub *stub = entry.fallbackStub(); |
michael@0 | 387 | |
michael@0 | 388 | return stub->toIteratorNext_Fallback()->hasNonStringResult(); |
michael@0 | 389 | } |
michael@0 | 390 | |
michael@0 | 391 | bool |
michael@0 | 392 | BaselineInspector::hasSeenDoubleResult(jsbytecode *pc) |
michael@0 | 393 | { |
michael@0 | 394 | if (!hasBaselineScript()) |
michael@0 | 395 | return false; |
michael@0 | 396 | |
michael@0 | 397 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 398 | ICStub *stub = entry.fallbackStub(); |
michael@0 | 399 | |
michael@0 | 400 | JS_ASSERT(stub->isUnaryArith_Fallback() || stub->isBinaryArith_Fallback()); |
michael@0 | 401 | |
michael@0 | 402 | if (stub->isUnaryArith_Fallback()) |
michael@0 | 403 | return stub->toUnaryArith_Fallback()->sawDoubleResult(); |
michael@0 | 404 | else |
michael@0 | 405 | return stub->toBinaryArith_Fallback()->sawDoubleResult(); |
michael@0 | 406 | |
michael@0 | 407 | return false; |
michael@0 | 408 | } |
michael@0 | 409 | |
michael@0 | 410 | JSObject * |
michael@0 | 411 | BaselineInspector::getTemplateObject(jsbytecode *pc) |
michael@0 | 412 | { |
michael@0 | 413 | if (!hasBaselineScript()) |
michael@0 | 414 | return nullptr; |
michael@0 | 415 | |
michael@0 | 416 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 417 | for (ICStub *stub = entry.firstStub(); stub; stub = stub->next()) { |
michael@0 | 418 | switch (stub->kind()) { |
michael@0 | 419 | case ICStub::NewArray_Fallback: |
michael@0 | 420 | return stub->toNewArray_Fallback()->templateObject(); |
michael@0 | 421 | case ICStub::NewObject_Fallback: |
michael@0 | 422 | return stub->toNewObject_Fallback()->templateObject(); |
michael@0 | 423 | case ICStub::Rest_Fallback: |
michael@0 | 424 | return stub->toRest_Fallback()->templateObject(); |
michael@0 | 425 | case ICStub::Call_Scripted: |
michael@0 | 426 | if (JSObject *obj = stub->toCall_Scripted()->templateObject()) |
michael@0 | 427 | return obj; |
michael@0 | 428 | break; |
michael@0 | 429 | default: |
michael@0 | 430 | break; |
michael@0 | 431 | } |
michael@0 | 432 | } |
michael@0 | 433 | |
michael@0 | 434 | return nullptr; |
michael@0 | 435 | } |
michael@0 | 436 | |
michael@0 | 437 | JSObject * |
michael@0 | 438 | BaselineInspector::getTemplateObjectForNative(jsbytecode *pc, Native native) |
michael@0 | 439 | { |
michael@0 | 440 | if (!hasBaselineScript()) |
michael@0 | 441 | return nullptr; |
michael@0 | 442 | |
michael@0 | 443 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 444 | for (ICStub *stub = entry.firstStub(); stub; stub = stub->next()) { |
michael@0 | 445 | if (stub->isCall_Native() && stub->toCall_Native()->callee()->native() == native) |
michael@0 | 446 | return stub->toCall_Native()->templateObject(); |
michael@0 | 447 | } |
michael@0 | 448 | |
michael@0 | 449 | return nullptr; |
michael@0 | 450 | } |
michael@0 | 451 | |
michael@0 | 452 | DeclEnvObject * |
michael@0 | 453 | BaselineInspector::templateDeclEnvObject() |
michael@0 | 454 | { |
michael@0 | 455 | if (!hasBaselineScript()) |
michael@0 | 456 | return nullptr; |
michael@0 | 457 | |
michael@0 | 458 | JSObject *res = &templateCallObject()->as<ScopeObject>().enclosingScope(); |
michael@0 | 459 | JS_ASSERT(res); |
michael@0 | 460 | |
michael@0 | 461 | return &res->as<DeclEnvObject>(); |
michael@0 | 462 | } |
michael@0 | 463 | |
michael@0 | 464 | CallObject * |
michael@0 | 465 | BaselineInspector::templateCallObject() |
michael@0 | 466 | { |
michael@0 | 467 | if (!hasBaselineScript()) |
michael@0 | 468 | return nullptr; |
michael@0 | 469 | |
michael@0 | 470 | JSObject *res = baselineScript()->templateScope(); |
michael@0 | 471 | JS_ASSERT(res); |
michael@0 | 472 | |
michael@0 | 473 | return &res->as<CallObject>(); |
michael@0 | 474 | } |
michael@0 | 475 | |
michael@0 | 476 | JSObject * |
michael@0 | 477 | BaselineInspector::commonGetPropFunction(jsbytecode *pc, Shape **lastProperty, JSFunction **commonGetter) |
michael@0 | 478 | { |
michael@0 | 479 | if (!hasBaselineScript()) |
michael@0 | 480 | return nullptr; |
michael@0 | 481 | |
michael@0 | 482 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 483 | for (ICStub *stub = entry.firstStub(); stub; stub = stub->next()) { |
michael@0 | 484 | if (stub->isGetProp_CallScripted() || |
michael@0 | 485 | stub->isGetProp_CallNative() || |
michael@0 | 486 | stub->isGetProp_CallNativePrototype()) |
michael@0 | 487 | { |
michael@0 | 488 | ICGetPropCallGetter *nstub = static_cast<ICGetPropCallGetter *>(stub); |
michael@0 | 489 | *lastProperty = nstub->holderShape(); |
michael@0 | 490 | *commonGetter = nstub->getter(); |
michael@0 | 491 | return nstub->holder(); |
michael@0 | 492 | } |
michael@0 | 493 | } |
michael@0 | 494 | return nullptr; |
michael@0 | 495 | } |
michael@0 | 496 | |
michael@0 | 497 | JSObject * |
michael@0 | 498 | BaselineInspector::commonSetPropFunction(jsbytecode *pc, Shape **lastProperty, JSFunction **commonSetter) |
michael@0 | 499 | { |
michael@0 | 500 | if (!hasBaselineScript()) |
michael@0 | 501 | return nullptr; |
michael@0 | 502 | |
michael@0 | 503 | const ICEntry &entry = icEntryFromPC(pc); |
michael@0 | 504 | for (ICStub *stub = entry.firstStub(); stub; stub = stub->next()) { |
michael@0 | 505 | if (stub->isSetProp_CallScripted() || stub->isSetProp_CallNative()) { |
michael@0 | 506 | ICSetPropCallSetter *nstub = static_cast<ICSetPropCallSetter *>(stub); |
michael@0 | 507 | *lastProperty = nstub->holderShape(); |
michael@0 | 508 | *commonSetter = nstub->setter(); |
michael@0 | 509 | return nstub->holder(); |
michael@0 | 510 | } |
michael@0 | 511 | } |
michael@0 | 512 | return nullptr; |
michael@0 | 513 | } |