diff --git a/deps/v8/ChangeLog b/deps/v8/ChangeLog index 7e7df06809e..6901729b01e 100644 --- a/deps/v8/ChangeLog +++ b/deps/v8/ChangeLog @@ -1,3 +1,42 @@ +2011-07-20: Version 3.4.14 + + Fix the debugger for strict-mode functions. (Chromium issue 89236) + + Add GetPropertyAttribute method for Object in the API. (Patch by Peter Varga) + + Fix -Wunused-but-set-variable for gcc-4.6 on x64. (Issue 1291) + + +2011-07-18: Version 3.4.13 + + Improved debugger support to allow inspection of optimized frames (issue + 1140). + + Fixed a bug in prototype transitions cache clearing introduced by r8165. + + Fixed shortcutting bug in HInferRepresentation. Patch by Andy Wingo. + + Fixed a memory leak in sample/shell.cc (dispose semaphores). + + Simplified HClampToUint8. Patch by Andy Wingo. + + Exposed APIs for detecting boxed primitives, native errors. Patch by + Luke Zarko. + + Added map check for COW elements to crankshaft array handling code + (issue 1560). + + Sample shell and (a light version of) D8 links against a shared library + now. + + Fixed bug in array filter and reduce functions (issue 1559). + + Avoid TLS load in AstNode constructor. + + Introduced a random entropy source which can optionally be provided at + initialization. (Chromium issue 89462). + + 2011-07-13: Version 3.4.12 Added --prof profiling option to d8 shell. diff --git a/deps/v8/SConstruct b/deps/v8/SConstruct index 5276ce2cae6..8e16a7824e3 100644 --- a/deps/v8/SConstruct +++ b/deps/v8/SConstruct @@ -404,6 +404,7 @@ CCTEST_EXTRA_FLAGS = { }, 'os:linux': { 'LIBS': ['pthread'], + 'CCFLAGS': ['-Wno-unused-but-set-variable'], }, 'os:macos': { 'LIBS': ['pthread'], @@ -773,6 +774,13 @@ PREPARSER_FLAGS = { D8_FLAGS = { + 'all': { + 'library:shared': { + 'CPPDEFINES': ['V8_SHARED'], + 'LIBS': ['v8'], + 'LIBPATH': ['.'] + }, + }, 'gcc': { 'all': { 'CCFLAGS': ['$DIALECTFLAGS', '$WARNINGFLAGS'], @@ -1370,7 +1378,11 @@ def BuildSpecific(env, mode, env_overrides, tools): d8_env = Environment(tools=tools) d8_env.Replace(**context.flags['d8']) context.ApplyEnvOverrides(d8_env) - shell = d8_env.Program('d8' + suffix, object_files + shell_files) + if context.options['library'] == 'static': + shell = d8_env.Program('d8' + suffix, object_files + shell_files) + else: + shell = d8_env.Program('d8' + suffix, shell_files) + d8_env.Depends(shell, library) context.d8_targets.append(shell) for sample in context.samples: diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 08724110674..f4f81e4c72c 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -80,9 +80,11 @@ namespace v8 { class Context; class String; +class StringObject; class Value; class Utils; class Number; +class NumberObject; class Object; class Array; class Int32; @@ -90,6 +92,7 @@ class Uint32; class External; class Primitive; class Boolean; +class BooleanObject; class Integer; class Function; class Date; @@ -928,6 +931,26 @@ class Value : public Data { */ V8EXPORT bool IsDate() const; + /** + * Returns true if this value is a Boolean object. + */ + V8EXPORT bool IsBooleanObject() const; + + /** + * Returns true if this value is a Number object. + */ + V8EXPORT bool IsNumberObject() const; + + /** + * Returns true if this value is a String object. + */ + V8EXPORT bool IsStringObject() const; + + /** + * Returns true if this value is a NativeError. + */ + V8EXPORT bool IsNativeError() const; + /** * Returns true if this value is a RegExp. */ @@ -1435,6 +1458,13 @@ class Object : public Value { V8EXPORT Local Get(uint32_t index); + /** + * Gets the property attributes of a property which can be None or + * any combination of ReadOnly, DontEnum and DontDelete. Returns + * None when the property doesn't exist. + */ + V8EXPORT PropertyAttribute GetPropertyAttributes(Handle key); + // TODO(1245389): Replace the type-specific versions of these // functions with generic ones that accept a Handle key. V8EXPORT bool Has(Handle key); @@ -1744,6 +1774,63 @@ class Date : public Object { }; +/** + * A Number object (ECMA-262, 4.3.21). + */ +class NumberObject : public Object { + public: + V8EXPORT static Local New(double value); + + /** + * Returns the Number held by the object. + */ + V8EXPORT double NumberValue() const; + + static inline NumberObject* Cast(v8::Value* obj); + + private: + V8EXPORT static void CheckCast(v8::Value* obj); +}; + + +/** + * A Boolean object (ECMA-262, 4.3.15). + */ +class BooleanObject : public Object { + public: + V8EXPORT static Local New(bool value); + + /** + * Returns the Boolean held by the object. + */ + V8EXPORT bool BooleanValue() const; + + static inline BooleanObject* Cast(v8::Value* obj); + + private: + V8EXPORT static void CheckCast(v8::Value* obj); +}; + + +/** + * A String object (ECMA-262, 4.3.18). + */ +class StringObject : public Object { + public: + V8EXPORT static Local New(Handle value); + + /** + * Returns the String held by the object. + */ + V8EXPORT Local StringValue() const; + + static inline StringObject* Cast(v8::Value* obj); + + private: + V8EXPORT static void CheckCast(v8::Value* obj); +}; + + /** * An instance of the built-in RegExp constructor (ECMA-262, 15.10). */ @@ -2721,6 +2808,13 @@ class V8EXPORT StartupDataDecompressor { // NOLINT char** raw_data; }; + +/** + * EntropySource is used as a callback function when v8 needs a source + * of entropy. + */ +typedef bool (*EntropySource)(unsigned char* buffer, size_t length); + /** * Container class for static utility functions. */ @@ -2945,6 +3039,12 @@ class V8EXPORT V8 { */ static bool Initialize(); + /** + * Allows the host application to provide a callback which can be used + * as a source of entropy for random number generators. + */ + static void SetEntropySource(EntropySource source); + /** * Adjusts the amount of registered external memory. Used to give * V8 an indication of the amount of externally allocated memory @@ -4010,6 +4110,30 @@ Date* Date::Cast(v8::Value* value) { } +StringObject* StringObject::Cast(v8::Value* value) { +#ifdef V8_ENABLE_CHECKS + CheckCast(value); +#endif + return static_cast(value); +} + + +NumberObject* NumberObject::Cast(v8::Value* value) { +#ifdef V8_ENABLE_CHECKS + CheckCast(value); +#endif + return static_cast(value); +} + + +BooleanObject* BooleanObject::Cast(v8::Value* value) { +#ifdef V8_ENABLE_CHECKS + CheckCast(value); +#endif + return static_cast(value); +} + + RegExp* RegExp::Cast(v8::Value* value) { #ifdef V8_ENABLE_CHECKS CheckCast(value); diff --git a/deps/v8/preparser/preparser-process.cc b/deps/v8/preparser/preparser-process.cc index d7c96f0c735..e67851cbd4b 100644 --- a/deps/v8/preparser/preparser-process.cc +++ b/deps/v8/preparser/preparser-process.cc @@ -208,7 +208,7 @@ void fail(v8::PreParserData* data, const char* message, ...) { fflush(stderr); } exit(EXIT_FAILURE); -}; +} bool IsFlag(const char* arg) { diff --git a/deps/v8/samples/shell.cc b/deps/v8/samples/shell.cc index 7c30beccd5f..f37e731f389 100644 --- a/deps/v8/samples/shell.cc +++ b/deps/v8/samples/shell.cc @@ -95,6 +95,13 @@ class SourceGroup { begin_offset_(0), end_offset_(0) { } +#if !(defined(USING_V8_SHARED) || defined(V8_SHARED)) + ~SourceGroup() { + delete next_semaphore_; + delete done_semaphore_; + } +#endif // USING_V8_SHARED + void Begin(char** argv, int offset) { argv_ = const_cast(argv); begin_offset_ = offset; diff --git a/deps/v8/src/SConscript b/deps/v8/src/SConscript index 6b3059aea60..b45a5677ade 100755 --- a/deps/v8/src/SConscript +++ b/deps/v8/src/SConscript @@ -243,7 +243,14 @@ PREPARSER_SOURCES = { } -D8_FILES = { +D8_LIGHT_FILES = { + 'all': [ + 'd8.cc' + ] +} + + +D8_FULL_FILES = { 'all': [ 'd8.cc', 'd8-debug.cc' ], @@ -323,11 +330,15 @@ def ConfigureObjectFiles(): # Build the standard platform-independent source files. source_files = context.GetRelevantSources(SOURCES) - - d8_files = context.GetRelevantSources(D8_FILES) d8_js = env.JS2C('d8-js.cc', 'd8.js', **{'TYPE': 'D8', 'COMPRESSION': 'off'}) d8_js_obj = context.ConfigureObject(env, d8_js, CPPPATH=['.']) - d8_objs = [context.ConfigureObject(env, [d8_files]), d8_js_obj] + if context.options['library'] == 'shared': + d8_files = context.GetRelevantSources(D8_LIGHT_FILES) + d8_objs = [] + else: + d8_files = context.GetRelevantSources(D8_FULL_FILES) + d8_objs = [d8_js_obj] + d8_objs.append(context.ConfigureObject(env, [d8_files])) # Combine the JavaScript library files into a single C++ file and # compile it. diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index dc1f90c0e28..b0e977564b8 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -2167,6 +2167,65 @@ bool Value::IsDate() const { } +bool Value::IsStringObject() const { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::Value::IsStringObject()")) return false; + i::Handle obj = Utils::OpenHandle(this); + return obj->HasSpecificClassOf(isolate->heap()->String_symbol()); +} + + +bool Value::IsNumberObject() const { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::Value::IsNumberObject()")) return false; + i::Handle obj = Utils::OpenHandle(this); + return obj->HasSpecificClassOf(isolate->heap()->Number_symbol()); +} + + +static i::Object* LookupBuiltin(i::Isolate* isolate, + const char* builtin_name) { + i::Handle symbol = + isolate->factory()->LookupAsciiSymbol(builtin_name); + i::Handle builtins = isolate->js_builtins_object(); + return builtins->GetPropertyNoExceptionThrown(*symbol); +} + + +static bool CheckConstructor(i::Isolate* isolate, + i::Handle obj, + const char* class_name) { + return obj->map()->constructor() == LookupBuiltin(isolate, class_name); +} + + +bool Value::IsNativeError() const { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::Value::IsNativeError()")) return false; + i::Handle obj = Utils::OpenHandle(this); + if (obj->IsJSObject()) { + i::Handle js_obj(i::JSObject::cast(*obj)); + return CheckConstructor(isolate, js_obj, "$Error") || + CheckConstructor(isolate, js_obj, "$EvalError") || + CheckConstructor(isolate, js_obj, "$RangeError") || + CheckConstructor(isolate, js_obj, "$ReferenceError") || + CheckConstructor(isolate, js_obj, "$SyntaxError") || + CheckConstructor(isolate, js_obj, "$TypeError") || + CheckConstructor(isolate, js_obj, "$URIError"); + } else { + return false; + } +} + + +bool Value::IsBooleanObject() const { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::Value::IsBooleanObject()")) return false; + i::Handle obj = Utils::OpenHandle(this); + return obj->HasSpecificClassOf(isolate->heap()->Boolean_symbol()); +} + + bool Value::IsRegExp() const { if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false; i::Handle obj = Utils::OpenHandle(this); @@ -2362,6 +2421,36 @@ void v8::Date::CheckCast(v8::Value* that) { } +void v8::StringObject::CheckCast(v8::Value* that) { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::StringObject::Cast()")) return; + i::Handle obj = Utils::OpenHandle(that); + ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_symbol()), + "v8::StringObject::Cast()", + "Could not convert to StringObject"); +} + + +void v8::NumberObject::CheckCast(v8::Value* that) { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::NumberObject::Cast()")) return; + i::Handle obj = Utils::OpenHandle(that); + ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_symbol()), + "v8::NumberObject::Cast()", + "Could not convert to NumberObject"); +} + + +void v8::BooleanObject::CheckCast(v8::Value* that) { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::BooleanObject::Cast()")) return; + i::Handle obj = Utils::OpenHandle(that); + ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_symbol()), + "v8::BooleanObject::Cast()", + "Could not convert to BooleanObject"); +} + + void v8::RegExp::CheckCast(v8::Value* that) { if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return; i::Handle obj = Utils::OpenHandle(that); @@ -2705,6 +2794,26 @@ Local v8::Object::Get(uint32_t index) { } +PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle key) { + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()", + return static_cast(NONE)); + ENTER_V8(isolate); + i::HandleScope scope(isolate); + i::Handle self = Utils::OpenHandle(this); + i::Handle key_obj = Utils::OpenHandle(*key); + if (!key_obj->IsString()) { + EXCEPTION_PREAMBLE(isolate); + key_obj = i::Execution::ToString(key_obj, &has_pending_exception); + EXCEPTION_BAILOUT_CHECK(isolate, static_cast(NONE)); + } + i::Handle key_string = i::Handle::cast(key_obj); + PropertyAttributes result = self->GetPropertyAttribute(*key_string); + if (result == ABSENT) return static_cast(NONE); + return static_cast(result); +} + + Local v8::Object::GetPrototype() { i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); ON_BAILOUT(isolate, "v8::Object::GetPrototype()", @@ -3844,6 +3953,11 @@ bool v8::V8::Initialize() { } +void v8::V8::SetEntropySource(EntropySource source) { + i::V8::SetEntropySource(source); +} + + bool v8::V8::Dispose() { i::Isolate* isolate = i::Isolate::Current(); if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), @@ -4427,6 +4541,73 @@ Local v8::Object::New() { } +Local v8::NumberObject::New(double value) { + i::Isolate* isolate = i::Isolate::Current(); + EnsureInitializedForIsolate(isolate, "v8::NumberObject::New()"); + LOG_API(isolate, "NumberObject::New"); + ENTER_V8(isolate); + i::Handle number = isolate->factory()->NewNumber(value); + i::Handle obj = isolate->factory()->ToObject(number); + return Utils::ToLocal(obj); +} + + +double v8::NumberObject::NumberValue() const { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::NumberObject::NumberValue()")) return 0; + LOG_API(isolate, "NumberObject::NumberValue"); + i::Handle obj = Utils::OpenHandle(this); + i::Handle jsvalue = i::Handle::cast(obj); + return jsvalue->value()->Number(); +} + + +Local v8::BooleanObject::New(bool value) { + i::Isolate* isolate = i::Isolate::Current(); + EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()"); + LOG_API(isolate, "BooleanObject::New"); + ENTER_V8(isolate); + i::Handle boolean(value ? isolate->heap()->true_value() + : isolate->heap()->false_value()); + i::Handle obj = isolate->factory()->ToObject(boolean); + return Utils::ToLocal(obj); +} + + +bool v8::BooleanObject::BooleanValue() const { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::BooleanObject::BooleanValue()")) return 0; + LOG_API(isolate, "BooleanObject::BooleanValue"); + i::Handle obj = Utils::OpenHandle(this); + i::Handle jsvalue = i::Handle::cast(obj); + return jsvalue->value()->IsTrue(); +} + + +Local v8::StringObject::New(Handle value) { + i::Isolate* isolate = i::Isolate::Current(); + EnsureInitializedForIsolate(isolate, "v8::StringObject::New()"); + LOG_API(isolate, "StringObject::New"); + ENTER_V8(isolate); + i::Handle obj = + isolate->factory()->ToObject(Utils::OpenHandle(*value)); + return Utils::ToLocal(obj); +} + + +Local v8::StringObject::StringValue() const { + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::StringObject::StringValue()")) { + return Local(); + } + LOG_API(isolate, "StringObject::StringValue"); + i::Handle obj = Utils::OpenHandle(this); + i::Handle jsvalue = i::Handle::cast(obj); + return Utils::ToLocal( + i::Handle(i::String::cast(jsvalue->value()))); +} + + Local v8::Date::New(double time) { i::Isolate* isolate = i::Isolate::Current(); EnsureInitializedForIsolate(isolate, "v8::Date::New()"); diff --git a/deps/v8/src/arm/assembler-arm.cc b/deps/v8/src/arm/assembler-arm.cc index efa252dbacc..89df079f901 100644 --- a/deps/v8/src/arm/assembler-arm.cc +++ b/deps/v8/src/arm/assembler-arm.cc @@ -326,7 +326,7 @@ Assembler::Assembler(Isolate* arg_isolate, void* buffer, int buffer_size) no_const_pool_before_ = 0; first_const_pool_use_ = -1; last_bound_pos_ = 0; - ast_id_for_reloc_info_ = kNoASTId; + ClearRecordedAstId(); } @@ -2537,9 +2537,8 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { } ASSERT(buffer_space() >= kMaxRelocSize); // too late to grow buffer here if (rmode == RelocInfo::CODE_TARGET_WITH_ID) { - ASSERT(ast_id_for_reloc_info_ != kNoASTId); - RelocInfo reloc_info_with_ast_id(pc_, rmode, ast_id_for_reloc_info_); - ast_id_for_reloc_info_ = kNoASTId; + RelocInfo reloc_info_with_ast_id(pc_, rmode, RecordedAstId()); + ClearRecordedAstId(); reloc_info_writer.Write(&reloc_info_with_ast_id); } else { reloc_info_writer.Write(&rinfo); diff --git a/deps/v8/src/arm/assembler-arm.h b/deps/v8/src/arm/assembler-arm.h index fbf610a4340..97d4226503b 100644 --- a/deps/v8/src/arm/assembler-arm.h +++ b/deps/v8/src/arm/assembler-arm.h @@ -1178,7 +1178,17 @@ class Assembler : public AssemblerBase { // Record the AST id of the CallIC being compiled, so that it can be placed // in the relocation information. - void RecordAstId(unsigned ast_id) { ast_id_for_reloc_info_ = ast_id; } + void SetRecordedAstId(unsigned ast_id) { + ASSERT(recorded_ast_id_ == kNoASTId); + recorded_ast_id_ = ast_id; + } + + unsigned RecordedAstId() { + ASSERT(recorded_ast_id_ != kNoASTId); + return recorded_ast_id_; + } + + void ClearRecordedAstId() { recorded_ast_id_ = kNoASTId; } // Record a comment relocation entry that can be used by a disassembler. // Use --code-comments to enable. @@ -1244,7 +1254,7 @@ class Assembler : public AssemblerBase { // Relocation for a type-recording IC has the AST id added to it. This // member variable is a way to pass the information from the call site to // the relocation info. - unsigned ast_id_for_reloc_info_; + unsigned recorded_ast_id_; bool emit_debug_code() const { return emit_debug_code_; } diff --git a/deps/v8/src/arm/code-stubs-arm.cc b/deps/v8/src/arm/code-stubs-arm.cc index ab7c6f247a9..eaad9f293b3 100644 --- a/deps/v8/src/arm/code-stubs-arm.cc +++ b/deps/v8/src/arm/code-stubs-arm.cc @@ -4722,6 +4722,7 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { __ mov(r0, Operand(argc_)); // Setup the number of arguments. __ mov(r2, Operand(0, RelocInfo::NONE)); __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); + __ SetCallKind(r5, CALL_AS_METHOD); __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), RelocInfo::CODE_TARGET); } diff --git a/deps/v8/src/arm/lithium-arm.cc b/deps/v8/src/arm/lithium-arm.cc index 22e7e413284..ea06064e5eb 100644 --- a/deps/v8/src/arm/lithium-arm.cc +++ b/deps/v8/src/arm/lithium-arm.cc @@ -372,6 +372,15 @@ void LStoreKeyedFastElement::PrintDataTo(StringStream* stream) { } +void LStoreKeyedFastDoubleElement::PrintDataTo(StringStream* stream) { + elements()->PrintTo(stream); + stream->Add("["); + key()->PrintTo(stream); + stream->Add("] <- "); + value()->PrintTo(stream); +} + + void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { object()->PrintTo(stream); stream->Add("["); @@ -1844,6 +1853,18 @@ LInstruction* LChunkBuilder::DoLoadKeyedFastElement( } +LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement( + HLoadKeyedFastDoubleElement* instr) { + ASSERT(instr->representation().IsDouble()); + ASSERT(instr->key()->representation().IsInteger32()); + LOperand* elements = UseTempRegister(instr->elements()); + LOperand* key = UseRegisterOrConstantAtStart(instr->key()); + LLoadKeyedFastDoubleElement* result = + new LLoadKeyedFastDoubleElement(elements, key); + return AssignEnvironment(DefineAsRegister(result)); +} + + LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( HLoadKeyedSpecializedArrayElement* instr) { JSObject::ElementsKind elements_kind = instr->elements_kind(); @@ -1897,6 +1918,20 @@ LInstruction* LChunkBuilder::DoStoreKeyedFastElement( } +LInstruction* LChunkBuilder::DoStoreKeyedFastDoubleElement( + HStoreKeyedFastDoubleElement* instr) { + ASSERT(instr->value()->representation().IsDouble()); + ASSERT(instr->elements()->representation().IsTagged()); + ASSERT(instr->key()->representation().IsInteger32()); + + LOperand* elements = UseRegisterAtStart(instr->elements()); + LOperand* val = UseTempRegister(instr->value()); + LOperand* key = UseRegisterOrConstantAtStart(instr->key()); + + return new LStoreKeyedFastDoubleElement(elements, key, val); +} + + LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( HStoreKeyedSpecializedArrayElement* instr) { Representation representation(instr->value()->representation()); diff --git a/deps/v8/src/arm/lithium-arm.h b/deps/v8/src/arm/lithium-arm.h index ebeba86943a..70c348de69f 100644 --- a/deps/v8/src/arm/lithium-arm.h +++ b/deps/v8/src/arm/lithium-arm.h @@ -121,6 +121,7 @@ class LCodeGen; V(LoadFunctionPrototype) \ V(LoadGlobalCell) \ V(LoadGlobalGeneric) \ + V(LoadKeyedFastDoubleElement) \ V(LoadKeyedFastElement) \ V(LoadKeyedGeneric) \ V(LoadKeyedSpecializedArrayElement) \ @@ -147,6 +148,7 @@ class LCodeGen; V(StoreContextSlot) \ V(StoreGlobalCell) \ V(StoreGlobalGeneric) \ + V(StoreKeyedFastDoubleElement) \ V(StoreKeyedFastElement) \ V(StoreKeyedGeneric) \ V(StoreKeyedSpecializedArrayElement) \ @@ -1137,6 +1139,22 @@ class LLoadKeyedFastElement: public LTemplateInstruction<1, 2, 0> { }; +class LLoadKeyedFastDoubleElement: public LTemplateInstruction<1, 2, 0> { + public: + LLoadKeyedFastDoubleElement(LOperand* elements, LOperand* key) { + inputs_[0] = elements; + inputs_[1] = key; + } + + DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement, + "load-keyed-fast-double-element") + DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastDoubleElement) + + LOperand* elements() { return inputs_[0]; } + LOperand* key() { return inputs_[1]; } +}; + + class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> { public: LLoadKeyedSpecializedArrayElement(LOperand* external_pointer, @@ -1597,6 +1615,28 @@ class LStoreKeyedFastElement: public LTemplateInstruction<0, 3, 0> { }; +class LStoreKeyedFastDoubleElement: public LTemplateInstruction<0, 3, 0> { + public: + LStoreKeyedFastDoubleElement(LOperand* elements, + LOperand* key, + LOperand* val) { + inputs_[0] = elements; + inputs_[1] = key; + inputs_[2] = val; + } + + DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement, + "store-keyed-fast-double-element") + DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastDoubleElement) + + virtual void PrintDataTo(StringStream* stream); + + LOperand* elements() { return inputs_[0]; } + LOperand* key() { return inputs_[1]; } + LOperand* value() { return inputs_[2]; } +}; + + class LStoreKeyedGeneric: public LTemplateInstruction<0, 3, 0> { public: LStoreKeyedGeneric(LOperand* obj, LOperand* key, LOperand* val) { diff --git a/deps/v8/src/arm/lithium-codegen-arm.cc b/deps/v8/src/arm/lithium-codegen-arm.cc index dc93aea3461..e4a14af7e45 100644 --- a/deps/v8/src/arm/lithium-codegen-arm.cc +++ b/deps/v8/src/arm/lithium-codegen-arm.cc @@ -2433,6 +2433,48 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { } +void LCodeGen::DoLoadKeyedFastDoubleElement( + LLoadKeyedFastDoubleElement* instr) { + Register elements = ToRegister(instr->elements()); + bool key_is_constant = instr->key()->IsConstantOperand(); + Register key = no_reg; + DwVfpRegister result = ToDoubleRegister(instr->result()); + Register scratch = scratch0(); + + int shift_size = + ElementsKindToShiftSize(JSObject::FAST_DOUBLE_ELEMENTS); + int constant_key = 0; + if (key_is_constant) { + constant_key = ToInteger32(LConstantOperand::cast(instr->key())); + if (constant_key & 0xF0000000) { + Abort("array index constant value too big."); + } + } else { + key = ToRegister(instr->key()); + } + + Operand operand = key_is_constant + ? Operand(constant_key * (1 << shift_size) + + FixedDoubleArray::kHeaderSize - kHeapObjectTag) + : Operand(key, LSL, shift_size); + __ add(elements, elements, operand); + if (!key_is_constant) { + __ add(elements, elements, + Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag)); + } + + if (instr->hydrogen()->RequiresHoleCheck()) { + // TODO(danno): If no hole check is required, there is no need to allocate + // elements into a temporary register, instead scratch can be used. + __ ldr(scratch, MemOperand(elements, sizeof(kHoleNanLower32))); + __ cmp(scratch, Operand(kHoleNanUpper32)); + DeoptimizeIf(eq, instr->environment()); + } + + __ vldr(result, elements, 0); +} + + void LCodeGen::DoLoadKeyedSpecializedArrayElement( LLoadKeyedSpecializedArrayElement* instr) { Register external_pointer = ToRegister(instr->external_pointer()); @@ -2453,9 +2495,10 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS || elements_kind == JSObject::EXTERNAL_DOUBLE_ELEMENTS) { CpuFeatures::Scope scope(VFP3); - DwVfpRegister result(ToDoubleRegister(instr->result())); - Operand operand(key_is_constant ? Operand(constant_key * (1 << shift_size)) - : Operand(key, LSL, shift_size)); + DwVfpRegister result = ToDoubleRegister(instr->result()); + Operand operand = key_is_constant + ? Operand(constant_key * (1 << shift_size)) + : Operand(key, LSL, shift_size); __ add(scratch0(), external_pointer, operand); if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { __ vldr(result.low(), scratch0(), 0); @@ -2464,7 +2507,7 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( __ vldr(result, scratch0(), 0); } } else { - Register result(ToRegister(instr->result())); + Register result = ToRegister(instr->result()); MemOperand mem_operand(key_is_constant ? MemOperand(external_pointer, constant_key * (1 << shift_size)) : MemOperand(external_pointer, key, LSL, shift_size)); @@ -3243,6 +3286,48 @@ void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { } +void LCodeGen::DoStoreKeyedFastDoubleElement( + LStoreKeyedFastDoubleElement* instr) { + DwVfpRegister value = ToDoubleRegister(instr->value()); + Register elements = ToRegister(instr->elements()); + Register key = no_reg; + Register scratch = scratch0(); + bool key_is_constant = instr->key()->IsConstantOperand(); + int constant_key = 0; + Label not_nan; + + // Calculate the effective address of the slot in the array to store the + // double value. + if (key_is_constant) { + constant_key = ToInteger32(LConstantOperand::cast(instr->key())); + if (constant_key & 0xF0000000) { + Abort("array index constant value too big."); + } + } else { + key = ToRegister(instr->key()); + } + int shift_size = ElementsKindToShiftSize(JSObject::FAST_DOUBLE_ELEMENTS); + Operand operand = key_is_constant + ? Operand(constant_key * (1 << shift_size) + + FixedDoubleArray::kHeaderSize - kHeapObjectTag) + : Operand(key, LSL, shift_size); + __ add(scratch, elements, operand); + if (!key_is_constant) { + __ add(scratch, scratch, + Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag)); + } + + // Check for NaN. All NaNs must be canonicalized. + __ VFPCompareAndSetFlags(value, value); + + // Only load canonical NaN if the comparison above set the overflow. + __ Vmov(value, FixedDoubleArray::canonical_not_the_hole_nan_as_double(), vs); + + __ bind(¬_nan); + __ vstr(value, scratch, 0); +} + + void LCodeGen::DoStoreKeyedSpecializedArrayElement( LStoreKeyedSpecializedArrayElement* instr) { diff --git a/deps/v8/src/arm/macro-assembler-arm.cc b/deps/v8/src/arm/macro-assembler-arm.cc index 320879a6279..c34a57920a8 100644 --- a/deps/v8/src/arm/macro-assembler-arm.cc +++ b/deps/v8/src/arm/macro-assembler-arm.cc @@ -192,13 +192,13 @@ void MacroAssembler::Call(Handle code, bind(&start); ASSERT(RelocInfo::IsCodeTarget(rmode)); if (rmode == RelocInfo::CODE_TARGET && ast_id != kNoASTId) { - ASSERT(ast_id_for_reloc_info_ == kNoASTId); - ast_id_for_reloc_info_ = ast_id; + SetRecordedAstId(ast_id); rmode = RelocInfo::CODE_TARGET_WITH_ID; } // 'code' is always generated ARM code, never THUMB code Call(reinterpret_cast
(code.location()), rmode, cond); - ASSERT_EQ(CallSize(code, rmode, cond), SizeOfCodeGeneratedSince(&start)); + ASSERT_EQ(CallSize(code, rmode, ast_id, cond), + SizeOfCodeGeneratedSince(&start)); } @@ -1862,7 +1862,7 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, void MacroAssembler::CallStub(CodeStub* stub, Condition cond) { ASSERT(allow_stub_calls()); // Stub calls are not allowed in some stubs. - Call(stub->GetCode(), RelocInfo::CODE_TARGET, cond); + Call(stub->GetCode(), RelocInfo::CODE_TARGET, kNoASTId, cond); } @@ -1872,7 +1872,8 @@ MaybeObject* MacroAssembler::TryCallStub(CodeStub* stub, Condition cond) { { MaybeObject* maybe_result = stub->TryGetCode(); if (!maybe_result->ToObject(&result)) return maybe_result; } - Call(Handle(Code::cast(result)), RelocInfo::CODE_TARGET, cond); + Handle code(Code::cast(result)); + Call(code, RelocInfo::CODE_TARGET, kNoASTId, cond); return result; } @@ -2548,6 +2549,9 @@ void MacroAssembler::AssertFastElements(Register elements) { LoadRoot(ip, Heap::kFixedArrayMapRootIndex); cmp(elements, ip); b(eq, &ok); + LoadRoot(ip, Heap::kFixedDoubleArrayMapRootIndex); + cmp(elements, ip); + b(eq, &ok); LoadRoot(ip, Heap::kFixedCOWArrayMapRootIndex); cmp(elements, ip); b(eq, &ok); diff --git a/deps/v8/src/arm/stub-cache-arm.cc b/deps/v8/src/arm/stub-cache-arm.cc index 86e49716d3b..c2665f8853a 100644 --- a/deps/v8/src/arm/stub-cache-arm.cc +++ b/deps/v8/src/arm/stub-cache-arm.cc @@ -4168,6 +4168,77 @@ void KeyedLoadStubCompiler::GenerateLoadFastElement(MacroAssembler* masm) { } +void KeyedLoadStubCompiler::GenerateLoadFastDoubleElement( + MacroAssembler* masm) { + // ----------- S t a t e ------------- + // -- lr : return address + // -- r0 : key + // -- r1 : receiver + // ----------------------------------- + Label miss_force_generic, slow_allocate_heapnumber; + + Register key_reg = r0; + Register receiver_reg = r1; + Register elements_reg = r2; + Register heap_number_reg = r2; + Register indexed_double_offset = r3; + Register scratch = r4; + Register scratch2 = r5; + Register scratch3 = r6; + Register heap_number_map = r7; + + // This stub is meant to be tail-jumped to, the receiver must already + // have been verified by the caller to not be a smi. + + // Check that the key is a smi. + __ JumpIfNotSmi(key_reg, &miss_force_generic); + + // Get the elements array. + __ ldr(elements_reg, + FieldMemOperand(receiver_reg, JSObject::kElementsOffset)); + + // Check that the key is within bounds. + __ ldr(scratch, FieldMemOperand(elements_reg, FixedArray::kLengthOffset)); + __ cmp(key_reg, Operand(scratch)); + __ b(hs, &miss_force_generic); + + // Load the upper word of the double in the fixed array and test for NaN. + __ add(indexed_double_offset, elements_reg, + Operand(key_reg, LSL, kDoubleSizeLog2 - kSmiTagSize)); + uint32_t upper_32_offset = FixedArray::kHeaderSize + sizeof(kHoleNanLower32); + __ ldr(scratch, FieldMemOperand(indexed_double_offset, upper_32_offset)); + __ cmp(scratch, Operand(kHoleNanUpper32)); + __ b(&miss_force_generic, eq); + + // Non-NaN. Allocate a new heap number and copy the double value into it. + __ LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); + __ AllocateHeapNumber(heap_number_reg, scratch2, scratch3, + heap_number_map, &slow_allocate_heapnumber); + + // Don't need to reload the upper 32 bits of the double, it's already in + // scratch. + __ str(scratch, FieldMemOperand(heap_number_reg, + HeapNumber::kExponentOffset)); + __ ldr(scratch, FieldMemOperand(indexed_double_offset, + FixedArray::kHeaderSize)); + __ str(scratch, FieldMemOperand(heap_number_reg, + HeapNumber::kMantissaOffset)); + + __ mov(r0, heap_number_reg); + __ Ret(); + + __ bind(&slow_allocate_heapnumber); + Handle slow_ic = + masm->isolate()->builtins()->KeyedLoadIC_Slow(); + __ Jump(slow_ic, RelocInfo::CODE_TARGET); + + __ bind(&miss_force_generic); + Handle miss_ic = + masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); + __ Jump(miss_ic, RelocInfo::CODE_TARGET); +} + + void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, bool is_js_array) { // ----------- S t a t e ------------- @@ -4231,6 +4302,125 @@ void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, } +void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement( + MacroAssembler* masm, + bool is_js_array) { + // ----------- S t a t e ------------- + // -- r0 : value + // -- r1 : key + // -- r2 : receiver + // -- lr : return address + // -- r3 : scratch + // -- r4 : scratch + // -- r5 : scratch + // ----------------------------------- + Label miss_force_generic, smi_value, is_nan, maybe_nan, have_double_value; + + Register value_reg = r0; + Register key_reg = r1; + Register receiver_reg = r2; + Register scratch = r3; + Register elements_reg = r4; + Register mantissa_reg = r5; + Register exponent_reg = r6; + Register scratch4 = r7; + + // This stub is meant to be tail-jumped to, the receiver must already + // have been verified by the caller to not be a smi. + __ JumpIfNotSmi(key_reg, &miss_force_generic); + + __ ldr(elements_reg, + FieldMemOperand(receiver_reg, JSObject::kElementsOffset)); + + // Check that the key is within bounds. + if (is_js_array) { + __ ldr(scratch, FieldMemOperand(receiver_reg, JSArray::kLengthOffset)); + } else { + __ ldr(scratch, + FieldMemOperand(elements_reg, FixedArray::kLengthOffset)); + } + // Compare smis, unsigned compare catches both negative and out-of-bound + // indexes. + __ cmp(key_reg, scratch); + __ b(hs, &miss_force_generic); + + // Handle smi values specially. + __ JumpIfSmi(value_reg, &smi_value); + + // Ensure that the object is a heap number + __ CheckMap(value_reg, + scratch, + masm->isolate()->factory()->heap_number_map(), + &miss_force_generic, + DONT_DO_SMI_CHECK); + + // Check for nan: all NaN values have a value greater (signed) than 0x7ff00000 + // in the exponent. + __ mov(scratch, Operand(kNaNOrInfinityLowerBoundUpper32)); + __ ldr(exponent_reg, FieldMemOperand(value_reg, HeapNumber::kExponentOffset)); + __ cmp(exponent_reg, scratch); + __ b(ge, &maybe_nan); + + __ ldr(mantissa_reg, FieldMemOperand(value_reg, HeapNumber::kMantissaOffset)); + + __ bind(&have_double_value); + __ add(scratch, elements_reg, + Operand(key_reg, LSL, kDoubleSizeLog2 - kSmiTagSize)); + __ str(mantissa_reg, FieldMemOperand(scratch, FixedDoubleArray::kHeaderSize)); + uint32_t offset = FixedDoubleArray::kHeaderSize + sizeof(kHoleNanLower32); + __ str(exponent_reg, FieldMemOperand(scratch, offset)); + __ Ret(); + + __ bind(&maybe_nan); + // Could be NaN or Infinity. If fraction is not zero, it's NaN, otherwise + // it's an Infinity, and the non-NaN code path applies. + __ b(gt, &is_nan); + __ ldr(mantissa_reg, FieldMemOperand(value_reg, HeapNumber::kMantissaOffset)); + __ cmp(mantissa_reg, Operand(0)); + __ b(eq, &have_double_value); + __ bind(&is_nan); + // Load canonical NaN for storing into the double array. + uint64_t nan_int64 = BitCast( + FixedDoubleArray::canonical_not_the_hole_nan_as_double()); + __ mov(mantissa_reg, Operand(static_cast(nan_int64))); + __ mov(exponent_reg, Operand(static_cast(nan_int64 >> 32))); + __ jmp(&have_double_value); + + __ bind(&smi_value); + __ add(scratch, elements_reg, + Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag)); + __ add(scratch, scratch, + Operand(key_reg, LSL, kDoubleSizeLog2 - kSmiTagSize)); + // scratch is now effective address of the double element + + FloatingPointHelper::Destination destination; + if (CpuFeatures::IsSupported(VFP3)) { + destination = FloatingPointHelper::kVFPRegisters; + } else { + destination = FloatingPointHelper::kCoreRegisters; + } + __ SmiUntag(value_reg, value_reg); + FloatingPointHelper::ConvertIntToDouble( + masm, value_reg, destination, + d0, mantissa_reg, exponent_reg, // These are: double_dst, dst1, dst2. + scratch4, s2); // These are: scratch2, single_scratch. + if (destination == FloatingPointHelper::kVFPRegisters) { + CpuFeatures::Scope scope(VFP3); + __ vstr(d0, scratch, 0); + } else { + __ str(mantissa_reg, MemOperand(scratch, 0)); + __ str(exponent_reg, MemOperand(scratch, Register::kSizeInBytes)); + } + __ Ret(); + + // Handle store cache miss, replacing the ic with the generic stub. + __ bind(&miss_force_generic); + Handle ic = + masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); + __ Jump(ic, RelocInfo::CODE_TARGET); +} + + #undef __ } } // namespace v8::internal diff --git a/deps/v8/src/array.js b/deps/v8/src/array.js index 60cf3f0c527..e6c13d9547c 100644 --- a/deps/v8/src/array.js +++ b/deps/v8/src/array.js @@ -999,7 +999,7 @@ function ArrayFilter(f, receiver) { } // Pull out the length so that modifications to the length in the // loop will not affect the looping. - var length = this.length; + var length = ToUint32(this.length); var result = []; var result_length = 0; for (var i = 0; i < length; i++) { @@ -1236,7 +1236,7 @@ function ArrayReduce(callback, current) { } // Pull out the length so that modifications to the length in the // loop will not affect the looping. - var length = this.length; + var length = ToUint32(this.length); var i = 0; find_initial: if (%_ArgumentsLength() < 2) { @@ -1268,7 +1268,7 @@ function ArrayReduceRight(callback, current) { if (!IS_FUNCTION(callback)) { throw MakeTypeError('called_non_callable', [callback]); } - var i = this.length - 1; + var i = ToUint32(this.length) - 1; find_initial: if (%_ArgumentsLength() < 2) { for (; i >= 0; i--) { diff --git a/deps/v8/src/assembler.cc b/deps/v8/src/assembler.cc index 3c7fc1c6313..fbd80895804 100644 --- a/deps/v8/src/assembler.cc +++ b/deps/v8/src/assembler.cc @@ -1,4 +1,4 @@ -// Copyright (c) 1994-2006 Sun Microsystems Inc. +// Copyright (c) 2011 Sun Microsystems Inc. // All Rights Reserved. // // Redistribution and use in source and binary forms, with or without @@ -71,7 +71,8 @@ const double DoubleConstant::one_half = 0.5; const double DoubleConstant::minus_zero = -0.0; const double DoubleConstant::uint8_max_value = 255; const double DoubleConstant::zero = 0.0; -const double DoubleConstant::nan = OS::nan_value(); +const double DoubleConstant::canonical_non_hole_nan = OS::nan_value(); +const double DoubleConstant::the_hole_nan = BitCast(kHoleNanInt64); const double DoubleConstant::negative_infinity = -V8_INFINITY; const char* RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING"; @@ -921,9 +922,15 @@ ExternalReference ExternalReference::address_of_negative_infinity() { } -ExternalReference ExternalReference::address_of_nan() { +ExternalReference ExternalReference::address_of_canonical_non_hole_nan() { return ExternalReference(reinterpret_cast( - const_cast(&DoubleConstant::nan))); + const_cast(&DoubleConstant::canonical_non_hole_nan))); +} + + +ExternalReference ExternalReference::address_of_the_hole_nan() { + return ExternalReference(reinterpret_cast( + const_cast(&DoubleConstant::the_hole_nan))); } diff --git a/deps/v8/src/assembler.h b/deps/v8/src/assembler.h index bced11fec2e..2d14f06914d 100644 --- a/deps/v8/src/assembler.h +++ b/deps/v8/src/assembler.h @@ -70,7 +70,8 @@ class DoubleConstant: public AllStatic { static const double zero; static const double uint8_max_value; static const double negative_infinity; - static const double nan; + static const double canonical_non_hole_nan; + static const double the_hole_nan; }; @@ -629,7 +630,8 @@ class ExternalReference BASE_EMBEDDED { static ExternalReference address_of_zero(); static ExternalReference address_of_uint8_max_value(); static ExternalReference address_of_negative_infinity(); - static ExternalReference address_of_nan(); + static ExternalReference address_of_canonical_non_hole_nan(); + static ExternalReference address_of_the_hole_nan(); static ExternalReference math_sin_double_function(Isolate* isolate); static ExternalReference math_cos_double_function(Isolate* isolate); diff --git a/deps/v8/src/ast-inl.h b/deps/v8/src/ast-inl.h index c2bd6134449..c750e6b03c3 100644 --- a/deps/v8/src/ast-inl.h +++ b/deps/v8/src/ast-inl.h @@ -37,68 +37,76 @@ namespace v8 { namespace internal { -SwitchStatement::SwitchStatement(ZoneStringList* labels) - : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), +SwitchStatement::SwitchStatement(Isolate* isolate, + ZoneStringList* labels) + : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), tag_(NULL), cases_(NULL) { } -Block::Block(ZoneStringList* labels, int capacity, bool is_initializer_block) - : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY), +Block::Block(Isolate* isolate, + ZoneStringList* labels, + int capacity, + bool is_initializer_block) + : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY), statements_(capacity), is_initializer_block_(is_initializer_block) { } -BreakableStatement::BreakableStatement(ZoneStringList* labels, Type type) +BreakableStatement::BreakableStatement(Isolate* isolate, + ZoneStringList* labels, + Type type) : labels_(labels), type_(type), - entry_id_(GetNextId()), - exit_id_(GetNextId()) { + entry_id_(GetNextId(isolate)), + exit_id_(GetNextId(isolate)) { ASSERT(labels == NULL || labels->length() > 0); } -IterationStatement::IterationStatement(ZoneStringList* labels) - : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), +IterationStatement::IterationStatement(Isolate* isolate, ZoneStringList* labels) + : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), body_(NULL), continue_target_(), - osr_entry_id_(GetNextId()) { + osr_entry_id_(GetNextId(isolate)) { } -DoWhileStatement::DoWhileStatement(ZoneStringList* labels) - : IterationStatement(labels), +DoWhileStatement::DoWhileStatement(Isolate* isolate, ZoneStringList* labels) + : IterationStatement(isolate, labels), cond_(NULL), condition_position_(-1), - continue_id_(GetNextId()), - back_edge_id_(GetNextId()) { + continue_id_(GetNextId(isolate)), + back_edge_id_(GetNextId(isolate)) { } -WhileStatement::WhileStatement(ZoneStringList* labels) - : IterationStatement(labels), +WhileStatement::WhileStatement(Isolate* isolate, ZoneStringList* labels) + : IterationStatement(isolate, labels), cond_(NULL), may_have_function_literal_(true), - body_id_(GetNextId()) { + body_id_(GetNextId(isolate)) { } -ForStatement::ForStatement(ZoneStringList* labels) - : IterationStatement(labels), +ForStatement::ForStatement(Isolate* isolate, ZoneStringList* labels) + : IterationStatement(isolate, labels), init_(NULL), cond_(NULL), next_(NULL), may_have_function_literal_(true), loop_variable_(NULL), - continue_id_(GetNextId()), - body_id_(GetNextId()) { + continue_id_(GetNextId(isolate)), + body_id_(GetNextId(isolate)) { } -ForInStatement::ForInStatement(ZoneStringList* labels) - : IterationStatement(labels), each_(NULL), enumerable_(NULL), - assignment_id_(GetNextId()) { +ForInStatement::ForInStatement(Isolate* isolate, ZoneStringList* labels) + : IterationStatement(isolate, labels), + each_(NULL), + enumerable_(NULL), + assignment_id_(GetNextId(isolate)) { } diff --git a/deps/v8/src/ast.cc b/deps/v8/src/ast.cc index 8b6cdcee9fe..2df62ee96a4 100644 --- a/deps/v8/src/ast.cc +++ b/deps/v8/src/ast.cc @@ -37,11 +37,11 @@ namespace v8 { namespace internal { AstSentinels::AstSentinels() - : this_proxy_(true), - identifier_proxy_(false), - valid_left_hand_side_sentinel_(), - this_property_(&this_proxy_, NULL, 0), - call_sentinel_(NULL, NULL, 0) { + : this_proxy_(Isolate::Current(), true), + identifier_proxy_(Isolate::Current(), false), + valid_left_hand_side_sentinel_(Isolate::Current()), + this_property_(Isolate::Current(), &this_proxy_, NULL, 0), + call_sentinel_(Isolate::Current(), NULL, NULL, 0) { } @@ -72,8 +72,9 @@ CountOperation* ExpressionStatement::StatementAsCountOperation() { } -VariableProxy::VariableProxy(Variable* var) - : name_(var->name()), +VariableProxy::VariableProxy(Isolate* isolate, Variable* var) + : Expression(isolate), + name_(var->name()), var_(NULL), // Will be set by the call to BindTo. is_this_(var->is_this()), inside_with_(false), @@ -83,26 +84,29 @@ VariableProxy::VariableProxy(Variable* var) } -VariableProxy::VariableProxy(Handle name, +VariableProxy::VariableProxy(Isolate* isolate, + Handle name, bool is_this, bool inside_with, int position) - : name_(name), - var_(NULL), - is_this_(is_this), - inside_with_(inside_with), - is_trivial_(false), - position_(position) { + : Expression(isolate), + name_(name), + var_(NULL), + is_this_(is_this), + inside_with_(inside_with), + is_trivial_(false), + position_(position) { // Names must be canonicalized for fast equality checks. ASSERT(name->IsSymbol()); } -VariableProxy::VariableProxy(bool is_this) - : var_(NULL), - is_this_(is_this), - inside_with_(false), - is_trivial_(false) { +VariableProxy::VariableProxy(Isolate* isolate, bool is_this) + : Expression(isolate), + var_(NULL), + is_this_(is_this), + inside_with_(false), + is_trivial_(false) { } @@ -120,17 +124,19 @@ void VariableProxy::BindTo(Variable* var) { } -Assignment::Assignment(Token::Value op, +Assignment::Assignment(Isolate* isolate, + Token::Value op, Expression* target, Expression* value, int pos) - : op_(op), + : Expression(isolate), + op_(op), target_(target), value_(value), pos_(pos), binary_operation_(NULL), compound_load_id_(kNoNumber), - assignment_id_(GetNextId()), + assignment_id_(GetNextId(isolate)), block_start_(false), block_end_(false), is_monomorphic_(false), @@ -138,8 +144,12 @@ Assignment::Assignment(Token::Value op, ASSERT(Token::IsAssignmentOp(op)); if (is_compound()) { binary_operation_ = - new BinaryOperation(binary_op(), target, value, pos + 1); - compound_load_id_ = GetNextId(); + new(isolate->zone()) BinaryOperation(isolate, + binary_op(), + target, + value, + pos + 1); + compound_load_id_ = GetNextId(isolate); } } @@ -186,8 +196,9 @@ ObjectLiteral::Property::Property(Literal* key, Expression* value) { ObjectLiteral::Property::Property(bool is_getter, FunctionLiteral* value) { + Isolate* isolate = Isolate::Current(); emit_store_ = true; - key_ = new Literal(value->name()); + key_ = new(isolate->zone()) Literal(isolate, value->name()); value_ = value; kind_ = is_getter ? GETTER : SETTER; } @@ -1190,15 +1201,16 @@ RegExpAlternative::RegExpAlternative(ZoneList* nodes) } -CaseClause::CaseClause(Expression* label, +CaseClause::CaseClause(Isolate* isolate, + Expression* label, ZoneList* statements, int pos) : label_(label), statements_(statements), position_(pos), compare_type_(NONE), - compare_id_(AstNode::GetNextId()), - entry_id_(AstNode::GetNextId()) { + compare_id_(AstNode::GetNextId(isolate)), + entry_id_(AstNode::GetNextId(isolate)) { } } } // namespace v8::internal diff --git a/deps/v8/src/ast.h b/deps/v8/src/ast.h index 27d82cb3413..23df48b8b1e 100644 --- a/deps/v8/src/ast.h +++ b/deps/v8/src/ast.h @@ -134,11 +134,15 @@ class AstNode: public ZoneObject { static const int kNoNumber = -1; static const int kFunctionEntryId = 2; // Using 0 could disguise errors. - AstNode() { - Isolate* isolate = Isolate::Current(); + // Override ZoneObject's new to count allocated AST nodes. + void* operator new(size_t size, Zone* zone) { + Isolate* isolate = zone->isolate(); isolate->set_ast_node_count(isolate->ast_node_count() + 1); + return zone->New(static_cast(size)); } + AstNode() {} + virtual ~AstNode() { } virtual void Accept(AstVisitor* v) = 0; @@ -165,14 +169,21 @@ class AstNode: public ZoneObject { static void ResetIds() { Isolate::Current()->set_ast_node_id(0); } protected: - static unsigned GetNextId() { return ReserveIdRange(1); } - static unsigned ReserveIdRange(int n) { - Isolate* isolate = Isolate::Current(); + static unsigned GetNextId(Isolate* isolate) { + return ReserveIdRange(isolate, 1); + } + + static unsigned ReserveIdRange(Isolate* isolate, int n) { unsigned tmp = isolate->ast_node_id(); isolate->set_ast_node_id(tmp + n); return tmp; } + private: + // Hidden to prevent accidental usage. It would have to load the + // current zone from the TLS. + void* operator new(size_t size); + friend class CaseClause; // Generates AST IDs. }; @@ -210,7 +221,9 @@ class Expression: public AstNode { kTest }; - Expression() : id_(GetNextId()), test_id_(GetNextId()) {} + explicit Expression(Isolate* isolate) + : id_(GetNextId(isolate)), + test_id_(GetNextId(isolate)) {} virtual int position() const { UNREACHABLE(); @@ -277,6 +290,7 @@ class Expression: public AstNode { */ class ValidLeftHandSideSentinel: public Expression { public: + explicit ValidLeftHandSideSentinel(Isolate* isolate) : Expression(isolate) {} virtual bool IsValidLeftHandSide() { return true; } virtual void Accept(AstVisitor* v) { UNREACHABLE(); } virtual bool IsInlineable() const; @@ -308,7 +322,7 @@ class BreakableStatement: public Statement { int ExitId() const { return exit_id_; } protected: - inline BreakableStatement(ZoneStringList* labels, Type type); + BreakableStatement(Isolate* isolate, ZoneStringList* labels, Type type); private: ZoneStringList* labels_; @@ -321,7 +335,10 @@ class BreakableStatement: public Statement { class Block: public BreakableStatement { public: - inline Block(ZoneStringList* labels, int capacity, bool is_initializer_block); + inline Block(Isolate* isolate, + ZoneStringList* labels, + int capacity, + bool is_initializer_block); DECLARE_NODE_TYPE(Block) @@ -389,7 +406,7 @@ class IterationStatement: public BreakableStatement { Label* continue_target() { return &continue_target_; } protected: - explicit inline IterationStatement(ZoneStringList* labels); + inline IterationStatement(Isolate* isolate, ZoneStringList* labels); void Initialize(Statement* body) { body_ = body; @@ -404,7 +421,7 @@ class IterationStatement: public BreakableStatement { class DoWhileStatement: public IterationStatement { public: - explicit inline DoWhileStatement(ZoneStringList* labels); + inline DoWhileStatement(Isolate* isolate, ZoneStringList* labels); DECLARE_NODE_TYPE(DoWhileStatement) @@ -437,7 +454,7 @@ class DoWhileStatement: public IterationStatement { class WhileStatement: public IterationStatement { public: - explicit inline WhileStatement(ZoneStringList* labels); + inline WhileStatement(Isolate* isolate, ZoneStringList* labels); DECLARE_NODE_TYPE(WhileStatement) @@ -470,7 +487,7 @@ class WhileStatement: public IterationStatement { class ForStatement: public IterationStatement { public: - explicit inline ForStatement(ZoneStringList* labels); + inline ForStatement(Isolate* isolate, ZoneStringList* labels); DECLARE_NODE_TYPE(ForStatement) @@ -519,7 +536,7 @@ class ForStatement: public IterationStatement { class ForInStatement: public IterationStatement { public: - explicit inline ForInStatement(ZoneStringList* labels); + inline ForInStatement(Isolate* isolate, ZoneStringList* labels); DECLARE_NODE_TYPE(ForInStatement) @@ -636,7 +653,10 @@ class ExitContextStatement: public Statement { class CaseClause: public ZoneObject { public: - CaseClause(Expression* label, ZoneList* statements, int pos); + CaseClause(Isolate* isolate, + Expression* label, + ZoneList* statements, + int pos); bool is_default() const { return label_ == NULL; } Expression* label() const { @@ -671,7 +691,7 @@ class CaseClause: public ZoneObject { class SwitchStatement: public BreakableStatement { public: - explicit inline SwitchStatement(ZoneStringList* labels); + inline SwitchStatement(Isolate* isolate, ZoneStringList* labels); DECLARE_NODE_TYPE(SwitchStatement) @@ -697,15 +717,16 @@ class SwitchStatement: public BreakableStatement { // given if-statement has a then- or an else-part containing code. class IfStatement: public Statement { public: - IfStatement(Expression* condition, + IfStatement(Isolate* isolate, + Expression* condition, Statement* then_statement, Statement* else_statement) : condition_(condition), then_statement_(then_statement), else_statement_(else_statement), - if_id_(GetNextId()), - then_id_(GetNextId()), - else_id_(GetNextId()) { + if_id_(GetNextId(isolate)), + then_id_(GetNextId(isolate)), + else_id_(GetNextId(isolate)) { } DECLARE_NODE_TYPE(IfStatement) @@ -834,7 +855,8 @@ class EmptyStatement: public Statement { class Literal: public Expression { public: - explicit Literal(Handle handle) : handle_(handle) { } + Literal(Isolate* isolate, Handle handle) + : Expression(isolate), handle_(handle) { } DECLARE_NODE_TYPE(Literal) @@ -887,8 +909,14 @@ class Literal: public Expression { // Base class for literals that needs space in the corresponding JSFunction. class MaterializedLiteral: public Expression { public: - explicit MaterializedLiteral(int literal_index, bool is_simple, int depth) - : literal_index_(literal_index), is_simple_(is_simple), depth_(depth) {} + MaterializedLiteral(Isolate* isolate, + int literal_index, + bool is_simple, + int depth) + : Expression(isolate), + literal_index_(literal_index), + is_simple_(is_simple), + depth_(depth) {} virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } @@ -944,14 +972,15 @@ class ObjectLiteral: public MaterializedLiteral { bool emit_store_; }; - ObjectLiteral(Handle constant_properties, + ObjectLiteral(Isolate* isolate, + Handle constant_properties, ZoneList* properties, int literal_index, bool is_simple, bool fast_elements, int depth, bool has_function) - : MaterializedLiteral(literal_index, is_simple, depth), + : MaterializedLiteral(isolate, literal_index, is_simple, depth), constant_properties_(constant_properties), properties_(properties), fast_elements_(fast_elements), @@ -990,10 +1019,11 @@ class ObjectLiteral: public MaterializedLiteral { // Node for capturing a regexp literal. class RegExpLiteral: public MaterializedLiteral { public: - RegExpLiteral(Handle pattern, + RegExpLiteral(Isolate* isolate, + Handle pattern, Handle flags, int literal_index) - : MaterializedLiteral(literal_index, false, 1), + : MaterializedLiteral(isolate, literal_index, false, 1), pattern_(pattern), flags_(flags) {} @@ -1011,15 +1041,16 @@ class RegExpLiteral: public MaterializedLiteral { // for minimizing the work when constructing it at runtime. class ArrayLiteral: public MaterializedLiteral { public: - ArrayLiteral(Handle constant_elements, + ArrayLiteral(Isolate* isolate, + Handle constant_elements, ZoneList* values, int literal_index, bool is_simple, int depth) - : MaterializedLiteral(literal_index, is_simple, depth), + : MaterializedLiteral(isolate, literal_index, is_simple, depth), constant_elements_(constant_elements), values_(values), - first_element_id_(ReserveIdRange(values->length())) {} + first_element_id_(ReserveIdRange(isolate, values->length())) {} DECLARE_NODE_TYPE(ArrayLiteral) @@ -1038,7 +1069,7 @@ class ArrayLiteral: public MaterializedLiteral { class VariableProxy: public Expression { public: - explicit VariableProxy(Variable* var); + VariableProxy(Isolate* isolate, Variable* var); DECLARE_NODE_TYPE(VariableProxy) @@ -1085,11 +1116,12 @@ class VariableProxy: public Expression { bool is_trivial_; int position_; - VariableProxy(Handle name, + VariableProxy(Isolate* isolate, + Handle name, bool is_this, bool inside_with, int position = RelocInfo::kNoPosition); - explicit VariableProxy(bool is_this); + VariableProxy(Isolate* isolate, bool is_this); friend class Scope; }; @@ -1100,7 +1132,8 @@ class VariableProxySentinel: public VariableProxy { virtual bool IsValidLeftHandSide() { return !is_this(); } private: - explicit VariableProxySentinel(bool is_this) : VariableProxy(is_this) { } + VariableProxySentinel(Isolate* isolate, bool is_this) + : VariableProxy(isolate, is_this) { } friend class AstSentinels; }; @@ -1130,8 +1163,8 @@ class Slot: public Expression { LOOKUP }; - Slot(Variable* var, Type type, int index) - : var_(var), type_(type), index_(index) { + Slot(Isolate* isolate, Variable* var, Type type, int index) + : Expression(isolate), var_(var), type_(type), index_(index) { ASSERT(var != NULL); } @@ -1162,8 +1195,13 @@ class Property: public Expression { // properties should use the global object as receiver, not the base object // of the resolved Reference. enum Type { NORMAL, SYNTHETIC }; - Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) - : obj_(obj), + Property(Isolate* isolate, + Expression* obj, + Expression* key, + int pos, + Type type = NORMAL) + : Expression(isolate), + obj_(obj), key_(key), pos_(pos), type_(type), @@ -1215,14 +1253,18 @@ class Property: public Expression { class Call: public Expression { public: - Call(Expression* expression, ZoneList* arguments, int pos) - : expression_(expression), + Call(Isolate* isolate, + Expression* expression, + ZoneList* arguments, + int pos) + : Expression(isolate), + expression_(expression), arguments_(arguments), pos_(pos), is_monomorphic_(false), check_type_(RECEIVER_MAP_CHECK), receiver_types_(NULL), - return_id_(GetNextId()) { + return_id_(GetNextId(isolate)) { } DECLARE_NODE_TYPE(Call) @@ -1301,8 +1343,14 @@ class AstSentinels { class CallNew: public Expression { public: - CallNew(Expression* expression, ZoneList* arguments, int pos) - : expression_(expression), arguments_(arguments), pos_(pos) { } + CallNew(Isolate* isolate, + Expression* expression, + ZoneList* arguments, + int pos) + : Expression(isolate), + expression_(expression), + arguments_(arguments), + pos_(pos) { } DECLARE_NODE_TYPE(CallNew) @@ -1325,10 +1373,14 @@ class CallNew: public Expression { // implemented in JavaScript (see "v8natives.js"). class CallRuntime: public Expression { public: - CallRuntime(Handle name, + CallRuntime(Isolate* isolate, + Handle name, const Runtime::Function* function, ZoneList* arguments) - : name_(name), function_(function), arguments_(arguments) { } + : Expression(isolate), + name_(name), + function_(function), + arguments_(arguments) { } DECLARE_NODE_TYPE(CallRuntime) @@ -1348,8 +1400,11 @@ class CallRuntime: public Expression { class UnaryOperation: public Expression { public: - UnaryOperation(Token::Value op, Expression* expression, int pos) - : op_(op), expression_(expression), pos_(pos) { + UnaryOperation(Isolate* isolate, + Token::Value op, + Expression* expression, + int pos) + : Expression(isolate), op_(op), expression_(expression), pos_(pos) { ASSERT(Token::IsUnaryOp(op)); } @@ -1372,14 +1427,15 @@ class UnaryOperation: public Expression { class BinaryOperation: public Expression { public: - BinaryOperation(Token::Value op, + BinaryOperation(Isolate* isolate, + Token::Value op, Expression* left, Expression* right, int pos) - : op_(op), left_(left), right_(right), pos_(pos) { + : Expression(isolate), op_(op), left_(left), right_(right), pos_(pos) { ASSERT(Token::IsBinaryOp(op)); right_id_ = (op == Token::AND || op == Token::OR) - ? static_cast(GetNextId()) + ? static_cast(GetNextId(isolate)) : AstNode::kNoNumber; } @@ -1410,13 +1466,18 @@ class BinaryOperation: public Expression { class CountOperation: public Expression { public: - CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) - : op_(op), + CountOperation(Isolate* isolate, + Token::Value op, + bool is_prefix, + Expression* expr, + int pos) + : Expression(isolate), + op_(op), is_prefix_(is_prefix), expression_(expr), pos_(pos), - assignment_id_(GetNextId()), - count_id_(GetNextId()), + assignment_id_(GetNextId(isolate)), + count_id_(GetNextId(isolate)), receiver_types_(NULL) { } DECLARE_NODE_TYPE(CountOperation) @@ -1462,11 +1523,17 @@ class CountOperation: public Expression { class CompareOperation: public Expression { public: - CompareOperation(Token::Value op, + CompareOperation(Isolate* isolate, + Token::Value op, Expression* left, Expression* right, int pos) - : op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) { + : Expression(isolate), + op_(op), + left_(left), + right_(right), + pos_(pos), + compare_type_(NONE) { ASSERT(Token::IsCompareOp(op)); } @@ -1501,8 +1568,8 @@ class CompareOperation: public Expression { class CompareToNull: public Expression { public: - CompareToNull(bool is_strict, Expression* expression) - : is_strict_(is_strict), expression_(expression) { } + CompareToNull(Isolate* isolate, bool is_strict, Expression* expression) + : Expression(isolate), is_strict_(is_strict), expression_(expression) { } DECLARE_NODE_TYPE(CompareToNull) @@ -1520,18 +1587,20 @@ class CompareToNull: public Expression { class Conditional: public Expression { public: - Conditional(Expression* condition, + Conditional(Isolate* isolate, + Expression* condition, Expression* then_expression, Expression* else_expression, int then_expression_position, int else_expression_position) - : condition_(condition), + : Expression(isolate), + condition_(condition), then_expression_(then_expression), else_expression_(else_expression), then_expression_position_(then_expression_position), else_expression_position_(else_expression_position), - then_id_(GetNextId()), - else_id_(GetNextId()) { + then_id_(GetNextId(isolate)), + else_id_(GetNextId(isolate)) { } DECLARE_NODE_TYPE(Conditional) @@ -1561,7 +1630,11 @@ class Conditional: public Expression { class Assignment: public Expression { public: - Assignment(Token::Value op, Expression* target, Expression* value, int pos); + Assignment(Isolate* isolate, + Token::Value op, + Expression* target, + Expression* value, + int pos); DECLARE_NODE_TYPE(Assignment) @@ -1621,8 +1694,8 @@ class Assignment: public Expression { class Throw: public Expression { public: - Throw(Expression* exception, int pos) - : exception_(exception), pos_(pos) {} + Throw(Isolate* isolate, Expression* exception, int pos) + : Expression(isolate), exception_(exception), pos_(pos) {} DECLARE_NODE_TYPE(Throw) @@ -1638,7 +1711,8 @@ class Throw: public Expression { class FunctionLiteral: public Expression { public: - FunctionLiteral(Handle name, + FunctionLiteral(Isolate* isolate, + Handle name, Scope* scope, ZoneList* body, int materialized_literal_count, @@ -1650,7 +1724,8 @@ class FunctionLiteral: public Expression { int end_position, bool is_expression, bool has_duplicate_parameters) - : name_(name), + : Expression(isolate), + name_(name), scope_(scope), body_(body), materialized_literal_count_(materialized_literal_count), @@ -1729,9 +1804,10 @@ class FunctionLiteral: public Expression { class SharedFunctionInfoLiteral: public Expression { public: - explicit SharedFunctionInfoLiteral( + SharedFunctionInfoLiteral( + Isolate* isolate, Handle shared_function_info) - : shared_function_info_(shared_function_info) { } + : Expression(isolate), shared_function_info_(shared_function_info) { } DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) @@ -1747,6 +1823,7 @@ class SharedFunctionInfoLiteral: public Expression { class ThisFunction: public Expression { public: + explicit ThisFunction(Isolate* isolate) : Expression(isolate) {} DECLARE_NODE_TYPE(ThisFunction) virtual bool IsInlineable() const; }; diff --git a/deps/v8/src/bootstrapper.cc b/deps/v8/src/bootstrapper.cc index 8e34b9cf50c..8cca5614b00 100644 --- a/deps/v8/src/bootstrapper.cc +++ b/deps/v8/src/bootstrapper.cc @@ -1309,6 +1309,7 @@ void Genesis::InstallNativeFunctions() { void Genesis::InstallExperimentalNativeFunctions() { if (FLAG_harmony_proxies) { + INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); } diff --git a/deps/v8/src/builtins.cc b/deps/v8/src/builtins.cc index 6a44d8cae55..d403a951cfb 100644 --- a/deps/v8/src/builtins.cc +++ b/deps/v8/src/builtins.cc @@ -1202,10 +1202,10 @@ MUST_USE_RESULT static MaybeObject* HandleApiCallAsFunctionOrConstructor( ASSERT(!CalledAsConstructor(isolate)); Heap* heap = isolate->heap(); - Handle receiver = args.at(0); + Handle receiver = args.receiver(); // Get the object called. - JSObject* obj = JSObject::cast(*args.receiver()); + JSObject* obj = JSObject::cast(*receiver); // Get the invocation callback from the function descriptor that was // used to create the called object. diff --git a/deps/v8/src/code-stubs.cc b/deps/v8/src/code-stubs.cc index 5c0ef5a4a5c..1d1128f2d14 100644 --- a/deps/v8/src/code-stubs.cc +++ b/deps/v8/src/code-stubs.cc @@ -250,7 +250,7 @@ void KeyedLoadElementStub::Generate(MacroAssembler* masm) { KeyedLoadStubCompiler::GenerateLoadFastElement(masm); break; case JSObject::FAST_DOUBLE_ELEMENTS: - UNIMPLEMENTED(); + KeyedLoadStubCompiler::GenerateLoadFastDoubleElement(masm); break; case JSObject::EXTERNAL_BYTE_ELEMENTS: case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: @@ -279,7 +279,8 @@ void KeyedStoreElementStub::Generate(MacroAssembler* masm) { KeyedStoreStubCompiler::GenerateStoreFastElement(masm, is_js_array_); break; case JSObject::FAST_DOUBLE_ELEMENTS: - UNIMPLEMENTED(); + KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm, + is_js_array_); break; case JSObject::EXTERNAL_BYTE_ELEMENTS: case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: diff --git a/deps/v8/src/compiler.cc b/deps/v8/src/compiler.cc index e09b72f7d37..c265b95aca0 100755 --- a/deps/v8/src/compiler.cc +++ b/deps/v8/src/compiler.cc @@ -511,7 +511,6 @@ Handle Compiler::Compile(Handle source, info.SetPreParseData(pre_data); if (natives == NATIVES_CODE) { info.MarkAsAllowingNativesSyntax(); - info.MarkAsNative(); } result = MakeFunctionInfo(&info); if (extension == NULL && !result.is_null()) { @@ -679,7 +678,6 @@ Handle Compiler::BuildFunctionInfo(FunctionLiteral* literal, info.SetFunction(literal); info.SetScope(literal->scope()); if (literal->scope()->is_strict_mode()) info.MarkAsStrictMode(); - if (script->type()->value() == Script::TYPE_NATIVE) info.MarkAsNative(); LiveEditFunctionTracker live_edit_tracker(info.isolate(), literal); // Determine if the function can be lazily compiled. This is necessary to diff --git a/deps/v8/src/compiler.h b/deps/v8/src/compiler.h index a77fc8ea4ab..8e92cf5a177 100644 --- a/deps/v8/src/compiler.h +++ b/deps/v8/src/compiler.h @@ -173,9 +173,12 @@ class CompilationInfo BASE_EMBEDDED { void Initialize(Mode mode) { mode_ = V8::UseCrankshaft() ? mode : NONOPT; - if (!shared_info_.is_null()) { - if (shared_info_->strict_mode()) MarkAsStrictMode(); - if (shared_info_->native()) MarkAsNative(); + ASSERT(!script_.is_null()); + if (script_->type()->value() == Script::TYPE_NATIVE) { + MarkAsNative(); + } + if (!shared_info_.is_null() && shared_info_->strict_mode()) { + MarkAsStrictMode(); } } diff --git a/deps/v8/src/contexts.h b/deps/v8/src/contexts.h index 0f3d44cc25f..53b40f127d8 100644 --- a/deps/v8/src/contexts.h +++ b/deps/v8/src/contexts.h @@ -110,6 +110,7 @@ enum ContextLookupFlags { V(MAP_CACHE_INDEX, Object, map_cache) \ V(CONTEXT_DATA_INDEX, Object, data) \ V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings) \ + V(DERIVED_HAS_TRAP_INDEX, JSFunction, derived_has_trap) \ V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \ V(DERIVED_SET_TRAP_INDEX, JSFunction, derived_set_trap) @@ -227,6 +228,7 @@ class Context: public FixedArray { OUT_OF_MEMORY_INDEX, CONTEXT_DATA_INDEX, ALLOW_CODE_GEN_FROM_STRINGS_INDEX, + DERIVED_HAS_TRAP_INDEX, DERIVED_GET_TRAP_INDEX, DERIVED_SET_TRAP_INDEX, diff --git a/deps/v8/src/conversions-inl.h b/deps/v8/src/conversions-inl.h index f1f526ffc02..b828638568a 100644 --- a/deps/v8/src/conversions-inl.h +++ b/deps/v8/src/conversions-inl.h @@ -454,7 +454,6 @@ static double InternalStringToDouble(UnicodeCache* unicode_cache, int significant_digits = 0; int insignificant_digits = 0; bool nonzero_digit_dropped = false; - bool fractional_part = false; bool negative = false; @@ -557,10 +556,8 @@ static double InternalStringToDouble(UnicodeCache* unicode_cache, } } - // We don't emit a '.', but adjust the exponent instead. - fractional_part = true; - - // There is a fractional part. + // There is a fractional part. We don't emit a '.', but adjust the exponent + // instead. while (*current >= '0' && *current <= '9') { if (significant_digits < kMaxSignificantDigits) { ASSERT(buffer_pos < kBufferSize); diff --git a/deps/v8/src/d8.cc b/deps/v8/src/d8.cc index 5f573500939..4917f7d64af 100644 --- a/deps/v8/src/d8.cc +++ b/deps/v8/src/d8.cc @@ -26,33 +26,49 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#ifdef V8_SHARED +#define USING_V8_SHARED +#endif + #ifdef COMPRESS_STARTUP_DATA_BZ2 #include #endif + #include #include +#include -#include "v8.h" +#ifdef USING_V8_SHARED +#include +#include "../include/v8-testing.h" +#endif // USING_V8_SHARED #include "d8.h" + +#ifndef USING_V8_SHARED +#include "api.h" +#include "checks.h" #include "d8-debug.h" #include "debug.h" -#include "api.h" #include "natives.h" #include "platform.h" +#include "v8.h" +#endif // USING_V8_SHARED #if !defined(_WIN32) && !defined(_WIN64) #include // NOLINT #endif +#ifdef USING_V8_SHARED +#define ASSERT(condition) assert(condition) +#endif // USING_V8_SHARED + namespace v8 { -const char* Shell::kHistoryFileName = ".d8_history"; -const char* Shell::kPrompt = "d8> "; - - +#ifndef USING_V8_SHARED LineEditor *LineEditor::first_ = NULL; +const char* Shell::kHistoryFileName = ".d8_history"; LineEditor::LineEditor(Type type, const char* name) @@ -98,17 +114,22 @@ CounterMap* Shell::counter_map_; i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; CounterCollection Shell::local_counters_; CounterCollection* Shell::counters_ = &local_counters_; -Persistent Shell::utility_context_; -Persistent Shell::evaluation_context_; i::Mutex* Shell::context_mutex_(i::OS::CreateMutex()); +Persistent Shell::utility_context_; +#endif // USING_V8_SHARED + +Persistent Shell::evaluation_context_; ShellOptions Shell::options; +const char* Shell::kPrompt = "d8> "; +#ifndef USING_V8_SHARED bool CounterMap::Match(void* key1, void* key2) { const char* name1 = reinterpret_cast(key1); const char* name2 = reinterpret_cast(key2); return strcmp(name1, name2) == 0; } +#endif // USING_V8_SHARED // Converts a V8 value to a C string. @@ -122,17 +143,22 @@ bool Shell::ExecuteString(Handle source, Handle name, bool print_result, bool report_exceptions) { +#ifndef USING_V8_SHARED + bool FLAG_debugger = i::FLAG_debugger; +#else + bool FLAG_debugger = false; +#endif // USING_V8_SHARED HandleScope handle_scope; TryCatch try_catch; options.script_executed = true; - if (i::FLAG_debugger) { + if (FLAG_debugger) { // When debugging make exceptions appear to be uncaught. try_catch.SetVerbose(true); } Handle