code = CompileHandler(lookup, value, flag);
DCHECK(code->is_handler());
- if (code->type() != Code::NORMAL) {
+ // TODO(mvstanton): we'd only like to cache code on the map when it's custom
+ // code compiled for this map, otherwise it's already cached in the global
+ // code
+ // cache. We are also guarding against installing code with flags that don't
+ // match the desired CacheHolderFlag computed above, which would lead to
+ // invalid lookups later.
+ if (code->type() != Code::NORMAL &&
+ Code::ExtractCacheHolderFromFlags(code->flags()) == flag) {
Map::UpdateCodeCache(stub_holder_map, lookup->name(), code);
}
--- /dev/null
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function foo() {
+ try {
+ String.prototype.length.x();
+ } catch (e) {
+ }
+}
+
+foo();
+foo();
+foo();