OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 Loading... |
300 ASSERT(kNotStringTag != 0); | 300 ASSERT(kNotStringTag != 0); |
301 __ testl(scratch, Immediate(kNotStringTag)); | 301 __ testl(scratch, Immediate(kNotStringTag)); |
302 __ j(not_zero, non_string_object); | 302 __ j(not_zero, non_string_object); |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, | 306 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, |
307 Register receiver, | 307 Register receiver, |
308 Register scratch1, | 308 Register scratch1, |
309 Register scratch2, | 309 Register scratch2, |
310 Label* miss) { | 310 Label* miss, |
| 311 bool support_wrappers) { |
311 Label check_wrapper; | 312 Label check_wrapper; |
312 | 313 |
313 // Check if the object is a string leaving the instance type in the | 314 // Check if the object is a string leaving the instance type in the |
314 // scratch register. | 315 // scratch register. |
315 GenerateStringCheck(masm, receiver, scratch1, miss, &check_wrapper); | 316 GenerateStringCheck(masm, receiver, scratch1, miss, |
| 317 support_wrappers ? &check_wrapper : miss); |
316 | 318 |
317 // Load length directly from the string. | 319 // Load length directly from the string. |
318 __ movq(rax, FieldOperand(receiver, String::kLengthOffset)); | 320 __ movq(rax, FieldOperand(receiver, String::kLengthOffset)); |
319 __ ret(0); | 321 __ ret(0); |
320 | 322 |
321 // Check if the object is a JSValue wrapper. | 323 if (support_wrappers) { |
322 __ bind(&check_wrapper); | 324 // Check if the object is a JSValue wrapper. |
323 __ cmpl(scratch1, Immediate(JS_VALUE_TYPE)); | 325 __ bind(&check_wrapper); |
324 __ j(not_equal, miss); | 326 __ cmpl(scratch1, Immediate(JS_VALUE_TYPE)); |
| 327 __ j(not_equal, miss); |
325 | 328 |
326 // Check if the wrapped value is a string and load the length | 329 // Check if the wrapped value is a string and load the length |
327 // directly if it is. | 330 // directly if it is. |
328 __ movq(scratch2, FieldOperand(receiver, JSValue::kValueOffset)); | 331 __ movq(scratch2, FieldOperand(receiver, JSValue::kValueOffset)); |
329 GenerateStringCheck(masm, scratch2, scratch1, miss, miss); | 332 GenerateStringCheck(masm, scratch2, scratch1, miss, miss); |
330 __ movq(rax, FieldOperand(scratch2, String::kLengthOffset)); | 333 __ movq(rax, FieldOperand(scratch2, String::kLengthOffset)); |
331 __ ret(0); | 334 __ ret(0); |
| 335 } |
332 } | 336 } |
333 | 337 |
334 | 338 |
335 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, | 339 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, |
336 Register receiver, | 340 Register receiver, |
337 Register result, | 341 Register result, |
338 Register scratch, | 342 Register scratch, |
339 Label* miss_label) { | 343 Label* miss_label) { |
340 __ TryGetFunctionPrototype(receiver, result, miss_label); | 344 __ TryGetFunctionPrototype(receiver, result, miss_label); |
341 if (!result.is(rax)) __ movq(rax, result); | 345 if (!result.is(rax)) __ movq(rax, result); |
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 // -- rsp[0] : return address | 2930 // -- rsp[0] : return address |
2927 // ----------------------------------- | 2931 // ----------------------------------- |
2928 Label miss; | 2932 Label miss; |
2929 | 2933 |
2930 __ IncrementCounter(&Counters::keyed_load_string_length, 1); | 2934 __ IncrementCounter(&Counters::keyed_load_string_length, 1); |
2931 | 2935 |
2932 // Check that the name has not changed. | 2936 // Check that the name has not changed. |
2933 __ Cmp(rax, Handle<String>(name)); | 2937 __ Cmp(rax, Handle<String>(name)); |
2934 __ j(not_equal, &miss); | 2938 __ j(not_equal, &miss); |
2935 | 2939 |
2936 GenerateLoadStringLength(masm(), rdx, rcx, rbx, &miss); | 2940 GenerateLoadStringLength(masm(), rdx, rcx, rbx, &miss, true); |
2937 __ bind(&miss); | 2941 __ bind(&miss); |
2938 __ DecrementCounter(&Counters::keyed_load_string_length, 1); | 2942 __ DecrementCounter(&Counters::keyed_load_string_length, 1); |
2939 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 2943 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
2940 | 2944 |
2941 // Return the generated code. | 2945 // Return the generated code. |
2942 return GetCode(CALLBACKS, name); | 2946 return GetCode(CALLBACKS, name); |
2943 } | 2947 } |
2944 | 2948 |
2945 | 2949 |
2946 MaybeObject* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) { | 2950 MaybeObject* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) { |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3442 __ TailCallRuntime(Runtime::kSetProperty, 3, 1); | 3446 __ TailCallRuntime(Runtime::kSetProperty, 3, 1); |
3443 | 3447 |
3444 return GetCode(flags); | 3448 return GetCode(flags); |
3445 } | 3449 } |
3446 | 3450 |
3447 #undef __ | 3451 #undef __ |
3448 | 3452 |
3449 } } // namespace v8::internal | 3453 } } // namespace v8::internal |
3450 | 3454 |
3451 #endif // V8_TARGET_ARCH_X64 | 3455 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |