Changeset 194613 in webkit for trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
- Timestamp:
- Jan 5, 2016, 3:08:58 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
r194294 r194613 136 136 } while (false) 137 137 138 #define RETURN_WITH_RESULT_PROFILING(value__) \139 RETURN_WITH_PROFILING(value__, PROFILE_RESULT(returnValue__))140 141 #define PROFILE_RESULT(value__) do { \142 CodeBlock* codeBlock = exec->codeBlock(); \143 unsigned bytecodeOffset = codeBlock->bytecodeOffset(pc); \144 codeBlock->updateResultProfileForBytecodeOffset(bytecodeOffset, value__); \145 } while (false)146 147 138 #define CALL_END_IMPL(exec, callTarget) RETURN_TWO((callTarget), (exec)) 148 139 … … 359 350 } 360 351 352 #if ENABLE(DFG_JIT) 353 static void updateResultProfileForBinaryArithOp(ExecState* exec, Instruction* pc, JSValue result, JSValue left, JSValue right) 354 { 355 CodeBlock* codeBlock = exec->codeBlock(); 356 unsigned bytecodeOffset = codeBlock->bytecodeOffset(pc); 357 ResultProfile* profile = codeBlock->ensureResultProfile(bytecodeOffset); 358 359 if (result.isNumber()) { 360 if (!result.isInt32()) { 361 if (left.isInt32() && right.isInt32()) 362 profile->setObservedInt32Overflow(); 363 364 double doubleVal = result.asNumber(); 365 if (!doubleVal && std::signbit(doubleVal)) 366 profile->setObservedNegZeroDouble(); 367 else { 368 profile->setObservedNonNegZeroDouble(); 369 370 // The Int52 overflow check here intentionally omits 1ll << 51 as a valid negative Int52 value. 371 // Therefore, we will get a false positive if the result is that value. This is intentionally 372 // done to simplify the checking algorithm. 373 static const int64_t int52OverflowPoint = (1ll << 51); 374 int64_t int64Val = static_cast<int64_t>(std::abs(doubleVal)); 375 if (int64Val >= int52OverflowPoint) 376 profile->setObservedInt52Overflow(); 377 } 378 } 379 } else 380 profile->setObservedNonNumber(); 381 } 382 #else 383 static void updateResultProfileForBinaryArithOp(ExecState*, Instruction*, JSValue, JSValue, JSValue) { } 384 #endif 385 361 386 SLOW_PATH_DECL(slow_path_add) 362 387 { … … 364 389 JSValue v1 = OP_C(2).jsValue(); 365 390 JSValue v2 = OP_C(3).jsValue(); 366 391 JSValue result; 392 367 393 if (v1.isString() && !v2.isObject()) 368 RETURN_WITH_RESULT_PROFILING(jsString(exec, asString(v1), v2.toString(exec))); 369 370 if (v1.isNumber() && v2.isNumber()) 371 RETURN_WITH_RESULT_PROFILING(jsNumber(v1.asNumber() + v2.asNumber())); 372 373 RETURN_WITH_RESULT_PROFILING(jsAddSlowCase(exec, v1, v2)); 394 result = jsString(exec, asString(v1), v2.toString(exec)); 395 else if (v1.isNumber() && v2.isNumber()) 396 result = jsNumber(v1.asNumber() + v2.asNumber()); 397 else 398 result = jsAddSlowCase(exec, v1, v2); 399 400 RETURN_WITH_PROFILING(result, { 401 updateResultProfileForBinaryArithOp(exec, pc, result, v1, v2); 402 }); 374 403 } 375 404 … … 381 410 { 382 411 BEGIN(); 383 double a = OP_C(2).jsValue().toNumber(exec); 384 double b = OP_C(3).jsValue().toNumber(exec); 385 RETURN_WITH_RESULT_PROFILING(jsNumber(a * b)); 412 JSValue left = OP_C(2).jsValue(); 413 JSValue right = OP_C(3).jsValue(); 414 double a = left.toNumber(exec); 415 double b = right.toNumber(exec); 416 JSValue result = jsNumber(a * b); 417 RETURN_WITH_PROFILING(result, { 418 updateResultProfileForBinaryArithOp(exec, pc, result, left, right); 419 }); 386 420 } 387 421 … … 389 423 { 390 424 BEGIN(); 391 double a = OP_C(2).jsValue().toNumber(exec); 392 double b = OP_C(3).jsValue().toNumber(exec); 393 RETURN_WITH_RESULT_PROFILING(jsNumber(a - b)); 425 JSValue left = OP_C(2).jsValue(); 426 JSValue right = OP_C(3).jsValue(); 427 double a = left.toNumber(exec); 428 double b = right.toNumber(exec); 429 JSValue result = jsNumber(a - b); 430 RETURN_WITH_PROFILING(result, { 431 updateResultProfileForBinaryArithOp(exec, pc, result, left, right); 432 }); 394 433 } 395 434 … … 397 436 { 398 437 BEGIN(); 399 double a = OP_C(2).jsValue().toNumber(exec); 400 double b = OP_C(3).jsValue().toNumber(exec); 401 RETURN_WITH_RESULT_PROFILING(jsNumber(a / b)); 438 JSValue left = OP_C(2).jsValue(); 439 JSValue right = OP_C(3).jsValue(); 440 double a = left.toNumber(exec); 441 double b = right.toNumber(exec); 442 JSValue result = jsNumber(a / b); 443 RETURN_WITH_PROFILING(result, { 444 updateResultProfileForBinaryArithOp(exec, pc, result, left, right); 445 }); 402 446 } 403 447
Note:
See TracChangeset
for help on using the changeset viewer.