summaryrefslogtreecommitdiff
path: root/deps/v8/src/ic/handler-configuration.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2017-10-18 15:03:02 -0700
committerMichaël Zasso <targos@protonmail.com>2017-10-18 17:01:41 -0700
commit3d1b3df9486c0e7708065257f7311902f6b7b366 (patch)
treecb051bdeaead11e06dcd97725783e0f113afb1bf /deps/v8/src/ic/handler-configuration.cc
parente2cddbb8ccdb7b3c4a40c8acc630f68703bc77b5 (diff)
downloadnode-new-3d1b3df9486c0e7708065257f7311902f6b7b366.tar.gz
deps: update V8 to 6.2.414.32
PR-URL: https://github.com/nodejs/node/pull/15362 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/src/ic/handler-configuration.cc')
-rw-r--r--deps/v8/src/ic/handler-configuration.cc82
1 files changed, 82 insertions, 0 deletions
diff --git a/deps/v8/src/ic/handler-configuration.cc b/deps/v8/src/ic/handler-configuration.cc
new file mode 100644
index 0000000000..7071941bd7
--- /dev/null
+++ b/deps/v8/src/ic/handler-configuration.cc
@@ -0,0 +1,82 @@
+// Copyright 2017 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.
+
+#include "src/ic/handler-configuration.h"
+
+#include "src/ic/handler-configuration-inl.h"
+#include "src/transitions.h"
+
+namespace v8 {
+namespace internal {
+
+// |name| can be nullptr if no name/details check needs to be performed.
+Object* StoreHandler::ValidTuple3HandlerOrNull(Object* handler, Name* name,
+ Handle<Map>* out_transition) {
+ DCHECK(handler->IsTuple3());
+ // Step 1: Check validity cell.
+ STATIC_ASSERT(kValidityCellOffset == Tuple3::kValue3Offset);
+ Object* raw_validity_cell = Tuple3::cast(handler)->value3();
+ Smi* valid = Smi::FromInt(Map::kPrototypeChainValid);
+ // |raw_valitity_cell| can be Smi::kZero if no validity cell is required
+ // (which counts as valid).
+ if (raw_validity_cell->IsCell() &&
+ Cell::cast(raw_validity_cell)->value() != valid) {
+ return nullptr;
+ }
+ // Step 2 (optional): Check transition key.
+ WeakCell* target_cell = StoreHandler::GetTuple3TransitionCell(handler);
+ if (name != nullptr) {
+ if (!TransitionsAccessor::IsMatchingMap(target_cell, name, kData, NONE)) {
+ return nullptr;
+ }
+ }
+ // Step 3: Check if the transition target is deprecated.
+ Map* transition = Map::cast(target_cell->value());
+ if (transition->is_deprecated()) return nullptr;
+ *out_transition = handle(transition);
+ return handler;
+}
+
+Object* StoreHandler::ValidFixedArrayHandlerOrNull(
+ Object* raw_handler, Name* name, Handle<Map>* out_transition) {
+ DCHECK(raw_handler->IsFixedArray());
+ FixedArray* handler = FixedArray::cast(raw_handler);
+ // Step 1: Check validity cell.
+ Object* value = Cell::cast(handler->get(kValidityCellIndex))->value();
+ if (value != Smi::FromInt(Map::kPrototypeChainValid)) return nullptr;
+ // Step 2: Check transition key.
+ WeakCell* target_cell = StoreHandler::GetArrayTransitionCell(handler);
+ if (!TransitionsAccessor::IsMatchingMap(target_cell, name, kData, NONE)) {
+ return nullptr;
+ }
+ // Step 3: Check prototypes.
+ Heap* heap = handler->GetHeap();
+ Isolate* isolate = heap->isolate();
+ Handle<Name> name_handle(name, isolate);
+ for (int i = kFirstPrototypeIndex; i < handler->length(); i++) {
+ // This mirrors AccessorAssembler::CheckPrototype.
+ WeakCell* prototype_cell = WeakCell::cast(handler->get(i));
+ if (prototype_cell->cleared()) return nullptr;
+ HeapObject* maybe_prototype = HeapObject::cast(prototype_cell->value());
+ if (maybe_prototype->IsPropertyCell()) {
+ Object* value = PropertyCell::cast(maybe_prototype)->value();
+ if (value != heap->the_hole_value()) return nullptr;
+ } else {
+ DCHECK(maybe_prototype->map()->is_dictionary_map());
+ // Do a negative dictionary lookup.
+ NameDictionary* dict =
+ JSObject::cast(maybe_prototype)->property_dictionary();
+ int number = dict->FindEntry(isolate, name_handle);
+ if (number != NameDictionary::kNotFound) return nullptr;
+ }
+ }
+ // Step 4: Check if the transition target is deprecated.
+ Map* transition = Map::cast(target_cell->value());
+ if (transition->is_deprecated()) return nullptr;
+ *out_transition = handle(transition);
+ return handler;
+}
+
+} // namespace internal
+} // namespace v8