Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1443)

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 19793005: Turn ToNumberStub into a hydrogen code stub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/code-stubs.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 ASSERT(descriptor->stack_parameter_count_ == NULL); 300 ASSERT(descriptor->stack_parameter_count_ == NULL);
301 return stub->GenerateLightweightMissCode(isolate); 301 return stub->GenerateLightweightMissCode(isolate);
302 } 302 }
303 CodeStubGraphBuilder<Stub> builder(stub); 303 CodeStubGraphBuilder<Stub> builder(stub);
304 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 304 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
305 return chunk->Codegen(); 305 return chunk->Codegen();
306 } 306 }
307 307
308 308
309 template <> 309 template <>
310 HValue* CodeStubGraphBuilder<ToNumberStub>::BuildCodeStub() {
311 HValue* value = GetParameter(0);
312
313 // Check if the parameter is already a SMI or heap number.
314 IfBuilder if_number(this);
315 if_number.If<HIsSmiAndBranch>(value);
316 if_number.OrIf<HCompareMap>(value, isolate()->factory()->heap_number_map());
317 if_number.Then();
318
319 // Return the number.
320 Push(value);
321
322 if_number.Else();
323
324 // Convert the parameter to number using the builtin.
325 HValue* function = AddLoadJSBuiltin(Builtins::TO_NUMBER, context());
326 Add<HPushArgument>(value);
327 Push(Add<HInvokeFunction>(context(), function, 1));
328
329 if_number.End();
330
331 return Pop();
332 }
333
334
335 Handle<Code> ToNumberStub::GenerateCode() {
336 return DoGenerateCode(this);
337 }
338
339
340 template <>
310 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { 341 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
311 Zone* zone = this->zone(); 342 Zone* zone = this->zone();
312 Factory* factory = isolate()->factory(); 343 Factory* factory = isolate()->factory();
313 HValue* undefined = graph()->GetConstantUndefined(); 344 HValue* undefined = graph()->GetConstantUndefined();
314 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); 345 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode();
315 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); 346 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode();
316 int length = casted_stub()->length(); 347 int length = casted_stub()->length();
317 348
318 HInstruction* allocation_site = 349 HInstruction* allocation_site =
319 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), 350 AddInstruction(new(zone) HLoadKeyed(GetParameter(0),
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 return value; 945 return value;
915 } 946 }
916 947
917 948
918 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() { 949 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() {
919 return DoGenerateCode(this); 950 return DoGenerateCode(this);
920 } 951 }
921 952
922 953
923 } } // namespace v8::internal 954 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698