| 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/bailout-reason.h" | 7 #include "src/bailout-reason.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/field-index.h" | 9 #include "src/field-index.h" |
| 10 #include "src/hydrogen.h" | 10 #include "src/hydrogen.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 if (FLAG_profile_hydrogen_code_stub_compilation) { | 277 if (FLAG_profile_hydrogen_code_stub_compilation) { |
| 278 OFStream os(stdout); | 278 OFStream os(stdout); |
| 279 os << "[Lazy compilation of " << stub << " took " | 279 os << "[Lazy compilation of " << stub << " took " |
| 280 << timer.Elapsed().InMillisecondsF() << " ms]" << std::endl; | 280 << timer.Elapsed().InMillisecondsF() << " ms]" << std::endl; |
| 281 } | 281 } |
| 282 return code; | 282 return code; |
| 283 } | 283 } |
| 284 | 284 |
| 285 | 285 |
| 286 template <> | 286 template <> |
| 287 HValue* CodeStubGraphBuilder<ToNumberStub>::BuildCodeStub() { | |
| 288 HValue* value = GetParameter(0); | |
| 289 | |
| 290 // Check if the parameter is already a SMI or heap number. | |
| 291 IfBuilder if_number(this); | |
| 292 if_number.If<HIsSmiAndBranch>(value); | |
| 293 if_number.OrIf<HCompareMap>(value, isolate()->factory()->heap_number_map()); | |
| 294 if_number.Then(); | |
| 295 | |
| 296 // Return the number. | |
| 297 Push(value); | |
| 298 | |
| 299 if_number.Else(); | |
| 300 | |
| 301 // Convert the parameter to number using the builtin. | |
| 302 HValue* function = AddLoadJSBuiltin(Builtins::TO_NUMBER); | |
| 303 Add<HPushArguments>(value); | |
| 304 Push(Add<HInvokeFunction>(function, 1)); | |
| 305 | |
| 306 if_number.End(); | |
| 307 | |
| 308 return Pop(); | |
| 309 } | |
| 310 | |
| 311 | |
| 312 Handle<Code> ToNumberStub::GenerateCode() { | |
| 313 return DoGenerateCode(this); | |
| 314 } | |
| 315 | |
| 316 | |
| 317 template <> | |
| 318 HValue* CodeStubGraphBuilder<NumberToStringStub>::BuildCodeStub() { | 287 HValue* CodeStubGraphBuilder<NumberToStringStub>::BuildCodeStub() { |
| 319 info()->MarkAsSavesCallerDoubles(); | 288 info()->MarkAsSavesCallerDoubles(); |
| 320 HValue* number = GetParameter(NumberToStringStub::kNumber); | 289 HValue* number = GetParameter(NumberToStringStub::kNumber); |
| 321 return BuildNumberToString(number, Type::Number(zone())); | 290 return BuildNumberToString(number, Type::Number(zone())); |
| 322 } | 291 } |
| 323 | 292 |
| 324 | 293 |
| 325 Handle<Code> NumberToStringStub::GenerateCode() { | 294 Handle<Code> NumberToStringStub::GenerateCode() { |
| 326 return DoGenerateCode(this); | 295 return DoGenerateCode(this); |
| 327 } | 296 } |
| (...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 | 2004 |
| 2036 // Probe the stub cache. | 2005 // Probe the stub cache. |
| 2037 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( | 2006 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( |
| 2038 Code::ComputeHandlerFlags(Code::LOAD_IC)); | 2007 Code::ComputeHandlerFlags(Code::LOAD_IC)); |
| 2039 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); | 2008 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); |
| 2040 | 2009 |
| 2041 // We never continue. | 2010 // We never continue. |
| 2042 return graph()->GetConstant0(); | 2011 return graph()->GetConstant0(); |
| 2043 } | 2012 } |
| 2044 } } // namespace v8::internal | 2013 } } // namespace v8::internal |
| OLD | NEW |