diff options
author | Zeno Albisser <zeno.albisser@theqtcompany.com> | 2014-12-05 15:04:29 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@theqtcompany.com> | 2014-12-09 10:49:28 +0100 |
commit | af6588f8d723931a298c995fa97259bb7f7deb55 (patch) | |
tree | 060ca707847ba1735f01af2372e0d5e494dc0366 /chromium/v8/src/messages.js | |
parent | 2fff84d821cc7b1c785f6404e0f8091333283e74 (diff) | |
download | qtwebengine-chromium-af6588f8d723931a298c995fa97259bb7f7deb55.tar.gz |
BASELINE: Update chromium to 40.0.2214.28 and ninja to 1.5.3.
Change-Id: I759465284fd64d59ad120219cbe257f7402c4181
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/v8/src/messages.js')
-rw-r--r-- | chromium/v8/src/messages.js | 245 |
1 files changed, 116 insertions, 129 deletions
diff --git a/chromium/v8/src/messages.js b/chromium/v8/src/messages.js index 859bc0d721c..b15ccc6e42a 100644 --- a/chromium/v8/src/messages.js +++ b/chromium/v8/src/messages.js @@ -8,6 +8,7 @@ var kMessages = { // Error cyclic_proto: ["Cyclic __proto__ value"], code_gen_from_strings: ["%0"], + constructor_special_method: ["Class constructor may not be an accessor"], generator_running: ["Generator is already running"], generator_finished: ["Generator has already finished"], // TypeError @@ -19,6 +20,7 @@ var kMessages = { unexpected_strict_reserved: ["Unexpected strict mode reserved word"], unexpected_eos: ["Unexpected end of input"], malformed_regexp: ["Invalid regular expression: /", "%0", "/: ", "%1"], + malformed_regexp_flags: ["Invalid regular expression flags"], unterminated_regexp: ["Invalid regular expression: missing /"], regexp_flags: ["Cannot supply flags when constructing one RegExp from another"], incompatible_method_receiver: ["Method ", "%0", " called on incompatible receiver ", "%1"], @@ -26,6 +28,7 @@ var kMessages = { newline_after_throw: ["Illegal newline after throw"], label_redeclaration: ["Label '", "%0", "' has already been declared"], var_redeclaration: ["Identifier '", "%0", "' has already been declared"], + duplicate_template_property: ["Object template has duplicate property '", "%0", "'"], no_catch_or_finally: ["Missing catch or finally after try"], unknown_label: ["Undefined label '", "%0", "'"], uncaught_exception: ["Uncaught ", "%0"], @@ -36,6 +39,8 @@ var kMessages = { cannot_convert_to_primitive: ["Cannot convert object to primitive value"], not_constructor: ["%0", " is not a constructor"], not_defined: ["%0", " is not defined"], + non_method: ["'super' is referenced from non-method"], + unsupported_super: ["Unsupported reference to 'super'"], non_object_property_load: ["Cannot read property '", "%0", "' of ", "%1"], non_object_property_store: ["Cannot set property '", "%0", "' of ", "%1"], with_expression: ["%0", " has no properties"], @@ -43,6 +48,8 @@ var kMessages = { no_setter_in_callback: ["Cannot set property ", "%0", " of ", "%1", " which has only a getter"], apply_non_function: ["Function.prototype.apply was called on ", "%0", ", which is a ", "%1", " and not a function"], apply_wrong_args: ["Function.prototype.apply: Arguments list has wrong type"], + toMethod_non_function: ["Function.prototype.toMethod was called on ", "%0", ", which is a ", "%1", " and not a function"], + toMethod_non_object: ["Function.prototype.toMethod: home object ", "%0", " is not an object"], invalid_in_operator_use: ["Cannot use 'in' operator to search for '", "%0", "' in ", "%1"], instanceof_function_expected: ["Expecting a function in instanceof check, but got ", "%0"], instanceof_nonobject_proto: ["Function has non-object prototype '", "%0", "' in instanceof check"], @@ -89,6 +96,10 @@ var kMessages = { array_functions_on_frozen: ["Cannot modify frozen array elements"], array_functions_change_sealed: ["Cannot add/remove sealed array elements"], first_argument_not_regexp: ["First argument to ", "%0", " must not be a regular expression"], + not_iterable: ["%0", " is not iterable"], + not_an_iterator: ["%0", " is not an iterator"], + iterator_result_not_an_object: ["Iterator result ", "%0", " is not an object"], + iterator_value_not_an_object: ["Iterator value ", "%0", " is not an entry object"], // RangeError invalid_array_length: ["Invalid array length"], invalid_array_buffer_length: ["Invalid array buffer length"], @@ -108,6 +119,7 @@ var kMessages = { stack_overflow: ["Maximum call stack size exceeded"], invalid_time_value: ["Invalid time value"], invalid_count_value: ["Invalid count value"], + invalid_code_point: ["Invalid code point ", "%0"], // ReferenceError invalid_lhs_in_assignment: ["Invalid left-hand side in assignment"], invalid_lhs_in_for: ["Invalid left-hand side in for-loop"], @@ -122,7 +134,6 @@ var kMessages = { illegal_break: ["Illegal break statement"], illegal_continue: ["Illegal continue statement"], illegal_return: ["Illegal return statement"], - illegal_let: ["Illegal let declaration outside extended mode"], error_loading_debugger: ["Error loading debugger"], no_input_to_regexp: ["No input to ", "%0"], invalid_json: ["String '", "%0", "' is not valid JSON"], @@ -132,8 +143,7 @@ var kMessages = { array_indexof_not_defined: ["Array.getIndexOf: Argument undefined"], object_not_extensible: ["Can't add property ", "%0", ", object is not extensible"], illegal_access: ["Illegal access"], - invalid_cached_data_function: ["Invalid cached data for function ", "%0"], - invalid_cached_data: ["Invalid cached data"], + static_prototype: ["Classes may not have static property named prototype"], strict_mode_with: ["Strict mode code may not include a with statement"], strict_eval_arguments: ["Unexpected eval or arguments in strict mode"], too_many_arguments: ["Too many arguments in function call (only 65535 allowed)"], @@ -152,6 +162,7 @@ var kMessages = { strict_cannot_assign: ["Cannot assign to read only '", "%0", "' in strict mode"], strict_poison_pill: ["'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"], strict_caller: ["Illegal access to a strict mode caller function."], + malformed_arrow_function_parameter_list: ["Malformed arrow function parameter list"], generator_poison_pill: ["'caller' and 'arguments' properties may not be accessed on generator functions."], unprotected_let: ["Illegal let declaration in unprotected statement context."], unprotected_const: ["Illegal const declaration in unprotected statement context."], @@ -160,9 +171,14 @@ var kMessages = { harmony_const_assign: ["Assignment to constant variable."], symbol_to_string: ["Cannot convert a Symbol value to a string"], symbol_to_primitive: ["Cannot convert a Symbol wrapper object to a primitive value"], + symbol_to_number: ["Cannot convert a Symbol value to a number"], invalid_module_path: ["Module does not export '", "%0", "', or export is not itself a module"], module_type_error: ["Module '", "%0", "' used improperly"], - module_export_undefined: ["Export '", "%0", "' is not defined in module"] + module_export_undefined: ["Export '", "%0", "' is not defined in module"], + unexpected_super: ["'super' keyword unexpected here"], + extends_value_not_a_function: ["Class extends value ", "%0", " is not a function or null"], + prototype_parent_not_an_object: ["Class extends value does not have valid prototype property ", "%0"], + duplicate_constructor: ["A class may only have one constructor"] }; @@ -208,7 +224,9 @@ function NoSideEffectToString(obj) { } return str; } - if (IS_OBJECT(obj) && %GetDataProperty(obj, "toString") === ObjectToString) { + if (IS_SYMBOL(obj)) return %_CallFunction(obj, SymbolToString); + if (IS_OBJECT(obj) + && %GetDataProperty(obj, "toString") === DefaultObjectToString) { var constructor = %GetDataProperty(obj, "constructor"); if (typeof constructor == "function") { var constructorName = constructor.name; @@ -220,7 +238,8 @@ function NoSideEffectToString(obj) { if (CanBeSafelyTreatedAsAnErrorObject(obj)) { return %_CallFunction(obj, ErrorToString); } - return %_CallFunction(obj, ObjectToString); + + return %_CallFunction(obj, NoSideEffectsObjectToString); } // To determine whether we can safely stringify an object using ErrorToString @@ -259,7 +278,7 @@ function ToStringCheckErrorObject(obj) { function ToDetailString(obj) { - if (obj != null && IS_OBJECT(obj) && obj.toString === ObjectToString) { + if (obj != null && IS_OBJECT(obj) && obj.toString === DefaultObjectToString) { var constructor = obj.constructor; if (typeof constructor == "function") { var constructorName = constructor.name; @@ -282,8 +301,8 @@ function MakeGenericError(constructor, type, args) { * Set up the Script function and constructor. */ %FunctionSetInstanceClassName(Script, 'Script'); -%SetProperty(Script.prototype, 'constructor', Script, - DONT_ENUM | DONT_DELETE | READ_ONLY); +%AddNamedProperty(Script.prototype, 'constructor', Script, + DONT_ENUM | DONT_DELETE | READ_ONLY); %SetCode(Script, function(x) { // Script objects can only be created by the VM. throw new $Error("Not supported"); @@ -349,6 +368,23 @@ function MakeError(type, args) { return MakeGenericError($Error, type, args); } + +// The embedded versions are called from unoptimized code, with embedded +// arguments. Those arguments cannot be arrays, which are context-dependent. +function MakeTypeErrorEmbedded(type, arg) { + return MakeGenericError($TypeError, type, [arg]); +} + + +function MakeSyntaxErrorEmbedded(type, arg) { + return MakeGenericError($SyntaxError, type, [arg]); +} + + +function MakeReferenceErrorEmbedded(type, arg) { + return MakeGenericError($ReferenceError, type, [arg]); +} + /** * Find a line number given a specific source position. * @param {number} position The source position. @@ -555,44 +591,16 @@ function ScriptNameOrSourceURL() { if (this.line_offset > 0 || this.column_offset > 0) { return this.name; } - - // The result is cached as on long scripts it takes noticable time to search - // for the sourceURL. - if (this.hasCachedNameOrSourceURL) { - return this.cachedNameOrSourceURL; + if (this.source_url) { + return this.source_url; } - this.hasCachedNameOrSourceURL = true; - - // TODO(608): the spaces in a regexp below had to be escaped as \040 - // because this file is being processed by js2c whose handling of spaces - // in regexps is broken. Also, ['"] are excluded from allowed URLs to - // avoid matches against sources that invoke evals with sourceURL. - // A better solution would be to detect these special comments in - // the scanner/parser. - var source = ToString(this.source); - var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0); - this.cachedNameOrSourceURL = this.name; - if (sourceUrlPos > 4) { - var sourceUrlPattern = - /\/\/[#@][\040\t]sourceURL=[\040\t]*([^\s\'\"]*)[\040\t]*$/gm; - // Don't reuse lastMatchInfo here, so we create a new array with room - // for four captures (array with length one longer than the index - // of the fourth capture, where the numbering is zero-based). - var matchInfo = new InternalArray(CAPTURE(3) + 1); - var match = - %_RegExpExec(sourceUrlPattern, source, sourceUrlPos - 4, matchInfo); - if (match) { - this.cachedNameOrSourceURL = - %_SubString(source, matchInfo[CAPTURE(2)], matchInfo[CAPTURE(3)]); - } - } - return this.cachedNameOrSourceURL; + return this.name; } SetUpLockedPrototype(Script, - $Array("source", "name", "line_ends", "line_offset", "column_offset", - "cachedNameOrSourceURL", "hasCachedNameOrSourceURL" ), + $Array("source", "name", "source_url", "source_mapping_url", "line_ends", + "line_offset", "column_offset"), $Array( "lineFromPosition", ScriptLineFromPosition, "locationFromPosition", ScriptLocationFromPosition, @@ -772,10 +780,10 @@ function GetStackTraceLine(recv, fun, pos, isGlobal) { // ---------------------------------------------------------------------------- // Error implementation -var CallSiteReceiverKey = NEW_PRIVATE("CallSite#receiver"); -var CallSiteFunctionKey = NEW_PRIVATE("CallSite#function"); -var CallSitePositionKey = NEW_PRIVATE("CallSite#position"); -var CallSiteStrictModeKey = NEW_PRIVATE("CallSite#strict_mode"); +var CallSiteReceiverKey = NEW_PRIVATE_OWN("CallSite#receiver"); +var CallSiteFunctionKey = NEW_PRIVATE_OWN("CallSite#function"); +var CallSitePositionKey = NEW_PRIVATE_OWN("CallSite#position"); +var CallSiteStrictModeKey = NEW_PRIVATE_OWN("CallSite#strict_mode"); function CallSite(receiver, fun, pos, strict_mode) { SET_PRIVATE(this, CallSiteReceiverKey, receiver); @@ -1076,7 +1084,8 @@ function GetStackFrames(raw_stack) { var formatting_custom_stack_trace = false; -function FormatStackTrace(obj, error_string, frames) { +function FormatStackTrace(obj, raw_stack) { + var frames = GetStackFrames(raw_stack); if (IS_FUNCTION($Error.prepareStackTrace) && !formatting_custom_stack_trace) { var array = []; %MoveArrayContents(frames, array); @@ -1093,7 +1102,7 @@ function FormatStackTrace(obj, error_string, frames) { } var lines = new InternalArray(); - lines.push(error_string); + lines.push(FormatErrorString(obj)); for (var i = 0; i < frames.length; i++) { var frame = frames[i]; var line; @@ -1117,56 +1126,66 @@ function GetTypeName(receiver, requireConstructor) { var constructor = receiver.constructor; if (!constructor) { return requireConstructor ? null : - %_CallFunction(receiver, ObjectToString); + %_CallFunction(receiver, NoSideEffectsObjectToString); } var constructorName = constructor.name; if (!constructorName) { return requireConstructor ? null : - %_CallFunction(receiver, ObjectToString); + %_CallFunction(receiver, NoSideEffectsObjectToString); } return constructorName; } -function captureStackTrace(obj, cons_opt) { - var stackTraceLimit = $Error.stackTraceLimit; - if (!stackTraceLimit || !IS_NUMBER(stackTraceLimit)) return; - if (stackTraceLimit < 0 || stackTraceLimit > 10000) { - stackTraceLimit = 10000; - } - var stack = %CollectStackTrace(obj, - cons_opt ? cons_opt : captureStackTrace, - stackTraceLimit); - - var error_string = FormatErrorString(obj); - - // Set the 'stack' property on the receiver. If the receiver is the same as - // holder of this setter, the accessor pair is turned into a data property. - var setter = function(v) { - // Set data property on the receiver (not necessarily holder). - %DefineOrRedefineDataProperty(this, 'stack', v, NONE); - if (this === obj) { - // Release context values if holder is the same as the receiver. - stack = error_string = UNDEFINED; +var stack_trace_symbol; // Set during bootstrapping. +var formatted_stack_trace_symbol = NEW_PRIVATE_OWN("formatted stack trace"); + + +// Format the stack trace if not yet done, and return it. +// Cache the formatted stack trace on the holder. +var StackTraceGetter = function() { + var formatted_stack_trace = UNDEFINED; + var holder = this; + while (holder) { + var formatted_stack_trace = + GET_PRIVATE(holder, formatted_stack_trace_symbol); + if (IS_UNDEFINED(formatted_stack_trace)) { + // No formatted stack trace available. + var stack_trace = GET_PRIVATE(holder, stack_trace_symbol); + if (IS_UNDEFINED(stack_trace)) { + // Neither formatted nor structured stack trace available. + // Look further up the prototype chain. + holder = %GetPrototype(holder); + continue; + } + formatted_stack_trace = FormatStackTrace(holder, stack_trace); + SET_PRIVATE(holder, stack_trace_symbol, UNDEFINED); + SET_PRIVATE(holder, formatted_stack_trace_symbol, formatted_stack_trace); } - }; + return formatted_stack_trace; + } + return UNDEFINED; +}; - // The holder of this getter ('obj') may not be the receiver ('this'). - // When this getter is called the first time, we use the context values to - // format a stack trace string and turn this accessor pair into a data - // property (on the holder). - var getter = function() { - // Stack is still a raw array awaiting to be formatted. - var result = FormatStackTrace(obj, error_string, GetStackFrames(stack)); - // Replace this accessor to return result directly. - %DefineOrRedefineAccessorProperty( - obj, 'stack', function() { return result }, setter, DONT_ENUM); - // Release context values. - stack = error_string = UNDEFINED; - return result; - }; - %DefineOrRedefineAccessorProperty(obj, 'stack', getter, setter, DONT_ENUM); +// If the receiver equals the holder, set the formatted stack trace that the +// getter returns. +var StackTraceSetter = function(v) { + if (HAS_PRIVATE(this, stack_trace_symbol)) { + SET_PRIVATE(this, stack_trace_symbol, UNDEFINED); + SET_PRIVATE(this, formatted_stack_trace_symbol, v); + } +}; + + +// Use a dummy function since we do not actually want to capture a stack trace +// when constructing the initial Error prototytpes. +var captureStackTrace = function captureStackTrace(obj, cons_opt) { + // Define accessors first, as this may fail and throw. + ObjectDefineProperty(obj, 'stack', { get: StackTraceGetter, + set: StackTraceSetter, + configurable: true }); + %CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace); } @@ -1181,8 +1200,9 @@ function SetUpError() { // effects when overwriting the error functions from // user code. var name = f.name; - %SetProperty(global, name, f, DONT_ENUM); - %SetProperty(builtins, '$' + name, f, DONT_ENUM | DONT_DELETE | READ_ONLY); + %AddNamedProperty(global, name, f, DONT_ENUM); + %AddNamedProperty(builtins, '$' + name, f, + DONT_ENUM | DONT_DELETE | READ_ONLY); // Configure the error function. if (name == 'Error') { // The prototype of the Error object must itself be an error. @@ -1197,19 +1217,18 @@ function SetUpError() { %FunctionSetPrototype(f, new $Error()); } %FunctionSetInstanceClassName(f, 'Error'); - %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); - %SetProperty(f.prototype, "name", name, DONT_ENUM); + %AddNamedProperty(f.prototype, 'constructor', f, DONT_ENUM); + %AddNamedProperty(f.prototype, "name", name, DONT_ENUM); %SetCode(f, function(m) { if (%_IsConstructCall()) { // Define all the expected properties directly on the error // object. This avoids going through getters and setters defined // on prototype objects. - %IgnoreAttributesAndSetProperty(this, 'stack', UNDEFINED, DONT_ENUM); + %AddNamedProperty(this, 'stack', UNDEFINED, DONT_ENUM); if (!IS_UNDEFINED(m)) { - %IgnoreAttributesAndSetProperty( - this, 'message', ToString(m), DONT_ENUM); + %AddNamedProperty(this, 'message', ToString(m), DONT_ENUM); } - captureStackTrace(this, f); + try { captureStackTrace(this, f); } catch (e) { } } else { return new f(m); } @@ -1230,7 +1249,7 @@ SetUpError(); $Error.captureStackTrace = captureStackTrace; -%SetProperty($Error.prototype, 'message', '', DONT_ENUM); +%AddNamedProperty($Error.prototype, 'message', '', DONT_ENUM); // Global list of error objects visited during ErrorToString. This is // used to detect cycles in error toString formatting. @@ -1302,40 +1321,8 @@ InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); function SetUpStackOverflowBoilerplate() { var boilerplate = MakeRangeError('stack_overflow', []); - var error_string = boilerplate.name + ": " + boilerplate.message; - - // Set the 'stack' property on the receiver. If the receiver is the same as - // holder of this setter, the accessor pair is turned into a data property. - var setter = function(v) { - %DefineOrRedefineDataProperty(this, 'stack', v, NONE); - // Tentatively clear the hidden property. If the receiver is the same as - // holder, we release the raw stack trace this way. - %GetAndClearOverflowedStackTrace(this); - }; - - // The raw stack trace is stored as a hidden property on the holder of this - // getter, which may not be the same as the receiver. Find the holder to - // retrieve the raw stack trace and then turn this accessor pair into a - // data property. - var getter = function() { - var holder = this; - while (!IS_ERROR(holder)) { - holder = %GetPrototype(holder); - if (IS_NULL(holder)) return MakeSyntaxError('illegal_access', []); - } - var stack = %GetAndClearOverflowedStackTrace(holder); - // We may not have captured any stack trace. - if (IS_UNDEFINED(stack)) return stack; - - var result = FormatStackTrace(holder, error_string, GetStackFrames(stack)); - // Replace this accessor to return result directly. - %DefineOrRedefineAccessorProperty( - holder, 'stack', function() { return result }, setter, DONT_ENUM); - return result; - }; - - %DefineOrRedefineAccessorProperty( - boilerplate, 'stack', getter, setter, DONT_ENUM); + %DefineAccessorPropertyUnchecked( + boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); return boilerplate; } |