| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 // Jump to the first instruction in the code stub. | 111 // Jump to the first instruction in the code stub. |
| 112 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 112 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 113 __ Jump(at); | 113 __ Jump(at); |
| 114 | 114 |
| 115 // Miss: fall through. | 115 // Miss: fall through. |
| 116 __ bind(&miss); | 116 __ bind(&miss); |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 // Helper function used to check that the dictionary doesn't contain | 120 void StubCompiler::GenerateDictionaryNegativeLookup(MacroAssembler* masm, |
| 121 // the property. This function may return false negatives, so miss_label | 121 Label* miss_label, |
| 122 // must always call a backup property check that is complete. | 122 Register receiver, |
| 123 // This function is safe to call if the receiver has fast properties. | 123 Handle<Name> name, |
| 124 // Name must be unique and receiver must be a heap object. | 124 Register scratch0, |
| 125 static void GenerateDictionaryNegativeLookup(MacroAssembler* masm, | 125 Register scratch1) { |
| 126 Label* miss_label, | |
| 127 Register receiver, | |
| 128 Handle<Name> name, | |
| 129 Register scratch0, | |
| 130 Register scratch1) { | |
| 131 ASSERT(name->IsUniqueName()); | 126 ASSERT(name->IsUniqueName()); |
| 127 ASSERT(!receiver.is(scratch0)); |
| 132 Counters* counters = masm->isolate()->counters(); | 128 Counters* counters = masm->isolate()->counters(); |
| 133 __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1); | 129 __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1); |
| 134 __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1); | 130 __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1); |
| 135 | 131 |
| 136 Label done; | 132 Label done; |
| 137 | 133 |
| 138 const int kInterceptorOrAccessCheckNeededMask = | 134 const int kInterceptorOrAccessCheckNeededMask = |
| 139 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); | 135 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); |
| 140 | 136 |
| 141 // Bail out if the receiver has a named interceptor or requires access checks. | 137 // Bail out if the receiver has a named interceptor or requires access checks. |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 Register receiver, | 397 Register receiver, |
| 402 Register scratch1, | 398 Register scratch1, |
| 403 Register scratch2, | 399 Register scratch2, |
| 404 Label* miss_label) { | 400 Label* miss_label) { |
| 405 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | 401 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); |
| 406 __ Ret(USE_DELAY_SLOT); | 402 __ Ret(USE_DELAY_SLOT); |
| 407 __ mov(v0, scratch1); | 403 __ mov(v0, scratch1); |
| 408 } | 404 } |
| 409 | 405 |
| 410 | 406 |
| 411 // Generate code to check that a global property cell is empty. Create | 407 void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm, |
| 412 // the property cell at compilation time if no cell exists for the | 408 Handle<JSGlobalObject> global, |
| 413 // property. | 409 Handle<Name> name, |
| 414 static void GenerateCheckPropertyCell(MacroAssembler* masm, | 410 Register scratch, |
| 415 Handle<GlobalObject> global, | 411 Label* miss) { |
| 416 Handle<Name> name, | 412 Handle<Cell> cell = JSGlobalObject::EnsurePropertyCell(global, name); |
| 417 Register scratch, | |
| 418 Label* miss) { | |
| 419 Handle<Cell> cell = GlobalObject::EnsurePropertyCell(global, name); | |
| 420 ASSERT(cell->value()->IsTheHole()); | 413 ASSERT(cell->value()->IsTheHole()); |
| 421 __ li(scratch, Operand(cell)); | 414 __ li(scratch, Operand(cell)); |
| 422 __ lw(scratch, FieldMemOperand(scratch, Cell::kValueOffset)); | 415 __ lw(scratch, FieldMemOperand(scratch, Cell::kValueOffset)); |
| 423 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 416 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
| 424 __ Branch(miss, ne, scratch, Operand(at)); | 417 __ Branch(miss, ne, scratch, Operand(at)); |
| 425 } | 418 } |
| 426 | 419 |
| 427 | 420 |
| 428 void StoreStubCompiler::GenerateNegativeHolderLookup( | 421 void StoreStubCompiler::GenerateNegativeHolderLookup( |
| 429 MacroAssembler* masm, | 422 MacroAssembler* masm, |
| 430 Handle<JSObject> holder, | 423 Handle<JSObject> holder, |
| 431 Register holder_reg, | 424 Register holder_reg, |
| 432 Handle<Name> name, | 425 Handle<Name> name, |
| 433 Label* miss) { | 426 Label* miss) { |
| 434 if (holder->IsJSGlobalObject()) { | 427 if (holder->IsJSGlobalObject()) { |
| 435 GenerateCheckPropertyCell( | 428 GenerateCheckPropertyCell( |
| 436 masm, Handle<GlobalObject>::cast(holder), name, scratch1(), miss); | 429 masm, Handle<JSGlobalObject>::cast(holder), name, scratch1(), miss); |
| 437 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { | 430 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { |
| 438 GenerateDictionaryNegativeLookup( | 431 GenerateDictionaryNegativeLookup( |
| 439 masm, miss, holder_reg, name, scratch1(), scratch2()); | 432 masm, miss, holder_reg, name, scratch1(), scratch2()); |
| 440 } | 433 } |
| 441 } | 434 } |
| 442 | 435 |
| 443 | 436 |
| 444 // Generate StoreTransition code, value is passed in a0 register. | 437 // Generate StoreTransition code, value is passed in a0 register. |
| 445 // After executing generated code, the receiver_reg and name_reg | 438 // After executing generated code, the receiver_reg and name_reg |
| 446 // may be clobbered. | 439 // may be clobbered. |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 __ Branch(interceptor_succeeded, ne, v0, Operand(scratch)); | 1135 __ Branch(interceptor_succeeded, ne, v0, Operand(scratch)); |
| 1143 } | 1136 } |
| 1144 | 1137 |
| 1145 StubCompiler* stub_compiler_; | 1138 StubCompiler* stub_compiler_; |
| 1146 const ParameterCount& arguments_; | 1139 const ParameterCount& arguments_; |
| 1147 Register name_; | 1140 Register name_; |
| 1148 Code::ExtraICState extra_ic_state_; | 1141 Code::ExtraICState extra_ic_state_; |
| 1149 }; | 1142 }; |
| 1150 | 1143 |
| 1151 | 1144 |
| 1152 // Calls GenerateCheckPropertyCell for each global object in the prototype chain | 1145 void StubCompiler::GenerateCheckPropertyCells(MacroAssembler* masm, |
| 1153 // from object to (but not including) holder. | 1146 Handle<JSObject> object, |
| 1154 static void GenerateCheckPropertyCells(MacroAssembler* masm, | 1147 Handle<JSObject> holder, |
| 1155 Handle<JSObject> object, | 1148 Handle<Name> name, |
| 1156 Handle<JSObject> holder, | 1149 Register scratch, |
| 1157 Handle<Name> name, | 1150 Label* miss) { |
| 1158 Register scratch, | |
| 1159 Label* miss) { | |
| 1160 Handle<JSObject> current = object; | 1151 Handle<JSObject> current = object; |
| 1161 while (!current.is_identical_to(holder)) { | 1152 while (!current.is_identical_to(holder)) { |
| 1162 if (current->IsGlobalObject()) { | 1153 if (current->IsJSGlobalObject()) { |
| 1163 GenerateCheckPropertyCell(masm, | 1154 GenerateCheckPropertyCell(masm, |
| 1164 Handle<GlobalObject>::cast(current), | 1155 Handle<JSGlobalObject>::cast(current), |
| 1165 name, | 1156 name, |
| 1166 scratch, | 1157 scratch, |
| 1167 miss); | 1158 miss); |
| 1168 } | 1159 } |
| 1169 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); | 1160 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); |
| 1170 } | 1161 } |
| 1171 } | 1162 } |
| 1172 | 1163 |
| 1173 | 1164 |
| 1174 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { | 1165 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 const int kValueOffset = kElementsStartOffset + kPointerSize; | 1348 const int kValueOffset = kElementsStartOffset + kPointerSize; |
| 1358 __ lw(scratch2(), FieldMemOperand(pointer, kValueOffset)); | 1349 __ lw(scratch2(), FieldMemOperand(pointer, kValueOffset)); |
| 1359 __ Branch(&miss, ne, scratch2(), Operand(callback)); | 1350 __ Branch(&miss, ne, scratch2(), Operand(callback)); |
| 1360 } | 1351 } |
| 1361 | 1352 |
| 1362 HandlerFrontendFooter(name, success, &miss); | 1353 HandlerFrontendFooter(name, success, &miss); |
| 1363 return reg; | 1354 return reg; |
| 1364 } | 1355 } |
| 1365 | 1356 |
| 1366 | 1357 |
| 1367 void LoadStubCompiler::NonexistentHandlerFrontend( | |
| 1368 Handle<JSObject> object, | |
| 1369 Handle<JSObject> last, | |
| 1370 Handle<Name> name, | |
| 1371 Label* success, | |
| 1372 Handle<GlobalObject> global) { | |
| 1373 Label miss; | |
| 1374 | |
| 1375 HandlerFrontendHeader(object, receiver(), last, name, &miss); | |
| 1376 | |
| 1377 // If the last object in the prototype chain is a global object, | |
| 1378 // check that the global property cell is empty. | |
| 1379 if (!global.is_null()) { | |
| 1380 GenerateCheckPropertyCell(masm(), global, name, scratch2(), &miss); | |
| 1381 } | |
| 1382 | |
| 1383 HandlerFrontendFooter(name, success, &miss); | |
| 1384 } | |
| 1385 | |
| 1386 | |
| 1387 void LoadStubCompiler::GenerateLoadField(Register reg, | 1358 void LoadStubCompiler::GenerateLoadField(Register reg, |
| 1388 Handle<JSObject> holder, | 1359 Handle<JSObject> holder, |
| 1389 PropertyIndex field, | 1360 PropertyIndex field, |
| 1390 Representation representation) { | 1361 Representation representation) { |
| 1391 if (!reg.is(receiver())) __ mov(receiver(), reg); | 1362 if (!reg.is(receiver())) __ mov(receiver(), reg); |
| 1392 if (kind() == Code::LOAD_IC) { | 1363 if (kind() == Code::LOAD_IC) { |
| 1393 LoadFieldStub stub(field.is_inobject(holder), | 1364 LoadFieldStub stub(field.is_inobject(holder), |
| 1394 field.translate(holder), | 1365 field.translate(holder), |
| 1395 representation); | 1366 representation); |
| 1396 GenerateTailCall(masm(), stub.GetCode(isolate())); | 1367 GenerateTailCall(masm(), stub.GetCode(isolate())); |
| (...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2950 | 2921 |
| 2951 // Return the generated code. | 2922 // Return the generated code. |
| 2952 return GetCode(kind(), Code::INTERCEPTOR, name); | 2923 return GetCode(kind(), Code::INTERCEPTOR, name); |
| 2953 } | 2924 } |
| 2954 | 2925 |
| 2955 | 2926 |
| 2956 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( | 2927 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( |
| 2957 Handle<JSObject> object, | 2928 Handle<JSObject> object, |
| 2958 Handle<JSObject> last, | 2929 Handle<JSObject> last, |
| 2959 Handle<Name> name, | 2930 Handle<Name> name, |
| 2960 Handle<GlobalObject> global) { | 2931 Handle<JSGlobalObject> global) { |
| 2961 Label success; | 2932 Label success; |
| 2962 | 2933 |
| 2963 NonexistentHandlerFrontend(object, last, name, &success, global); | 2934 NonexistentHandlerFrontend(object, last, name, &success, global); |
| 2964 | 2935 |
| 2965 __ bind(&success); | 2936 __ bind(&success); |
| 2966 // Return undefined if maps of the full prototype chain is still the same. | 2937 // Return undefined if maps of the full prototype chain is still the same. |
| 2967 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); | 2938 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); |
| 2968 __ Ret(); | 2939 __ Ret(); |
| 2969 | 2940 |
| 2970 // Return the generated code. | 2941 // Return the generated code. |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3203 // ----------------------------------- | 3174 // ----------------------------------- |
| 3204 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); | 3175 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
| 3205 } | 3176 } |
| 3206 | 3177 |
| 3207 | 3178 |
| 3208 #undef __ | 3179 #undef __ |
| 3209 | 3180 |
| 3210 } } // namespace v8::internal | 3181 } } // namespace v8::internal |
| 3211 | 3182 |
| 3212 #endif // V8_TARGET_ARCH_MIPS | 3183 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |