| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2286 } | 2286 } |
| 2287 | 2287 |
| 2288 // Check for oddball objects. | 2288 // Check for oddball objects. |
| 2289 if (left->IsUndefined() && right->IsNumber()) return ODDBALL; | 2289 if (left->IsUndefined() && right->IsNumber()) return ODDBALL; |
| 2290 if (left->IsNumber() && right->IsUndefined()) return ODDBALL; | 2290 if (left->IsNumber() && right->IsUndefined()) return ODDBALL; |
| 2291 | 2291 |
| 2292 return GENERIC; | 2292 return GENERIC; |
| 2293 } | 2293 } |
| 2294 | 2294 |
| 2295 | 2295 |
| 2296 // defined in code-stubs-<arch>.cc | |
| 2297 // Only needed to remove dependency of ic.cc on code-stubs-<arch>.h. | |
| 2298 Handle<Code> GetUnaryOpStub(int key, UnaryOpIC::TypeInfo type_info); | |
| 2299 | |
| 2300 | |
| 2301 RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) { | 2296 RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) { |
| 2302 ASSERT(args.length() == 4); | 2297 ASSERT(args.length() == 4); |
| 2303 | 2298 |
| 2304 HandleScope scope(isolate); | 2299 HandleScope scope(isolate); |
| 2305 Handle<Object> operand = args.at<Object>(0); | 2300 Handle<Object> operand = args.at<Object>(0); |
| 2306 int key = Smi::cast(args[1])->value(); | 2301 int key = Smi::cast(args[1])->value(); |
| 2307 Token::Value op = static_cast<Token::Value>(Smi::cast(args[2])->value()); | 2302 Token::Value op = static_cast<Token::Value>(Smi::cast(args[2])->value()); |
| 2308 UnaryOpIC::TypeInfo previous_type = | 2303 UnaryOpIC::TypeInfo previous_type = |
| 2309 static_cast<UnaryOpIC::TypeInfo>(Smi::cast(args[3])->value()); | 2304 static_cast<UnaryOpIC::TypeInfo>(Smi::cast(args[3])->value()); |
| 2310 | 2305 |
| 2311 UnaryOpIC::TypeInfo type = UnaryOpIC::GetTypeInfo(operand); | 2306 UnaryOpIC::TypeInfo type = UnaryOpIC::GetTypeInfo(operand); |
| 2312 type = UnaryOpIC::ComputeNewType(type, previous_type); | 2307 type = UnaryOpIC::ComputeNewType(type, previous_type); |
| 2313 | 2308 |
| 2314 Handle<Code> code = GetUnaryOpStub(key, type); | 2309 UnaryOpStub stub(key, type); |
| 2310 Handle<Code> code = stub.GetCode(); |
| 2315 if (!code.is_null()) { | 2311 if (!code.is_null()) { |
| 2316 if (FLAG_trace_ic) { | 2312 if (FLAG_trace_ic) { |
| 2317 PrintF("[UnaryOpIC (%s->%s)#%s]\n", | 2313 PrintF("[UnaryOpIC (%s->%s)#%s]\n", |
| 2318 UnaryOpIC::GetName(previous_type), | 2314 UnaryOpIC::GetName(previous_type), |
| 2319 UnaryOpIC::GetName(type), | 2315 UnaryOpIC::GetName(type), |
| 2320 Token::Name(op)); | 2316 Token::Name(op)); |
| 2321 } | 2317 } |
| 2322 UnaryOpIC ic(isolate); | 2318 UnaryOpIC ic(isolate); |
| 2323 ic.patch(*code); | 2319 ic.patch(*code); |
| 2324 } | 2320 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2341 | 2337 |
| 2342 bool caught_exception; | 2338 bool caught_exception; |
| 2343 Handle<Object> result = Execution::Call(builtin_function, operand, 0, NULL, | 2339 Handle<Object> result = Execution::Call(builtin_function, operand, 0, NULL, |
| 2344 &caught_exception); | 2340 &caught_exception); |
| 2345 if (caught_exception) { | 2341 if (caught_exception) { |
| 2346 return Failure::Exception(); | 2342 return Failure::Exception(); |
| 2347 } | 2343 } |
| 2348 return *result; | 2344 return *result; |
| 2349 } | 2345 } |
| 2350 | 2346 |
| 2351 // defined in code-stubs-<arch>.cc | |
| 2352 // Only needed to remove dependency of ic.cc on code-stubs-<arch>.h. | |
| 2353 Handle<Code> GetBinaryOpStub(int key, | |
| 2354 BinaryOpIC::TypeInfo type_info, | |
| 2355 BinaryOpIC::TypeInfo result_type); | |
| 2356 | |
| 2357 | |
| 2358 RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) { | 2347 RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) { |
| 2359 ASSERT(args.length() == 5); | 2348 ASSERT(args.length() == 5); |
| 2360 | 2349 |
| 2361 HandleScope scope(isolate); | 2350 HandleScope scope(isolate); |
| 2362 Handle<Object> left = args.at<Object>(0); | 2351 Handle<Object> left = args.at<Object>(0); |
| 2363 Handle<Object> right = args.at<Object>(1); | 2352 Handle<Object> right = args.at<Object>(1); |
| 2364 int key = Smi::cast(args[2])->value(); | 2353 int key = Smi::cast(args[2])->value(); |
| 2365 Token::Value op = static_cast<Token::Value>(Smi::cast(args[3])->value()); | 2354 Token::Value op = static_cast<Token::Value>(Smi::cast(args[3])->value()); |
| 2366 BinaryOpIC::TypeInfo previous_type = | 2355 BinaryOpIC::TypeInfo previous_type = |
| 2367 static_cast<BinaryOpIC::TypeInfo>(Smi::cast(args[4])->value()); | 2356 static_cast<BinaryOpIC::TypeInfo>(Smi::cast(args[4])->value()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2386 } else { | 2375 } else { |
| 2387 // Other operations on SMIs that overflow yield int32s. | 2376 // Other operations on SMIs that overflow yield int32s. |
| 2388 result_type = BinaryOpIC::INT32; | 2377 result_type = BinaryOpIC::INT32; |
| 2389 } | 2378 } |
| 2390 } | 2379 } |
| 2391 if (type == BinaryOpIC::INT32 && previous_type == BinaryOpIC::INT32) { | 2380 if (type == BinaryOpIC::INT32 && previous_type == BinaryOpIC::INT32) { |
| 2392 // We must be here because an operation on two INT32 types overflowed. | 2381 // We must be here because an operation on two INT32 types overflowed. |
| 2393 result_type = BinaryOpIC::HEAP_NUMBER; | 2382 result_type = BinaryOpIC::HEAP_NUMBER; |
| 2394 } | 2383 } |
| 2395 | 2384 |
| 2396 Handle<Code> code = GetBinaryOpStub(key, type, result_type); | 2385 BinaryOpStub stub(key, type, result_type); |
| 2386 Handle<Code> code = stub.GetCode(); |
| 2397 if (!code.is_null()) { | 2387 if (!code.is_null()) { |
| 2398 if (FLAG_trace_ic) { | 2388 if (FLAG_trace_ic) { |
| 2399 PrintF("[BinaryOpIC (%s->(%s->%s))#%s]\n", | 2389 PrintF("[BinaryOpIC (%s->(%s->%s))#%s]\n", |
| 2400 BinaryOpIC::GetName(previous_type), | 2390 BinaryOpIC::GetName(previous_type), |
| 2401 BinaryOpIC::GetName(type), | 2391 BinaryOpIC::GetName(type), |
| 2402 BinaryOpIC::GetName(result_type), | 2392 BinaryOpIC::GetName(result_type), |
| 2403 Token::Name(op)); | 2393 Token::Name(op)); |
| 2404 } | 2394 } |
| 2405 BinaryOpIC ic(isolate); | 2395 BinaryOpIC ic(isolate); |
| 2406 ic.patch(*code); | 2396 ic.patch(*code); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2536 #undef ADDR | 2526 #undef ADDR |
| 2537 }; | 2527 }; |
| 2538 | 2528 |
| 2539 | 2529 |
| 2540 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2530 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2541 return IC_utilities[id]; | 2531 return IC_utilities[id]; |
| 2542 } | 2532 } |
| 2543 | 2533 |
| 2544 | 2534 |
| 2545 } } // namespace v8::internal | 2535 } } // namespace v8::internal |
| OLD | NEW |