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

Side by Side Diff: runtime/vm/stub_code_arm.cc

Issue 557913002: Allow invalidation and recompilation of instance allocation stubs. Requested in order to implement… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 __ PopList((1 << R0) | (1 << R4)); 386 __ PopList((1 << R0) | (1 << R4));
387 // Remove the stub frame. 387 // Remove the stub frame.
388 __ LeaveStubFrame(); 388 __ LeaveStubFrame();
389 // Jump to the dart function. 389 // Jump to the dart function.
390 __ ldr(R0, FieldAddress(R0, Code::instructions_offset())); 390 __ ldr(R0, FieldAddress(R0, Code::instructions_offset()));
391 __ AddImmediate(R0, R0, Instructions::HeaderSize() - kHeapObjectTag); 391 __ AddImmediate(R0, R0, Instructions::HeaderSize() - kHeapObjectTag);
392 __ bx(R0); 392 __ bx(R0);
393 } 393 }
394 394
395 395
396 // Called from object allocate instruction when the allocation stub has been
397 // disabled.
398 void StubCode::GenerateFixAllocationStubTargetStub(Assembler* assembler) {
399 __ EnterStubFrame();
400 // Setup space on stack for return value.
401 __ LoadImmediate(R0, reinterpret_cast<intptr_t>(Object::null()));
402 __ Push(R0);
403 __ CallRuntime(kFixAllocationStubTargetRuntimeEntry, 0);
404 // Get Code object result.
405 __ Pop(R0);
406 // Remove the stub frame.
407 __ LeaveStubFrame();
408 // Jump to the dart function.
409 __ ldr(R0, FieldAddress(R0, Code::instructions_offset()));
410 __ AddImmediate(R0, R0, Instructions::HeaderSize() - kHeapObjectTag);
411 __ bx(R0);
412 }
413
414
396 // Input parameters: 415 // Input parameters:
397 // R2: smi-tagged argument count, may be zero. 416 // R2: smi-tagged argument count, may be zero.
398 // FP[kParamEndSlotFromFp + 1]: last argument. 417 // FP[kParamEndSlotFromFp + 1]: last argument.
399 static void PushArgumentsArray(Assembler* assembler) { 418 static void PushArgumentsArray(Assembler* assembler) {
400 StubCode* stub_code = Isolate::Current()->stub_code(); 419 StubCode* stub_code = Isolate::Current()->stub_code();
401 // Allocate array to store arguments of caller. 420 // Allocate array to store arguments of caller.
402 __ LoadImmediate(R1, reinterpret_cast<intptr_t>(Object::null())); 421 __ LoadImmediate(R1, reinterpret_cast<intptr_t>(Object::null()));
403 // R1: null element type for raw Array. 422 // R1: null element type for raw Array.
404 // R2: smi-tagged argument count, may be zero. 423 // R2: smi-tagged argument count, may be zero.
405 __ BranchLink(&stub_code->AllocateArrayLabel()); 424 __ BranchLink(&stub_code->AllocateArrayLabel());
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 // Restore callee-saved registers, tear down frame. 1039 // Restore callee-saved registers, tear down frame.
1021 __ LeaveCallRuntimeFrame(); 1040 __ LeaveCallRuntimeFrame();
1022 __ Ret(); 1041 __ Ret();
1023 } 1042 }
1024 1043
1025 1044
1026 // Called for inline allocation of objects. 1045 // Called for inline allocation of objects.
1027 // Input parameters: 1046 // Input parameters:
1028 // LR : return address. 1047 // LR : return address.
1029 // SP + 0 : type arguments object (only if class is parameterized). 1048 // SP + 0 : type arguments object (only if class is parameterized).
1030 void StubCode::GenerateAllocationStubForClass(Assembler* assembler, 1049 // Returns patch_code_pc offset where patching code for disabling the stub
1031 const Class& cls) { 1050 // has been generated (similar to regularly generated Dart code).
1051 uword StubCode::GenerateAllocationStubForClass(Assembler* assembler,
1052 const Class& cls) {
1032 // The generated code is different if the class is parameterized. 1053 // The generated code is different if the class is parameterized.
1033 const bool is_cls_parameterized = cls.NumTypeArguments() > 0; 1054 const bool is_cls_parameterized = cls.NumTypeArguments() > 0;
1034 ASSERT(!is_cls_parameterized || 1055 ASSERT(!is_cls_parameterized ||
1035 (cls.type_arguments_field_offset() != Class::kNoTypeArguments)); 1056 (cls.type_arguments_field_offset() != Class::kNoTypeArguments));
1036 // kInlineInstanceSize is a constant used as a threshold for determining 1057 // kInlineInstanceSize is a constant used as a threshold for determining
1037 // when the object initialization should be done as a loop or as 1058 // when the object initialization should be done as a loop or as
1038 // straight line code. 1059 // straight line code.
1039 const int kInlineInstanceSize = 12; 1060 const int kInlineInstanceSize = 12;
1040 const intptr_t instance_size = cls.instance_size(); 1061 const intptr_t instance_size = cls.instance_size();
1041 ASSERT(instance_size > 0); 1062 ASSERT(instance_size > 0);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 // Push null type arguments. 1160 // Push null type arguments.
1140 __ Push(R2); 1161 __ Push(R2);
1141 } 1162 }
1142 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object. 1163 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object.
1143 __ Drop(2); // Pop arguments. 1164 __ Drop(2); // Pop arguments.
1144 __ Pop(R0); // Pop result (newly allocated object). 1165 __ Pop(R0); // Pop result (newly allocated object).
1145 // R0: new object 1166 // R0: new object
1146 // Restore the frame pointer. 1167 // Restore the frame pointer.
1147 __ LeaveStubFrame(); 1168 __ LeaveStubFrame();
1148 __ Ret(); 1169 __ Ret();
1170 uword patch_code_pc_offset = assembler->CodeSize();
1171 StubCode* stub_code = Isolate::Current()->stub_code();
1172 __ BranchPatchable(&stub_code->FixAllocationStubTargetLabel());
1173 return patch_code_pc_offset;
1149 } 1174 }
1150 1175
1151 1176
1152 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function 1177 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function
1153 // from the entry code of a dart function after an error in passed argument 1178 // from the entry code of a dart function after an error in passed argument
1154 // name or number is detected. 1179 // name or number is detected.
1155 // Input parameters: 1180 // Input parameters:
1156 // LR : return address. 1181 // LR : return address.
1157 // SP : address of last argument. 1182 // SP : address of last argument.
1158 // R4: arguments descriptor array. 1183 // R4: arguments descriptor array.
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 const Register right = R0; 1971 const Register right = R0;
1947 __ ldr(left, Address(SP, 1 * kWordSize)); 1972 __ ldr(left, Address(SP, 1 * kWordSize));
1948 __ ldr(right, Address(SP, 0 * kWordSize)); 1973 __ ldr(right, Address(SP, 0 * kWordSize));
1949 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 1974 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
1950 __ Ret(); 1975 __ Ret();
1951 } 1976 }
1952 1977
1953 } // namespace dart 1978 } // namespace dart
1954 1979
1955 #endif // defined TARGET_ARCH_ARM 1980 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698