Mercurial > hg > truffle
comparison src/share/vm/opto/memnode.cpp @ 2320:41d4973cf100
6942326: x86 code in string_indexof() could read beyond reserved heap space
Summary: copy small (<8) strings on stack if str+16 crosses a page boundary and load from stack into XMM. Back up pointer when loading string's tail.
Reviewed-by: never
author | kvn |
---|---|
date | Sat, 26 Feb 2011 12:10:54 -0800 |
parents | 5a41a201d08c |
children | b099aaf51bf8 |
comparison
equal
deleted
inserted
replaced
2319:8190d4b75e09 | 2320:41d4973cf100 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
1557 tp->is_oopptr()->klass()->is_java_lang_Object() || | 1557 tp->is_oopptr()->klass()->is_java_lang_Object() || |
1558 // unsafe field access may not have a constant offset | 1558 // unsafe field access may not have a constant offset |
1559 phase->C->has_unsafe_access(), | 1559 phase->C->has_unsafe_access(), |
1560 "Field accesses must be precise" ); | 1560 "Field accesses must be precise" ); |
1561 // For oop loads, we expect the _type to be precise | 1561 // For oop loads, we expect the _type to be precise |
1562 if (OptimizeStringConcat && klass == phase->C->env()->String_klass() && | 1562 if (klass == phase->C->env()->String_klass() && |
1563 adr->is_AddP() && off != Type::OffsetBot) { | 1563 adr->is_AddP() && off != Type::OffsetBot) { |
1564 // For constant Strings treat the fields as compile time constants. | 1564 // For constant Strings treat the final fields as compile time constants. |
1565 Node* base = adr->in(AddPNode::Base); | 1565 Node* base = adr->in(AddPNode::Base); |
1566 const TypeOopPtr* t = phase->type(base)->isa_oopptr(); | 1566 const TypeOopPtr* t = phase->type(base)->isa_oopptr(); |
1567 if (t != NULL && t->singleton()) { | 1567 if (t != NULL && t->singleton()) { |
1568 ciObject* string = t->const_oop(); | 1568 ciField* field = phase->C->env()->String_klass()->get_field_by_offset(off, false); |
1569 ciConstant constant = string->as_instance()->field_value_by_offset(off); | 1569 if (field != NULL && field->is_final()) { |
1570 if (constant.basic_type() == T_INT) { | 1570 ciObject* string = t->const_oop(); |
1571 return TypeInt::make(constant.as_int()); | 1571 ciConstant constant = string->as_instance()->field_value(field); |
1572 } else if (constant.basic_type() == T_ARRAY) { | 1572 if (constant.basic_type() == T_INT) { |
1573 if (adr->bottom_type()->is_ptr_to_narrowoop()) { | 1573 return TypeInt::make(constant.as_int()); |
1574 return TypeNarrowOop::make_from_constant(constant.as_object()); | 1574 } else if (constant.basic_type() == T_ARRAY) { |
1575 } else { | 1575 if (adr->bottom_type()->is_ptr_to_narrowoop()) { |
1576 return TypeOopPtr::make_from_constant(constant.as_object()); | 1576 return TypeNarrowOop::make_from_constant(constant.as_object()); |
1577 } else { | |
1578 return TypeOopPtr::make_from_constant(constant.as_object()); | |
1579 } | |
1577 } | 1580 } |
1578 } | 1581 } |
1579 } | 1582 } |
1580 } | 1583 } |
1581 } else if (tp->base() == Type::KlassPtr) { | 1584 } else if (tp->base() == Type::KlassPtr) { |