Skip to content

Commit

Permalink
Version 4.7.80.25 (cherry-pick)
Browse files Browse the repository at this point in the history
Merged 200315c

Make AstRawString deduplication encoding-agnostic.

BUG=v8:4450
LOG=N
R=hablich@chromium.org
TBR=hablich@chromium.org

Review URL: https://codereview.chromium.org/1494293003 .

Cr-Commit-Position: refs/branch-heads/4.7@{#36}
Cr-Branched-From: f3c8926-refs/heads/master@{#31014}
  • Loading branch information
hashseed committed Dec 4, 2015
1 parent be169f8 commit c408ea7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/v8-version.h
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 4
#define V8_MINOR_VERSION 7
#define V8_BUILD_NUMBER 80
#define V8_PATCH_LEVEL 24
#define V8_PATCH_LEVEL 25

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
30 changes: 26 additions & 4 deletions src/ast-value-factory.cc
Expand Up @@ -29,6 +29,7 @@

#include "src/api.h"
#include "src/objects.h"
#include "src/utils.h"

namespace v8 {
namespace internal {
Expand Down Expand Up @@ -379,11 +380,32 @@ AstRawString* AstValueFactory::GetString(uint32_t hash, bool is_one_byte,
bool AstValueFactory::AstRawStringCompare(void* a, void* b) {
const AstRawString* lhs = static_cast<AstRawString*>(a);
const AstRawString* rhs = static_cast<AstRawString*>(b);
if (lhs->is_one_byte() != rhs->is_one_byte()) return false;
if (lhs->length() != rhs->length()) return false;
if (lhs->hash() != rhs->hash()) return false;
int len = lhs->byte_length();
if (rhs->byte_length() != len) return false;
return memcmp(lhs->raw_data(), rhs->raw_data(), len) == 0;
const unsigned char* l = lhs->raw_data();
const unsigned char* r = rhs->raw_data();
size_t length = rhs->length();
if (lhs->is_one_byte()) {
if (rhs->is_one_byte()) {
return CompareCharsUnsigned(reinterpret_cast<const uint8_t*>(l),
reinterpret_cast<const uint8_t*>(r),
length) == 0;
} else {
return CompareCharsUnsigned(reinterpret_cast<const uint8_t*>(l),
reinterpret_cast<const uint16_t*>(r),
length) == 0;
}
} else {
if (rhs->is_one_byte()) {
return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l),
reinterpret_cast<const uint8_t*>(r),
length) == 0;
} else {
return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l),
reinterpret_cast<const uint16_t*>(r),
length) == 0;
}
}
}
} // namespace internal
} // namespace v8
8 changes: 8 additions & 0 deletions test/mjsunit/regress/regress-4450.js
@@ -0,0 +1,8 @@
// Copyright 2015 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.

({})['foobar\u2653'.slice(0, 6)] = null;
var x;
eval('x = function foobar() { return foobar };');
x();

0 comments on commit c408ea7

Please sign in to comment.