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

Side by Side Diff: src/arm/builtins-arm.cc

Issue 9016041: Ensure that InternalArrays remain InternalArrays regardless of how they are constructed. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix whitespace Created 8 years, 12 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 | « no previous file | src/bootstrapper.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 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); 65 ASSERT(extra_args == NO_EXTRA_ARGUMENTS);
66 } 66 }
67 67
68 // JumpToExternalReference expects r0 to contain the number of arguments 68 // JumpToExternalReference expects r0 to contain the number of arguments
69 // including the receiver and the extra arguments. 69 // including the receiver and the extra arguments.
70 __ add(r0, r0, Operand(num_extra_args + 1)); 70 __ add(r0, r0, Operand(num_extra_args + 1));
71 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); 71 __ JumpToExternalReference(ExternalReference(id, masm->isolate()));
72 } 72 }
73 73
74 74
75 // Load the built-in InternalArray function from the current context.
76 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm,
77 Register result) {
78 // Load the global context.
79
80 __ ldr(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
81 __ ldr(result,
82 FieldMemOperand(result, GlobalObject::kGlobalContextOffset));
83 // Load the InternalArray function from the global context.
84 __ ldr(result,
85 MemOperand(result,
86 Context::SlotOffset(
87 Context::INTERNAL_ARRAY_FUNCTION_INDEX)));
88 }
89
90
75 // Load the built-in Array function from the current context. 91 // Load the built-in Array function from the current context.
76 static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { 92 static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
77 // Load the global context. 93 // Load the global context.
78 94
79 __ ldr(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); 95 __ ldr(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
80 __ ldr(result, 96 __ ldr(result,
81 FieldMemOperand(result, GlobalObject::kGlobalContextOffset)); 97 FieldMemOperand(result, GlobalObject::kGlobalContextOffset));
82 // Load the Array function from the global context. 98 // Load the Array function from the global context.
83 __ ldr(result, 99 __ ldr(result,
84 MemOperand(result, 100 MemOperand(result,
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // return. 427 // return.
412 // r0: argc 428 // r0: argc
413 // r3: JSArray 429 // r3: JSArray
414 // sp[0]: receiver 430 // sp[0]: receiver
415 __ add(sp, sp, Operand(kPointerSize)); 431 __ add(sp, sp, Operand(kPointerSize));
416 __ mov(r0, r3); 432 __ mov(r0, r3);
417 __ Jump(lr); 433 __ Jump(lr);
418 } 434 }
419 435
420 436
437 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
438 // ----------- S t a t e -------------
439 // -- r0 : number of arguments
440 // -- lr : return address
441 // -- sp[...]: constructor arguments
442 // -----------------------------------
443 Label generic_array_code, one_or_more_arguments, two_or_more_arguments;
444
445 // Get the InternalArray function.
446 GenerateLoadInternalArrayFunction(masm, r1);
447
448 if (FLAG_debug_code) {
449 // Initial map for the builtin InternalArray functions should be maps.
450 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
451 __ tst(r2, Operand(kSmiTagMask));
452 __ Assert(ne, "Unexpected initial map for InternalArray function");
453 __ CompareObjectType(r2, r3, r4, MAP_TYPE);
454 __ Assert(eq, "Unexpected initial map for InternalArray function");
455 }
456
457 // Run the native code for the InternalArray function called as a normal
458 // function.
459 ArrayNativeCode(masm, &generic_array_code);
460
461 // Jump to the generic array code if the specialized code cannot handle the
462 // construction.
463 __ bind(&generic_array_code);
464
465 Handle<Code> array_code =
466 masm->isolate()->builtins()->ArrayCodeGeneric();
467 __ Jump(array_code, RelocInfo::CODE_TARGET);
468 }
469
470
421 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { 471 void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
422 // ----------- S t a t e ------------- 472 // ----------- S t a t e -------------
423 // -- r0 : number of arguments 473 // -- r0 : number of arguments
424 // -- lr : return address 474 // -- lr : return address
425 // -- sp[...]: constructor arguments 475 // -- sp[...]: constructor arguments
426 // ----------------------------------- 476 // -----------------------------------
427 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; 477 Label generic_array_code, one_or_more_arguments, two_or_more_arguments;
428 478
429 // Get the Array function. 479 // Get the Array function.
430 GenerateLoadArrayFunction(masm, r1); 480 GenerateLoadArrayFunction(masm, r1);
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 __ bind(&dont_adapt_arguments); 1769 __ bind(&dont_adapt_arguments);
1720 __ Jump(r3); 1770 __ Jump(r3);
1721 } 1771 }
1722 1772
1723 1773
1724 #undef __ 1774 #undef __
1725 1775
1726 } } // namespace v8::internal 1776 } } // namespace v8::internal
1727 1777
1728 #endif // V8_TARGET_ARCH_ARM 1778 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698