DataView object underlying ArrayBuffer should be marked during GC. (#2849)

This patch fixes #2848 and fixes #2850 as well.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik 2019-05-08 15:14:21 +02:00 committed by László Langó
parent 372ebd8260
commit eb993d57ed
3 changed files with 51 additions and 0 deletions

View File

@ -296,6 +296,14 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
break;
}
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROMISE) */
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
case LIT_MAGIC_STRING_DATAVIEW_UL:
{
ecma_dataview_object_t *dataview_p = (ecma_dataview_object_t *) object_p;
ecma_gc_set_object_visited (dataview_p->buffer_p);
break;
}
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW) */
default:
{
break;

View File

@ -0,0 +1,17 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var arrayBuffer = new ArrayBuffer;
var dataView = new DataView(arrayBuffer);
assert (dataView.buffer === arrayBuffer);

View File

@ -0,0 +1,26 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
try {
(function () {
var d = new DataView(new ArrayBuffer())
for (var $; ;) {
d.setInt8(0)
}
})()
assert (false);
} catch (e) {
assert (e instanceof RangeError);
}