OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 2490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2501 BinaryOpICState state(isolate(), target()->extra_ic_state()); | 2501 BinaryOpICState state(isolate(), target()->extra_ic_state()); |
2502 | 2502 |
2503 // Compute the actual result using the builtin for the binary operation. | 2503 // Compute the actual result using the builtin for the binary operation. |
2504 Object* builtin = isolate()->js_builtins_object()->javascript_builtin( | 2504 Object* builtin = isolate()->js_builtins_object()->javascript_builtin( |
2505 TokenToJSBuiltin(state.op())); | 2505 TokenToJSBuiltin(state.op())); |
2506 Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate()); | 2506 Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate()); |
2507 Handle<Object> result; | 2507 Handle<Object> result; |
2508 ASSIGN_RETURN_ON_EXCEPTION( | 2508 ASSIGN_RETURN_ON_EXCEPTION( |
2509 isolate(), result, Execution::Call(isolate(), function, left, 1, &right), | 2509 isolate(), result, Execution::Call(isolate(), function, left, 1, &right), |
2510 Object); | 2510 Object); |
2511 if (result->IsHeapNumber()) { | |
2512 // If the result of this BinaryOpIC is used as left or right hand side of | |
2513 // another binary operation, full-codegen.cc might have decided that its | |
2514 // safe to reuse the double box returned by this BinaryOpIC, but the builtin | |
2515 // above does not know or care about this fact and might return a canonical | |
2516 // value (i.e. the global minus zero constant), which we would then | |
2517 // overwrite in the surrounding binary operation. So to be safe, we need to | |
2518 // take a copy of heap numbers here. | |
2519 result = isolate()->factory()->NewHeapNumber(result->Number()); | |
2520 } | |
2521 DCHECK(!result.is_identical_to(isolate()->factory()->nan_value())); | |
2522 DCHECK(!result.is_identical_to(isolate()->factory()->infinity_value())); | |
2523 DCHECK(!result.is_identical_to(isolate()->factory()->minus_zero_value())); | |
2524 | 2511 |
2525 // Execution::Call can execute arbitrary JavaScript, hence potentially | 2512 // Execution::Call can execute arbitrary JavaScript, hence potentially |
2526 // update the state of this very IC, so we must update the stored state. | 2513 // update the state of this very IC, so we must update the stored state. |
2527 UpdateTarget(); | 2514 UpdateTarget(); |
2528 // Compute the new state. | 2515 // Compute the new state. |
2529 BinaryOpICState old_state(isolate(), target()->extra_ic_state()); | 2516 BinaryOpICState old_state(isolate(), target()->extra_ic_state()); |
2530 state.Update(left, right, result); | 2517 state.Update(left, right, result); |
2531 | 2518 |
2532 // Check if we have a string operation here. | 2519 // Check if we have a string operation here. |
2533 Handle<Code> target; | 2520 Handle<Code> target; |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3002 static const Address IC_utilities[] = { | 2989 static const Address IC_utilities[] = { |
3003 #define ADDR(name) FUNCTION_ADDR(name), | 2990 #define ADDR(name) FUNCTION_ADDR(name), |
3004 IC_UTIL_LIST(ADDR) NULL | 2991 IC_UTIL_LIST(ADDR) NULL |
3005 #undef ADDR | 2992 #undef ADDR |
3006 }; | 2993 }; |
3007 | 2994 |
3008 | 2995 |
3009 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 2996 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
3010 } | 2997 } |
3011 } // namespace v8::internal | 2998 } // namespace v8::internal |
OLD | NEW |