OLD | NEW |
| (Empty) |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | |
2 // Redistribution and use in source and binary forms, with or without | |
3 // modification, are permitted provided that the following conditions are | |
4 // met: | |
5 // | |
6 // * Redistributions of source code must retain the above copyright | |
7 // notice, this list of conditions and the following disclaimer. | |
8 // * Redistributions in binary form must reproduce the above | |
9 // copyright notice, this list of conditions and the following | |
10 // disclaimer in the documentation and/or other materials provided | |
11 // with the distribution. | |
12 // * Neither the name of Google Inc. nor the names of its | |
13 // contributors may be used to endorse or promote products derived | |
14 // from this software without specific prior written permission. | |
15 // | |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 | |
28 #include "v8.h" | |
29 | |
30 #include "ic-inl.h" | |
31 #include "codegen-inl.h" | |
32 #include "stub-cache.h" | |
33 | |
34 namespace v8 { namespace internal { | |
35 | |
36 #define __ ACCESS_MASM(masm) | |
37 | |
38 | |
39 static void ProbeTable(MacroAssembler* masm, | |
40 Code::Flags flags, | |
41 StubCache::Table table, | |
42 Register name, | |
43 Register offset) { | |
44 ExternalReference key_offset(SCTableReference::keyReference(table)); | |
45 ExternalReference value_offset(SCTableReference::valueReference(table)); | |
46 | |
47 Label miss; | |
48 | |
49 // Save the offset on the stack. | |
50 __ push(offset); | |
51 | |
52 // Check that the key in the entry matches the name. | |
53 __ cmp(name, Operand::StaticArray(offset, times_2, key_offset)); | |
54 __ j(not_equal, &miss, not_taken); | |
55 | |
56 // Get the code entry from the cache. | |
57 __ mov(offset, Operand::StaticArray(offset, times_2, value_offset)); | |
58 | |
59 // Check that the flags match what we're looking for. | |
60 __ mov(offset, FieldOperand(offset, Code::kFlagsOffset)); | |
61 __ and_(offset, ~Code::kFlagsTypeMask); | |
62 __ cmp(offset, flags); | |
63 __ j(not_equal, &miss); | |
64 | |
65 // Restore offset and re-load code entry from cache. | |
66 __ pop(offset); | |
67 __ mov(offset, Operand::StaticArray(offset, times_2, value_offset)); | |
68 | |
69 // Jump to the first instruction in the code stub. | |
70 __ add(Operand(offset), Immediate(Code::kHeaderSize - kHeapObjectTag)); | |
71 __ jmp(Operand(offset)); | |
72 | |
73 // Miss: Restore offset and fall through. | |
74 __ bind(&miss); | |
75 __ pop(offset); | |
76 } | |
77 | |
78 | |
79 void StubCache::GenerateProbe(MacroAssembler* masm, | |
80 Code::Flags flags, | |
81 Register receiver, | |
82 Register name, | |
83 Register scratch) { | |
84 Label miss; | |
85 | |
86 // Make sure that code is valid. The shifting code relies on the | |
87 // entry size being 8. | |
88 ASSERT(sizeof(Entry) == 8); | |
89 | |
90 // Make sure the flags does not name a specific type. | |
91 ASSERT(Code::ExtractTypeFromFlags(flags) == 0); | |
92 | |
93 // Make sure that there are no register conflicts. | |
94 ASSERT(!scratch.is(receiver)); | |
95 ASSERT(!scratch.is(name)); | |
96 | |
97 // Check that the receiver isn't a smi. | |
98 __ test(receiver, Immediate(kSmiTagMask)); | |
99 __ j(zero, &miss, not_taken); | |
100 | |
101 // Get the map of the receiver and compute the hash. | |
102 __ mov(scratch, FieldOperand(name, String::kLengthOffset)); | |
103 __ add(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | |
104 __ xor_(scratch, flags); | |
105 __ and_(scratch, (kPrimaryTableSize - 1) << kHeapObjectTagSize); | |
106 | |
107 // Probe the primary table. | |
108 ProbeTable(masm, flags, kPrimary, name, scratch); | |
109 | |
110 // Primary miss: Compute hash for secondary probe. | |
111 __ sub(scratch, Operand(name)); | |
112 __ add(Operand(scratch), Immediate(flags)); | |
113 __ and_(scratch, (kSecondaryTableSize - 1) << kHeapObjectTagSize); | |
114 | |
115 // Probe the secondary table. | |
116 ProbeTable(masm, flags, kSecondary, name, scratch); | |
117 | |
118 // Cache miss: Fall-through and let caller handle the miss by | |
119 // entering the runtime system. | |
120 __ bind(&miss); | |
121 } | |
122 | |
123 | |
124 void StubCompiler::GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, | |
125 int index, | |
126 Register prototype) { | |
127 // Load the global or builtins object from the current context. | |
128 __ mov(prototype, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | |
129 // Load the global context from the global or builtins object. | |
130 __ mov(prototype, | |
131 FieldOperand(prototype, GlobalObject::kGlobalContextOffset)); | |
132 // Load the function from the global context. | |
133 __ mov(prototype, Operand(prototype, Context::SlotOffset(index))); | |
134 // Load the initial map. The global functions all have initial maps. | |
135 __ mov(prototype, | |
136 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); | |
137 // Load the prototype from the initial map. | |
138 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); | |
139 } | |
140 | |
141 | |
142 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, | |
143 Register receiver, | |
144 Register scratch, | |
145 Label* miss_label) { | |
146 // Check that the receiver isn't a smi. | |
147 __ test(receiver, Immediate(kSmiTagMask)); | |
148 __ j(zero, miss_label, not_taken); | |
149 | |
150 // Check that the object is a JS array. | |
151 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch); | |
152 __ j(not_equal, miss_label, not_taken); | |
153 | |
154 // Load length directly from the JS array. | |
155 __ mov(eax, FieldOperand(receiver, JSArray::kLengthOffset)); | |
156 __ ret(0); | |
157 } | |
158 | |
159 | |
160 // Generate code to check if an object is a string. If the object is | |
161 // a string, the map's instance type is left in the scratch register. | |
162 static void GenerateStringCheck(MacroAssembler* masm, | |
163 Register receiver, | |
164 Register scratch, | |
165 Label* smi, | |
166 Label* non_string_object) { | |
167 // Check that the object isn't a smi. | |
168 __ test(receiver, Immediate(kSmiTagMask)); | |
169 __ j(zero, smi, not_taken); | |
170 | |
171 // Check that the object is a string. | |
172 __ mov(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | |
173 __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); | |
174 ASSERT(kNotStringTag != 0); | |
175 __ test(scratch, Immediate(kNotStringTag)); | |
176 __ j(not_zero, non_string_object, not_taken); | |
177 } | |
178 | |
179 | |
180 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, | |
181 Register receiver, | |
182 Register scratch, | |
183 Label* miss) { | |
184 Label load_length, check_wrapper; | |
185 | |
186 // Check if the object is a string leaving the instance type in the | |
187 // scratch register. | |
188 GenerateStringCheck(masm, receiver, scratch, miss, &check_wrapper); | |
189 | |
190 // Load length directly from the string. | |
191 __ bind(&load_length); | |
192 __ and_(scratch, kStringSizeMask); | |
193 __ mov(eax, FieldOperand(receiver, String::kLengthOffset)); | |
194 // ecx is also the receiver. | |
195 __ lea(ecx, Operand(scratch, String::kLongLengthShift)); | |
196 __ shr(eax); // ecx is implicit shift register. | |
197 __ shl(eax, kSmiTagSize); | |
198 __ ret(0); | |
199 | |
200 // Check if the object is a JSValue wrapper. | |
201 __ bind(&check_wrapper); | |
202 __ cmp(scratch, JS_VALUE_TYPE); | |
203 __ j(not_equal, miss, not_taken); | |
204 | |
205 // Check if the wrapped value is a string and load the length | |
206 // directly if it is. | |
207 __ mov(receiver, FieldOperand(receiver, JSValue::kValueOffset)); | |
208 GenerateStringCheck(masm, receiver, scratch, miss, miss); | |
209 __ jmp(&load_length); | |
210 } | |
211 | |
212 | |
213 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, | |
214 Register receiver, | |
215 Register scratch1, | |
216 Register scratch2, | |
217 Label* miss_label) { | |
218 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | |
219 __ mov(eax, Operand(scratch1)); | |
220 __ ret(0); | |
221 } | |
222 | |
223 | |
224 // Load a fast property out of a holder object (src). In-object properties | |
225 // are loaded directly otherwise the property is loaded from the properties | |
226 // fixed array. | |
227 void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm, | |
228 Register dst, Register src, | |
229 JSObject* holder, int index) { | |
230 // Adjust for the number of properties stored in the holder. | |
231 index -= holder->map()->inobject_properties(); | |
232 if (index < 0) { | |
233 // Get the property straight out of the holder. | |
234 int offset = holder->map()->instance_size() + (index * kPointerSize); | |
235 __ mov(dst, FieldOperand(src, offset)); | |
236 } else { | |
237 // Calculate the offset into the properties array. | |
238 int offset = index * kPointerSize + Array::kHeaderSize; | |
239 __ mov(dst, FieldOperand(src, JSObject::kPropertiesOffset)); | |
240 __ mov(dst, FieldOperand(dst, offset)); | |
241 } | |
242 } | |
243 | |
244 | |
245 void StubCompiler::GenerateLoadField(MacroAssembler* masm, | |
246 JSObject* object, | |
247 JSObject* holder, | |
248 Register receiver, | |
249 Register scratch1, | |
250 Register scratch2, | |
251 int index, | |
252 Label* miss_label) { | |
253 // Check that the receiver isn't a smi. | |
254 __ test(receiver, Immediate(kSmiTagMask)); | |
255 __ j(zero, miss_label, not_taken); | |
256 | |
257 // Check that the maps haven't changed. | |
258 Register reg = | |
259 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | |
260 | |
261 // Get the value from the properties. | |
262 GenerateFastPropertyLoad(masm, eax, reg, holder, index); | |
263 __ ret(0); | |
264 } | |
265 | |
266 | |
267 void StubCompiler::GenerateLoadCallback(MacroAssembler* masm, | |
268 JSObject* object, | |
269 JSObject* holder, | |
270 Register receiver, | |
271 Register name, | |
272 Register scratch1, | |
273 Register scratch2, | |
274 AccessorInfo* callback, | |
275 Label* miss_label) { | |
276 // Check that the receiver isn't a smi. | |
277 __ test(receiver, Immediate(kSmiTagMask)); | |
278 __ j(zero, miss_label, not_taken); | |
279 | |
280 // Check that the maps haven't changed. | |
281 Register reg = | |
282 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | |
283 | |
284 // Push the arguments on the JS stack of the caller. | |
285 __ pop(scratch2); // remove return address | |
286 __ push(receiver); // receiver | |
287 __ push(Immediate(Handle<AccessorInfo>(callback))); // callback data | |
288 __ push(name); // name | |
289 __ push(reg); // holder | |
290 __ push(scratch2); // restore return address | |
291 | |
292 // Do tail-call to the runtime system. | |
293 ExternalReference load_callback_property = | |
294 ExternalReference(IC_Utility(IC::kLoadCallbackProperty)); | |
295 __ TailCallRuntime(load_callback_property, 4); | |
296 } | |
297 | |
298 | |
299 void StubCompiler::GenerateLoadConstant(MacroAssembler* masm, | |
300 JSObject* object, | |
301 JSObject* holder, | |
302 Register receiver, | |
303 Register scratch1, | |
304 Register scratch2, | |
305 Object* value, | |
306 Label* miss_label) { | |
307 // Check that the receiver isn't a smi. | |
308 __ test(receiver, Immediate(kSmiTagMask)); | |
309 __ j(zero, miss_label, not_taken); | |
310 | |
311 // Check that the maps haven't changed. | |
312 Register reg = | |
313 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | |
314 | |
315 // Return the constant value. | |
316 __ mov(eax, Handle<Object>(value)); | |
317 __ ret(0); | |
318 } | |
319 | |
320 | |
321 void StubCompiler::GenerateLoadInterceptor(MacroAssembler* masm, | |
322 JSObject* object, | |
323 JSObject* holder, | |
324 Register receiver, | |
325 Register name, | |
326 Register scratch1, | |
327 Register scratch2, | |
328 Label* miss_label) { | |
329 // Check that the receiver isn't a smi. | |
330 __ test(receiver, Immediate(kSmiTagMask)); | |
331 __ j(zero, miss_label, not_taken); | |
332 | |
333 // Check that the maps haven't changed. | |
334 Register reg = | |
335 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | |
336 | |
337 // Push the arguments on the JS stack of the caller. | |
338 __ pop(scratch2); // remove return address | |
339 __ push(receiver); // receiver | |
340 __ push(reg); // holder | |
341 __ push(name); // name | |
342 __ push(scratch2); // restore return address | |
343 | |
344 // Do tail-call to the runtime system. | |
345 ExternalReference load_ic_property = | |
346 ExternalReference(IC_Utility(IC::kLoadInterceptorProperty)); | |
347 __ TailCallRuntime(load_ic_property, 3); | |
348 } | |
349 | |
350 | |
351 void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) { | |
352 ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC); | |
353 Code* code = NULL; | |
354 if (kind == Code::LOAD_IC) { | |
355 code = Builtins::builtin(Builtins::LoadIC_Miss); | |
356 } else { | |
357 code = Builtins::builtin(Builtins::KeyedLoadIC_Miss); | |
358 } | |
359 | |
360 Handle<Code> ic(code); | |
361 __ jmp(ic, RelocInfo::CODE_TARGET); | |
362 } | |
363 | |
364 | |
365 void StubCompiler::GenerateStoreField(MacroAssembler* masm, | |
366 Builtins::Name storage_extend, | |
367 JSObject* object, | |
368 int index, | |
369 Map* transition, | |
370 Register receiver_reg, | |
371 Register name_reg, | |
372 Register scratch, | |
373 Label* miss_label) { | |
374 // Check that the object isn't a smi. | |
375 __ test(receiver_reg, Immediate(kSmiTagMask)); | |
376 __ j(zero, miss_label, not_taken); | |
377 | |
378 // Check that the map of the object hasn't changed. | |
379 __ cmp(FieldOperand(receiver_reg, HeapObject::kMapOffset), | |
380 Immediate(Handle<Map>(object->map()))); | |
381 __ j(not_equal, miss_label, not_taken); | |
382 | |
383 // Perform global security token check if needed. | |
384 if (object->IsJSGlobalProxy()) { | |
385 __ CheckAccessGlobalProxy(receiver_reg, scratch, miss_label); | |
386 } | |
387 | |
388 // Stub never generated for non-global objects that require access | |
389 // checks. | |
390 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); | |
391 | |
392 // Perform map transition for the receiver if necessary. | |
393 if ((transition != NULL) && (object->map()->unused_property_fields() == 0)) { | |
394 // The properties must be extended before we can store the value. | |
395 // We jump to a runtime call that extends the properties array. | |
396 __ mov(ecx, Immediate(Handle<Map>(transition))); | |
397 Handle<Code> ic(Builtins::builtin(storage_extend)); | |
398 __ jmp(ic, RelocInfo::CODE_TARGET); | |
399 return; | |
400 } | |
401 | |
402 if (transition != NULL) { | |
403 // Update the map of the object; no write barrier updating is | |
404 // needed because the map is never in new space. | |
405 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), | |
406 Immediate(Handle<Map>(transition))); | |
407 } | |
408 | |
409 // Adjust for the number of properties stored in the object. Even in the | |
410 // face of a transition we can use the old map here because the size of the | |
411 // object and the number of in-object properties is not going to change. | |
412 index -= object->map()->inobject_properties(); | |
413 | |
414 if (index < 0) { | |
415 // Set the property straight into the object. | |
416 int offset = object->map()->instance_size() + (index * kPointerSize); | |
417 __ mov(FieldOperand(receiver_reg, offset), eax); | |
418 | |
419 // Update the write barrier for the array address. | |
420 // Pass the value being stored in the now unused name_reg. | |
421 __ mov(name_reg, Operand(eax)); | |
422 __ RecordWrite(receiver_reg, offset, name_reg, scratch); | |
423 } else { | |
424 // Write to the properties array. | |
425 int offset = index * kPointerSize + Array::kHeaderSize; | |
426 // Get the properties array (optimistically). | |
427 __ mov(scratch, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); | |
428 __ mov(FieldOperand(scratch, offset), eax); | |
429 | |
430 // Update the write barrier for the array address. | |
431 // Pass the value being stored in the now unused name_reg. | |
432 __ mov(name_reg, Operand(eax)); | |
433 __ RecordWrite(scratch, offset, name_reg, receiver_reg); | |
434 } | |
435 | |
436 // Return the value (register eax). | |
437 __ ret(0); | |
438 } | |
439 | |
440 | |
441 #undef __ | |
442 | |
443 #define __ ACCESS_MASM(masm()) | |
444 | |
445 | |
446 // TODO(1241006): Avoid having lazy compile stubs specialized by the | |
447 // number of arguments. It is not needed anymore. | |
448 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { | |
449 // Enter an internal frame. | |
450 __ EnterInternalFrame(); | |
451 | |
452 // Push a copy of the function onto the stack. | |
453 __ push(edi); | |
454 | |
455 __ push(edi); // function is also the parameter to the runtime call | |
456 __ CallRuntime(Runtime::kLazyCompile, 1); | |
457 __ pop(edi); | |
458 | |
459 // Tear down temporary frame. | |
460 __ LeaveInternalFrame(); | |
461 | |
462 // Do a tail-call of the compiled function. | |
463 __ lea(ecx, FieldOperand(eax, Code::kHeaderSize)); | |
464 __ jmp(Operand(ecx)); | |
465 | |
466 return GetCodeWithFlags(flags, "LazyCompileStub"); | |
467 } | |
468 | |
469 | |
470 Object* CallStubCompiler::CompileCallField(Object* object, | |
471 JSObject* holder, | |
472 int index, | |
473 String* name) { | |
474 // ----------- S t a t e ------------- | |
475 // ----------------------------------- | |
476 Label miss; | |
477 | |
478 // Get the receiver from the stack. | |
479 const int argc = arguments().immediate(); | |
480 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | |
481 | |
482 // Check that the receiver isn't a smi. | |
483 __ test(edx, Immediate(kSmiTagMask)); | |
484 __ j(zero, &miss, not_taken); | |
485 | |
486 // Do the right check and compute the holder register. | |
487 Register reg = | |
488 masm()->CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); | |
489 | |
490 GenerateFastPropertyLoad(masm(), edi, reg, holder, index); | |
491 | |
492 // Check that the function really is a function. | |
493 __ test(edi, Immediate(kSmiTagMask)); | |
494 __ j(zero, &miss, not_taken); | |
495 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ebx); | |
496 __ j(not_equal, &miss, not_taken); | |
497 | |
498 // Patch the receiver on the stack with the global proxy if | |
499 // necessary. | |
500 if (object->IsGlobalObject()) { | |
501 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); | |
502 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); | |
503 } | |
504 | |
505 // Invoke the function. | |
506 __ InvokeFunction(edi, arguments(), JUMP_FUNCTION); | |
507 | |
508 // Handle call cache miss. | |
509 __ bind(&miss); | |
510 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); | |
511 __ jmp(ic, RelocInfo::CODE_TARGET); | |
512 | |
513 // Return the generated code. | |
514 return GetCode(FIELD, name); | |
515 } | |
516 | |
517 | |
518 Object* CallStubCompiler::CompileCallConstant(Object* object, | |
519 JSObject* holder, | |
520 JSFunction* function, | |
521 CheckType check) { | |
522 // ----------- S t a t e ------------- | |
523 // ----------------------------------- | |
524 Label miss; | |
525 | |
526 // Get the receiver from the stack. | |
527 const int argc = arguments().immediate(); | |
528 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | |
529 | |
530 // Check that the receiver isn't a smi. | |
531 if (check != NUMBER_CHECK) { | |
532 __ test(edx, Immediate(kSmiTagMask)); | |
533 __ j(zero, &miss, not_taken); | |
534 } | |
535 | |
536 // Make sure that it's okay not to patch the on stack receiver | |
537 // unless we're doing a receiver map check. | |
538 ASSERT(!object->IsGlobalObject() || check == RECEIVER_MAP_CHECK); | |
539 | |
540 switch (check) { | |
541 case RECEIVER_MAP_CHECK: | |
542 // Check that the maps haven't changed. | |
543 __ CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); | |
544 | |
545 // Patch the receiver on the stack with the global proxy if | |
546 // necessary. | |
547 if (object->IsGlobalObject()) { | |
548 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); | |
549 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); | |
550 } | |
551 break; | |
552 | |
553 case STRING_CHECK: | |
554 // Check that the object is a two-byte string or a symbol. | |
555 __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); | |
556 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | |
557 __ cmp(ecx, FIRST_NONSTRING_TYPE); | |
558 __ j(above_equal, &miss, not_taken); | |
559 // Check that the maps starting from the prototype haven't changed. | |
560 GenerateLoadGlobalFunctionPrototype(masm(), | |
561 Context::STRING_FUNCTION_INDEX, | |
562 ecx); | |
563 __ CheckMaps(JSObject::cast(object->GetPrototype()), | |
564 ecx, holder, ebx, edx, &miss); | |
565 break; | |
566 | |
567 case NUMBER_CHECK: { | |
568 Label fast; | |
569 // Check that the object is a smi or a heap number. | |
570 __ test(edx, Immediate(kSmiTagMask)); | |
571 __ j(zero, &fast, taken); | |
572 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ecx); | |
573 __ j(not_equal, &miss, not_taken); | |
574 __ bind(&fast); | |
575 // Check that the maps starting from the prototype haven't changed. | |
576 GenerateLoadGlobalFunctionPrototype(masm(), | |
577 Context::NUMBER_FUNCTION_INDEX, | |
578 ecx); | |
579 __ CheckMaps(JSObject::cast(object->GetPrototype()), | |
580 ecx, holder, ebx, edx, &miss); | |
581 break; | |
582 } | |
583 | |
584 case BOOLEAN_CHECK: { | |
585 Label fast; | |
586 // Check that the object is a boolean. | |
587 __ cmp(edx, Factory::true_value()); | |
588 __ j(equal, &fast, taken); | |
589 __ cmp(edx, Factory::false_value()); | |
590 __ j(not_equal, &miss, not_taken); | |
591 __ bind(&fast); | |
592 // Check that the maps starting from the prototype haven't changed. | |
593 GenerateLoadGlobalFunctionPrototype(masm(), | |
594 Context::BOOLEAN_FUNCTION_INDEX, | |
595 ecx); | |
596 __ CheckMaps(JSObject::cast(object->GetPrototype()), | |
597 ecx, holder, ebx, edx, &miss); | |
598 break; | |
599 } | |
600 | |
601 case JSARRAY_HAS_FAST_ELEMENTS_CHECK: | |
602 __ CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); | |
603 // Make sure object->elements()->map() != Heap::dictionary_array_map() | |
604 // Get the elements array of the object. | |
605 __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset)); | |
606 // Check that the object is in fast mode (not dictionary). | |
607 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), | |
608 Immediate(Factory::hash_table_map())); | |
609 __ j(equal, &miss, not_taken); | |
610 break; | |
611 | |
612 default: | |
613 UNREACHABLE(); | |
614 } | |
615 | |
616 // Get the function and setup the context. | |
617 __ mov(edi, Immediate(Handle<JSFunction>(function))); | |
618 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | |
619 | |
620 // Jump to the cached code (tail call). | |
621 Handle<Code> code(function->code()); | |
622 ParameterCount expected(function->shared()->formal_parameter_count()); | |
623 __ InvokeCode(code, expected, arguments(), | |
624 RelocInfo::CODE_TARGET, JUMP_FUNCTION); | |
625 | |
626 // Handle call cache miss. | |
627 __ bind(&miss); | |
628 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); | |
629 __ jmp(ic, RelocInfo::CODE_TARGET); | |
630 | |
631 // Return the generated code. | |
632 String* function_name = NULL; | |
633 if (function->shared()->name()->IsString()) { | |
634 function_name = String::cast(function->shared()->name()); | |
635 } | |
636 return GetCode(CONSTANT_FUNCTION, function_name); | |
637 } | |
638 | |
639 | |
640 Object* CallStubCompiler::CompileCallInterceptor(Object* object, | |
641 JSObject* holder, | |
642 String* name) { | |
643 // ----------- S t a t e ------------- | |
644 // ----------------------------------- | |
645 Label miss; | |
646 | |
647 // Get the number of arguments. | |
648 const int argc = arguments().immediate(); | |
649 | |
650 // Get the receiver from the stack. | |
651 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | |
652 | |
653 // Check that the receiver isn't a smi. | |
654 __ test(edx, Immediate(kSmiTagMask)); | |
655 __ j(zero, &miss, not_taken); | |
656 | |
657 // Check that maps have not changed and compute the holder register. | |
658 Register reg = | |
659 masm()->CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); | |
660 | |
661 // Enter an internal frame. | |
662 __ EnterInternalFrame(); | |
663 | |
664 // Push arguments on the expression stack. | |
665 __ push(edx); // receiver | |
666 __ push(reg); // holder | |
667 __ push(Operand(ebp, (argc + 3) * kPointerSize)); // name | |
668 | |
669 // Perform call. | |
670 ExternalReference load_interceptor = | |
671 ExternalReference(IC_Utility(IC::kLoadInterceptorProperty)); | |
672 __ mov(eax, Immediate(3)); | |
673 __ mov(ebx, Immediate(load_interceptor)); | |
674 | |
675 CEntryStub stub; | |
676 __ CallStub(&stub); | |
677 | |
678 // Move result to edi and restore receiver. | |
679 __ mov(edi, eax); | |
680 __ mov(edx, Operand(ebp, (argc + 2) * kPointerSize)); // receiver | |
681 | |
682 // Exit frame. | |
683 __ LeaveInternalFrame(); | |
684 | |
685 // Check that the function really is a function. | |
686 __ test(edi, Immediate(kSmiTagMask)); | |
687 __ j(zero, &miss, not_taken); | |
688 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ebx); | |
689 __ j(not_equal, &miss, not_taken); | |
690 | |
691 // Patch the receiver on the stack with the global proxy if | |
692 // necessary. | |
693 if (object->IsGlobalObject()) { | |
694 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); | |
695 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); | |
696 } | |
697 | |
698 // Invoke the function. | |
699 __ InvokeFunction(edi, arguments(), JUMP_FUNCTION); | |
700 | |
701 // Handle load cache miss. | |
702 __ bind(&miss); | |
703 Handle<Code> ic = ComputeCallMiss(argc); | |
704 __ jmp(ic, RelocInfo::CODE_TARGET); | |
705 | |
706 // Return the generated code. | |
707 return GetCode(INTERCEPTOR, name); | |
708 } | |
709 | |
710 | |
711 Object* StoreStubCompiler::CompileStoreField(JSObject* object, | |
712 int index, | |
713 Map* transition, | |
714 String* name) { | |
715 // ----------- S t a t e ------------- | |
716 // -- eax : value | |
717 // -- ecx : name | |
718 // -- esp[0] : return address | |
719 // -- esp[4] : receiver | |
720 // ----------------------------------- | |
721 Label miss; | |
722 | |
723 // Get the object from the stack. | |
724 __ mov(ebx, Operand(esp, 1 * kPointerSize)); | |
725 | |
726 // Generate store field code. Trashes the name register. | |
727 GenerateStoreField(masm(), | |
728 Builtins::StoreIC_ExtendStorage, | |
729 object, | |
730 index, | |
731 transition, | |
732 ebx, ecx, edx, | |
733 &miss); | |
734 | |
735 // Handle store cache miss. | |
736 __ bind(&miss); | |
737 __ mov(ecx, Immediate(Handle<String>(name))); // restore name | |
738 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); | |
739 __ jmp(ic, RelocInfo::CODE_TARGET); | |
740 | |
741 // Return the generated code. | |
742 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); | |
743 } | |
744 | |
745 | |
746 Object* StoreStubCompiler::CompileStoreCallback(JSObject* object, | |
747 AccessorInfo* callback, | |
748 String* name) { | |
749 // ----------- S t a t e ------------- | |
750 // -- eax : value | |
751 // -- ecx : name | |
752 // -- esp[0] : return address | |
753 // -- esp[4] : receiver | |
754 // ----------------------------------- | |
755 Label miss; | |
756 | |
757 // Get the object from the stack. | |
758 __ mov(ebx, Operand(esp, 1 * kPointerSize)); | |
759 | |
760 // Check that the object isn't a smi. | |
761 __ test(ebx, Immediate(kSmiTagMask)); | |
762 __ j(zero, &miss, not_taken); | |
763 | |
764 // Check that the map of the object hasn't changed. | |
765 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), | |
766 Immediate(Handle<Map>(object->map()))); | |
767 __ j(not_equal, &miss, not_taken); | |
768 | |
769 // Perform global security token check if needed. | |
770 if (object->IsJSGlobalProxy()) { | |
771 __ CheckAccessGlobalProxy(ebx, edx, &miss); | |
772 } | |
773 | |
774 // Stub never generated for non-global objects that require access | |
775 // checks. | |
776 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); | |
777 | |
778 __ pop(ebx); // remove the return address | |
779 __ push(Operand(esp, 0)); // receiver | |
780 __ push(Immediate(Handle<AccessorInfo>(callback))); // callback info | |
781 __ push(ecx); // name | |
782 __ push(eax); // value | |
783 __ push(ebx); // restore return address | |
784 | |
785 // Do tail-call to the runtime system. | |
786 ExternalReference store_callback_property = | |
787 ExternalReference(IC_Utility(IC::kStoreCallbackProperty)); | |
788 __ TailCallRuntime(store_callback_property, 4); | |
789 | |
790 // Handle store cache miss. | |
791 __ bind(&miss); | |
792 __ mov(ecx, Immediate(Handle<String>(name))); // restore name | |
793 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); | |
794 __ jmp(ic, RelocInfo::CODE_TARGET); | |
795 | |
796 // Return the generated code. | |
797 return GetCode(CALLBACKS, name); | |
798 } | |
799 | |
800 | |
801 Object* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, | |
802 String* name) { | |
803 // ----------- S t a t e ------------- | |
804 // -- eax : value | |
805 // -- ecx : name | |
806 // -- esp[0] : return address | |
807 // -- esp[4] : receiver | |
808 // ----------------------------------- | |
809 Label miss; | |
810 | |
811 // Get the object from the stack. | |
812 __ mov(ebx, Operand(esp, 1 * kPointerSize)); | |
813 | |
814 // Check that the object isn't a smi. | |
815 __ test(ebx, Immediate(kSmiTagMask)); | |
816 __ j(zero, &miss, not_taken); | |
817 | |
818 // Check that the map of the object hasn't changed. | |
819 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), | |
820 Immediate(Handle<Map>(receiver->map()))); | |
821 __ j(not_equal, &miss, not_taken); | |
822 | |
823 // Perform global security token check if needed. | |
824 if (receiver->IsJSGlobalProxy()) { | |
825 __ CheckAccessGlobalProxy(ebx, edx, &miss); | |
826 } | |
827 | |
828 // Stub never generated for non-global objects that require access | |
829 // checks. | |
830 ASSERT(receiver->IsJSGlobalProxy() || !receiver->IsAccessCheckNeeded()); | |
831 | |
832 __ pop(ebx); // remove the return address | |
833 __ push(Operand(esp, 0)); // receiver | |
834 __ push(ecx); // name | |
835 __ push(eax); // value | |
836 __ push(ebx); // restore return address | |
837 | |
838 // Do tail-call to the runtime system. | |
839 ExternalReference store_ic_property = | |
840 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty)); | |
841 __ TailCallRuntime(store_ic_property, 3); | |
842 | |
843 // Handle store cache miss. | |
844 __ bind(&miss); | |
845 __ mov(ecx, Immediate(Handle<String>(name))); // restore name | |
846 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); | |
847 __ jmp(ic, RelocInfo::CODE_TARGET); | |
848 | |
849 // Return the generated code. | |
850 return GetCode(INTERCEPTOR, name); | |
851 } | |
852 | |
853 | |
854 Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, | |
855 int index, | |
856 Map* transition, | |
857 String* name) { | |
858 // ----------- S t a t e ------------- | |
859 // -- eax : value | |
860 // -- esp[0] : return address | |
861 // -- esp[4] : key | |
862 // -- esp[8] : receiver | |
863 // ----------------------------------- | |
864 Label miss; | |
865 | |
866 __ IncrementCounter(&Counters::keyed_store_field, 1); | |
867 | |
868 // Get the name from the stack. | |
869 __ mov(ecx, Operand(esp, 1 * kPointerSize)); | |
870 // Check that the name has not changed. | |
871 __ cmp(Operand(ecx), Immediate(Handle<String>(name))); | |
872 __ j(not_equal, &miss, not_taken); | |
873 | |
874 // Get the object from the stack. | |
875 __ mov(ebx, Operand(esp, 2 * kPointerSize)); | |
876 | |
877 // Generate store field code. Trashes the name register. | |
878 GenerateStoreField(masm(), | |
879 Builtins::KeyedStoreIC_ExtendStorage, | |
880 object, | |
881 index, | |
882 transition, | |
883 ebx, ecx, edx, | |
884 &miss); | |
885 | |
886 // Handle store cache miss. | |
887 __ bind(&miss); | |
888 __ DecrementCounter(&Counters::keyed_store_field, 1); | |
889 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Miss)); | |
890 __ jmp(ic, RelocInfo::CODE_TARGET); | |
891 | |
892 // Return the generated code. | |
893 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); | |
894 } | |
895 | |
896 | |
897 Object* LoadStubCompiler::CompileLoadField(JSObject* object, | |
898 JSObject* holder, | |
899 int index, | |
900 String* name) { | |
901 // ----------- S t a t e ------------- | |
902 // -- ecx : name | |
903 // -- esp[0] : return address | |
904 // -- esp[4] : receiver | |
905 // ----------------------------------- | |
906 Label miss; | |
907 | |
908 __ mov(eax, (Operand(esp, kPointerSize))); | |
909 GenerateLoadField(masm(), object, holder, eax, ebx, edx, index, &miss); | |
910 __ bind(&miss); | |
911 GenerateLoadMiss(masm(), Code::LOAD_IC); | |
912 | |
913 // Return the generated code. | |
914 return GetCode(FIELD, name); | |
915 } | |
916 | |
917 | |
918 Object* LoadStubCompiler::CompileLoadCallback(JSObject* object, | |
919 JSObject* holder, | |
920 AccessorInfo* callback, | |
921 String* name) { | |
922 // ----------- S t a t e ------------- | |
923 // -- ecx : name | |
924 // -- esp[0] : return address | |
925 // -- esp[4] : receiver | |
926 // ----------------------------------- | |
927 Label miss; | |
928 | |
929 __ mov(eax, (Operand(esp, kPointerSize))); | |
930 GenerateLoadCallback(masm(), object, holder, eax, ecx, ebx, | |
931 edx, callback, &miss); | |
932 __ bind(&miss); | |
933 GenerateLoadMiss(masm(), Code::LOAD_IC); | |
934 | |
935 // Return the generated code. | |
936 return GetCode(CALLBACKS, name); | |
937 } | |
938 | |
939 | |
940 Object* LoadStubCompiler::CompileLoadConstant(JSObject* object, | |
941 JSObject* holder, | |
942 Object* value, | |
943 String* name) { | |
944 // ----------- S t a t e ------------- | |
945 // -- ecx : name | |
946 // -- esp[0] : return address | |
947 // -- esp[4] : receiver | |
948 // ----------------------------------- | |
949 Label miss; | |
950 | |
951 __ mov(eax, (Operand(esp, kPointerSize))); | |
952 GenerateLoadConstant(masm(), object, holder, eax, ebx, edx, value, &miss); | |
953 __ bind(&miss); | |
954 GenerateLoadMiss(masm(), Code::LOAD_IC); | |
955 | |
956 // Return the generated code. | |
957 return GetCode(CONSTANT_FUNCTION, name); | |
958 } | |
959 | |
960 | |
961 Object* LoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, | |
962 JSObject* holder, | |
963 String* name) { | |
964 // ----------- S t a t e ------------- | |
965 // -- ecx : name | |
966 // -- esp[0] : return address | |
967 // -- esp[4] : receiver | |
968 // ----------------------------------- | |
969 Label miss; | |
970 | |
971 __ mov(eax, (Operand(esp, kPointerSize))); | |
972 GenerateLoadInterceptor(masm(), receiver, holder, eax, ecx, edx, ebx, &miss); | |
973 __ bind(&miss); | |
974 GenerateLoadMiss(masm(), Code::LOAD_IC); | |
975 | |
976 // Return the generated code. | |
977 return GetCode(INTERCEPTOR, name); | |
978 } | |
979 | |
980 | |
981 Object* KeyedLoadStubCompiler::CompileLoadField(String* name, | |
982 JSObject* receiver, | |
983 JSObject* holder, | |
984 int index) { | |
985 // ----------- S t a t e ------------- | |
986 // -- esp[0] : return address | |
987 // -- esp[4] : name | |
988 // -- esp[8] : receiver | |
989 // ----------------------------------- | |
990 Label miss; | |
991 | |
992 __ mov(eax, (Operand(esp, kPointerSize))); | |
993 __ mov(ecx, (Operand(esp, 2 * kPointerSize))); | |
994 __ IncrementCounter(&Counters::keyed_load_field, 1); | |
995 | |
996 // Check that the name has not changed. | |
997 __ cmp(Operand(eax), Immediate(Handle<String>(name))); | |
998 __ j(not_equal, &miss, not_taken); | |
999 | |
1000 GenerateLoadField(masm(), receiver, holder, ecx, ebx, edx, index, &miss); | |
1001 __ bind(&miss); | |
1002 __ DecrementCounter(&Counters::keyed_load_field, 1); | |
1003 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | |
1004 | |
1005 // Return the generated code. | |
1006 return GetCode(FIELD, name); | |
1007 } | |
1008 | |
1009 | |
1010 Object* KeyedLoadStubCompiler::CompileLoadCallback(String* name, | |
1011 JSObject* receiver, | |
1012 JSObject* holder, | |
1013 AccessorInfo* callback) { | |
1014 // ----------- S t a t e ------------- | |
1015 // -- esp[0] : return address | |
1016 // -- esp[4] : name | |
1017 // -- esp[8] : receiver | |
1018 // ----------------------------------- | |
1019 Label miss; | |
1020 | |
1021 __ mov(eax, (Operand(esp, kPointerSize))); | |
1022 __ mov(ecx, (Operand(esp, 2 * kPointerSize))); | |
1023 __ IncrementCounter(&Counters::keyed_load_callback, 1); | |
1024 | |
1025 // Check that the name has not changed. | |
1026 __ cmp(Operand(eax), Immediate(Handle<String>(name))); | |
1027 __ j(not_equal, &miss, not_taken); | |
1028 | |
1029 GenerateLoadCallback(masm(), receiver, holder, ecx, eax, ebx, edx, | |
1030 callback, &miss); | |
1031 __ bind(&miss); | |
1032 __ DecrementCounter(&Counters::keyed_load_callback, 1); | |
1033 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | |
1034 | |
1035 // Return the generated code. | |
1036 return GetCode(CALLBACKS, name); | |
1037 } | |
1038 | |
1039 | |
1040 Object* KeyedLoadStubCompiler::CompileLoadConstant(String* name, | |
1041 JSObject* receiver, | |
1042 JSObject* holder, | |
1043 Object* value) { | |
1044 // ----------- S t a t e ------------- | |
1045 // -- esp[0] : return address | |
1046 // -- esp[4] : name | |
1047 // -- esp[8] : receiver | |
1048 // ----------------------------------- | |
1049 Label miss; | |
1050 | |
1051 __ mov(eax, (Operand(esp, kPointerSize))); | |
1052 __ mov(ecx, (Operand(esp, 2 * kPointerSize))); | |
1053 __ IncrementCounter(&Counters::keyed_load_constant_function, 1); | |
1054 | |
1055 // Check that the name has not changed. | |
1056 __ cmp(Operand(eax), Immediate(Handle<String>(name))); | |
1057 __ j(not_equal, &miss, not_taken); | |
1058 | |
1059 GenerateLoadConstant(masm(), receiver, holder, ecx, ebx, edx, value, &miss); | |
1060 __ bind(&miss); | |
1061 __ DecrementCounter(&Counters::keyed_load_constant_function, 1); | |
1062 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | |
1063 | |
1064 // Return the generated code. | |
1065 return GetCode(CONSTANT_FUNCTION, name); | |
1066 } | |
1067 | |
1068 | |
1069 Object* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, | |
1070 JSObject* holder, | |
1071 String* name) { | |
1072 // ----------- S t a t e ------------- | |
1073 // -- esp[0] : return address | |
1074 // -- esp[4] : name | |
1075 // -- esp[8] : receiver | |
1076 // ----------------------------------- | |
1077 Label miss; | |
1078 | |
1079 __ mov(eax, (Operand(esp, kPointerSize))); | |
1080 __ mov(ecx, (Operand(esp, 2 * kPointerSize))); | |
1081 __ IncrementCounter(&Counters::keyed_load_interceptor, 1); | |
1082 | |
1083 // Check that the name has not changed. | |
1084 __ cmp(Operand(eax), Immediate(Handle<String>(name))); | |
1085 __ j(not_equal, &miss, not_taken); | |
1086 | |
1087 GenerateLoadInterceptor(masm(), receiver, holder, ecx, eax, edx, ebx, &miss); | |
1088 __ bind(&miss); | |
1089 __ DecrementCounter(&Counters::keyed_load_interceptor, 1); | |
1090 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | |
1091 | |
1092 // Return the generated code. | |
1093 return GetCode(INTERCEPTOR, name); | |
1094 } | |
1095 | |
1096 | |
1097 | |
1098 | |
1099 Object* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) { | |
1100 // ----------- S t a t e ------------- | |
1101 // -- esp[0] : return address | |
1102 // -- esp[4] : name | |
1103 // -- esp[8] : receiver | |
1104 // ----------------------------------- | |
1105 Label miss; | |
1106 | |
1107 __ mov(eax, (Operand(esp, kPointerSize))); | |
1108 __ mov(ecx, (Operand(esp, 2 * kPointerSize))); | |
1109 __ IncrementCounter(&Counters::keyed_load_array_length, 1); | |
1110 | |
1111 // Check that the name has not changed. | |
1112 __ cmp(Operand(eax), Immediate(Handle<String>(name))); | |
1113 __ j(not_equal, &miss, not_taken); | |
1114 | |
1115 GenerateLoadArrayLength(masm(), ecx, edx, &miss); | |
1116 __ bind(&miss); | |
1117 __ DecrementCounter(&Counters::keyed_load_array_length, 1); | |
1118 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | |
1119 | |
1120 // Return the generated code. | |
1121 return GetCode(CALLBACKS, name); | |
1122 } | |
1123 | |
1124 | |
1125 Object* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) { | |
1126 // ----------- S t a t e ------------- | |
1127 // -- esp[0] : return address | |
1128 // -- esp[4] : name | |
1129 // -- esp[8] : receiver | |
1130 // ----------------------------------- | |
1131 Label miss; | |
1132 | |
1133 __ mov(eax, (Operand(esp, kPointerSize))); | |
1134 __ mov(ecx, (Operand(esp, 2 * kPointerSize))); | |
1135 __ IncrementCounter(&Counters::keyed_load_string_length, 1); | |
1136 | |
1137 // Check that the name has not changed. | |
1138 __ cmp(Operand(eax), Immediate(Handle<String>(name))); | |
1139 __ j(not_equal, &miss, not_taken); | |
1140 | |
1141 GenerateLoadStringLength(masm(), ecx, edx, &miss); | |
1142 __ bind(&miss); | |
1143 __ DecrementCounter(&Counters::keyed_load_string_length, 1); | |
1144 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | |
1145 | |
1146 // Return the generated code. | |
1147 return GetCode(CALLBACKS, name); | |
1148 } | |
1149 | |
1150 | |
1151 Object* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) { | |
1152 // ----------- S t a t e ------------- | |
1153 // -- esp[0] : return address | |
1154 // -- esp[4] : name | |
1155 // -- esp[8] : receiver | |
1156 // ----------------------------------- | |
1157 Label miss; | |
1158 | |
1159 __ mov(eax, (Operand(esp, kPointerSize))); | |
1160 __ mov(ecx, (Operand(esp, 2 * kPointerSize))); | |
1161 __ IncrementCounter(&Counters::keyed_load_function_prototype, 1); | |
1162 | |
1163 // Check that the name has not changed. | |
1164 __ cmp(Operand(eax), Immediate(Handle<String>(name))); | |
1165 __ j(not_equal, &miss, not_taken); | |
1166 | |
1167 GenerateLoadFunctionPrototype(masm(), ecx, edx, ebx, &miss); | |
1168 __ bind(&miss); | |
1169 __ DecrementCounter(&Counters::keyed_load_function_prototype, 1); | |
1170 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | |
1171 | |
1172 // Return the generated code. | |
1173 return GetCode(CALLBACKS, name); | |
1174 } | |
1175 | |
1176 | |
1177 #undef __ | |
1178 | |
1179 } } // namespace v8::internal | |
OLD | NEW |