From 2335545108a3f9617b37da4cda1fe537887be3b4 Mon Sep 17 00:00:00 2001 From: "danno@chromium.org" Date: Wed, 4 Jan 2012 17:29:01 +0000 Subject: [PATCH] Rollback 10331: Make sure transitioned arrays efficiently call builtin Array functions Due to perf regressions TBR=fschneider@chromium.org BUG=none TEST=none Review URL: http://codereview.chromium.org/8983027 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10332 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-codegen-arm.cc | 31 +++++++---------------- src/arm/lithium-codegen-arm.h | 5 +--- src/arm/macro-assembler-arm.cc | 42 ++++---------------------------- src/arm/macro-assembler-arm.h | 23 +++++------------ src/arm/stub-cache-arm.cc | 14 ++++++----- src/hydrogen-instructions.h | 18 +++----------- src/hydrogen.cc | 5 ++-- src/ia32/lithium-codegen-ia32.cc | 29 ++++++++-------------- src/ia32/lithium-codegen-ia32.h | 5 +--- src/ia32/macro-assembler-ia32.cc | 40 +++--------------------------- src/ia32/macro-assembler-ia32.h | 17 +++---------- src/ia32/stub-cache-ia32.cc | 14 +++++++---- src/lithium.h | 4 ++- src/objects.h | 7 +----- src/x64/lithium-codegen-x64.cc | 28 ++++++++------------- src/x64/lithium-codegen-x64.h | 7 ++---- src/x64/macro-assembler-x64.cc | 40 +++--------------------------- src/x64/macro-assembler-x64.h | 21 ++++------------ src/x64/stub-cache-x64.cc | 14 ++++++----- 19 files changed, 93 insertions(+), 271 deletions(-) diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index e79caf185..e1e35d251 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -4155,26 +4155,14 @@ void LCodeGen::DoCheckFunction(LCheckFunction* instr) { } -void LCodeGen::DoCheckMapCommon(Register reg, - Register scratch, - Handle map, - CompareMapMode mode, - LEnvironment* env) { - Label success; - __ CompareMap(reg, scratch, map, &success, mode); - DeoptimizeIf(ne, env); - __ bind(&success); -} - - void LCodeGen::DoCheckMap(LCheckMap* instr) { Register scratch = scratch0(); LOperand* input = instr->InputAt(0); ASSERT(input->IsRegister()); Register reg = ToRegister(input); - Handle map = instr->hydrogen()->map(); - DoCheckMapCommon(reg, scratch, map, instr->hydrogen()->mode(), - instr->environment()); + __ ldr(scratch, FieldMemOperand(reg, HeapObject::kMapOffset)); + __ cmp(scratch, Operand(instr->hydrogen()->map())); + DeoptimizeIf(ne, instr->environment()); } @@ -4243,9 +4231,9 @@ void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { // Check prototype maps up to the holder. while (!current_prototype.is_identical_to(holder)) { - DoCheckMapCommon(temp1, temp2, - Handle(current_prototype->map()), - ALLOW_ELEMENT_TRANSITION_MAPS, instr->environment()); + __ ldr(temp2, FieldMemOperand(temp1, HeapObject::kMapOffset)); + __ cmp(temp2, Operand(Handle(current_prototype->map()))); + DeoptimizeIf(ne, instr->environment()); current_prototype = Handle(JSObject::cast(current_prototype->GetPrototype())); // Load next prototype object. @@ -4253,9 +4241,8 @@ void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { } // Check the holder map. - DoCheckMapCommon(temp1, temp2, - Handle(current_prototype->map()), - ALLOW_ELEMENT_TRANSITION_MAPS, instr->environment()); + __ ldr(temp2, FieldMemOperand(temp1, HeapObject::kMapOffset)); + __ cmp(temp2, Operand(Handle(current_prototype->map()))); DeoptimizeIf(ne, instr->environment()); } diff --git a/src/arm/lithium-codegen-arm.h b/src/arm/lithium-codegen-arm.h index 4d6a0c9c0..e6626481b 100644 --- a/src/arm/lithium-codegen-arm.h +++ b/src/arm/lithium-codegen-arm.h @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -119,9 +119,6 @@ class LCodeGen BASE_EMBEDDED { void DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, Label* map_check); - void DoCheckMapCommon(Register reg, Register scratch, Handle map, - CompareMapMode mode, LEnvironment* env); - // Parallel move support. void DoParallelMove(LParallelMove* move); void DoGap(LGap* instr); diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index ca3771fc9..59a5e5ba7 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -1992,50 +1992,18 @@ void MacroAssembler::StoreNumberToDoubleElements(Register value_reg, } -void MacroAssembler::CompareMap(Register obj, - Register scratch, - Handle map, - Label* early_success, - CompareMapMode mode) { - ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); - cmp(scratch, Operand(map)); - if (mode == ALLOW_ELEMENT_TRANSITION_MAPS) { - bool ignore; - Map* transitioned_fast_element_map( - map->LookupElementsTransitionMap(FAST_ELEMENTS, &ignore)); - ASSERT(transitioned_fast_element_map == NULL || - map->elements_kind() != FAST_ELEMENTS); - if (transitioned_fast_element_map != NULL) { - b(eq, early_success); - cmp(scratch, Operand(Handle(transitioned_fast_element_map))); - } - - Map* transitioned_double_map( - map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, &ignore)); - ASSERT(transitioned_double_map == NULL || - map->elements_kind() == FAST_SMI_ONLY_ELEMENTS); - if (transitioned_double_map != NULL) { - b(eq, early_success); - cmp(scratch, Operand(Handle(transitioned_double_map))); - } - } -} - - void MacroAssembler::CheckMap(Register obj, Register scratch, Handle map, Label* fail, - SmiCheckType smi_check_type, - CompareMapMode mode) { + SmiCheckType smi_check_type) { if (smi_check_type == DO_SMI_CHECK) { JumpIfSmi(obj, fail); } - - Label success; - CompareMap(obj, scratch, map, &success, mode); + ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); + mov(ip, Operand(map)); + cmp(scratch, ip); b(ne, fail); - bind(&success); } diff --git a/src/arm/macro-assembler-arm.h b/src/arm/macro-assembler-arm.h index 20db22f46..392c2f750 100644 --- a/src/arm/macro-assembler-arm.h +++ b/src/arm/macro-assembler-arm.h @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -790,26 +790,15 @@ class MacroAssembler: public Assembler { Register scratch4, Label* fail); - // Compare an object's map with the specified map and its transitioned - // elements maps if mode is ALLOW_ELEMENT_TRANSITION_MAPS. Condition flags are - // set with result of map compare. If multiple map compares are required, the - // compare sequences branches to early_success. - void CompareMap(Register obj, - Register scratch, - Handle map, - Label* early_success, - CompareMapMode mode = REQUIRE_EXACT_MAP); - - // Check if the map of an object is equal to a specified map and branch to - // label if not. Skip the smi check if not required (object is known to be a - // heap object). If mode is ALLOW_ELEMENT_TRANSITION_MAPS, then also match - // against maps that are ElementsKind transition maps of the specificed map. + // Check if the map of an object is equal to a specified map (either + // given directly or as an index into the root list) and branch to + // label if not. Skip the smi check if not required (object is known + // to be a heap object) void CheckMap(Register obj, Register scratch, Handle map, Label* fail, - SmiCheckType smi_check_type, - CompareMapMode mode = REQUIRE_EXACT_MAP); + SmiCheckType smi_check_type); void CheckMap(Register obj, diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc index 8947550eb..b6b2ee2f0 100644 --- a/src/arm/stub-cache-arm.cc +++ b/src/arm/stub-cache-arm.cc @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -1019,9 +1019,10 @@ Register StubCompiler::CheckPrototypes(Handle object, __ ldr(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset)); } else { Handle current_map(current->map()); - __ CheckMap(reg, scratch1, current_map, miss, DONT_DO_SMI_CHECK, - ALLOW_ELEMENT_TRANSITION_MAPS); - + __ ldr(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); + __ cmp(scratch1, Operand(current_map)); + // Branch on the result of the map check. + __ b(ne, miss); // Check access rights to the global object. This has to happen after // the map check so that we know that the object is actually a global // object. @@ -1052,8 +1053,9 @@ Register StubCompiler::CheckPrototypes(Handle object, LOG(masm()->isolate(), IntEvent("check-maps-depth", depth + 1)); // Check the holder map. - __ CheckMap(reg, scratch1, Handle(current->map()), miss, - DONT_DO_SMI_CHECK, ALLOW_ELEMENT_TRANSITION_MAPS); + __ ldr(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); + __ cmp(scratch1, Operand(Handle(current->map()))); + __ b(ne, miss); // Perform security check for access to the global object. ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded()); diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 014175146..1856c8092 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -1921,11 +1921,8 @@ class HLoadExternalArrayPointer: public HUnaryOperation { class HCheckMap: public HTemplateInstruction<2> { public: - HCheckMap(HValue* value, Handle map, - HValue* typecheck = NULL, - CompareMapMode mode = REQUIRE_EXACT_MAP) - : map_(map), - mode_(mode) { + HCheckMap(HValue* value, Handle map, HValue* typecheck = NULL) + : map_(map) { SetOperandAt(0, value); // If callers don't depend on a typecheck, they can pass in NULL. In that // case we use a copy of the |value| argument as a dummy value. @@ -1943,24 +1940,17 @@ class HCheckMap: public HTemplateInstruction<2> { HValue* value() { return OperandAt(0); } Handle map() const { return map_; } - CompareMapMode mode() const { return mode_; } DECLARE_CONCRETE_INSTRUCTION(CheckMap) protected: virtual bool DataEquals(HValue* other) { HCheckMap* b = HCheckMap::cast(other); - // Two CheckMaps instructions are DataEqual if their maps are identical and - // they have the same mode. If the map to check has FAST_ELEMENTS, then the - // mode doesn't have to match: since there are no transitioned maps to - // compare the generated code will be equivalent regardless of mode. - return map_.is_identical_to(b->map()) && - (b->mode() == mode() || map_->elements_kind() == FAST_ELEMENTS); + return map_.is_identical_to(b->map()); } private: Handle map_; - CompareMapMode mode_; }; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index cd0297484..923087043 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -4652,8 +4652,7 @@ void HGraphBuilder::AddCheckConstantFunction(Call* expr, // its prototypes. if (smi_and_map_check) { AddInstruction(new(zone()) HCheckNonSmi(receiver)); - AddInstruction(new(zone()) HCheckMap(receiver, receiver_map, - NULL, ALLOW_ELEMENT_TRANSITION_MAPS)); + AddInstruction(new(zone()) HCheckMap(receiver, receiver_map)); } if (!expr->holder().is_null()) { AddInstruction(new(zone()) HCheckPrototypeMaps( diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index edde934b4..137d62c55 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -4033,23 +4033,13 @@ void LCodeGen::DoCheckFunction(LCheckFunction* instr) { } -void LCodeGen::DoCheckMapCommon(Register reg, - Handle map, - CompareMapMode mode, - LEnvironment* env) { - Label success; - __ CompareMap(reg, map, &success, mode); - DeoptimizeIf(not_equal, env); - __ bind(&success); -} - - void LCodeGen::DoCheckMap(LCheckMap* instr) { LOperand* input = instr->InputAt(0); ASSERT(input->IsRegister()); Register reg = ToRegister(input); - Handle map = instr->hydrogen()->map(); - DoCheckMapCommon(reg, map, instr->hydrogen()->mode(), instr->environment()); + __ cmp(FieldOperand(reg, HeapObject::kMapOffset), + instr->hydrogen()->map()); + DeoptimizeIf(not_equal, instr->environment()); } @@ -4112,9 +4102,9 @@ void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { // Check prototype maps up to the holder. while (!current_prototype.is_identical_to(holder)) { - DoCheckMapCommon(reg, Handle(current_prototype->map()), - ALLOW_ELEMENT_TRANSITION_MAPS, instr->environment()); - + __ cmp(FieldOperand(reg, HeapObject::kMapOffset), + Handle(current_prototype->map())); + DeoptimizeIf(not_equal, instr->environment()); current_prototype = Handle(JSObject::cast(current_prototype->GetPrototype())); // Load next prototype object. @@ -4122,8 +4112,9 @@ void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { } // Check the holder map. - DoCheckMapCommon(reg, Handle(current_prototype->map()), - ALLOW_ELEMENT_TRANSITION_MAPS, instr->environment()); + __ cmp(FieldOperand(reg, HeapObject::kMapOffset), + Handle(current_prototype->map())); + DeoptimizeIf(not_equal, instr->environment()); } diff --git a/src/ia32/lithium-codegen-ia32.h b/src/ia32/lithium-codegen-ia32.h index 38d0b3bce..375f137d7 100644 --- a/src/ia32/lithium-codegen-ia32.h +++ b/src/ia32/lithium-codegen-ia32.h @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -110,9 +110,6 @@ class LCodeGen BASE_EMBEDDED { void DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, Label* map_check); - void DoCheckMapCommon(Register reg, Handle map, - CompareMapMode mode, LEnvironment* env); - // Parallel move support. void DoParallelMove(LParallelMove* move); void DoGap(LGap* instr); diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index ace1bed56..3356e8189 100644 --- a/src/ia32/macro-assembler-ia32.cc +++ b/src/ia32/macro-assembler-ia32.cc @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -487,49 +487,15 @@ void MacroAssembler::StoreNumberToDoubleElements( } -void MacroAssembler::CompareMap(Register obj, - Handle map, - Label* early_success, - CompareMapMode mode) { - cmp(FieldOperand(obj, HeapObject::kMapOffset), map); - if (mode == ALLOW_ELEMENT_TRANSITION_MAPS) { - bool ignore; - Map* transitioned_fast_element_map( - map->LookupElementsTransitionMap(FAST_ELEMENTS, &ignore)); - ASSERT(transitioned_fast_element_map == NULL || - map->elements_kind() != FAST_ELEMENTS); - if (transitioned_fast_element_map != NULL) { - j(equal, early_success, Label::kNear); - cmp(FieldOperand(obj, HeapObject::kMapOffset), - Handle(transitioned_fast_element_map)); - } - - Map* transitioned_double_map( - map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, &ignore)); - ASSERT(transitioned_double_map == NULL || - map->elements_kind() == FAST_SMI_ONLY_ELEMENTS); - if (transitioned_double_map != NULL) { - j(equal, early_success, Label::kNear); - cmp(FieldOperand(obj, HeapObject::kMapOffset), - Handle(transitioned_double_map)); - } - } -} - - void MacroAssembler::CheckMap(Register obj, Handle map, Label* fail, - SmiCheckType smi_check_type, - CompareMapMode mode) { + SmiCheckType smi_check_type) { if (smi_check_type == DO_SMI_CHECK) { JumpIfSmi(obj, fail); } - - Label success; - CompareMap(obj, map, &success, mode); + cmp(FieldOperand(obj, HeapObject::kMapOffset), Immediate(map)); j(not_equal, fail); - bind(&success); } diff --git a/src/ia32/macro-assembler-ia32.h b/src/ia32/macro-assembler-ia32.h index f7400ad39..e6a17417d 100644 --- a/src/ia32/macro-assembler-ia32.h +++ b/src/ia32/macro-assembler-ia32.h @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -356,24 +356,13 @@ class MacroAssembler: public Assembler { Label* fail, bool specialize_for_processor); - // Compare an object's map with the specified map and its transitioned - // elements maps if mode is ALLOW_ELEMENT_TRANSITION_MAPS. FLAGS are set with - // result of map compare. If multiple map compares are required, the compare - // sequences branches to early_success. - void CompareMap(Register obj, - Handle map, - Label* early_success, - CompareMapMode mode = REQUIRE_EXACT_MAP); - // Check if the map of an object is equal to a specified map and branch to // label if not. Skip the smi check if not required (object is known to be a - // heap object). If mode is ALLOW_ELEMENT_TRANSITION_MAPS, then also match - // against maps that are ElementsKind transition maps of the specificed map. + // heap object) void CheckMap(Register obj, Handle map, Label* fail, - SmiCheckType smi_check_type, - CompareMapMode mode = REQUIRE_EXACT_MAP); + SmiCheckType smi_check_type); // Check if the map of an object is equal to a specified map and branch to a // specified target if equal. Skip the smi check if not required (object is diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc index 051a8177e..c27a60fd0 100644 --- a/src/ia32/stub-cache-ia32.cc +++ b/src/ia32/stub-cache-ia32.cc @@ -878,10 +878,13 @@ Register StubCompiler::CheckPrototypes(Handle object, if (in_new_space) { // Save the map in scratch1 for later. __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); + __ cmp(scratch1, Immediate(current_map)); + } else { + __ cmp(FieldOperand(reg, HeapObject::kMapOffset), + Immediate(current_map)); } - __ CheckMap(reg, current_map, miss, DONT_DO_SMI_CHECK, - ALLOW_ELEMENT_TRANSITION_MAPS); - + // Branch on the result of the map check. + __ j(not_equal, miss); // Check access rights to the global object. This has to happen after // the map check so that we know that the object is actually a global // object. @@ -913,8 +916,9 @@ Register StubCompiler::CheckPrototypes(Handle object, LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); // Check the holder map. - __ CheckMap(reg, Handle(holder->map()), - miss, DONT_DO_SMI_CHECK, ALLOW_ELEMENT_TRANSITION_MAPS); + __ cmp(FieldOperand(reg, HeapObject::kMapOffset), + Immediate(Handle(holder->map()))); + __ j(not_equal, miss); // Perform security check for access to the global object. ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded()); diff --git a/src/lithium.h b/src/lithium.h index 48a533c57..b605eb97b 100644 --- a/src/lithium.h +++ b/src/lithium.h @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -523,6 +523,8 @@ class LEnvironment: public ZoneObject { LOperand** spilled_double_registers_; LEnvironment* outer_; + + friend class LCodegen; }; diff --git a/src/objects.h b/src/objects.h index 906afa13b..5aaadcc3e 100644 --- a/src/objects.h +++ b/src/objects.h @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -162,11 +162,6 @@ enum ElementsKind { LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS }; -enum CompareMapMode { - REQUIRE_EXACT_MAP, - ALLOW_ELEMENT_TRANSITION_MAPS -}; - const int kElementsKindCount = LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; void PrintElementsKind(FILE* out, ElementsKind kind); diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index bafe74eec..6239acb51 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -3747,23 +3747,13 @@ void LCodeGen::DoCheckFunction(LCheckFunction* instr) { } -void LCodeGen::DoCheckMapCommon(Register reg, - Handle map, - CompareMapMode mode, - LEnvironment* env) { - Label success; - __ CompareMap(reg, map, &success, mode); - DeoptimizeIf(not_equal, env); - __ bind(&success); -} - - void LCodeGen::DoCheckMap(LCheckMap* instr) { LOperand* input = instr->InputAt(0); ASSERT(input->IsRegister()); Register reg = ToRegister(input); - Handle map = instr->hydrogen()->map(); - DoCheckMapCommon(reg, map, instr->hydrogen()->mode(), instr->environment()); + __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), + instr->hydrogen()->map()); + DeoptimizeIf(not_equal, instr->environment()); } @@ -3829,8 +3819,9 @@ void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { // Check prototype maps up to the holder. while (!current_prototype.is_identical_to(holder)) { - DoCheckMapCommon(reg, Handle(current_prototype->map()), - ALLOW_ELEMENT_TRANSITION_MAPS, instr->environment()); + __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), + Handle(current_prototype->map())); + DeoptimizeIf(not_equal, instr->environment()); current_prototype = Handle(JSObject::cast(current_prototype->GetPrototype())); // Load next prototype object. @@ -3838,8 +3829,9 @@ void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { } // Check the holder map. - DoCheckMapCommon(reg, Handle(current_prototype->map()), - ALLOW_ELEMENT_TRANSITION_MAPS, instr->environment()); + __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), + Handle(current_prototype->map())); + DeoptimizeIf(not_equal, instr->environment()); } diff --git a/src/x64/lithium-codegen-x64.h b/src/x64/lithium-codegen-x64.h index 5cffb5a68..832942f1e 100644 --- a/src/x64/lithium-codegen-x64.h +++ b/src/x64/lithium-codegen-x64.h @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -102,10 +102,7 @@ class LCodeGen BASE_EMBEDDED { void DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, Label* map_check); - void DoCheckMapCommon(Register reg, Handle map, - CompareMapMode mode, LEnvironment* env); - -// Parallel move support. + // Parallel move support. void DoParallelMove(LParallelMove* move); void DoGap(LGap* instr); diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index e139df75b..10e423b5b 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -2739,49 +2739,15 @@ void MacroAssembler::StoreNumberToDoubleElements( } -void MacroAssembler::CompareMap(Register obj, - Handle map, - Label* early_success, - CompareMapMode mode) { - Cmp(FieldOperand(obj, HeapObject::kMapOffset), map); - if (mode == ALLOW_ELEMENT_TRANSITION_MAPS) { - bool ignore; - Map* transitioned_fast_element_map( - map->LookupElementsTransitionMap(FAST_ELEMENTS, &ignore)); - ASSERT(transitioned_fast_element_map == NULL || - map->elements_kind() != FAST_ELEMENTS); - if (transitioned_fast_element_map != NULL) { - j(equal, early_success, Label::kNear); - Cmp(FieldOperand(obj, HeapObject::kMapOffset), - Handle(transitioned_fast_element_map)); - } - - Map* transitioned_double_map( - map->LookupElementsTransitionMap(FAST_DOUBLE_ELEMENTS, &ignore)); - ASSERT(transitioned_double_map == NULL || - map->elements_kind() == FAST_SMI_ONLY_ELEMENTS); - if (transitioned_double_map != NULL) { - j(equal, early_success, Label::kNear); - Cmp(FieldOperand(obj, HeapObject::kMapOffset), - Handle(transitioned_double_map)); - } - } -} - - void MacroAssembler::CheckMap(Register obj, Handle map, Label* fail, - SmiCheckType smi_check_type, - CompareMapMode mode) { + SmiCheckType smi_check_type) { if (smi_check_type == DO_SMI_CHECK) { JumpIfSmi(obj, fail); } - - Label success; - CompareMap(obj, map, &success, mode); + Cmp(FieldOperand(obj, HeapObject::kMapOffset), map); j(not_equal, fail); - bind(&success); } diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h index 82f8f6df7..97a98017c 100644 --- a/src/x64/macro-assembler-x64.h +++ b/src/x64/macro-assembler-x64.h @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -889,24 +889,13 @@ class MacroAssembler: public Assembler { XMMRegister xmm_scratch, Label* fail); - // Compare an object's map with the specified map and its transitioned - // elements maps if mode is ALLOW_ELEMENT_TRANSITION_MAPS. FLAGS are set with - // result of map compare. If multiple map compares are required, the compare - // sequences branches to early_success. - void CompareMap(Register obj, - Handle map, - Label* early_success, - CompareMapMode mode = REQUIRE_EXACT_MAP); - - // Check if the map of an object is equal to a specified map and branch to - // label if not. Skip the smi check if not required (object is known to be a - // heap object). If mode is ALLOW_ELEMENT_TRANSITION_MAPS, then also match - // against maps that are ElementsKind transition maps of the specificed map. + // Check if the map of an object is equal to a specified map and + // branch to label if not. Skip the smi check if not required + // (object is known to be a heap object) void CheckMap(Register obj, Handle map, Label* fail, - SmiCheckType smi_check_type, - CompareMapMode mode = REQUIRE_EXACT_MAP); + SmiCheckType smi_check_type); // Check if the map of an object is equal to a specified map and branch to a // specified target if equal. Skip the smi check if not required (object is diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc index 8830bc14a..a28dbbf02 100644 --- a/src/x64/stub-cache-x64.cc +++ b/src/x64/stub-cache-x64.cc @@ -1,4 +1,4 @@ -// Copyright 2012 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -864,10 +864,12 @@ Register StubCompiler::CheckPrototypes(Handle object, if (in_new_space) { // Save the map in scratch1 for later. __ movq(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); + __ Cmp(scratch1, current_map); + } else { + __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), current_map); } - __ CheckMap(reg, Handle(current_map), - miss, DONT_DO_SMI_CHECK, ALLOW_ELEMENT_TRANSITION_MAPS); - + // Branch on the result of the map check. + __ j(not_equal, miss); // Check access rights to the global object. This has to happen after // the map check so that we know that the object is actually a global // object. @@ -899,8 +901,8 @@ Register StubCompiler::CheckPrototypes(Handle object, LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); // Check the holder map. - __ CheckMap(reg, Handle(holder->map()), - miss, DONT_DO_SMI_CHECK, ALLOW_ELEMENT_TRANSITION_MAPS); + __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), Handle(holder->map())); + __ j(not_equal, miss); // Perform security check for access to the global object. ASSERT(current->IsJSGlobalProxy() || !current->IsAccessCheckNeeded()); -- 2.34.1