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

Side by Side Diff: runtime/vm/stub_code_ia32.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_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 __ popl(EAX); // Get Code object. 387 __ popl(EAX); // Get Code object.
388 __ popl(EDX); // Restore arguments descriptor array. 388 __ popl(EDX); // Restore arguments descriptor array.
389 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); 389 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset()));
390 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); 390 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
391 __ LeaveFrame(); 391 __ LeaveFrame();
392 __ jmp(EAX); 392 __ jmp(EAX);
393 __ int3(); 393 __ int3();
394 } 394 }
395 395
396 396
397 // Called from object allocate instruction when the allocation stub has been
398 // disabled.
399 void StubCode::GenerateFixAllocationStubTargetStub(Assembler* assembler) {
400 const Immediate& raw_null =
401 Immediate(reinterpret_cast<intptr_t>(Object::null()));
402 __ EnterStubFrame();
403 __ pushl(raw_null); // Setup space on stack for return value.
404 __ CallRuntime(kFixAllocationStubTargetRuntimeEntry, 0);
405 __ popl(EAX); // Get Code object.
406 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset()));
407 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
408 __ LeaveFrame();
409 __ jmp(EAX);
410 __ int3();
411 }
412
413
397 // Input parameters: 414 // Input parameters:
398 // EDX: smi-tagged argument count, may be zero. 415 // EDX: smi-tagged argument count, may be zero.
399 // EBP[kParamEndSlotFromFp + 1]: last argument. 416 // EBP[kParamEndSlotFromFp + 1]: last argument.
400 // Uses EAX, EBX, ECX, EDX. 417 // Uses EAX, EBX, ECX, EDX.
401 static void PushArgumentsArray(Assembler* assembler) { 418 static void PushArgumentsArray(Assembler* assembler) {
402 const Immediate& raw_null = 419 const Immediate& raw_null =
403 Immediate(reinterpret_cast<intptr_t>(Object::null())); 420 Immediate(reinterpret_cast<intptr_t>(Object::null()));
404 StubCode* stub_code = Isolate::Current()->stub_code(); 421 StubCode* stub_code = Isolate::Current()->stub_code();
405 422
406 // Allocate array to store arguments of caller. 423 // Allocate array to store arguments of caller.
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 __ LeaveCallRuntimeFrame(); 1086 __ LeaveCallRuntimeFrame();
1070 __ ret(); 1087 __ ret();
1071 } 1088 }
1072 1089
1073 1090
1074 // Called for inline allocation of objects. 1091 // Called for inline allocation of objects.
1075 // Input parameters: 1092 // Input parameters:
1076 // ESP + 4 : type arguments object (only if class is parameterized). 1093 // ESP + 4 : type arguments object (only if class is parameterized).
1077 // ESP : points to return address. 1094 // ESP : points to return address.
1078 // Uses EAX, EBX, ECX, EDX, EDI as temporary registers. 1095 // Uses EAX, EBX, ECX, EDX, EDI as temporary registers.
1079 void StubCode::GenerateAllocationStubForClass(Assembler* assembler, 1096 // Returns patch_code_pc offset where patching code for disabling the stub
1080 const Class& cls) { 1097 // has been generated (similar to regularly generated Dart code).
1098 uword StubCode::GenerateAllocationStubForClass(Assembler* assembler,
1099 const Class& cls) {
1081 const intptr_t kObjectTypeArgumentsOffset = 1 * kWordSize; 1100 const intptr_t kObjectTypeArgumentsOffset = 1 * kWordSize;
1082 const Immediate& raw_null = 1101 const Immediate& raw_null =
1083 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1102 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1084 // The generated code is different if the class is parameterized. 1103 // The generated code is different if the class is parameterized.
1085 const bool is_cls_parameterized = cls.NumTypeArguments() > 0; 1104 const bool is_cls_parameterized = cls.NumTypeArguments() > 0;
1086 ASSERT(!is_cls_parameterized || 1105 ASSERT(!is_cls_parameterized ||
1087 (cls.type_arguments_field_offset() != Class::kNoTypeArguments)); 1106 (cls.type_arguments_field_offset() != Class::kNoTypeArguments));
1088 // kInlineInstanceSize is a constant used as a threshold for determining 1107 // kInlineInstanceSize is a constant used as a threshold for determining
1089 // when the object initialization should be done as a loop or as 1108 // when the object initialization should be done as a loop or as
1090 // straight line code. 1109 // straight line code.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 __ pushl(raw_null); // Push null type arguments. 1202 __ pushl(raw_null); // Push null type arguments.
1184 } 1203 }
1185 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object. 1204 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object.
1186 __ popl(EAX); // Pop argument (type arguments of object). 1205 __ popl(EAX); // Pop argument (type arguments of object).
1187 __ popl(EAX); // Pop argument (class of object). 1206 __ popl(EAX); // Pop argument (class of object).
1188 __ popl(EAX); // Pop result (newly allocated object). 1207 __ popl(EAX); // Pop result (newly allocated object).
1189 // EAX: new object 1208 // EAX: new object
1190 // Restore the frame pointer. 1209 // Restore the frame pointer.
1191 __ LeaveFrame(); 1210 __ LeaveFrame();
1192 __ ret(); 1211 __ ret();
1212 // Emit function patching code. This will be swapped with the first 5 bytes
1213 // at entry point.
1214 uword patch_code_pc_offset = assembler->CodeSize();
1215 StubCode* stub_code = Isolate::Current()->stub_code();
1216 __ jmp(&stub_code->FixAllocationStubTargetLabel());
1217 return patch_code_pc_offset;
1193 } 1218 }
1194 1219
1195 1220
1196 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function 1221 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function
1197 // from the entry code of a dart function after an error in passed argument 1222 // from the entry code of a dart function after an error in passed argument
1198 // name or number is detected. 1223 // name or number is detected.
1199 // Input parameters: 1224 // Input parameters:
1200 // ESP : points to return address. 1225 // ESP : points to return address.
1201 // ESP + 4 : address of last argument. 1226 // ESP + 4 : address of last argument.
1202 // EDX : arguments descriptor array. 1227 // EDX : arguments descriptor array.
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 const Register temp = ECX; 2052 const Register temp = ECX;
2028 __ movl(left, Address(ESP, 2 * kWordSize)); 2053 __ movl(left, Address(ESP, 2 * kWordSize));
2029 __ movl(right, Address(ESP, 1 * kWordSize)); 2054 __ movl(right, Address(ESP, 1 * kWordSize));
2030 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 2055 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
2031 __ ret(); 2056 __ ret();
2032 } 2057 }
2033 2058
2034 } // namespace dart 2059 } // namespace dart
2035 2060
2036 #endif // defined TARGET_ARCH_IA32 2061 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698